• Stars
    star
    491
  • Rank 89,615 (Top 2 %)
  • Language
    Objective-C
  • License
    MIT License
  • Created over 9 years ago
  • Updated about 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

dns library for objective c

Happy DNS for Objective-C

@qiniu on weibo LICENSE Build Status GitHub release codecov Platform

用途

调用系统底层Dns解析库,可以使用114 等第三方dns解析,可以使用 Doh 协议的 Dns 解析方案,也可以集成dnspod等httpdns。另外也有丰富的hosts 域名配置。

安装

通过CocoaPods

pod "HappyDNS"

通过 Swift Package Manager (Xcode 11+)

App 对接:
File -> Swift Packages -> Add Package Dependency,输入 HappyDNS 库链接,选择相应版本即可
库链接: https://github.com/qiniu/happy-dns-objc

库对接:
let package = Package(
    dependencies: [
        .package(url: "https://github.com/qiniu/happy-dns-objc", from: "1.0.3")
    ],
    // ...
)

运行环境

使用方法

* 返回IP列表

 NSMutableArray *array = [[NSMutableArray alloc] init];
[array addObject:[QNResolver systemResolver]];
[array addObject:[[QNResolver alloc] initWithAddress:@"119.29.29.29"]];
[array addObject:[QNDohResolver resolverWithServer:@"https://dns.alidns.com/dns-query"]];
QNDnsManager *dns = [[QNDnsManager alloc] init:array networkInfo:[QNNetworkInfo normal]];
NSArray <QNRecord *> *records = [dns queryRecords:@"www.qiniu.com"];

* url 请求,返回一个IP 替换URL 里的domain

NSMutableArray *array = [[NSMutableArray alloc] init];
[array addObject:[QNResolver systemResolver]];
[array addObject:[[QNResolver alloc] initWithAddress:@"119.29.29.29"]];
QNDnsManager *dns = [[QNDnsManager alloc] init:array networkInfo:[QNNetworkInfo normal]];
NSURL *u = [[NSURL alloc] initWithString:@"rtmp://www.qiniu.com/abc?q=1"];
NSURL *u2 = [dns queryAndReplaceWithIP:u];
  • 兼容 getaddrinfo, 方便底层C代码接入
static QNDnsManager *dns = nil;
dns = [[QNDnsManager alloc] init:@[ [QNResolver systemResolver] ] networkInfo:nil];
[QNDnsManager setGetAddrInfoBlock:^NSArray *(NSString *host) {
        return [dns query:host];
    }];
struct addrinfo hints = {0};
struct addrinfo *ai = NULL;
int x = qn_getaddrinfo(host, "http", &hints, &ai);
qn_freeaddrinfo(ai); // 也可以用系统的freeaddrinfo, 代码一致,不过最好用这个

运行测试

$ xctool -workspace HappyDNS.xcworkspace -scheme "HappyDNS_Mac" -sdk macosx -configuration Release test -test-sdk macosx

指定测试

可以在单元测试上修改,熟悉使用

常见问题

  • 如果碰到其他编译错误,请参考 CocoaPods 的 troubleshooting
  • httpdns 在ios8 时不支持 nat64 模式下 IP 直接访问url,原因是 NSUrlConnection 不支持。无论是用http://119.29.29.29/d 还是http://[64:ff9b::771d:1d1d]/d 都不行,此时可以使用localdns方式。
  • 如果软件有国外的使用情况时,建议初始化程序采取这样的方式
QNDnsManager *dns;
if([QNDnsManager needHttpDns]){
    NSMutableArray *array = [[NSMutableArray alloc] init];
    [array addObject:[[QNResolver alloc] initWithAddress:@"119.29.29.29"]];
    [array addObject:[QNResolver systemResolver]];
    dns = [[QNDnsManager alloc] init:array networkInfo:[QNNetworkInfo normal]];
}else{
    NSMutableArray *array = [[NSMutableArray alloc] init];
    [array addObject:[QNResolver systemResolver]];
    [array addObject:[[QNResolver alloc] initWithAddress:@"114.114.114.114"]];
    dns = [[QNDnsManager alloc] init:array networkInfo:[QNNetworkInfo normal]];
}

代码贡献

详情参考代码提交指南

贡献记录

联系我们

  • 如果有什么问题,可以到问答社区提问,问答社区
  • 如果发现了bug, 欢迎提交 issue
  • 如果有功能需求,欢迎提交 issue
  • 如果要提交代码,欢迎提交 pull request
  • 欢迎关注我们的微信 微博,及时获取动态信息。

代码许可

