• Stars
    star
    170
  • Rank 223,357 (Top 5 %)
  • Language
    Kotlin
  • Created over 8 years ago
  • Updated 4 months ago

Reviews

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

Repository Details

Tencent Cloud HTTPDNS SDK

HTTPDNS SDK Android

GitHub 目录结构说明

目录名称 说明 适用范围
HttpDNSLibs HttpDNS Android SDK 库目录 所有业务
HttpDnsSample HttpDNS Android 示例 SDK 开发维护人员
README.md HttpDNS Android 客户端接入文档 所有业务
CHANGELOG.md HttpDNS Android SDK 历史版本修改记录 SDK 开发维护人员

HTTPDNS SDK 接入步骤

文件拷贝

将 HttpDnsLibs 目录下的 aar 包及 jar 拷贝至项目工程中 libs 相应位置

HttpDnsLibs 目录下包含两个包:

  • 文件名以 HTTPDNS 为前缀的 aar 包(HTTPDNS_Android_xxxx.aar)为 HTTPDNS SDK
  • 文件名以 beacon 为前缀的 jar 包(beacon-android-xxxx.jar)为灯塔 SDK
    • HTTPDNS SDK 使用灯塔 SDK 进行数据上报

aar 引入配置

在 App module 的 build.gradle 文件中, 添加如下配置

android {

    // ...

    repositories {
        flatDir {
            dirs 'libs'
        }
    }
}

dependencies {

    // ...

    implementation(name: 'HTTPDNS_Android_xxxx', ext: 'aar')
}

网络安全配置兼容

App targetSdkVersion >= 28(Android 9.0)情况下,系统默认不允许 HTTP 网络请求,详细信息参见Opt out of cleartext trafficProtecting users with TLS by default in Android P

这种情况下,业务侧需要将 HTTPDNS 请求使用的 IP 配置到域名白名单中:

  • AndroidManifest 文件中配置
<?xml version="1.0" encoding="utf-8"?>
<manifest ... >
    <application android:networkSecurityConfig="@xml/network_security_config"
                    ... >
        ...
    </application>
</manifest>
  • xml 目录下添加 network_security_config.xml 配置文件
<?xml version="1.0" encoding="utf-8"?>
<network-security-config>
    <domain-config cleartextTrafficPermitted="true">
        <domain includeSubdomains="false">119.29.29.99</domain>
        <domain includeSubdomains="false">119.29.29.98</domain>
    </domain-config>
</network-security-config>

反混淆配置

# 灯塔
-keep class com.tencent.beacon.** {*;}

初始化

参考 Android SDK 文档 https://cloud.tencent.com/document/product/379/17655

i.初始化配置服务(可选,4.0.0版本开始支持)

在获取服务实例之前,我们可以通过初始化配置,设置服务的一些属性在SDK初始化时进行配置项传入。

DnsConfig dnsConfigBuilder = DnsConfig.Builder()
    //(必填)dns 解析 id,即授权 id,腾讯云官网(https://console.cloud.tencent.com/httpdns)申请获得,用于域名解析鉴权
    .dnsId("xxx")
    //(必填)dns 解析 key,即授权 id 对应的 key(加密密钥),在申请 SDK 后的邮箱里,腾讯云官网(https://console.cloud.tencent.com/httpdns)申请获得,用于域名解析鉴权
    .dnsKey("xxx")
    //(必填)Channel为desHttp()或aesHttp()时使用 119.29.29.98(默认填写这个就行),channel为https()时使用 119.29.29.99
    .dnsIp("xxx")
    //(可选)channel配置:基于 HTTP 请求的 DES 加密形式,默认为 desHttp(),另有 aesHttp()、https() 可选。(注意仅当选择 https 的 channel 需要选择 119.29.29.99 的dnsip并传入token,例如:.dnsIp('119.29.29.99').https().token('....') )。
    .desHttp()
    //(可选,选择 https channel 时进行设置)腾讯云官网(https://console.cloud.tencent.com/httpdns)申请获得,用于 HTTPS 校验。仅当选用https()时进行填写
    .token("xxx")
    //(可选)日志粒度,如开启Debug打印则传入"Log.VERBOSE"
    .logLevel(Log.VERBOSE)
    //(可选)填写形式:"baidu.com", "qq.com",预解析域名, 建议不要设置太多预解析域名, 当前限制为最多 10 个域名
    .preLookupDomains("baidu.com", "qq.com")
    //(可选)手动指定网络栈支持情况,仅进行 IPv4 解析传 1,仅进行 IPv6 解析传 2,进行 IPv4、IPv6 双栈解析传 3。默认为根据客户端本地网络栈支持情况发起对应的解析请求。
    .setCustomNetStack(3)
    //(可选)设置域名解析请求超时时间,默认为1000ms
    .timeoutMills(1000)
    //(可选)是否开启解析异常上报,默认false,不上报
    .enableReport(true)
    // 以build()结束
    .build();
    
