Skip to content

Commit

Permalink
Merge pull request #28 from HuYuee/feature/v1.8.0
Browse files Browse the repository at this point in the history
Feature/v1.8.0
  • Loading branch information
Vastness authored Jul 5, 2023
2 parents 3dea272 + 59ca5c2 commit 7c17b6b
Show file tree
Hide file tree
Showing 11 changed files with 170 additions and 275 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ DerivedData
# CocoaPods
Pods/

.idea/

# Header
MSDKDns/httpdnsIps.h
MSDKDns.xcodeproj/project.xcworkspace
26 changes: 14 additions & 12 deletions MSDKDns.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -1047,7 +1047,7 @@
LINK_WITH_STANDARD_LIBRARIES = NO;
MACH_O_TYPE = mh_object;
MACOSX_DEPLOYMENT_TARGET = "";
MARKETING_VERSION = 1.7.0;
MARKETING_VERSION = 1.8.0;
ONLY_ACTIVE_ARCH = NO;
OTHER_CFLAGS = "-fembed-bitcode";
OTHER_LDFLAGS = (
Expand Down Expand Up @@ -1094,7 +1094,7 @@
LINK_WITH_STANDARD_LIBRARIES = NO;
MACH_O_TYPE = mh_object;
MACOSX_DEPLOYMENT_TARGET = "";
MARKETING_VERSION = 1.7.0;
MARKETING_VERSION = 1.8.0;
OTHER_CFLAGS = "-fembed-bitcode";
OTHER_LDFLAGS = (
"-ObjC",
Expand All @@ -1118,14 +1118,15 @@
CLANG_ENABLE_MODULES = YES;
COMBINE_HIDPI_IMAGES = YES;
CURRENT_PROJECT_VERSION = 1107;
DEAD_CODE_STRIPPING = NO;
DEAD_CODE_STRIPPING = YES;
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
DEVELOPMENT_TEAM = 4PK94A7P3R;
DYLIB_COMPATIBILITY_VERSION = 1;
DYLIB_CURRENT_VERSION = 1;
ENABLE_BITCODE = YES;
FRAMEWORK_SEARCH_PATHS = "$(PROJECT_DIR)/..";
GCC_INPUT_FILETYPE = sourcecode.cpp.objcpp;
GCC_OPTIMIZATION_LEVEL = s;
GCC_PREPROCESSOR_DEFINITIONS = (
"DEBUG=1",
"IS_INTL=1",
Expand All @@ -1136,7 +1137,7 @@
LINK_WITH_STANDARD_LIBRARIES = NO;
MACH_O_TYPE = mh_object;
MACOSX_DEPLOYMENT_TARGET = "";
MARKETING_VERSION = 1.7.0;
MARKETING_VERSION = 1.8.0;
ONLY_ACTIVE_ARCH = NO;
OTHER_CFLAGS = "-fembed-bitcode";
OTHER_LDFLAGS = (
Expand All @@ -1162,22 +1163,23 @@
COMBINE_HIDPI_IMAGES = YES;
COPY_PHASE_STRIP = YES;
CURRENT_PROJECT_VERSION = 1107;
DEAD_CODE_STRIPPING = NO;
DEAD_CODE_STRIPPING = YES;
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
DEVELOPMENT_TEAM = 4PK94A7P3R;
DYLIB_COMPATIBILITY_VERSION = 1;
DYLIB_CURRENT_VERSION = 1;
ENABLE_BITCODE = YES;
FRAMEWORK_SEARCH_PATHS = "$(PROJECT_DIR)/..";
GCC_INPUT_FILETYPE = sourcecode.cpp.objcpp;
GCC_OPTIMIZATION_LEVEL = s;
GCC_PREPROCESSOR_DEFINITIONS = "IS_INTL=1";
INFOPLIST_FILE = MSDKDns/Info.plist;
INSTALL_PATH = "$(BUILT_PRODUCTS_DIR)";
IPHONEOS_DEPLOYMENT_TARGET = 10.0;
LINK_WITH_STANDARD_LIBRARIES = NO;
MACH_O_TYPE = mh_object;
MACOSX_DEPLOYMENT_TARGET = "";
MARKETING_VERSION = 1.7.0;
MARKETING_VERSION = 1.8.0;
OTHER_CFLAGS = "-fembed-bitcode";
OTHER_LDFLAGS = (
"-ObjC",
Expand Down Expand Up @@ -1226,7 +1228,7 @@
LINK_WITH_STANDARD_LIBRARIES = NO;
MACH_O_TYPE = mh_object;
MACOSX_DEPLOYMENT_TARGET = "";
MARKETING_VERSION = 1.7.0;
MARKETING_VERSION = 1.8.0;
ONLY_ACTIVE_ARCH = NO;
OTHER_CFLAGS = "-fembed-bitcode";
OTHER_LDFLAGS = (
Expand Down Expand Up @@ -1274,7 +1276,7 @@
LINK_WITH_STANDARD_LIBRARIES = NO;
MACH_O_TYPE = mh_object;
MACOSX_DEPLOYMENT_TARGET = "";
MARKETING_VERSION = 1.7.0;
MARKETING_VERSION = 1.8.0;
OTHER_CFLAGS = "-fembed-bitcode";
OTHER_LDFLAGS = (
"-ObjC",
Expand All @@ -1298,7 +1300,7 @@
CLANG_ENABLE_MODULES = YES;
COMBINE_HIDPI_IMAGES = YES;
CURRENT_PROJECT_VERSION = 1107;
DEAD_CODE_STRIPPING = NO;
DEAD_CODE_STRIPPING = YES;
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
DEVELOPMENT_TEAM = 4PK94A7P3R;
DYLIB_COMPATIBILITY_VERSION = 1;
Expand All @@ -1312,7 +1314,7 @@
LINK_WITH_STANDARD_LIBRARIES = NO;
MACH_O_TYPE = mh_object;
MACOSX_DEPLOYMENT_TARGET = "";
MARKETING_VERSION = 1.7.0;
MARKETING_VERSION = 1.8.0;
ONLY_ACTIVE_ARCH = NO;
OTHER_CFLAGS = "-fembed-bitcode";
OTHER_LDFLAGS = (
Expand All @@ -1338,7 +1340,7 @@
COMBINE_HIDPI_IMAGES = YES;
COPY_PHASE_STRIP = YES;
CURRENT_PROJECT_VERSION = 1107;
DEAD_CODE_STRIPPING = NO;
DEAD_CODE_STRIPPING = YES;
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
DEVELOPMENT_TEAM = 4PK94A7P3R;
DYLIB_COMPATIBILITY_VERSION = 1;
Expand All @@ -1352,7 +1354,7 @@
LINK_WITH_STANDARD_LIBRARIES = NO;
MACH_O_TYPE = mh_object;
MACOSX_DEPLOYMENT_TARGET = "";
MARKETING_VERSION = 1.7.0;
MARKETING_VERSION = 1.8.0;
OTHER_CFLAGS = "-fembed-bitcode";
OTHER_LDFLAGS = (
"-ObjC",
Expand Down
10 changes: 0 additions & 10 deletions MSDKDns/CacheManager/MSDKDnsManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,6 @@
#import "MSDKDnsPrivate.h"
#import "MSDKDns.h"

#if defined(__has_include)
#if __has_include(<MSDK/BeaconBaseInterface.h>)
#include <MSDK/BeaconBaseInterface.h>
#endif

#if __has_include("BeaconAPI_Base/BeaconBaseInterface.h")
#include "BeaconAPI_Base/BeaconBaseInterface.h"
#endif
#endif

@class MSDKDnsService;

typedef enum {
Expand Down
36 changes: 4 additions & 32 deletions MSDKDns/CacheManager/MSDKDnsManager.m
Original file line number Diff line number Diff line change
Expand Up @@ -610,41 +610,17 @@ - (void)uploadReport:(BOOL)isFromCache Domain:(NSString *)domain NetStack:(msdkd
if (isFromCache) {
[self hitCacheAttaUploadReport:domain];
}

Class beaconClass = NSClassFromString(@"BeaconBaseInterface");
if (beaconClass == 0x0) {
MSDKDNSLOG(@"Beacon framework is not imported");
return;
}

// 反射调用
// [BeaconBaseInterface onUserAction:MSDKDnsEventName isSucceed:YES elapse:0 size:0 params:params];
SEL methodSelector = NSSelectorFromString(@"onUserAction:isSucceed:elapse:size:params:");
NSMethodSignature *methodSignature = [beaconClass methodSignatureForSelector:methodSelector];
NSInvocation *myInvocation = [NSInvocation invocationWithMethodSignature:methodSignature];
[myInvocation setTarget:beaconClass];
[myInvocation setSelector:methodSelector];
// 接口传参
NSString *eventName = MSDKDnsEventName;
[myInvocation setArgument:&eventName atIndex:2];
BOOL success = YES;
[myInvocation setArgument:&success atIndex:3];
NSUInteger elapse = 0;
[myInvocation setArgument:&elapse atIndex:4];
NSUInteger size = 0;
[myInvocation setArgument:&size atIndex:5];

NSMutableDictionary *params = [self formatParams:isFromCache Domain:domain NetStack:netStack];
[myInvocation setArgument:&params atIndex:6];
// 在调用结束前,保持参数
[myInvocation retainArguments];

[myInvocation invoke];

MSDKDNSLOG(@"api name:%@, data:%@", eventName, params);

MSDKDNSLOG(@"ReportingEvent, name:%@, events:%@", eventName, params);
}

- (NSMutableDictionary *)formatParams:(BOOL)isFromCache Domain:(NSString *)domain NetStack:(msdkdns::MSDKDNS_TLocalIPStack)netStack {
MSDKDNSLOG(@"uploadReport %@",domain);
MSDKDNSLOG(@"domain:%@",domain);
//dns结束时上报结果
NSMutableDictionary * params = [NSMutableDictionary new];

Expand Down Expand Up @@ -681,10 +657,6 @@ - (NSMutableDictionary *)formatParams:(BOOL)isFromCache Domain:(NSString *)domai
NSString * networkType = [[MSDKDnsNetworkManager shareInstance] networkType];
[params setValue:networkType forKey:kMSDKDnsNetType];

//SSID
// NSString * ssid = [MSDKDnsInfoTool wifiSSID];
// [params setValue:ssid forKey:kMSDKDnsSSID];

//domain
NSString * domain_string = HTTP_DNS_UNKNOWN_STR;
if (domain) {
Expand Down
12 changes: 6 additions & 6 deletions MSDKDns/MSDKDns.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#ifndef __MSDKDns_H__
#define __MSDKDns_H__

#define MSDKDns_Version @"1.7.0"
#define MSDKDns_Version @"1.8.0"

#import <Foundation/Foundation.h>

Expand All @@ -27,7 +27,7 @@ typedef struct DnsConfigStruct {
int dnsId; // 授权ID,腾讯云控制台申请后,通过邮件发送,用于域名解析鉴权
NSString* dnsKey; // 加密密钥,加密方式为AES、DES时必传。腾讯云控制台申请后,通过邮件发送,用于域名解析鉴权
NSString* token; // 加密token,加密方式为 HTTPS 时必传
NSString* dnsIp; // HTTPDNS 服务器 IP
NSString* dnsIp __attribute__((deprecated("v1.8.0及以上SDK内部调度,无需设置"))); // HTTPDNS 服务器 IP
BOOL debug; // 是否开启Debug日志,YES:开启,NO:关闭。建议联调阶段开启,正式上线前关闭
int timeout; // 可选,超时时间,单位ms,如设置0,则设置为默认值2000ms
HttpDnsEncryptType encryptType; // 控制加密方式
Expand Down Expand Up @@ -105,7 +105,7 @@ typedef struct DnsConfigStruct {
@param domain 域名
@return 查询到的IP数组,超时(1s)或者未未查询到返回[0,0]数组
@return 查询到的IP数组,超时(默认2s)或者未未查询到返回[0,0]数组
*/
- (NSArray *) WGGetHostByName:(NSString *) domain;

Expand All @@ -131,23 +131,23 @@ typedef struct DnsConfigStruct {
域名异步解析(通用接口)
@param domain 域名
@param handler 返回查询到的IP数组,超时(1s)或者未未查询到返回[0,0]数组
@param handler 返回查询到的IP数组,超时(默认2s)或者未未查询到返回[0,0]数组
*/
- (void) WGGetHostByNameAsync:(NSString *) domain returnIps:(void (^)(NSArray * ipsArray))handler;

/**
域名批量异步解析(通用接口)
@param domains 域名数组
@param handler 返回查询到的IP数组,超时(1s)或者未未查询到返回[0,0]数组
@param handler 返回查询到的IP数组,超时(默认2s)或者未未查询到返回[0,0]数组
*/
- (void) WGGetHostsByNamesAsync:(NSArray *) domains returnIps:(void (^)(NSDictionary * ipsDictionary))handler;

/**
域名批量异步解析(查询所有ip)
@param domains 域名数组
@param handler 返回查询到的IP数组,超时(1s)或者未未查询到返回[0,0]数组
@param handler 返回查询到的IP数组,超时(默认2s)或者未未查询到返回[0,0]数组
*/
- (void)WGGetAllHostsByNamesAsync:(NSArray *)domains returnIps:(void (^)(NSDictionary * ipsDictionary))handler;

Expand Down
83 changes: 0 additions & 83 deletions MSDKDns/MSDKDns.m
Original file line number Diff line number Diff line change
Expand Up @@ -394,89 +394,6 @@ - (void)WGGetAllHostsByNamesAsync:(NSArray *)domains returnIps:(void (^)(NSDicti
}
}

- (NSArray *) WGGetHostByNameEnableExpired:(NSString *)domain {
@synchronized(self) {
NSArray * dnsResult = @[@"0", @"0"];
MSDKDNSLOG(@"GetHostByNameEnableExpired:%@",domain);
if (!domain || domain.length == 0) {
//请求域名为空,返回空
MSDKDNSLOG(@"MSDKDns Result is Empty!");
return dnsResult;
}
// 转换成小写
domain = [domain lowercaseString];
NSDate * date = [NSDate date];
//进行httpdns请求
NSDictionary *res = [[MSDKDnsManager shareInstance] getHostsByNamesEnableExpired:@[domain] verbose:NO];
dnsResult = [res objectForKey:domain];
NSTimeInterval time_consume = [[NSDate date] timeIntervalSinceDate:date] * 1000;
MSDKDNSLOG(@"MSDKDns WGGetHostByNameEnableExpired Total Time Consume is %.1fms", time_consume);
NSMutableString * ipsStr = [NSMutableString stringWithString:@""];
for (int i = 0; i < dnsResult.count; i++) {
NSString * ip = dnsResult[i];
[ipsStr appendFormat:@"%@,",ip];
}
MSDKDNSLOG(@"%@, MSDKDns Result is:%@",domain, ipsStr);
return dnsResult;
}
}

- (NSDictionary *) WGGetHostsByNamesEnableExpired:(NSArray *)domains {
@synchronized(self) {
NSDictionary * dnsResult = @{};
MSDKDNSLOG(@"GetHostsByNamesEnableExpired:%@",domains);
if (!domains || [domains count] == 0) {
//请求域名为空,返回空
MSDKDNSLOG(@"MSDKDns Result is Empty!");
return dnsResult;
}
// 转换成小写
NSMutableArray *lowerCaseArray = [NSMutableArray array];
for(int i = 0; i < [domains count]; i++) {
NSString *d = [domains objectAtIndex:i];
if (d && d.length > 0) {
[lowerCaseArray addObject:[d lowercaseString]];
}
}
domains = lowerCaseArray;
NSDate * date = [NSDate date];
//进行httpdns请求
dnsResult = [[MSDKDnsManager shareInstance] getHostsByNamesEnableExpired:domains verbose:NO];
NSTimeInterval time_consume = [[NSDate date] timeIntervalSinceDate:date] * 1000;
MSDKDNSLOG(@"%@, MSDKDns Result is:%@",domains, dnsResult);
MSDKDNSLOG(@"MSDKDns WGGetHostsByNamesEnableExpired Total Time Consume is %.1fms", time_consume);
return dnsResult;
}
}

- (NSDictionary *) WGGetAllHostsByNamesEnableExpired:(NSArray *)domains {
@synchronized(self) {
NSDictionary * dnsResult = @{};
MSDKDNSLOG(@"GetAllHostsByNamesEnableExpired:%@",domains);
if (!domains || [domains count] == 0) {
//请求域名为空,返回空
MSDKDNSLOG(@"MSDKDns Result is Empty!");
return dnsResult;
}
// 转换成小写
NSMutableArray *lowerCaseArray = [NSMutableArray array];
for(int i = 0; i < [domains count]; i++) {
NSString *d = [domains objectAtIndex:i];
if (d && d.length > 0) {
[lowerCaseArray addObject:[d lowercaseString]];
}
}
domains = lowerCaseArray;
NSDate * date = [NSDate date];
//进行httpdns请求
dnsResult = [[MSDKDnsManager shareInstance] getHostsByNamesEnableExpired:domains verbose:YES];
NSTimeInterval time_consume = [[NSDate date] timeIntervalSinceDate:date] * 1000;
MSDKDNSLOG(@"%@, MSDKDns Result is:%@",domains, dnsResult);
MSDKDNSLOG(@"MSDKDns WGGetAllHostsByNamesEnableExpired Total Time Consume is %.1fms", time_consume);
return dnsResult;
}
}

- (NSDictionary *) WGGetDnsDetail:(NSString *) domain {
return [[MSDKDnsManager shareInstance] getDnsDetail:domain];
}
Expand Down
Loading

0 comments on commit 7c17b6b

Please sign in to comment.