{"id":3563,"url":"https://github.com/qiniu/happy-dns-android","last_synced_at":"2025-05-05T20:18:18.857Z","repository":{"id":33100816,"uuid":"36738467","full_name":"qiniu/happy-dns-android","owner":"qiniu","description":"dns library for android","archived":false,"fork":false,"pushed_at":"2024-05-13T07:47:32.000Z","size":411,"stargazers_count":313,"open_issues_count":10,"forks_count":65,"subscribers_count":20,"default_branch":"master","last_synced_at":"2025-05-05T20:18:11.472Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/qiniu.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"Contributing.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2015-06-02T14:22:28.000Z","updated_at":"2025-04-18T06:56:02.000Z","dependencies_parsed_at":"2024-05-13T08:58:35.639Z","dependency_job_id":null,"html_url":"https://github.com/qiniu/happy-dns-android","commit_stats":null,"previous_names":[],"tags_count":21,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/qiniu%2Fhappy-dns-android","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/qiniu%2Fhappy-dns-android/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/qiniu%2Fhappy-dns-android/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/qiniu%2Fhappy-dns-android/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/qiniu","download_url":"https://codeload.github.com/qiniu/happy-dns-android/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252569641,"owners_count":21769517,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-01-05T20:16:45.041Z","updated_at":"2025-05-05T20:18:18.835Z","avatar_url":"https://github.com/qiniu.png","language":"Java","funding_links":[],"categories":["Libraries","网络编程"],"sub_categories":["Networking"],"readme":"# Qiniu Happy DNS for Android\n\n[![@qiniu on weibo](http://img.shields.io/badge/weibo-%40qiniutek-blue.svg)](http://weibo.com/qiniutek)\n[![LICENSE](https://img.shields.io/github/license/qiniu/happy-dns-android.svg)](https://github.com/qiniu/happy-dns-android/blob/master/LICENSE)\n[![Build Status](https://travis-ci.org/qiniu/happy-dns-android.svg?branch=master)](https://travis-ci.org/qiniu/happy-dns-android)\n[![GitHub release](https://img.shields.io/github/v/tag/qiniu/happy-dns-android.svg?label=release)](https://github.com/qiniu/happy-dns-android/releases)\n[![codecov](https://codecov.io/gh/qiniu/happy-dns-android/branch/master/graph/badge.svg)](https://codecov.io/gh/qiniu/happy-dns-android)\n[![Latest Stable Version](http://img.shields.io/maven-central/v/com.qiniu/happy-dns.svg)](https://github.com/qiniu/happy-dns-android/releases)\n\n## 用途\n可以使用114 等第三方dns解析，也可以使用 Doh 协议的 Dns 解析方案，也可以集成 dnspod 等httpdns。另外也有丰富的hosts 域名配置。\n\n## 安装\n\n### 直接安装\n将sdk jar文件 复制到项目中去，[jar包下载地址](https://search.maven.org/search?q=com%2Fqiniu%2Fqiniu-android-sdk) 下载对应的jar包\n\n### 通过maven\n* Android Studio中添加dependencies 或者 在项目中添加maven依赖\n```\nimplementation 'com.qiniu:happy-dns:2.0.1'\n```\n\n\n## 使用方法\nDnsManager 可以创建一次，一直使用。\n```java\n    IResolver[] resolvers = new IResolver[3];\n    resolvers[0] = AndroidDnsServer.defaultResolver(getContext()); //系统默认 DNS 服务器\n    resolvers[1] = new DnsUdpResolver(\"8.8.8.8\"); //自定义 DNS 服务器地址\n    resolvers[2] = new DohResolver(\"https://dns.alidns.com/dns-query\");\n    DnsManager dns = new DnsManager(NetworkInfo.normal(), resolvers);\n    Record[] records = dns.queryRecords(\"www.qiniu.com\");\n```\n\n## 测试\n\n``` bash\n$ ./gradlew connectedAndroidTest\n```\n\n## 运行环境\n\nAndroid 最低要求 2.3\n\n## 代码贡献\n\n详情参考[代码提交指南](https://github.com/qiniu/happy-dns-android/blob/master/CONTRIBUTING.md)。\n\n## 贡献记录\n\n- [所有贡献者](https://github.com/qiniu/happy-dns-android/contributors)\n\n## 联系我们\n\n- 如果需要帮助，请提交工单（在portal右侧点击咨询和建议提交工单，或者直接向 support@qiniu.com 发送邮件）\n- 如果有什么问题，可以到问答社区提问，[问答社区](http://qiniu.segmentfault.com/)\n- 如果发现了bug， 欢迎提交 [issue](https://github.com/qiniu/happy-dns-android/issues)\n- 如果有功能需求，欢迎提交 [issue](https://github.com/qiniu/happy-dns-android/issues)\n- 如果要提交代码，欢迎提交 pull request\n- 欢迎关注我们的[微信](http://www.qiniu.com/#weixin) [微博](http://weibo.com/qiniutek)，及时获取动态信息。\n\n## 常见问题\n- 如果软件有国外的使用情况时，建议初始化程序采取这样的方式，下面代码只是根据时区做简单判断，开发者可以根据自己需要使用更精确的判断方式\n\n```java\nDnsManager dns;\nif(DnsManager.needHttpDns()){\n\tIResolver[] resolvers = new IResolver[2];\n    // dohResolver 需要配置一个支持 Doh(Dns over http) 协议的 url\n    resolvers[0] = new DnhResolver(\"https://dns.alidns.com/dns-query\");\n    resolvers[1] = AndroidDnsServer.defaultResolver(getContext());\n    dns = new DnsManager(NetworkInfo.normal, resolvers);\n}else{\n\tIResolver[] resolvers = new IResolver[2];\n    resolvers[0] = AndroidDnsServer.defaultResolver(getContext());\n    resolvers[1] = new DnsUdpResolver(\"8.8.8.8\");\n    dns = new DnsManager(NetworkInfo.normal, resolvers);\n}\n```\n## 代码许可\n\nThe MIT License (MIT).详情见 [License文件](https://github.com/qiniu/happy-dns-android/blob/master/LICENSE).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fqiniu%2Fhappy-dns-android","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fqiniu%2Fhappy-dns-android","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fqiniu%2Fhappy-dns-android/lists"}