Skip to content

Commit

Permalink
Merge pull request #25 from HuYuee/feature/persistentCache
Browse files Browse the repository at this point in the history
新增允许使用TTL过期域名的IP和本地持久化缓存功能
  • Loading branch information
ocleo1 authored Sep 13, 2022
2 parents a36d313 + e576b5a commit db93d0b
Show file tree
Hide file tree
Showing 17 changed files with 807 additions and 24 deletions.
92 changes: 80 additions & 12 deletions MSDKDns.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,16 @@
54EA82232760890B005F68A9 /* AttaReport.m in Sources */ = {isa = PBXBuildFile; fileRef = 54EA82212760890B005F68A9 /* AttaReport.m */; };
54EA822427608A55005F68A9 /* AttaReport.h in Headers */ = {isa = PBXBuildFile; fileRef = 54EA82202760890B005F68A9 /* AttaReport.h */; };
54EA822527608A58005F68A9 /* AttaReport.m in Sources */ = {isa = PBXBuildFile; fileRef = 54EA82212760890B005F68A9 /* AttaReport.m */; };
5F1E288028B72A7D00AD0D9F /* HTTPDNSORM.m in Sources */ = {isa = PBXBuildFile; fileRef = 5F1E287B28B72A7D00AD0D9F /* HTTPDNSORM.m */; };
5F1E288128B72A7D00AD0D9F /* HTTPDNSORM.m in Sources */ = {isa = PBXBuildFile; fileRef = 5F1E287B28B72A7D00AD0D9F /* HTTPDNSORM.m */; };
5F1E288228B72A7D00AD0D9F /* HTTPDNSORM.h in Headers */ = {isa = PBXBuildFile; fileRef = 5F1E287C28B72A7D00AD0D9F /* HTTPDNSORM.h */; };
5F1E288328B72A7D00AD0D9F /* HTTPDNSORM.h in Headers */ = {isa = PBXBuildFile; fileRef = 5F1E287C28B72A7D00AD0D9F /* HTTPDNSORM.h */; };
5F1E288428B72A7D00AD0D9F /* MSDKDnsDB.m in Sources */ = {isa = PBXBuildFile; fileRef = 5F1E287D28B72A7D00AD0D9F /* MSDKDnsDB.m */; };
5F1E288528B72A7D00AD0D9F /* MSDKDnsDB.m in Sources */ = {isa = PBXBuildFile; fileRef = 5F1E287D28B72A7D00AD0D9F /* MSDKDnsDB.m */; };
5F1E288628B72A7D00AD0D9F /* HTTPDNSORM+WCTTableCoding.h in Headers */ = {isa = PBXBuildFile; fileRef = 5F1E287E28B72A7D00AD0D9F /* HTTPDNSORM+WCTTableCoding.h */; };
5F1E288728B72A7D00AD0D9F /* HTTPDNSORM+WCTTableCoding.h in Headers */ = {isa = PBXBuildFile; fileRef = 5F1E287E28B72A7D00AD0D9F /* HTTPDNSORM+WCTTableCoding.h */; };
5F1E288828B72A7D00AD0D9F /* MSDKDnsDB.h in Headers */ = {isa = PBXBuildFile; fileRef = 5F1E287F28B72A7D00AD0D9F /* MSDKDnsDB.h */; };
5F1E288928B72A7D00AD0D9F /* MSDKDnsDB.h in Headers */ = {isa = PBXBuildFile; fileRef = 5F1E287F28B72A7D00AD0D9F /* MSDKDnsDB.h */; };
5F5DAF4E28A525E300BF5B79 /* MSDKDnsTCPSpeedTester.h in Headers */ = {isa = PBXBuildFile; fileRef = 5F5DAF4B28A525E300BF5B79 /* MSDKDnsTCPSpeedTester.h */; };
5F5DAF4F28A525E300BF5B79 /* MSDKDnsTCPSpeedTester.h in Headers */ = {isa = PBXBuildFile; fileRef = 5F5DAF4B28A525E300BF5B79 /* MSDKDnsTCPSpeedTester.h */; };
5F5DAF5028A525E300BF5B79 /* MSDKDnsTCPSpeedTester.m in Sources */ = {isa = PBXBuildFile; fileRef = 5F5DAF4C28A525E300BF5B79 /* MSDKDnsTCPSpeedTester.m */; };
Expand Down Expand Up @@ -110,6 +120,12 @@
54EA81F1275478D1005F68A9 /* httpdnsIps.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = httpdnsIps.h; sourceTree = "<group>"; };
54EA82202760890B005F68A9 /* AttaReport.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AttaReport.h; sourceTree = "<group>"; };
54EA82212760890B005F68A9 /* AttaReport.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AttaReport.m; sourceTree = "<group>"; };
5F1E287B28B72A7D00AD0D9F /* HTTPDNSORM.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = HTTPDNSORM.m; sourceTree = "<group>"; };
5F1E287C28B72A7D00AD0D9F /* HTTPDNSORM.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = HTTPDNSORM.h; sourceTree = "<group>"; };
5F1E287D28B72A7D00AD0D9F /* MSDKDnsDB.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MSDKDnsDB.m; sourceTree = "<group>"; };
5F1E287E28B72A7D00AD0D9F /* HTTPDNSORM+WCTTableCoding.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "HTTPDNSORM+WCTTableCoding.h"; sourceTree = "<group>"; };
5F1E287F28B72A7D00AD0D9F /* MSDKDnsDB.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MSDKDnsDB.h; sourceTree = "<group>"; };
5F1E288F28B86DFD00AD0D9F /* WCDB.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = WCDB.framework; path = ../WCDB.framework; sourceTree = "<group>"; };
5F5DAF4B28A525E300BF5B79 /* MSDKDnsTCPSpeedTester.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MSDKDnsTCPSpeedTester.h; sourceTree = "<group>"; };
5F5DAF4C28A525E300BF5B79 /* MSDKDnsTCPSpeedTester.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MSDKDnsTCPSpeedTester.m; sourceTree = "<group>"; };
5F5DAF4D28A525E300BF5B79 /* MSDKDnsSpeedTester.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MSDKDnsSpeedTester.h; sourceTree = "<group>"; };
Expand Down Expand Up @@ -179,6 +195,7 @@
5F5DAF4C28A525E300BF5B79 /* MSDKDnsTCPSpeedTester.m */,
C8EBE7D1256664C400BEFEEC /* aes.h */,
C8EBE7D2256664C500BEFEEC /* aes.mm */,
5F85CBA828B4B3B1003D20D1 /* WCDB */,
54EA821F2760890B005F68A9 /* Reporter */,
501001EB215E1F1D003288A5 /* Network */,
445B363D1CBBBFAF00BD4345 /* Manager */,
Expand Down Expand Up @@ -251,9 +268,22 @@
path = Reporter;
sourceTree = "<group>";
};
5F85CBA828B4B3B1003D20D1 /* WCDB */ = {
isa = PBXGroup;
children = (
5F1E287C28B72A7D00AD0D9F /* HTTPDNSORM.h */,
5F1E287B28B72A7D00AD0D9F /* HTTPDNSORM.m */,
5F1E287E28B72A7D00AD0D9F /* HTTPDNSORM+WCTTableCoding.h */,
5F1E287F28B72A7D00AD0D9F /* MSDKDnsDB.h */,
5F1E287D28B72A7D00AD0D9F /* MSDKDnsDB.m */,
);
path = WCDB;
sourceTree = "<group>";
};
C8EBE7D92566675800BEFEEC /* Frameworks */ = {
isa = PBXGroup;
children = (
5F1E288F28B86DFD00AD0D9F /* WCDB.framework */,
C8EBE7DA2566675800BEFEEC /* libc++.tbd */,
);
name = Frameworks;
Expand All @@ -266,7 +296,9 @@
isa = PBXHeadersBuildPhase;
buildActionMask = 2147483647;
files = (
5F1E288228B72A7D00AD0D9F /* HTTPDNSORM.h in Headers */,
44BFE2481CA59D9800D7FE87 /* MSDKDnsReachability.h in Headers */,
5F1E288828B72A7D00AD0D9F /* MSDKDnsDB.h in Headers */,
504F543A1ECAF89F001BD7A9 /* MSDKDnsHttpMessageTools.h in Headers */,
445B36691CBD1D4700BD4345 /* MSDKDnsNetworkManager.h in Headers */,
C8EBE7D3256664C500BEFEEC /* aes.h in Headers */,
Expand All @@ -278,6 +310,7 @@
5F5DAF4E28A525E300BF5B79 /* MSDKDnsTCPSpeedTester.h in Headers */,
448EE4E81B329899004A2131 /* MSDKDnsResolver.h in Headers */,
54EA82222760890B005F68A9 /* AttaReport.h in Headers */,
5F1E288628B72A7D00AD0D9F /* HTTPDNSORM+WCTTableCoding.h in Headers */,
5F5DAF5228A525E300BF5B79 /* MSDKDnsSpeedTester.h in Headers */,
44BFE2371CA58C3A00D7FE87 /* MSDKDnsInfoTool.h in Headers */,
502422EC2140073F0094403C /* MSDKDnsParamsManager.h in Headers */,
Expand All @@ -291,7 +324,9 @@
isa = PBXHeadersBuildPhase;
buildActionMask = 2147483647;
files = (
5F1E288328B72A7D00AD0D9F /* HTTPDNSORM.h in Headers */,
DD43F4A6231CC36D0000A89F /* MSDKDnsReachability.h in Headers */,
5F1E288928B72A7D00AD0D9F /* MSDKDnsDB.h in Headers */,
DD43F4A7231CC36D0000A89F /* MSDKDnsHttpMessageTools.h in Headers */,
DD43F4A8231CC36D0000A89F /* MSDKDnsNetworkManager.h in Headers */,
2FBE52E825E77AFE0012A0DF /* aes.h in Headers */,
Expand All @@ -303,6 +338,7 @@
5F5DAF4F28A525E300BF5B79 /* MSDKDnsTCPSpeedTester.h in Headers */,
DD43F4AE231CC36D0000A89F /* MSDKDnsResolver.h in Headers */,
54EA822427608A55005F68A9 /* AttaReport.h in Headers */,
5F1E288728B72A7D00AD0D9F /* HTTPDNSORM+WCTTableCoding.h in Headers */,
5F5DAF5328A525E300BF5B79 /* MSDKDnsSpeedTester.h in Headers */,
DD43F4AF231CC36D0000A89F /* MSDKDnsInfoTool.h in Headers */,
DD43F4B0231CC36D0000A89F /* MSDKDnsParamsManager.h in Headers */,
Expand Down Expand Up @@ -363,7 +399,7 @@
44224FB81B312DD6003497C4 /* Project object */ = {
isa = PBXProject;
attributes = {
LastUpgradeCheck = 0730;
LastUpgradeCheck = 1340;
ORGANIZATIONNAME = Tencent;
TargetAttributes = {
44224FBF1B312DD6003497C4 = {
Expand Down Expand Up @@ -506,9 +542,11 @@
445B366B1CBD1D4700BD4345 /* MSDKDnsNetworkManager.m in Sources */,
4497F8BA1B4628F000D51391 /* MSDKDnsLog.m in Sources */,
504F543C1ECAF89F001BD7A9 /* MSDKDnsHttpMessageTools.m in Sources */,
5F1E288428B72A7D00AD0D9F /* MSDKDnsDB.m in Sources */,
448EE4E91B329899004A2131 /* MSDKDnsResolver.m in Sources */,
54EA82232760890B005F68A9 /* AttaReport.m in Sources */,
4455D15F1B3A5B90005BF126 /* MSDKDns.m in Sources */,
5F1E288028B72A7D00AD0D9F /* HTTPDNSORM.m in Sources */,
448EE4E71B329899004A2131 /* LocalDnsResolver.m in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
Expand All @@ -529,9 +567,11 @@
DD43F49D231CC36D0000A89F /* MSDKDnsNetworkManager.m in Sources */,
DD43F49E231CC36D0000A89F /* MSDKDnsLog.m in Sources */,
DD43F49F231CC36D0000A89F /* MSDKDnsHttpMessageTools.m in Sources */,
5F1E288528B72A7D00AD0D9F /* MSDKDnsDB.m in Sources */,
DD43F4A0231CC36D0000A89F /* MSDKDnsResolver.m in Sources */,
54EA822527608A58005F68A9 /* AttaReport.m in Sources */,
DD43F4A1231CC36D0000A89F /* MSDKDns.m in Sources */,
5F1E288128B72A7D00AD0D9F /* HTTPDNSORM.m in Sources */,
DD43F4A2231CC36D0000A89F /* LocalDnsResolver.m in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
Expand All @@ -548,13 +588,24 @@
CLANG_CXX_LIBRARY = "compiler-default";
CLANG_ENABLE_MODULES = YES;
CLANG_ENABLE_OBJC_ARC = YES;
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_COMMA = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES;
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
CLANG_WARN_STRICT_PROTOTYPES = YES;
CLANG_WARN_SUSPICIOUS_MOVE = YES;
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
COPY_PHASE_STRIP = NO;
Expand Down Expand Up @@ -595,13 +646,24 @@
CLANG_CXX_LIBRARY = "compiler-default";
CLANG_ENABLE_MODULES = YES;
CLANG_ENABLE_OBJC_ARC = YES;
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_COMMA = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES;
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
CLANG_WARN_STRICT_PROTOTYPES = YES;
CLANG_WARN_SUSPICIOUS_MOVE = YES;
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
COPY_PHASE_STRIP = NO;
Expand All @@ -617,7 +679,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 5.1;
IPHONEOS_DEPLOYMENT_TARGET = 10.0;
MACOSX_DEPLOYMENT_TARGET = "";
MTL_ENABLE_DEBUG_INFO = NO;
SDKROOT = iphoneos;
Expand All @@ -638,15 +700,18 @@
DYLIB_COMPATIBILITY_VERSION = 1;
DYLIB_CURRENT_VERSION = 1;
ENABLE_BITCODE = YES;
FRAMEWORK_SEARCH_PATHS = "$(inherited)";
FRAMEWORK_SEARCH_PATHS = (
"$(PROJECT_DIR)/../**",
"$(inherited)",
);
GCC_INPUT_FILETYPE = sourcecode.cpp.objcpp;
INFOPLIST_FILE = MSDKDns/Info.plist;
INSTALL_PATH = "$(BUILT_PRODUCTS_DIR)";
IPHONEOS_DEPLOYMENT_TARGET = 6.0;
IPHONEOS_DEPLOYMENT_TARGET = 10.0;
LINK_WITH_STANDARD_LIBRARIES = NO;
MACH_O_TYPE = mh_object;
MACOSX_DEPLOYMENT_TARGET = "";
MARKETING_VERSION = 1.5.0;
MARKETING_VERSION = 1.6.0;
ONLY_ACTIVE_ARCH = NO;
OTHER_CFLAGS = "-fembed-bitcode";
OTHER_LDFLAGS = (
Expand Down Expand Up @@ -677,15 +742,18 @@
DYLIB_COMPATIBILITY_VERSION = 1;
DYLIB_CURRENT_VERSION = 1;
ENABLE_BITCODE = YES;
FRAMEWORK_SEARCH_PATHS = "$(inherited)";
FRAMEWORK_SEARCH_PATHS = (
"$(PROJECT_DIR)/../**",
"$(inherited)",
);
GCC_INPUT_FILETYPE = sourcecode.cpp.objcpp;
INFOPLIST_FILE = MSDKDns/Info.plist;
INSTALL_PATH = "$(BUILT_PRODUCTS_DIR)";
IPHONEOS_DEPLOYMENT_TARGET = 6.0;
IPHONEOS_DEPLOYMENT_TARGET = 10.0;
LINK_WITH_STANDARD_LIBRARIES = NO;
MACH_O_TYPE = mh_object;
MACOSX_DEPLOYMENT_TARGET = "";
MARKETING_VERSION = 1.5.0;
MARKETING_VERSION = 1.6.0;
OTHER_CFLAGS = "-fembed-bitcode";
OTHER_LDFLAGS = (
"-ObjC",
Expand Down Expand Up @@ -714,15 +782,15 @@
DYLIB_COMPATIBILITY_VERSION = 1;
DYLIB_CURRENT_VERSION = 1;
ENABLE_BITCODE = YES;
FRAMEWORK_SEARCH_PATHS = "$(inherited)";
FRAMEWORK_SEARCH_PATHS = "$(PROJECT_DIR)/..";
GCC_INPUT_FILETYPE = sourcecode.cpp.objcpp;
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.5.0;
MARKETING_VERSION = 1.6.0;
ONLY_ACTIVE_ARCH = NO;
OTHER_CFLAGS = "-fembed-bitcode";
OTHER_LDFLAGS = (
Expand Down Expand Up @@ -753,15 +821,15 @@
DYLIB_COMPATIBILITY_VERSION = 1;
DYLIB_CURRENT_VERSION = 1;
ENABLE_BITCODE = YES;
FRAMEWORK_SEARCH_PATHS = "$(inherited)";
FRAMEWORK_SEARCH_PATHS = "$(PROJECT_DIR)/..";
GCC_INPUT_FILETYPE = sourcecode.cpp.objcpp;
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.5.0;
MARKETING_VERSION = 1.6.0;
OTHER_CFLAGS = "-fembed-bitcode";
OTHER_LDFLAGS = (
"-ObjC",
Expand Down
2 changes: 1 addition & 1 deletion MSDKDns.xcodeproj/xcshareddata/xcschemes/MSDKDns.xcscheme
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1310"
LastUpgradeVersion = "1340"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1310"
LastUpgradeVersion = "1340"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand Down
2 changes: 2 additions & 0 deletions MSDKDns/CacheManager/MSDKDnsManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@

- (void)getHostsByNames:(NSArray *)domains verbose:(BOOL)verbose returnIps:(void (^)(NSDictionary * ipsDict))handler;
- (NSDictionary *)getHostsByNames:(NSArray *)domains verbose:(BOOL)verbose;
- (NSDictionary *)getHostsByNamesEnableExpired:(NSArray *)domains verbose:(BOOL)verbose;
- (void)refreshCacheDelay:(NSArray *)domains clearDispatchTag:(BOOL)needClear;
- (void)preResolveDomains;
- (void)dnsHasDone:(MSDKDnsService *)service;
Expand All @@ -45,4 +46,5 @@
// 批量删除
- (void)msdkDnsClearDomainsOpenDelayDispatch:(NSArray *)domains;
- (NSMutableDictionary *)msdkDnsGetDomainISOpenDelayDispatch;
- (void)loadIPsFromPersistCacheAsync;
@end
Loading

0 comments on commit db93d0b

Please sign in to comment.