MSDKDnsResolver.getInstance().init(this, dnsConfigBuilder);

ii. 老版本初始化方法

  • HTTP 协议服务地址为 119.29.29.98,HTTPS 协议服务地址为 119.29.29.99(仅当采用自选加密方式并channelHttps时使用99的IP)。
  • 新版本 API 更新为使用 119.29.29.99/98 接入,同时原移动解析 HTTPDNS 服务地址 119.29.29.29 仅供开发调试使用,无 SLA 保障,不建议用于正式业务,请您尽快将正式业务迁移至 119.29.29.99/98
  • 具体以 API 说明 提供的 IP 为准。
  • 使用 SDK 方式接入 HTTPDNS,若 HTTPDNS 未查询到解析结果,则通过 LocalDNS 进行域名解析,返回 LocalDNS 的解析结果。

默认使用 DES 加密

默认不进行解析异常上报
// 以下鉴权信息可在腾讯云控制台(https://console.cloud.tencent.com/httpdns/configure)开通服务后获取

/**
 * 初始化 HTTPDNS(默认为 DES 加密):如果接入了 MSDK,建议初始化 MSDK 后再初始化 HTTPDNS
 *
 * @param context 应用上下文,最好传入 ApplicationContext
 * @param appkey 业务 appkey,即 SDK AppID,腾讯云官网(https://console.cloud.tencent.com/httpdns)申请获得,用于上报
 * @param dnsid dns解析id,即授权id,腾讯云官网(https://console.cloud.tencent.com/httpdns)申请获得,用于域名解析鉴权
 * @param dnskey dns解析key,即授权id对应的 key(加密密钥),在申请 SDK 后的邮箱里,腾讯云官网(https://console.cloud.tencent.com/httpdns)申请获得,用于域名解析鉴权
 * @param dnsIp 由外部传入的dnsIp,可选:"119.29.29.98",以腾讯云文档(https://cloud.tencent.com/document/product/379/54976)提供的 IP 为准
 * @param debug 是否开启 debug 日志,true 为打开,false 为关闭,建议测试阶段打开,正式上线时关闭
 * @param timeout dns请求超时时间,单位ms,建议设置1000
 */
MSDKDnsResolver.getInstance().init(MainActivity.this, appkey, dnsid, dnskey, dnsIp, debug, timeout);
手动开启异常解析上报
// 以下鉴权信息可在腾讯云控制台(https://console.cloud.tencent.com/httpdns/configure)开通服务后获取

/**
 * 初始化 HTTPDNS(默认为 DES 加密):如果接入了 MSDK,建议初始化 MSDK 后再初始化 HTTPDNS
 *
 * @param context 应用上下文,最好传入 ApplicationContext
 * @param appkey 业务 appkey,即 SDK AppID,腾讯云官网(https://console.cloud.tencent.com/httpdns)申请获得,用于上报
 * @param dnsid dns解析id,即授权id,腾讯云官网(https://console.cloud.tencent.com/httpdns)申请获得,用于域名解析鉴权
 * @param dnskey dns解析key,即授权id对应的 key(加密密钥),在申请 SDK 后的邮箱里,腾讯云官网(https://console.cloud.tencent.com/httpdns)申请获得,用于域名解析鉴权
 * @param dnsIp 由外部传入的dnsIp,可选:"119.29.29.98"(仅支持 http 请求,channel为DesHttp和AesHttp时选择),"119.29.29.99"(仅支持 https 请求,channel为Https时选择)以腾讯云文档(https://cloud.tencent.com/document/product/379/54976)提供的 IP 为准
 * @param debug 是否开启 debug 日志,true 为打开,false 为关闭,建议测试阶段打开,正式上线时关闭
 * @param timeout dns请求超时时间,单位ms,建议设置1000
 * @param enableReport 是否开启解析异常上报,默认false,不上报
 */
