https://github.com/yourtion/httpdns-swift
HTTPDNS 库 Swift 实现(支持 DNSPod 与 AliyunDNS )
https://github.com/yourtion/httpdns-swift
aliyun-httpdns carthage dns-over-https dnspod dnspod-httpdns google-dns httpdns httpdns-swift
Last synced: 7 months ago
JSON representation
HTTPDNS 库 Swift 实现(支持 DNSPod 与 AliyunDNS )
- Host: GitHub
- URL: https://github.com/yourtion/httpdns-swift
- Owner: yourtion
- License: mit
- Created: 2015-11-25T08:38:13.000Z (about 10 years ago)
- Default Branch: master
- Last Pushed: 2018-03-06T01:57:50.000Z (almost 8 years ago)
- Last Synced: 2025-06-09T18:49:21.569Z (7 months ago)
- Topics: aliyun-httpdns, carthage, dns-over-https, dnspod, dnspod-httpdns, google-dns, httpdns, httpdns-swift
- Language: Swift
- Homepage: http://cocoapods.org/pods/HTTPDNS-Swift
- Size: 78.1 KB
- Stars: 18
- Watchers: 3
- Forks: 4
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# HTTPDNS
[](https://github.com/Carthage/Carthage)
[](http://cocoapods.org/pods/HTTPDNS-Swift)
[](http://cocoapods.org/pods/HTTPDNS-Swift)
[](http://cocoapods.org/pods/HTTPDNS-Swift)
[](https://travis-ci.org/yourtion/HTTPDNS-Swift)
HTTPDNS 库 Swift 实现,支持 DNSPod、AliYunDNS、Google 等(方便扩展)
- DNSPod 的 [移动解析服务D+](https://www.dnspod.cn/httpdns)
- AliYun HTTPDNS [HTTPDNS API](https://help.aliyun.com/document_detail/dpa/sdk/RESTful/httpdns.html?spm=5176.docdpa/sdk/OneSDK/quick-start-ios.6.104.wmIJqo)
- Google DNS-over-HTTP [介绍](https://developers.google.com/speed/public-dns/docs/dns-over-https)
## 安装
### CocoaPod
在 `Podfile` 中添加:
```
platform :ios, '8.0'
pod 'HTTPDNS-Swift'
```
### Carthage
```
github "yourtion/HTTPDNS-Swift"
```
## 使用
### 异步解析
```swift
HTTPDNS.sharedInstance.getRecord("qq.com", callback: { (result) -> Void in
print("Async QQ.com", result)
})
```
### 同步解析
```swift
print("Sync baidu.com", HTTPDNS.sharedInstance.getRecordSync("baidu.com"))
```
### 清除缓存
```swift
HTTPDNS.sharedInstance.cleanCache()
```
### 切换解析服务
默认为 DNSPod 服务。
切换到 AliYun HTTPDNS,`Key` 为阿里云的 `account id`
```swift
HTTPDNS.sharedInstance.switchProvider(.AliYun, key: "100000")
```
切换到 DNSPod HTTPDNS,`Key` 为 `nil`
```swift
HTTPDNS.sharedInstance.switchProvider(.DNSPod, key: nil)
```
切换到 Google DNS-over-HTTP,`Key` 为 `nil`
```swift
HTTPDNS.sharedInstance.switchProvider(.Google, key: nil)
```
## TODO
- [X] 实现 DNSPod 免费版功能
- [ ] 实现 DNSPod 企业版功能(认证接入)
- [X] 实现AliYun HTTPDNS
- [X] 实现 Google DNS-over-HTTP
- [X] 提供同步获取方法
- [X] 提供清除缓存方法