Skip to content

Commit

Permalink
feat: 统一初始化方式
Browse files Browse the repository at this point in the history
  • Loading branch information
ocleo1 committed May 13, 2021
1 parent 50f0fbd commit 6afadaf
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 46 deletions.
35 changes: 8 additions & 27 deletions MSDKDns/MSDKDns.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,13 @@ typedef enum {
} HttpDnsEncryptType;

struct DnsConfig {
NSString* appId;
int dnsId;
NSString* dnsKey; // 加密方式为AES、DES时必传
NSString* appId; // 应用ID,腾讯云控制台申请获得,用于上报
int dnsId; // 授权ID,腾讯云控制台申请后,通过邮件发送,用于域名解析鉴权
NSString* dnsKey; // 加密密钥,加密方式为AES、DES时必传。腾讯云控制台申请后,通过邮件发送,用于域名解析鉴权
NSString* token; // 加密方式为 HTTPS 时必传
NSString* dnsIp; // httpdns 服务器ip
BOOL debug; // 是否打印调试日志
int timeout; // 请求超时时间
NSString* dnsIp; // HTTPDNS 服务器IP
BOOL debug; // 是否开启Debug日志,YES:开启,NO:关闭。建议联调阶段开启,正式上线前关闭
int timeout; // 超时时间,单位ms,如设置0,则设置为默认值2000ms
HttpDnsEncryptType encryptType; // 控制加密方式
NSString* routeIp; // 线路IP地址
};
Expand All @@ -41,33 +41,17 @@ struct DnsConfig {
/**
* 初始化SDK
*
* @param appId SDK AppID,腾讯云官网(https://console.cloud.tencent.com/httpdns)申请获得,用于上报
* @param dnsId 授权 ID,腾讯云官网(https://console.cloud.tencent.com/httpdns)申请后,通过邮件发送,用于域名解析鉴权
* @param dnsKey 加密密钥,腾讯云官网(https://console.cloud.tencent.com/httpdns)申请后,通过邮件发送,用于域名解析鉴权
* @param dnsIp HTTPDNS IP 地址
* @param debug 是否开启Debug日志,YES:开启,NO:关闭。建议联调阶段开启,正式上线前关闭
* @param timeout 超时时间,单位ms,如设置0,则设置为默认值2000ms
* @param config 配置
* @return YES:设置成功 NO:设置失败
*/
- (BOOL) initConfig:(NSString *)appId dnsId:(int)dnsId dnsKey:(NSString *)dnsKey dnsIp:(NSString *)dnsIp debug:(BOOL)debug timeout:(int)timeout;
- (BOOL) initConfig:(DnsConfig *)config;

/**
* @deprecated This method is deprecated starting in version 1.2.1i
* @note Please use @code initConfig:dnsId:dnsKey:dnsIp:debug:timeout @endcode instead.
*/
- (BOOL) WGSetDnsAppKey:(NSString *) appkey DnsID:(int)dnsid DnsKey:(NSString *)dnsKey DnsIP:(NSString *)dnsip Debug:(BOOL)debug TimeOut:(int)timeout DEPRECATED_ATTRIBUTE;

/**
* 初始化SDK
*
* @param appId SDK AppID,腾讯云官网(https://console.cloud.tencent.com/httpdns)申请获得,用于上报
* @param dnsIp HTTPDNS IP 地址
* @param debug 是否开启Debug日志,YES:开启,NO:关闭。建议联调阶段开启,正式上线前关闭
* @param timeout 超时时间,单位ms,如设置0,则设置为默认值2000ms
* @return YES:设置成功 NO:设置失败
*/
- (BOOL) initConfig:(NSString *)appId dnsIp:(NSString *)dnsIp debug:(BOOL)debug timeout:(int)timeout;

/**
* @deprecated This method is deprecated starting in version 1.2.1i
* @note Please use @code initConfig:dnsIp:debug:timeout @endcode instead.
Expand All @@ -82,9 +66,6 @@ struct DnsConfig {
*/
- (BOOL) WGSetDnsOpenId:(NSString *)openId;


- (BOOL) initConfig:(DnsConfig *)config;

#pragma mark - 域名解析接口,按需调用
/**
域名同步解析(通用接口)
Expand Down
19 changes: 0 additions & 19 deletions MSDKDns/MSDKDns.m
Original file line number Diff line number Diff line change
Expand Up @@ -30,25 +30,6 @@ - (instancetype) init {
return self;
}

- (BOOL) initConfig:(NSString *)appId dnsId:(int)dnsId dnsKey:(NSString *)dnsKey dnsIp:(NSString *)dnsIp debug:(BOOL)debug timeout:(int)timeout {
return [self initConfig:appId dnsId:dnsId dnsKey:dnsKey dnsIp:dnsIp debug:debug timeout:timeout encryptType:HttpDnsEncryptTypeDES];
}

- (BOOL) initConfig:(NSString *)appId dnsId:(int)dnsId dnsKey:(NSString *)dnsKey dnsIp:(NSString *)dnsIp debug:(BOOL)debug timeout:(int)timeout encryptType:(HttpDnsEncryptType)encryptType {
[[MSDKDnsLog sharedInstance] setEnableLog:debug];
[[MSDKDnsParamsManager shareInstance] msdkDnsSetMAppId:appId MTimeOut:timeout MEncryptType:encryptType];
[[MSDKDnsParamsManager shareInstance] msdkDnsSetMDnsId:dnsId MDnsKey:dnsKey];
[[MSDKDnsParamsManager shareInstance] msdkDnsSetMDnsIp:dnsIp];
return YES;
}

- (BOOL) initConfig:(NSString *)appId dnsIp:(NSString *)dnsIp debug:(BOOL)debug timeout:(int)timeout {
[[MSDKDnsLog sharedInstance] setEnableLog:debug];
[[MSDKDnsParamsManager shareInstance] msdkDnsSetMAppId:appId MTimeOut:timeout];
[[MSDKDnsParamsManager shareInstance] msdkDnsSetMDnsIp:dnsIp];
return YES;
}

- (BOOL) initConfig:(DnsConfig *)config {
[[MSDKDnsLog sharedInstance] setEnableLog:config->debug];
[[MSDKDnsParamsManager shareInstance] msdkDnsSetMAppId:config->appId MToken:config->token MTimeOut:config->timeout MEncryptType:config->encryptType];
Expand Down

0 comments on commit 6afadaf

Please sign in to comment.