dns library for android

Overview

Qiniu Happy DNS for Android

@qiniu on weibo LICENSE Build Status GitHub release codecov Latest Stable Version

安装

直接安装

通过maven

使用方法

DnsManager 可以创建一次,一直使用。

    IResolver[] resolvers = new IResolver[3];
    resolvers[0] = AndroidDnsServer.defaultResolver(getContext()); //系统默认 DNS 服务器
    resolvers[1] = new Resolver(InetAddress.getByName("119.29.29.29")); //自定义 DNS 服务器地址
    resolvers[2] = new QiniuDns(accountId, encryptKey, expireTimeMs); //七牛 http dns 服务
    DnsManager dns = new DnsManager(NetworkInfo.normal(), resolvers);

其中,七牛 http dns 服务所需的参数如下:

参数 描述
accountId 账户名称,从七牛控制台获取
encryptKey 加密所需的 key,从七牛控制台获取
expireTimeSecond Unix 时间戳,单位为秒,该时间后请求过期

QiniuDns 提供了 setHttpssetEncrypted 两个方法,用于设置是否启用 SSL,与请求的 URL 是否加密。

测试

$ ./gradlew connectedAndroidTest

运行环境

Android 最低要求 2.3

代码贡献

详情参考代码提交指南

贡献记录

联系我们

  • 如果需要帮助,请提交工单(在portal右侧点击咨询和建议提交工单,或者直接向 [email protected] 发送邮件)
  • 如果有什么问题,可以到问答社区提问,问答社区
  • 如果发现了bug, 欢迎提交 issue
  • 如果有功能需求,欢迎提交 issue
  • 如果要提交代码,欢迎提交 pull request
  • 欢迎关注我们的微信 微博,及时获取动态信息。

常见问题

  • 如果软件有国外的使用情况时,建议初始化程序采取这样的方式,下面代码只是根据时区做简单判断,开发者可以根据自己需要使用更精确的判断方式
DnsManager dns;
if(DnsManager.needHttpDns()){
	IResolver[] resolvers = new IResolver[2];
    resolvers[0] = new DnspodFree();
    resolvers[1] = AndroidDnsServer.defaultResolver(getContext());
    dns = new DnsManager(NetworkInfo.normal, resolvers);
}else{
	IResolver[] resolvers = new IResolver[2];
    resolvers[0] = AndroidDnsServer.defaultResolver(getContext());
    resolvers[1] = new Resolver(InetAddress.getByName("8.8.8.8"));
    dns = new DnsManager(NetworkInfo.normal, resolvers);
}

代码许可

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

Comments
  • 这种用法无法解决dns解析被网络运营商解析成错误的ip地址的问题

    这种用法无法解决dns解析被网络运营商解析成错误的ip地址的问题

    如果resolvers[0]能解析到ip地址,就算这个ip地址是无法访问的,也永远不会使用resolvers[1]

    IResolver[] resolvers = new IResolver[2];
    resolvers[0] = AndroidDnsServer.defaultResolver();
    resolvers[1] = new Resolver(InetAddress.getByName("8.8.8.8"));
    dns = new DnsManager(NetworkInfo.normal, resolvers);
    
    opened by kris520 2
  • DnsException 出现 ZipException 运行时异常

    DnsException 出现 ZipException 运行时异常

    编译 OK,无法打包。

    Error:Execution failed for task ':app:transformClassesWithJarMergingForOfficialDebug'.
    > com.android.build.api.transform.TransformException: java.util.zip.ZipException: duplicate entry: com/qiniu/android/dns/DnsException.class
    
    opened by cxyxlxdm 2
  • 添加Doh,DohJson,IPV6支持

    添加Doh,DohJson,IPV6支持

    https://github.com/qiniu/happy-dns-android/issues/35

    DoH JSON API

    https://dns.google/resolve?
    https://dns.alidns.com/resolve?
    https://doh.pub/dns-query?
    https://doh.360.cn/resolve?
    

    Dns over https(RFC8484)

    https://dns.google/dns-query
    https://dns.alidns.com/dns-query
    https://doh.pub/dns-query
    https://doh.360.cn/dns-query
    
    size/XL 
    opened by ag2s20150909 1
  •  ///Android 8 , net.dns* was disabled, query dns servers must use net…

    ///Android 8 , net.dns* was disabled, query dns servers must use net…

    …work callback

    ///@see https://developer.android.com/about/versions/oreo/android-8.0-changes.html

    if change build target to 26 and run in android 8.0, happy dns will not work.

    this commit try to fix it, and all test pass except LocalServerTest!

    opened by heroyin 1
  • DnspodEnterprise 内置默认ip更换

    DnspodEnterprise 内置默认ip更换

    DnspodEnterprise 默认ip是 119.29.29.29

    官方公告说明对于企业版也推荐更换ip https://cloud.tencent.com/document/product/379/56885

    DnspodEnterprise 实现是 DES 加解密,默认 ip 换成 119.29.29.98

    opened by ongakuer 1
  • AndroidDnsServer.defaultResolver(); 缺少参数

    AndroidDnsServer.defaultResolver(); 缺少参数

    编译时,AndroidDnsServer.defaultResolver(); 这行代码报错,提示:

            IResolver r1 = AndroidDnsServer.defaultResolver();
                                           ^
      需要: Context
      找到: 没有参数
      原因: 实际参数列表和形式参数列表长度不同
    

    看了源码,需要传入 Context,然而文档里没有提到需要传这个,也没讲如何获取

    opened by Lyrillind 1
