Skip to content

richardpiazza/DynuREST

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

28 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

DynuREST

A Dynu.com IP Update API wrapper.

Twitter: @richardpiazza

Face it... a REST API that responds in only text doesn't feel very modern. DynuREST translates the text responses from the Dynu.com IP Update API into proper HTTP status codes and meaningful errors.

Installation

DynuREST is distributed using the Swift Package Manager. To install it into a project, add it as a dependency within your Package.swift manifest:

let package = Package(
    ...
    dependencies: [
        .package(url: "https://github.com/richardpiazza/DynuREST.git", from: "3.0.0")
    ],
    ...
)

Then import the DynuREST packages wherever you'd like to use it:

import DynuREST

Usage

The DynuIPUpdater shared instance allows for sending IP information to the Dynu.com API.

let address = IPAddress.ipV4("X.X.X.X")
let response = try await DynuIPUpdater.shared.updateAddress(address, using: .basic("username", "password"))

IP address information can be obtained through any means, but DynuREST has two built-in providers:

  • IPifyClient.shared
  • IFConfigClient.shared

These both implement the IPSource protocol:

public protocol IPSource {
    func ipAddress() async throws -> IPAddress
}

DynuIPUpdater also contains a helper method which will automatically retrieve IP information from the built-in sources.

func requestIP(_ sources: [IPSource]) async -> [IPAddress]