MSDKDnsResolver.getInstance().init(MainActivity.this, appkey, dnsid, dnskey, dnsIp, debug, timeout, enableReport);

自选加密方式(DesHttp, AesHttp, Https)

/**
 * 初始化 HTTPDNS(自选加密方式):如果接入了 MSDK,建议初始化 MSDK 后再初始化 HTTPDNS
 *
 * @param context 应用上下文,最好传入 ApplicationContext
 * @param appkey 业务 appkey,即 SDK AppID,腾讯云官网(https://console.cloud.tencent.com/httpdns)申请获得,用于上报
 * @param dnsid dns解析id,即授权id,腾讯云官网(https://console.cloud.tencent.com/httpdns)申请获得,用于域名解析鉴权
 * @param dnskey dns解析key,即授权id对应的 key(加密密钥),在申请 SDK 后的邮箱里,腾讯云官网(https://console.cloud.tencent.com/httpdns)申请获得,用于域名解析鉴权
 * @param dnsIp 由外部传入的dnsIp,可选:"119.29.29.98"(仅支持 http 请求,channel为DesHttp和AesHttp时选择),"119.29.29.99"(仅支持 https 请求,channel为Https时选择)以腾讯云文档(https://cloud.tencent.com/document/product/379/54976)提供的 IP 为准
 * @param debug 是否开启 debug 日志,true 为打开,false 为关闭,建议测试阶段打开,正式上线时关闭
 * @param timeout dns请求超时时间,单位ms,建议设置1000
 * @param channel 设置 channel,可选:DesHttp(默认), AesHttp, Https
 * @param token 腾讯云官网(https://console.cloud.tencent.com/httpdns)申请获得,用于 HTTPS 校验
 * @param enableReport 是否开启解析异常上报,默认false,不上报
 */
MSDKDnsResolver.getInstance().init(MainActivity.this, appkey, dnsid, dnskey, dnsIp, debug, timeout, channel, token, true);

More Repositories

1

TIMSDK

Tencent Cloud Chat features a comprehensive suite of solutions including global access, one-to-one chat, group chat, message push, profile and relationship chain hosting, and account authentication.
Java
2,574
star
2

tencentcloud-sdk-go

Tencent Cloud API 3.0 SDK for Golang
Go
641
star
3

tencentcloud-sdk-python

Tencent Cloud API 3.0 SDK for Python
Python
534
star
4

tencentcloud-sdk-java

Tencent Cloud API 3.0 SDK for Java
Java
516
star
5

O266player

C
378
star
6

tencentcloud-sdk-nodejs

Tencent Cloud API 3.0 SDK for NodeJS
TypeScript
364
star
7

tencentcloud-sdk-php

Tencent Cloud API 3.0 SDK for PHP
PHP
350
star
8

tencentcloud-sdk-dotnet

Tencent Cloud API 3.0 SDK for .NET
C#
348
star
9

serverless

TencentCloud Serverless
Python
230
star
10

tencentcloud-monitor-grafana-app

Tencent Cloud Monitor App Plugin for Grafana
TypeScript
151
star
11

httpdns-sdk-ios

智营防劫持SDK
Objective-C
150
star
12

tencentcloud-iot-sdk-embedded-c

SDK for connecting to Tencent Cloud IoT from a device using embedded C.
C
149
star
13

chat-uikit-flutter

A powerful Flutter chat UI component library and business logic for Tencent Cloud Chat, creating seamless in-app chat modules for delightful user experiences.
Dart
145
star
14

chat-uikit-vue

Build In-App Chat & Audio/Video Call & Live Streaming in minutes with UIKit components for Vue
Vue
128
star
15

chat-uikit-uniapp

腾讯云 IM 的 uniapp UI 组件库,支持 vue2/vue3,在几分钟内即可构建应用内聊天、音视频通话和直播功能。
Vue
114
star
16

tencentcloud-iot-explorer-sdk-embedded-c

SDK for embedded system connect and comunicate with Tencent Cloud IoT Explorer Platform
C
113
star
17

chat-demo-flutter

The sample app showcasing Tencent Cloud Chat integration with Flutter across iOS, Android, Web, macOS, and Windows platforms.
C
92
star
18

cosbrowser

腾讯云 COS 客户端
88
star
19

tc-iot-sdk-embedded-for-esp8266

C
83
star
20

tencentcloud-cloud-controller-manager

tencentcloud cloud controller manager for kubernetes
Go
81
star
21

scf-node-debug

JavaScript
76
star
22