The MIT License (MIT).详情见 License文件.

More Repositories

1

js-sdk

Qiniu Cloud JavaScript SDK
JavaScript
1,378
star
2

logkit

Very powerful server agent for collecting & sending logs & metrics with an easy-to-use web console.
Go
1,350
star
3

qmgo

Qmgo - The Go driver for MongoDB. It‘s based on official mongo-go-driver but easier to use like Mgo.
Go
1,297
star
4

qshell

Shell Tools for Qiniu Cloud
Go
980
star
5

php-sdk

Qiniu Resource (Cloud) Storage SDK for PHP
PHP
810
star
6

goc

A Comprehensive Coverage Testing System for The Go Programming Language
Go
796
star
7

httptest

Qiniu httptest utilities
Go
635
star
8

android-sdk

Qiniu Resource (Cloud) Storage SDK for Android
Java
626
star
9

nodejs-sdk

Qiniu Resource (Cloud) Storage SDK for Node.js
JavaScript
587
star
10

java-sdk

Qiniu Resource (Cloud) Storage SDK for Java
Java
549
star
11

python-sdk

Qiniu Resource (Cloud) Storage SDK for Python
Python
543
star
12

iconv

Golang bindings to libiconv - Convert string to requested character encoding
Go
474
star
13

objc-sdk

Qiniu Resource (Cloud) Storage Objective-C SDK for Mac/iOS
Objective-C
436
star
14

arch

极客时间专栏《许式伟的架构课》相关的源代码:冯诺伊曼结构
Go
407
star
15

cerl

CERL2.0 - Erlang Model for C++
C++
376
star
16

gobook

The Go Programming Language
Go
362
star
17

py

Golang bindings to the CPython C-API
Go
319
star
18

qetag

qetag
Erlang
316
star
19

happy-dns-android

dns library for android
Java
293
star
20

QSunSync

七牛云文件同步图形化工具-Windows版本
C#
271
star
21

api.v7

Qiniu SDK for Golang (v7.x)
Go
264
star
22

csharp-sdk

Qiniu Resource (Cloud) Storage SDK for C#
C#
176
star
23

qpaint

极客时间专栏《许式伟的架构课》相关的源代码:QPaint (画图程序)
JavaScript
170
star
24

ruby-sdk

Qiniu Resource (Cloud) Storage SDK for Ruby
Ruby
164
star
25

kodo-browser

Kodo Browser 为七牛对象存储(Kodo)提供类似 Windows 资源管理器的功能。用户可以很方便的浏览文件,上传下载文件,支持断点续传等。
TypeScript
159
star
26

iOS-netdiag

Network Diagnosis for iOS
Objective-C
144
star
27

android-netdiag

Network Diagnosis for Android
Java
136
star
28

go-sdk

golang sdk
Go
136
star
29

webhook

Github.com webhook tools
Go
131
star
30

checkstyle

checkstyle for go
Go
128
star
31

legacy-ios-sdk

Qiniu Resource (Cloud) Storage SDK for iOS
Objective-C
103
star
32

QStreaming

A simplified, lightweight ETL pipeline framework for build stream/batch processing applications on top of Apache Spark
Scala
101
star
33

audio

Audio support for Go language.
Go
79
star
34

api.v6

Qiniu Resource (Cloud) Storage SDK for Golang (v6.x)
Go
68
star
35

c-sdk

Qiniu Resource (Cloud) Storage SDK for C/C++
C
63
star
36

x

Extension of Go standard library
Go
62
star
37

http

Extension module of golang http service
Go
61
star
38

qfetch

七牛资源批量抓取工具,根据指定URL列表抓取资源并存储到七牛云空间。
Go
59
star
39

qplayer-sdk

七牛播放器SDK支持点播,直播,首开快,延迟低,接口简单,易于使用。
Java
57
star
40

qiniutest

Qiniu httptest tool: qiniutest
Go
37
star
41

builder

TypeScript
34
star
42

text

Qiniu Text Processing Libraries for Go
Go
34
star
43

ip17mon-java

17mon ip库查询
Java
33
star
44

formstate-x

Manage state of form with ease.
TypeScript
33
star
45

developer.qiniu.com

developer center
JavaScript
32
star
46

mockhttp.v1

mockhttp is a unit test tool that allow you test web services without listening port
Go
29
star
47

form-upload

Form upload demo for Qiniu Cloud Storage
Python
28
star
48

happy-dns-java

dns query client for java
Java
27
star
49

qiniu-logging-plugin

轻松输出Java应用日志到七牛云大数据日志平台
Java
26
star
50