Releases(v2.0.1)
Owner
Qiniu Cloud
Connect Data, Redefine Value.
Qiniu Cloud
:satellite: [Android Library] Simplified async networking in android

Android library that simplifies networking in android via an async http client. Also featured in [Awesome Android Newsletter #Issue 15 ] Built with ❤︎

Nishant Srivastava 36 May 14, 2022
Android network client based on Cronet. This library let you easily use QUIC protocol in your Android projects

Android network client based on Cronet. This library let you easily use QUIC protocol in your Android projects

VK.com 104 Dec 12, 2022
Android Easy Http - Simplest android http request library.

Android Easy Http Library 繁體中文文檔 About Android Easy Http Library Made on OkHttp. Easy to do http request, just make request and listen for the respons

null 13 Sep 30, 2022
🚀 A Complete Fast Android Networking Library that also supports HTTP/2 🚀

Fast Android Networking Library About Fast Android Networking Library Fast Android Networking Library is a powerful library for doing any type of netw

AMIT SHEKHAR 5.5k Dec 27, 2022
The easiest HTTP networking library for Kotlin/Android

Fuel The easiest HTTP networking library for Kotlin/Android. You are looking at the documentation for 2.x.y.. If you are looking for the documentation

Kittinun Vantasin 4.3k Jan 8, 2023
Asynchronous socket, http(s) (client+server) and websocket library for android. Based on nio, not threads.

AndroidAsync AndroidAsync is a low level network protocol library. If you are looking for an easy to use, higher level, Android aware, http request li

Koushik Dutta 7.3k Jan 2, 2023
The best file downloader library for Android

Overview Fetch is a simple, powerful, customizable file download manager library for Android. Features Simple and easy to use API. Continuous download

Tonyo Francis 1.5k Jan 8, 2023
Android library listening network connection state and change of the WiFi signal strength with event bus

NetworkEvents Android library listening network connection state and change of the WiFi signal strength with event bus. It works with any implementati

Piotr Wittchen 452 Nov 21, 2022
🚀 A Complete Fast Android Networking Library that also supports HTTP/2 🚀

Fast Android Networking Library About Fast Android Networking Library Fast Android Networking Library is a powerful library for doing any type of netw

AMIT SHEKHAR 5.5k Jan 3, 2023
Flower - Super cool Android library to manage networking and database caching with ease

Flower Super cool Android library to manage networking and database caching with ease. It allows developers to use remote resources on-the-fly OR Comb

Rajesh Hadiya 192 Dec 26, 2022
android lightweight graphql library

android lightweight graphql library

Muh Isfhani Ghiath 30 Nov 12, 2022
Light library to check internet connection in android apps easily.

check-internet-android Light library to check internet connection in android apps easily. It checks real internet connection by connecting to Google's

Raheem 7 Nov 15, 2022
Volley is an HTTP library that makes networking for Android apps easier and, most importantly, faster.

Volley Volley is an HTTP library that makes networking for Android apps easier and, most importantly, faster. For more information about Volley and ho

Google 3.3k Jan 1, 2023
SimpleApiCalls is a type-safe REST client for Android. The library provides the ability to interact with APIs and send network requests with HttpURLConnection.

SimpleApiCalls ?? SimpleApiCalls is a type-safe REST client for Android. The library provides the ability to interact with APIs and send network reque

null 4 Nov 28, 2022
Asynchronous Http and WebSocket Client library for Java

Async Http Client Follow @AsyncHttpClient on Twitter. The AsyncHttpClient (AHC) library allows Java applications to easily execute HTTP requests and a

AsyncHttpClient 6k Jan 8, 2023
HttpMocker is a simple HTTP mocking library written in Kotlin to quickly and easily handle offline modes in your apps

HttpMocker HttpMocker is a very lightweight Kotlin library that allows to mock HTTP calls relying on either OkHttp or the Ktor client libraries. It ca

David Blanc 174 Nov 28, 2022
Kotlin HTTP requests library. Similar to Python requests.

khttp khttp is a simple library for HTTP requests in Kotlin. It functions similarly to Python's requests module. import khttp.get fun main(args: Arra

Anna Clemens 466 Dec 20, 2022
Java HTTP Request Library

Http Request A simple convenience library for using a HttpURLConnection to make requests and access the response. This library is available under the

Kevin Sawicki 3.3k Jan 6, 2023
Unirest in Java: Simplified, lightweight HTTP client library.

Unirest for Java Install With Maven: <!-- Pull in as a traditional dependency --> <dependency> <groupId>com.konghq</groupId> <artifactId>unire

Kong 2.4k Jan 5, 2023