chat-uikit-react

Build In-App Chat & Audio/Video Call & Live Streaming in minutes with UIKit components for React
TypeScript
69
star
23

libtquic-sdk

腾讯TQUIC-跨平台通用QUIC网络库
Objective-C
68
star
24

trtc-education-electron

教育场景化解决方案App,包含基础的实时音视频通信和即时通信功能,支持丰富的课堂互动(举手、点名/签到等)和教育白板。 技术栈:Electron、React、Material-ui react、Webpack、sass等。
TypeScript
66
star
25

chat-uikit-wechat

腾讯云即时通信 IM,基于微信小程序原生的开源 UI 组件
JavaScript
65
star
26

tencentcloud-cli

Tencent Cloud API 3.0 Command Line Interface
Python
62
star
27

TPNS-Flutter-Plugin

Dart
60
star
28

kubernetes-csi-tencentcloud

kubernetes csi volume plugin for tencentcloud
Go
57
star
29

tencentcloud-sdk-cpp

Tencent Cloud API 3.0 SDK for C++
C++
53
star
30

tencentcloud-speech-sdk-js

JavaScript
52
star
31

chat-uikit-android

Tencent Cloud Chat UI Components For Android
Java
28
star
32

tc-ocr-sdk

通用文字识别客户端SDK
JavaScript
28
star
33

tencentcloud-sdk-ruby

Tencent Cloud API 3.0 SDK for Ruby
Ruby
27
star
34

cos-action

Github Action to upload to Tencent Cloud COS
JavaScript
26
star
35

wemeet-restapi-sdk-java

腾讯会议开放平台java sdk
Java
25
star
36

chat-uikit-ios

Tencent Cloud Chat UI Components For iOS
Objective-C
24
star
37

tencentcloud-speech-sdk-python

Python
23
star
38

tencentcloud-sdk-android-soe

soe android sdk
Java
17
star
39

chat-sdk-flutter

腾讯云即时通信IM Flutter 无UI SDK
Dart
16
star
40

cluster-api-provider-tencent

Go
16
star
41

tencentcloud-im-sdk-java

腾讯云 即时通信IM RESTAPI SDK Java 版本
Java
16
star
42

tencentcloud-cls-sdk-go

cls log go sdk
Go
15
star
43

tencentcloud-speech-sdk-go

Go
14
star
44

tencentcloud-iot-explorer-ble-sdk-embedded

C
14
star
45

tcb-sdk-php

tencent cloud base sdk for php
PHP
13
star
46

tencentcloud-sdk-ios-soe

soe iOS sdk
C
13
star
47

signature-process-demo

Demonstrate Cloud API Signature Process.
C#
12
star
48

tencentcloud-im-sdk-php

腾讯云 即时通信IM RESTAPI SDK PHP 版本
PHP
12
star
49

container-demo

Tencent Cloud Container Products (TKE, EKS, Edge, TCM, TCR etc) Examples
Java
11
star
50

tencentcloud-demo-mp-soe

soe wechat miniprogram demo
JavaScript
10
star
51

joox-sdk-android

JOOX SDK/demo 仓库
Kotlin
10
star
52

chat-demo-electron

腾讯云即时通信IM Electron Demo
TypeScript
10
star
53

chat-demo-react-native

Tencent Cloud IM(Chat) React Native Demo
TypeScript
9
star
54

virtualman-render-demo

云小微数智人移动端渲染demo,包括云渲染以及端渲染示例代码
JavaScript
9
star
55

chat-demo-flutter-hybrid

Tencent Cloud Chat: Samples of integratation Flutter SDK to an existing app.
Dart
9
star
56

ERDN

基于同感受野可变形卷积网络的视频去模糊
Python
9
star
57

cls-iframe-demo

CLS iframe demo. https://cloud.tencent.com/document/product/614/45742
JavaScript
9
star
58

tencentcloud-cls-sdk-android

腾讯云CLS Android SDK
Java
8
star
59

tencentcloud-sdk-java-intl-en

Tencent Cloud API 3.0 SDK for Java
Java
8
star
60

hostpathperpod

A simple flex volume plugin like hostPath, but create a host directory with pod meta.
Go
8
star
61

tencentcloud-serverless-nodejs

腾讯云云函数SDK,集成云函数业务流接口
JavaScript
8
star
62

cls-console-sdk