rust-sdk

Generic Qiniu Resource Storage SDK
Rust
26
star
51

dart-sdk

Qiniu Resource (Cloud) Storage SDK for Dart
Dart
23
star
52

sdkspec

Qiniu Resource (Cloud) Storage SDK Specification
23
star
53

pandora-go-sdk

Go
21
star
54

doxygen.io

http://doxygen.io/ - Doxygen as Service
Go
19
star
55

go_dep_search

golang dependency search tool
Go
19
star
56

typed-less-modules

🎁 Generate type definitions (.d.ts) for CSS Modules using LESS
TypeScript
18
star
57

QiniuLiveWX

七牛直播、播放、连麦最简微信小程序demo
JavaScript
17
star
58

mockhttp.v2

mockhttp is a unit test tool that allow you test web services without listening port
Go
16
star
59

qlive

七牛直播命令行工具
Go
15
star
60

objc-DownloadSDK

Qiniu DownloadSDK for iOS
Objective-C
14
star
61

dyn

Package for dynamic programming
Go
12
star
62

reviewbot

reviewbot - establish software engineering best practices and efficiently promote them within the organization.
Go
12
star
63

pandora-java-sdk

Pandora Java SDK 多种方式灵活接入Pandora 大数据平台
Java
11
star
64

goplus-dt

Data Technology base of the Go+ language
Go
9
star
65

pandora-docs-old

CSS
9
star
66

kirk

Go
9
star
67

c-sdk-for-windows

Qiniu Resource (Cloud) Storage Windows SDK for C/C++
C
8
star
68

qwebtesttool

七牛本地网络环境检测图形界面。
C#
8
star
69

pandora-docs

pandora 文档站
JavaScript
7
star
70

php5.3-sdk

七牛云存储 php5.3 sdk(已经过时,请使用 php-sdk)
PHP
7
star
71

version

Go
6
star
72

qfetch-m3u8

qfetch m3u8专用版本,可以把m3u8和其引用的ts文件直接抓取到七牛云存储空间中
Go
6
star
73

openacc

Open Account System
6
star
74

api

Qiniu Resource (Cloud) Storage SDK for Golang
6
star
75

pandora-js-sdk

浏览器端使用的Pandora 大数据客户端打点SDK
JavaScript
6
star
76

deprecated-js-sdk

Qiniu Resource Storage SDK for JavaScript(deprecated)
JavaScript
6
star
77

docs.qiniu.com

CSS
5
star
78

eslint-config

ESLint config for Qiniu
JavaScript
5
star
79

php5-sdk

七牛云存储 PHP SDK,兼容 PHP 5.3 以下版本(已经过时,请使用 php-sdk)
PHP
5
star
80

httpping

http ping for test service
Go
5
star
81

link-c-sdk

qnlinking
C
5
star
82

QNLiveKit_Android

qlive-sdk是七牛云推出的一款互动直播低代码解决方案sdk。只需几行代码快速接入互动连麦pk直播。
Kotlin
5
star
83

cpp-sdk

Qiniu Resource Storage C++ SDK
C
4
star
84

objc-netinfo

Get NetworkInfo
Objective-C
4
star
85

pandora-python-sdk

Python
4
star
86

apidoc

Qiniu Resource (Cloud) Storage API Documents
4
star
87

kubernetes-csi-driver

CSI Plugin for Kubernetes, Support Qiniu Cloud Storage.
Go
4
star
88

qiniulab

C#
3
star
89

stack-go

七牛云主机服务 Go SDK
Go
3
star
90

Android-Universal-Image-Loader-HappyDns

Android-Universal-Image-Loader and happy dns
Java
3
star
91

kodo-enterprise-image

Shell
3
star
92

pfop

七牛持久化数据处理请求服务工具
Go
3
star
93

pandora-python-sdk.v2

SDK for Pandora 2.0
Python
3
star
94

raven

TypeScript
3
star
95

api-specs

Qiniu API Specs by YAML
3
star
96

pandora-php-sdk

PHP
3
star
97

pandora-nodejs-sdk

JavaScript
3
star
98

wp-sdk

Windows Phone SDK for Qiniu Cloud Storage API[不再维护]
C#
3
star
99

pandora-c-sdk

C/C++ SDK for Pandora Platform
C
2
star
100

rust-download-sdk

七牛下载 Rust SDK,负责下载完整或部分七牛对象。该 SDK 主要服务于专有云场景,对于普通的公有云 / 私有云场景,建议使用 https://github.com/qiniu/rust-sdk
Rust
2
star