目录
目录README.md

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]
关于
210.0 KB
邀请码
    Gitlink(确实开源)
  • 加入我们
  • 官网邮箱:gitlink@ccf.org.cn
  • QQ群
  • QQ群
  • 公众号
  • 公众号

©Copyright 2023 CCF 开源发展委员会
Powered by Trustie& IntelliDE 京ICP备13000930号