You can embed Tencent Cloud CLS into other systems to access logs without login, which can help you use CLS (including search and analysis, dashboard, and other features) more efficiently. 将腾讯云日志服务以内嵌方式集成到其他系统中,免登录实现一站式日志访问,方便快捷使用CLS日志服务(包含检索分析,仪表盘)
TypeScript
8
star
63

Serverless-demos

7
star
64

cos-sdk-flutter-plugin

对象存储COS Flutter语言SDK(桥接plugin实现)
Dart
7
star
65

tencentcloud-cls-sdk-java

cls日志sdk
Java
6
star
66

tencentcloud-speech-sdk-cpp

C++
6
star
67

tencentcloud-sdk-python-intl-en

Tencent Cloud API 3.0 SDK for Python
Python
6
star
68

tcb-sdk-dotnet

云开发 .NET SDK
C#
6
star
69

tencentcloud-cls-sdk-cpp

腾讯云CLS CPP SDK
C++
6
star
70

tencentcloud-cls-sdk-js

cls log js sdk
TypeScript
6
star
71

tencentcloud-cls-sdk-ios

腾讯云 CLS IOS SDK
C
6
star
72

tencentcloud-iot-explorer-ble-sdk-embedded-demo

C
6
star
73

wemeet-restapi-sdk-php

腾讯会议开放平台php sdk
PHP
5
star
74

tencentcloud-opentelemetry-java

腾讯云APM团队基于opentelemetry-java-instrumentation开源项目进行二次开发
5
star
75

Serverless-examples

云函数(Serverless Cloud Function,SCF)示例代码库
Python
5
star
76

cls-grafana-datasource

TencentCloud Log Service datasource plugin for Grafana
TypeScript
5
star
77

tdmq-go-client

Go
5
star
78

tencentcloud-cls-sdk-python

腾讯云日志服务python sdk
Python
5
star
79

chat-plugin-ue5

Tencent Cloud Chat for IM Unreal Engine 5
C++
5
star
80

tdmq-java-client

Java
5
star
81

cos-sdk-react-native-plugin

对象存储COS React Native语言SDK(桥接plugin实现)
TypeScript
5
star
82

tione-tilearn-angel

腾讯云TI平台tilearn-angel训练推理加速最佳实践案例集
Shell
5
star
83

tencentcloud-cls-logback-appender

tencentcloud cls logback appender
Java
4
star
84

ckafka-sdk-demo

腾讯云CKafka各语言demo
C
4
star
85

tencentcloud-sdk-go-intl-en

Tencent Cloud API 3.0 SDK for Golang
Go
4
star
86

tencent-chat-i18n-tool

An easy-to-use and versatile Flutter internationalization tool tailored for application using Tencent Cloud Chat, streamlining multi-language support for developers.
Dart
4
star
87

tencentcloud-speech-sdk-java

Java
4
star
88

smh-sdk-android

腾讯云智能媒资托管服务(https://cloud.tencent.com/product/smh) Android SDK,实现手机端媒体文件的上传、下载与云端管理功能。
Kotlin
4
star
89

rocketmq-demo

腾讯云 RocketMQ 当前有较多的用户尝试接入,但是很多用户在第一次接入的时候会有较多的问题,该仓库的目的在于给用户提供多种语言 SDK 接入的代码 Demo。根据不同的功能以及使用场景,提供规范的接入 Demo 代码,用户开箱即用,降低用户接入的成本而且可以避免用户由于错误使用导致的故障等问题。
Java
4
star
90

tavmedia-sdk-ios

全平台视频剪辑方案
Objective-C
3
star
91

tencentcloud-speech-sdk-java-example

Java
3
star
92

huiyan-faceid-demo

慧眼产品的对外使用示例代码的Example
Java
3
star
93

tencentcloud-sdk-dotnet-intl-en

Tencent Cloud API 3.0 SDK for .NET
C#
3
star
94

tcb-manager-sdk-php

PHP
3
star
95

TPNS-iOS-CocoaPods

腾讯移动推送iOS SDK pod仓库
Objective-C
3
star
96

qapm-sdk-ios

主要用来更新qapm性能监控组件
Objective-C
3
star
97

tke-cluster-credential-action

Retrieve TKE cluster credential and set it to $HOME/.kube/config.
JavaScript
3
star
98

tencentcloud-cls-sdk-php

腾讯云CLS PHP SDK
PHP
3
star
99

apigateway-demo

Python
3
star
100

tencentcloud-speech-sdk-dotnet

语音识别SDK
C#
3
star