├── imgs ├── lanscan.png ├── mainpage.PNG └── netinfo.PNG ├── frameworks └── v_1.0.12 │ └── PhoneNetSDK_armv7_x8664_arm64.zip ├── PhoneNetSDK ├── PhoneNetSDK.xcodeproj │ ├── project.xcworkspace │ │ ├── contents.xcworkspacedata │ │ └── xcshareddata │ │ │ └── IDEWorkspaceChecks.plist │ └── project.pbxproj ├── PhoneNetSDK │ ├── tools │ │ ├── PNetworkCalculator.h │ │ ├── PNetLog.h │ │ ├── PNetTools.h │ │ ├── PNetQueue.h │ │ ├── PNetTools.m │ │ ├── log4cplus_pn.h │ │ ├── PNetQueue.m │ │ ├── PNetLog.mm │ │ └── PNetworkCalculator.m │ ├── lookup │ │ ├── PNDomainLookup.h │ │ └── PNDomainLookup.mm │ ├── portscan │ │ ├── PNPortScan.h │ │ └── PNPortScan.mm │ ├── uping │ │ ├── control │ │ │ ├── PhonePingService.h │ │ │ ├── PhonePing.h │ │ │ ├── PhonePingService.mm │ │ │ └── PhonePing.mm │ │ └── model │ │ │ ├── PReportPingModel.h │ │ │ ├── PPingResModel.h │ │ │ ├── PReportPingModel.m │ │ │ └── PPingResModel.m │ ├── netInfo │ │ ├── PNetInfoTool.h │ │ ├── PNetReachability.h │ │ ├── PNetInfoTool.m │ │ └── PNetReachability.m │ ├── utracert │ │ ├── control │ │ │ ├── PhoneTraceRouteService.h │ │ │ ├── PhoneTraceRoute.h │ │ │ ├── PhoneTraceRouteService.m │ │ │ └── PhoneTraceRoute.mm │ │ └── model │ │ │ ├── PTracerRouteResModel.h │ │ │ └── PTracerRouteResModel.m │ ├── PhoneNetSDK.h │ ├── Info.plist │ ├── PhoneNetSDKConst.h │ ├── net │ │ └── control │ │ │ ├── UCNetworkService.h │ │ │ └── UCNetworkService.mm │ ├── lanscan │ │ ├── PNSamplePing.h │ │ ├── PNetMLanScanner.h │ │ ├── PNSamplePing.mm │ │ └── PNetMLanScanner.mm │ ├── udptracert │ │ ├── PNUdpTraceroute.h │ │ └── PNUdpTraceroute.m │ ├── public │ │ ├── PhoneNetSDKHelper.h │ │ ├── bean │ │ │ ├── PNetModel.h │ │ │ └── PNetModel.m │ │ ├── PhoneNetManager.h │ │ └── PhoneNetManager.mm │ ├── tcpping │ │ ├── PNTcpPing.h │ │ └── PNTcpPing.m │ └── common │ │ ├── PhoneNetDiagnosisHelper.h │ │ └── PhoneNetDiagnosisHelper.m └── PhoneNetSDKTests │ ├── Info.plist │ └── PhoneNetSDKTests.m ├── LICENSE ├── update.md ├── socket_server └── tcp_20000.cpp ├── .gitignore ├── README_CN.md ├── PhoneNetSDK.podspec └── README.md /imgs/lanscan.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mediaios/net-diagnosis/HEAD/imgs/lanscan.png -------------------------------------------------------------------------------- /imgs/mainpage.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mediaios/net-diagnosis/HEAD/imgs/mainpage.PNG -------------------------------------------------------------------------------- /imgs/netinfo.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mediaios/net-diagnosis/HEAD/imgs/netinfo.PNG -------------------------------------------------------------------------------- /frameworks/v_1.0.12/PhoneNetSDK_armv7_x8664_arm64.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mediaios/net-diagnosis/HEAD/frameworks/v_1.0.12/PhoneNetSDK_armv7_x8664_arm64.zip -------------------------------------------------------------------------------- /PhoneNetSDK/PhoneNetSDK.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /PhoneNetSDK/PhoneNetSDK.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /PhoneNetSDK/PhoneNetSDK/tools/PNetworkCalculator.h: -------------------------------------------------------------------------------- 1 | // 2 | // NetworkCalculator.h 3 | // MMLanScanDemo 4 | // 5 | // Created by mediaios on 2019/1/22. 6 | // Copyright © 2019 mediaios. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface PNetworkCalculator : NSObject 12 | +(NSArray*)getAllHostsForIP:(NSString*)ipAddress andSubnet:(NSString*)subnetMask; 13 | @end 14 | -------------------------------------------------------------------------------- /PhoneNetSDK/PhoneNetSDK/tools/PNetLog.h: -------------------------------------------------------------------------------- 1 | // 2 | // PNetLog.h 3 | // PhoneNetSDK 4 | // 5 | // Created by mediaios on 2019/2/27. 6 | // Copyright © 2019 mediaios. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "PhoneNetSDKHelper.h" 11 | 12 | NS_ASSUME_NONNULL_BEGIN 13 | 14 | @interface PNetLog : NSObject 15 | + (void)setSDKLogLevel:(PhoneNetSDKLogLevel)logLevel; 16 | @end 17 | 18 | NS_ASSUME_NONNULL_END 19 | -------------------------------------------------------------------------------- /PhoneNetSDK/PhoneNetSDK/tools/PNetTools.h: -------------------------------------------------------------------------------- 1 | // 2 | // PNetTools.h 3 | // PhoneNetSDK 4 | // 5 | // Created by mediaios on 2019/2/28. 6 | // Copyright © 2019 mediaios. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | NS_ASSUME_NONNULL_BEGIN 12 | 13 | @interface PNetTools : NSObject 14 | 15 | + (BOOL)validDomain:(NSString *)domain; 16 | 17 | + (NSInteger)currentTimestamp; 18 | @end 19 | 20 | NS_ASSUME_NONNULL_END 21 | -------------------------------------------------------------------------------- /PhoneNetSDK/PhoneNetSDK/lookup/PNDomainLookup.h: -------------------------------------------------------------------------------- 1 | // 2 | // PNDomainLook.h 3 | // PhoneNetSDK 4 | // 5 | // Created by mediaios on 2019/2/28. 6 | // Copyright © 2019 mediaios. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "PhoneNetSDKHelper.h" 11 | 12 | NS_ASSUME_NONNULL_BEGIN 13 | 14 | @interface PNDomainLookup : NSObject 15 | + (instancetype)shareInstance; 16 | - (void)lookupDomain:(NSString * _Nonnull)domain completeHandler:(NetLookupResultHandler _Nonnull)handler; 17 | @end 18 | 19 | NS_ASSUME_NONNULL_END 20 | -------------------------------------------------------------------------------- /PhoneNetSDK/PhoneNetSDK/tools/PNetQueue.h: -------------------------------------------------------------------------------- 1 | // 2 | // PNetQueue.h 3 | // UNetAnalysisSDK 4 | // 5 | // Created by mediaios on 2019/1/22. 6 | // Copyright © 2019 mediaios. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | NS_ASSUME_NONNULL_BEGIN 12 | 13 | @interface PNetQueue : NSObject 14 | 15 | + (void)pnet_ping_async:(dispatch_block_t)block; 16 | + (void)pnet_quick_ping_async:(dispatch_block_t)block; 17 | + (void)pnet_trace_async:(dispatch_block_t)block; 18 | + (void)pnet_async:(dispatch_block_t)block; 19 | 20 | @end 21 | 22 | NS_ASSUME_NONNULL_END 23 | -------------------------------------------------------------------------------- /PhoneNetSDK/PhoneNetSDK/portscan/PNPortScan.h: -------------------------------------------------------------------------------- 1 | // 2 | // PNPortScan.h 3 | // PhoneNetSDK 4 | // 5 | // Created by mediaios on 2019/2/28. 6 | // Copyright © 2019 mediaios. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "PhoneNetSDKHelper.h" 11 | 12 | NS_ASSUME_NONNULL_BEGIN 13 | 14 | @interface PNPortScan : NSObject 15 | + (instancetype)shareInstance; 16 | - (void)portScan:(NSString *)host beginPort:(NSUInteger)beginPort endPort:(NSUInteger)endPort completeHandler:(NetPortScanHandler)handler; 17 | - (BOOL)isDoingScanPort; 18 | - (void)stopPortScan; 19 | @end 20 | 21 | NS_ASSUME_NONNULL_END 22 | -------------------------------------------------------------------------------- /PhoneNetSDK/PhoneNetSDK/uping/control/PhonePingService.h: -------------------------------------------------------------------------------- 1 | // 2 | // PhonePingService.h 3 | // PingDemo 4 | // 5 | // Created by mediaios on 06/08/2018. 6 | // Copyright © 2018 mediaios. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "PhonePing.h" 11 | #import "PPingResModel.h" 12 | #import "PReportPingModel.h" 13 | #import "PhoneNetManager.h" 14 | 15 | @interface PhonePingService : NSObject 16 | + (instancetype)shareInstance; 17 | - (void)startPingHost:(NSString *)host packetCount:(int)count resultHandler:(NetPingResultHandler)handler; 18 | 19 | - (void)uStopPing; 20 | - (BOOL)uIsPing; 21 | 22 | @end 23 | -------------------------------------------------------------------------------- /PhoneNetSDK/PhoneNetSDK/netInfo/PNetInfoTool.h: -------------------------------------------------------------------------------- 1 | // 2 | // PNetInfoTool.h 3 | // PhoneNetSDK 4 | // 5 | // Created by mediaios on 2018/10/16. 6 | // Copyright © 2018 mediaios. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface PNetInfoTool : NSObject 12 | 13 | 14 | + (instancetype)shareInstance; 15 | - (void)refreshNetInfo; 16 | 17 | #pragma mark - for wifi 18 | - (NSString*)pGetNetworkType; 19 | - (NSString *)pGetSSID; 20 | - (NSString *)pGetBSSID; 21 | - (NSString *)pGetWifiIpv4; 22 | - (NSString *)pGetSubNetMask; 23 | - (NSString *)pGetWifiIpv6; 24 | - (NSString *)pGetCellIpv4; 25 | 26 | 27 | @end 28 | -------------------------------------------------------------------------------- /PhoneNetSDK/PhoneNetSDK/uping/model/PReportPingModel.h: -------------------------------------------------------------------------------- 1 | // 2 | // PReportPingModel.h 3 | // PingDemo 4 | // 5 | // Created by mediaios on 01/08/2018. 6 | // Copyright © 2018 mediaios. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface PReportPingModel : NSObject 12 | 13 | @property (nonatomic,assign) int totolPackets; 14 | @property (nonatomic,assign) int loss; 15 | @property (nonatomic,assign) float delay; 16 | @property (nonatomic,assign) int ttl; 17 | @property (nonatomic,copy) NSString *src_ip; 18 | @property (nonatomic,copy) NSString *dst_ip; 19 | 20 | 21 | - (instancetype)initWithDict:(NSDictionary *)dict; 22 | + (instancetype)uReporterPingmodelWithDict:(NSDictionary *)dict; 23 | - (NSDictionary *)objConvertToDict; 24 | @end 25 | 26 | 27 | -------------------------------------------------------------------------------- /PhoneNetSDK/PhoneNetSDK/tools/PNetTools.m: -------------------------------------------------------------------------------- 1 | // 2 | // PNetTools.m 3 | // PhoneNetSDK 4 | // 5 | // Created by mediaios on 2019/2/28. 6 | // Copyright © 2019 mediaios. All rights reserved. 7 | // 8 | 9 | #import "PNetTools.h" 10 | 11 | @implementation PNetTools 12 | 13 | // 14 | + (BOOL)validDomain:(NSString *)domain 15 | { 16 | BOOL result = NO; 17 | NSString *regex = @"^([a-zA-Z0-9]([a-zA-Z0-9\-]{0,61}[a-zA-Z0-9])?\.)+[a-zA-Z]{2,6}$"; 18 | NSPredicate *pred = [NSPredicate predicateWithFormat:@"SELF MATCHES %@", regex]; 19 | result = [pred evaluateWithObject:domain]; 20 | return result; 21 | } 22 | 23 | 24 | + (NSInteger)currentTimestamp 25 | { 26 | NSTimeInterval currentTime = [[NSDate date] timeIntervalSince1970]; 27 | return (NSInteger)currentTime; 28 | } 29 | @end 30 | -------------------------------------------------------------------------------- /PhoneNetSDK/PhoneNetSDK/uping/control/PhonePing.h: -------------------------------------------------------------------------------- 1 | // 2 | // PhonePing.h 3 | // PingDemo 4 | // 5 | // Created by mediaios on 03/08/2018. 6 | // Copyright © 2018 mediaios. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "PPingResModel.h" 11 | #import "PhoneNetDiagnosisHelper.h" 12 | 13 | @class PhonePing; 14 | 15 | @protocol PhonePingDelegate 16 | 17 | @optional 18 | - (void)pingResultWithUCPing:(PhonePing *)ucPing pingResult:(PPingResModel *)pingRes pingStatus:(PhoneNetPingStatus)status; 19 | 20 | 21 | @end 22 | 23 | @interface PhonePing : NSObject 24 | 25 | @property (nonatomic,strong) id delegate; 26 | 27 | - (void)startPingHosts:(NSString *)host packetCount:(int)count; 28 | 29 | - (void)stopPing; 30 | - (BOOL)isPing; 31 | @end 32 | -------------------------------------------------------------------------------- /PhoneNetSDK/PhoneNetSDK/utracert/control/PhoneTraceRouteService.h: -------------------------------------------------------------------------------- 1 | // 2 | // PhoneTraceRouteService.h 3 | // PingDemo 4 | // 5 | // Created by mediaios on 08/08/2018. 6 | // Copyright © 2018 mediaios. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "PhoneTraceRoute.h" 11 | #import "PTracerRouteResModel.h" 12 | #import "PhoneNetManager.h" 13 | 14 | @interface PhoneTraceRouteService : NSObject 15 | 16 | + (instancetype)shareInstance; 17 | 18 | 19 | /*! 20 | @discussion 21 | Start traceroute a set of host addresses 22 | 23 | @param host ip or doman 24 | @param handler traceroute results 25 | */ 26 | - (void)startTracerouteHost:(NSString *)host resultHandler:(NetTracerouteResultHandler)handler; 27 | 28 | - (void)uStopTracert; 29 | - (BOOL)uIsTracert; 30 | @end 31 | -------------------------------------------------------------------------------- /PhoneNetSDK/PhoneNetSDKTests/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | $(DEVELOPMENT_LANGUAGE) 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | BNDL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleVersion 20 | 1 21 | 22 | 23 | -------------------------------------------------------------------------------- /PhoneNetSDK/PhoneNetSDK/PhoneNetSDK.h: -------------------------------------------------------------------------------- 1 | // 2 | // PhoneNetSDK.h 3 | // PhoneNetSDK 4 | // 5 | // Created by mediaios on 2018/10/15. 6 | // Copyright © 2018 mediaios. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | //! Project version number for PhoneNetSDK. 12 | FOUNDATION_EXPORT double PhoneNetSDKVersionNumber; 13 | 14 | //! Project version string for PhoneNetSDK. 15 | FOUNDATION_EXPORT const unsigned char PhoneNetSDKVersionString[]; 16 | 17 | // In this header, you should import all the public headers of your framework using statements like #import 18 | 19 | #import 20 | #import 21 | #import 22 | #import 23 | #import 24 | #import 25 | -------------------------------------------------------------------------------- /PhoneNetSDK/PhoneNetSDK/utracert/model/PTracerRouteResModel.h: -------------------------------------------------------------------------------- 1 | // 2 | // PTracerRouteResModel.h 3 | // PingDemo 4 | // 5 | // Created by mediaios on 07/08/2018. 6 | // Copyright © 2018 mediaios. All rights reserved. 7 | // 8 | 9 | #import 10 | typedef enum Enum_Traceroute_Status 11 | { 12 | Enum_Traceroute_Status_doing = 0, 13 | Enum_Traceroute_Status_finish 14 | }Enum_Traceroute_Status; 15 | 16 | 17 | @interface PTracerRouteResModel : NSObject 18 | 19 | @property (readonly) NSInteger hop; 20 | @property NSString* ip; 21 | @property NSTimeInterval* durations; //ms 22 | @property (readonly) NSInteger count; //ms 23 | @property (nonatomic,assign) Enum_Traceroute_Status status; 24 | @property (nonatomic,copy) NSString *dstIp; 25 | 26 | 27 | - (instancetype)init:(NSInteger)hop 28 | count:(NSInteger)count; 29 | @end 30 | -------------------------------------------------------------------------------- /PhoneNetSDK/PhoneNetSDK/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | $(DEVELOPMENT_LANGUAGE) 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | FMWK 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleVersion 20 | $(CURRENT_PROJECT_VERSION) 21 | NSPrincipalClass 22 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /PhoneNetSDK/PhoneNetSDK/PhoneNetSDKConst.h: -------------------------------------------------------------------------------- 1 | // 2 | // UNetAnalysisConst.h 3 | // UNetAnalysisSDK 4 | // 5 | // Created by mediaios on 26/07/2018. 6 | // Copyright © 2018 mediaios. All rights reserved. 7 | // 8 | 9 | #ifndef PhoneNetSDKConst_h 10 | #define PhoneNetSDKConst_h 11 | 12 | 13 | /********** For log4cplus *************/ 14 | #ifndef PhoneNetSDK_IOS 15 | #define PhoneNetSDK_IOS 16 | #endif 17 | 18 | /*********** About http Interface ***********/ 19 | #define PhoneNet_Get_Public_Ip_Url @"http://ipinfo.io/json" //get public ip info interface 20 | 21 | 22 | /*********** Global define ***********/ 23 | #define PhoneNotification [NSNotificationCenter defaultCenter] 24 | #define PhoneNetSDKVersion @"1.0.12" 25 | 26 | /*********** Ping model ***********/ 27 | #define KPingIcmpIdBeginNum 8000 28 | 29 | #endif /* NetAnalysisConst_h */ 30 | -------------------------------------------------------------------------------- /PhoneNetSDK/PhoneNetSDK/net/control/UCNetworkService.h: -------------------------------------------------------------------------------- 1 | // 2 | // UCNetworkService.h 3 | // UCNetDiagnosisDemo 4 | // 5 | // Created by mediaios on 13/08/2018. 6 | // Copyright © 2018 mediaios. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | /************************ define Network request *************************/ 12 | typedef enum UNetHTTPRequestParamType 13 | { 14 | UNetHTTPRequestParamType_JSON = 0, 15 | UNetHTTPRequestParamType_KEYVALUE, 16 | UNetHTTPRequestParamType_XML, 17 | UNetHTTPRequestParamType_URLENCODED, 18 | UNetHTTPRequestParamType_MULTIPARTFORM 19 | }UNetHTTPRequestParamType; 20 | 21 | typedef void(^UNetHttpResponseHandler) (NSData *_Nullable data, NSError *_Nullable error); 22 | 23 | @interface UCNetworkService : NSObject 24 | 25 | + (void)uHttpGetRequestWithUrl:(NSString *)urlstr functionModule:(NSString *)module timeout:(NSTimeInterval)timeValue completionHandler:(UNetHttpResponseHandler)handler; 26 | @end 27 | -------------------------------------------------------------------------------- /PhoneNetSDK/PhoneNetSDK/lanscan/PNSamplePing.h: -------------------------------------------------------------------------------- 1 | // 2 | // PNSamplePing.h 3 | // PhoneNetSDK 4 | // 5 | // Created by mediaios on 2019/6/5. 6 | // Copyright © 2019年 mediaios. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "PPingResModel.h" 11 | #import "PhoneNetDiagnosisHelper.h" 12 | 13 | NS_ASSUME_NONNULL_BEGIN 14 | @class PNSamplePing; 15 | @protocol PNSamplePingDelegate 16 | 17 | @optional 18 | - (void)simplePing:(PNSamplePing *)samplePing didTimeOut:(NSString *)ip; 19 | - (void)simplePing:(PNSamplePing *)samplePing receivedPacket:(NSString *)ip; 20 | - (void)simplePing:(PNSamplePing *)samplePing pingError:(NSException *)exception; 21 | - (void)simplePing:(PNSamplePing *)samplePing finished:(NSString *)ip; 22 | 23 | @end 24 | 25 | 26 | 27 | @interface PNSamplePing : NSObject 28 | 29 | @property (nonatomic,weak) id delegate; 30 | 31 | - (void)startPingIp:(NSString *)ip packetCount:(int)count; 32 | 33 | - (void)stopPing; 34 | - (BOOL)isPing; 35 | @end 36 | 37 | NS_ASSUME_NONNULL_END 38 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2019 mediaios 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /PhoneNetSDK/PhoneNetSDK/uping/model/PPingResModel.h: -------------------------------------------------------------------------------- 1 | // 2 | // UPingResModel.h 3 | // PingDemo 4 | // 5 | // Created by mediaios on 31/07/2018. 6 | // Copyright © 2018 mediaios. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | typedef NS_ENUM(NSInteger, PhoneNetPingStatus) { 12 | PhoneNetPingStatusDidStart, 13 | PhoneNetPingStatusDidFailToSendPacket, 14 | PhoneNetPingStatusDidReceivePacket, 15 | PhoneNetPingStatusDidReceiveUnexpectedPacket, 16 | PhoneNetPingStatusDidTimeout, 17 | PhoneNetPingStatusError, 18 | PhoneNetPingStatusFinished, 19 | }; 20 | 21 | @interface PPingResModel : NSObject 22 | 23 | @property(nonatomic) NSString *originalAddress; 24 | @property(nonatomic, copy) NSString *IPAddress; 25 | @property(nonatomic) NSUInteger dateBytesLength; 26 | @property(nonatomic) float timeMilliseconds; 27 | @property(nonatomic) NSInteger timeToLive; 28 | @property(nonatomic) NSInteger tracertCount; 29 | @property(nonatomic) NSInteger ICMPSequence; 30 | @property(nonatomic) PhoneNetPingStatus status; 31 | 32 | + (NSDictionary *)pingResultWithPingItems:(NSArray *)pingItems; 33 | 34 | @end 35 | -------------------------------------------------------------------------------- /PhoneNetSDK/PhoneNetSDK/utracert/control/PhoneTraceRoute.h: -------------------------------------------------------------------------------- 1 | // 2 | // PhoneTraceRoute.h 3 | // PingDemo 4 | // 5 | // Created by mediaios on 08/08/2018. 6 | // Copyright © 2018 mediaios. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "PTracerRouteResModel.h" 11 | #import "PhoneNetDiagnosisHelper.h" 12 | 13 | const int kTracertRouteCount_noRes = 5; // 连续无响应的route个数 14 | const int kTracertMaxTTL = 30; // Max 30 hops(最多30跳) 15 | #define kTracertSendIcmpPacketTimes 3 // 对一个中间节点,发送2个icmp包 16 | const int kIcmpPacketTimeoutTime = 300; // ICMP包超时时间(ms) 17 | 18 | @class PhoneTraceRoute; 19 | @protocol PhoneTraceRouteDelegate 20 | - (void)tracerouteWithUCTraceRoute:(PhoneTraceRoute *)ucTraceRoute tracertResult:(PTracerRouteResModel *)tracertRes; 21 | - (void)tracerouteFinishedWithUCTraceRoute:(PhoneTraceRoute *)ucTraceRoute; 22 | @optional 23 | 24 | 25 | @end 26 | 27 | @interface PhoneTraceRoute : NSObject 28 | @property (nonatomic,strong) id delegate; 29 | 30 | - (void)startTracerouteHost:(NSString *)host; 31 | 32 | - (void)stopTracert; 33 | - (BOOL)isTracert; 34 | @end 35 | -------------------------------------------------------------------------------- /PhoneNetSDK/PhoneNetSDK/utracert/model/PTracerRouteResModel.m: -------------------------------------------------------------------------------- 1 | // 2 | // PTracerRouteResModel.m 3 | // PingDemo 4 | // 5 | // Created by mediaios on 07/08/2018. 6 | // Copyright © 2018 mediaios. All rights reserved. 7 | // 8 | 9 | #import "PTracerRouteResModel.h" 10 | 11 | @implementation PTracerRouteResModel 12 | - (instancetype)init:(NSInteger)hop 13 | count:(NSInteger)count { 14 | if (self = [super init]) { 15 | _ip = nil; 16 | _hop = hop; 17 | _durations = (NSTimeInterval*)calloc(count, sizeof(NSTimeInterval)); 18 | _count = count; 19 | _status = Enum_Traceroute_Status_doing; 20 | } 21 | return self; 22 | } 23 | 24 | - (NSString*)description { 25 | NSMutableString *mutableStr = [NSMutableString string]; 26 | for (int i = 0; i < _count; i++) { 27 | if (_durations[i] <= 0) { 28 | [mutableStr appendString:@"* "]; 29 | }else{ 30 | [mutableStr appendString:[NSString stringWithFormat:@" %.3fms",_durations[i] * 1000]]; 31 | } 32 | } 33 | return [NSString stringWithFormat:@"seq:%d , dstIp:%@, routeIp:%@, durations:%@ , status:%d",(int)_hop,_dstIp,_ip,mutableStr,(int)_status]; 34 | } 35 | 36 | 37 | - (void)dealloc { 38 | free(_durations); 39 | } 40 | @end 41 | -------------------------------------------------------------------------------- /update.md: -------------------------------------------------------------------------------- 1 | ## iOS network diagnostics sdk release note 2 | 3 | ### v-1.0.3(2019.03.01) 4 | 5 | * support `ping` function 6 | * support `traceroute` function 7 | * DNS parsing(`nslookup`) 8 | * Support for querying whether the service port is available 9 | * Get the device public ip info 10 | 11 | 12 | ### v-1.0.7(2019.03.22) 13 | 14 | * Add `tcp ping` function 15 | * Add `udp traceroute` function 16 | * Fixed some bugs 17 | 18 | ### v-1.0.10(2019.06.17) 19 | 20 | * Add LAN ip scanning function 21 | 22 | ### v-1.0.11(2019.07.01) 23 | 24 | * Fix bug: When the `tracert` reaches the destination host, the type of the icmp packet is filtered incorrectly. The replay package should be filtered instead of the timeout package. 25 | 26 | ### v-1.0.12(2019.10.12) 27 | 28 | * Fix bug: when the tcp conn fails,there is no response for a long time. 29 | 30 | ## iOS网络诊断SDK版本更新记录 31 | 32 | ### v-1.0.3(2019.03.01) 33 | 34 | * `ping`功能 35 | * `traceroute`功能 36 | * 根据域名查ip功能(`nslookup`) 37 | * 查询服务端口功能 38 | * 获取设备公网ip信息 39 | 40 | ### v-1.0.7(2019.03.22) 41 | 42 | * 添加 `tcp ping`功能 43 | * 添加 `udp traceroute`功能 44 | * 修复了部分bug 45 | 46 | ### v-1.0.10(2019.06.17) 47 | 48 | * 添加局域网ip扫描功能 49 | 50 | ### v-1.0.11(2019.07.01) 51 | 52 | * 修复bug: tracert到达目的主机时,过滤包的类型错误,应该直接过滤replay包而不是timeout包。 53 | 54 | ### v-1.0.12(2019.10.12) 55 | 56 | * 修复bug: tcp连接不通时,长时间没有响应。 -------------------------------------------------------------------------------- /PhoneNetSDK/PhoneNetSDK/uping/model/PReportPingModel.m: -------------------------------------------------------------------------------- 1 | // 2 | // PReportPingModel.m 3 | // PingDemo 4 | // 5 | // Created by mediaios on 01/08/2018. 6 | // Copyright © 2018 mediaios. All rights reserved. 7 | // 8 | 9 | #import "PReportPingModel.h" 10 | 11 | @implementation PReportPingModel 12 | 13 | - (instancetype)initWithDict:(NSDictionary *)dict 14 | { 15 | if (self = [super init]) { 16 | self.totolPackets = [dict[@"totolPackets"] intValue]; 17 | self.loss = [dict[@"loss"] intValue]; 18 | self.delay = [dict[@"delay"] floatValue]; 19 | self.ttl = [dict[@"ttl"] intValue]; 20 | self.src_ip = dict[@"src_ip"]; 21 | self.dst_ip = dict[@"dst_ip"]; 22 | } 23 | return self; 24 | } 25 | 26 | + (instancetype)uReporterPingmodelWithDict:(NSDictionary *)dict 27 | { 28 | return [[self alloc] initWithDict:dict]; 29 | } 30 | 31 | - (NSDictionary *)objConvertToDict 32 | { 33 | return @{@"loss":@(self.loss),@"delay":@(self.delay),@"src_ip":self.src_ip,@"dst_ip":self.dst_ip,@"ttl":@(self.ttl)}; 34 | } 35 | 36 | - (NSString *)description 37 | { 38 | return [NSString stringWithFormat:@"src_ip:%@ , dst_ip:%@ , totalPackets:%d , loss:%d , delay:%@ , ttl:%d ",self.src_ip,self.dst_ip,self.totolPackets,self.loss,[NSString stringWithFormat:@"%.3fms",self.delay],self.ttl]; 39 | } 40 | 41 | @end 42 | -------------------------------------------------------------------------------- /socket_server/tcp_20000.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | //#define MAXLINE 1024 11 | 12 | int main(int argc,char **argv) 13 | { 14 | int rec_socket,clent_addr; 15 | struct sockaddr_in serv_addr; 16 | // char buff[MAXLINE]; 17 | // int n; 18 | 19 | rec_socket = socket(AF_INET,SOCK_STREAM,0); // create server socket 20 | 21 | // bind socket,ip,port 22 | memset(&serv_addr,0,sizeof(serv_addr)); 23 | serv_addr.sin_family = AF_INET; // only support ipv4 24 | serv_addr.sin_addr.s_addr = htonl(INADDR_ANY); // source ip: any ip 25 | serv_addr.sin_port = htons(20000); // use 20000 port 26 | bind(rec_socket,(struct sockaddr *) &serv_addr,sizeof(serv_addr)); 27 | 28 | // listening tcp conn 29 | listen(rec_socket,1024); 30 | // printf("wait client connection\n"); 31 | for(;;) 32 | { 33 | if((clent_addr = accept(rec_socket,(struct sockaddr*)NULL,NULL))==-1) 34 | { 35 | printf("accpet socket error: %s errno :%d\n",strerror(errno),errno); 36 | continue; 37 | } 38 | // n = recv(clent_addr,buff,MAXLINE,0); 39 | // buff[n] = '\0'; 40 | // printf("recv msg from client:%s",buff); 41 | close(clent_addr); 42 | } 43 | close(rec_socket); 44 | } 45 | -------------------------------------------------------------------------------- /PhoneNetSDK/PhoneNetSDK/udptracert/PNUdpTraceroute.h: -------------------------------------------------------------------------------- 1 | // 2 | // PNUdpTraceroute.h 3 | // PhoneNetSDK 4 | // 5 | // Created by mediaios on 2019/3/13. 6 | // Copyright © 2019 mediaios. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | typedef void (^PNUdpTracerouteHandler)(NSMutableString *); 12 | 13 | 14 | @interface PNUdpTraceroute : NSObject 15 | 16 | /** 17 | @brief start udp traceroute. 18 | 19 | @discussion The default max TTL is 30, each route sends 3 udp packets. If there are five routes continuously losing 3 udp packets, the traceroute is terminated. 20 | 21 | @param host ip or domain 22 | @param complete udp traceroute result callback 23 | @return a `PNUdpTraceroute` instance. 24 | */ 25 | + (instancetype)start:(NSString * _Nonnull)host 26 | complete:(PNUdpTracerouteHandler _Nonnull)complete; 27 | 28 | 29 | /** 30 | @brief start udp traceroute. 31 | 32 | @discussion Use the max ttl you set to do traceroute 33 | 34 | @param host ip or domain 35 | @param maxTtl the max ttl 36 | @param complete udp traceroute result callback 37 | @return a `PNUdpTraceroute` instance. 38 | */ 39 | + (instancetype)start:(NSString * _Nonnull)host 40 | maxTtl:(NSUInteger)maxTtl 41 | complete:(PNUdpTracerouteHandler _Nonnull)complete; 42 | 43 | 44 | /** 45 | @brief get now is doing udp traceroute or not. 46 | 47 | @return YES: is doing; NO: is not doing 48 | */ 49 | - (BOOL)isDoingUdpTraceroute; 50 | 51 | 52 | /** 53 | @brief stop udp traceroute 54 | */ 55 | - (void)stopUdpTraceroute; 56 | 57 | @end 58 | 59 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Xcode 2 | # 3 | # gitignore contributors: remember to update Global/Xcode.gitignore, Objective-C.gitignore & Swift.gitignore 4 | 5 | ## Build generated 6 | build/ 7 | DerivedData/ 8 | 9 | ## Various settings 10 | *.pbxuser 11 | !default.pbxuser 12 | *.mode1v3 13 | !default.mode1v3 14 | *.mode2v3 15 | !default.mode2v3 16 | *.perspectivev3 17 | !default.perspectivev3 18 | xcuserdata/ 19 | 20 | ## Other 21 | *.moved-aside 22 | *.xccheckout 23 | *.xcscmblueprint 24 | 25 | ## Obj-C/Swift specific 26 | *.hmap 27 | *.ipa 28 | *.dSYM.zip 29 | *.dSYM 30 | 31 | # CocoaPods 32 | # 33 | # We recommend against adding the Pods directory to your .gitignore. However 34 | # you should judge for yourself, the pros and cons are mentioned at: 35 | # https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control 36 | # 37 | # Pods/ 38 | 39 | # Carthage 40 | # 41 | # Add this line if you want to avoid checking in source code from Carthage dependencies. 42 | # Carthage/Checkouts 43 | 44 | Carthage/Build 45 | 46 | # fastlane 47 | # 48 | # It is recommended to not store the screenshots in the git repo. Instead, use fastlane to re-generate the 49 | # screenshots whenever they are needed. 50 | # For more information about the recommended setup visit: 51 | # https://docs.fastlane.tools/best-practices/source-control/#source-control 52 | 53 | fastlane/report.xml 54 | fastlane/Preview.html 55 | fastlane/screenshots/**/*.png 56 | fastlane/test_output 57 | 58 | # Code Injection 59 | # 60 | # After new code Injection tools there's a generated folder /iOSInjectionProject 61 | # https://github.com/johnno1962/injectionforxcode 62 | 63 | iOSInjectionProject/ 64 | -------------------------------------------------------------------------------- /PhoneNetSDK/PhoneNetSDK/lanscan/PNetMLanScanner.h: -------------------------------------------------------------------------------- 1 | // 2 | // PNetMLanScanner.h 3 | // PhoneNetSDK 4 | // 5 | // Created by mediaios on 2019/6/5. 6 | // Copyright © 2019年 mediaios. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | NS_ASSUME_NONNULL_BEGIN 12 | 13 | @class PNetMLanScanner; 14 | @protocol PNetMLanScannerDelegate 15 | 16 | @optional 17 | 18 | /** 19 | @brief Show active ip in LAN 20 | 21 | @param scanner The instance of `PNetMLanScanner` 22 | @param ip Active ip (Accessible device ip) 23 | */ 24 | - (void) scanMLan:(PNetMLanScanner *)scanner activeIp:(NSString *)ip; 25 | 26 | 27 | /** 28 | @brief Show the percentage of scan progress, which is a decimal of 0-1 29 | 30 | @param scanner The instance of `PNetMLanScanner` 31 | @param percent The percentage of scan progress 32 | */ 33 | - (void) scanMlan:(PNetMLanScanner *)scanner percent:(float)percent; 34 | 35 | /** 36 | @brief Scan all ip ends in the LAN 37 | 38 | @param scanner The instance of `PNetMLanScanner` 39 | */ 40 | - (void) finishedScanMlan:(PNetMLanScanner *)scanner; 41 | 42 | @end 43 | 44 | @interface PNetMLanScanner : NSObject 45 | 46 | @property (nonatomic,weak) id delegate; 47 | 48 | 49 | /** 50 | @brief Get a `PNetMLanScanner` instance 51 | 52 | @return A `PNetMLanScanner` instance 53 | */ 54 | + (instancetype)shareInstance; 55 | 56 | 57 | /** 58 | @brief Start scanning ip in the LAN 59 | */ 60 | - (void)scan; 61 | 62 | 63 | /** 64 | @brief Stop lan scanning 65 | */ 66 | - (void)stop; 67 | 68 | 69 | /** 70 | @brief Get the status of the current LAN ip scan 71 | 72 | @return YES: scanning; NO: is not scanning 73 | */ 74 | - (BOOL)isScanning; 75 | 76 | @end 77 | 78 | NS_ASSUME_NONNULL_END 79 | -------------------------------------------------------------------------------- /PhoneNetSDK/PhoneNetSDK/public/PhoneNetSDKHelper.h: -------------------------------------------------------------------------------- 1 | // 2 | // PhoneNetSDKHelper.h 3 | // PhoneNetSDK 4 | // 5 | // Created by mediaios on 2019/2/27. 6 | // Copyright © 2019 mediaios. All rights reserved. 7 | // 8 | 9 | #ifndef PhoneNetSDKHelper_h 10 | #define PhoneNetSDKHelper_h 11 | #import "PNetModel.h" 12 | 13 | 14 | /** 15 | @brief This is an enumerated type that defines the log level 16 | 17 | @discussion When developing, it is recommended to set the log level of the SDK to `PhoneNetSDKLogLevel_DEBUG`, which is convenient for development and debugging. When you go online, change the level to a higher level of `PhoneNetSDKLogLevel_ERROR`. 18 | 19 | - PhoneNetSDKLogLevel_FATAL: FATAL level 20 | - PhoneNetSDKLogLevel_ERROR: ERROR level(If not set, the default is this level) 21 | - PhoneNetSDKLogLevel_WARN: WARN level 22 | - PhoneNetSDKLogLevel_INFO: INFO level 23 | - PhoneNetSDKLogLevel_DEBUG: DEBUG level 24 | */ 25 | typedef NS_ENUM(NSUInteger,PhoneNetSDKLogLevel) 26 | { 27 | PhoneNetSDKLogLevel_FATAL, 28 | PhoneNetSDKLogLevel_ERROR, 29 | PhoneNetSDKLogLevel_WARN, 30 | PhoneNetSDKLogLevel_INFO, 31 | PhoneNetSDKLogLevel_DEBUG 32 | }; 33 | 34 | #pragma mark -ping callback 35 | typedef void(^NetPingResultHandler)(NSString *_Nullable pingres); 36 | 37 | #pragma mark -tracert callback 38 | typedef void(^NetTracerouteResultHandler)(NSString *_Nullable tracertRes ,NSString *_Nullable destIp); 39 | 40 | #pragma mark -nslookup callback 41 | typedef void (^NetLookupResultHandler)(NSMutableArray *_Nullable lookupRes, PNError *_Nullable sdkError); 42 | 43 | #pragma mark -portscan callback 44 | typedef void (^NetPortScanHandler)(NSString * _Nullable port, BOOL isOpen, PNError * _Nullable sdkError); 45 | 46 | #endif /* PhoneNetSDKHelper_h */ 47 | -------------------------------------------------------------------------------- /PhoneNetSDK/PhoneNetSDK/net/control/UCNetworkService.mm: -------------------------------------------------------------------------------- 1 | // 2 | // UCNetworkService.m 3 | // UCNetDiagnosisDemo 4 | // 5 | // Created by mediaios on 13/08/2018. 6 | // Copyright © 2018 mediaios. All rights reserved. 7 | // 8 | 9 | #import "UCNetworkService.h" 10 | #import "PhoneNetSDKConst.h" 11 | #include "log4cplus_pn.h" 12 | 13 | @interface UCNetworkService() 14 | 15 | @end 16 | 17 | 18 | @implementation UCNetworkService 19 | 20 | + (void)uHttpGetRequestWithUrl:(NSString *)urlstr functionModule:(NSString *)module timeout:(NSTimeInterval)timeValue completionHandler:(UNetHttpResponseHandler)handler 21 | { 22 | if (urlstr == NULL || urlstr.length == 0) { 23 | log4cplus_warn("PhoneNetSDK", "%s module , request url is null..\n",[module UTF8String]); 24 | return; 25 | } 26 | 27 | log4cplus_debug("PhoneNetSDK", "%s module , request url: %s \n",[module UTF8String],[urlstr UTF8String]); 28 | NSURL *url = [NSURL URLWithString:urlstr]; 29 | NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:url]; 30 | [request setHTTPMethod:@"GET"]; 31 | [request setTimeoutInterval:10.0]; 32 | NSURLSession *session = [NSURLSession sharedSession]; 33 | 34 | NSURLSessionTask *sessionTask = [session dataTaskWithRequest:request completionHandler:^(NSData * _Nullable data, NSURLResponse * _Nullable response, NSError * _Nullable error) { 35 | NSHTTPURLResponse *httpUrlResponse = (NSHTTPURLResponse *)response; 36 | if (data == nil || error) { 37 | log4cplus_warn("PhoneNetSDK", "%s module , http request error , response code :%ld\n",[module UTF8String],(long)httpUrlResponse.statusCode); 38 | }else{ 39 | handler(data,error); 40 | } 41 | 42 | } ]; 43 | [sessionTask resume]; 44 | } 45 | 46 | 47 | @end 48 | -------------------------------------------------------------------------------- /PhoneNetSDK/PhoneNetSDK/tcpping/PNTcpPing.h: -------------------------------------------------------------------------------- 1 | // 2 | // PNTcpPing.h 3 | // PhoneNetSDK 4 | // 5 | // Created by mediaios on 2019/3/11. 6 | // Copyright © 2019 mediaios. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface PNTcpPingResult : NSObject 12 | @property (readonly) NSString *ip; 13 | @property (readonly) NSUInteger loss; 14 | @property (readonly) NSUInteger count; 15 | @property (readonly) NSTimeInterval max_time; 16 | @property (readonly) NSTimeInterval avg_time; 17 | @property (readonly) NSTimeInterval min_time; 18 | 19 | @end 20 | 21 | typedef void (^PNTcpPingHandler)(NSMutableString *); 22 | 23 | @interface PNTcpPing : NSObject 24 | 25 | 26 | /** 27 | @brief start TCP ping 28 | 29 | @discussion the default port is 80 30 | 31 | @param host domain or ip 32 | @param complete tcp ping callback 33 | @return `PNTcpPing` instance 34 | */ 35 | + (instancetype)start:(NSString * _Nonnull)host 36 | complete:(PNTcpPingHandler _Nonnull)complete; 37 | 38 | 39 | /** 40 | @brief start TCP ping 41 | 42 | @param host domain or ip 43 | @param port port number 44 | @param count ping times 45 | @param complete tcp ping callback 46 | @return `PNTcpPing` instance 47 | */ 48 | + (instancetype)start:(NSString * _Nonnull)host 49 | port:(NSUInteger)port 50 | count:(NSUInteger)count 51 | complete:(PNTcpPingHandler _Nonnull)complete; 52 | 53 | 54 | /** 55 | @brief check is doing tcp ping now. 56 | 57 | @return YES: is doing; NO: is not doing 58 | */ 59 | - (BOOL)isTcpPing; 60 | 61 | 62 | /** 63 | @brief stop tcp ping 64 | */ 65 | - (void)stopTcpPing; 66 | 67 | 68 | /** 69 | @brief processing long tcp conn(ip or port can not be connected) 70 | */ 71 | - (void)processLongConn; 72 | 73 | 74 | @end 75 | 76 | 77 | -------------------------------------------------------------------------------- /PhoneNetSDK/PhoneNetSDK/tools/log4cplus_pn.h: -------------------------------------------------------------------------------- 1 | #ifndef _LOG4CPLUS_H_ 2 | #define _LOG4CPLUS_H_ 3 | #endif // WIN32 4 | 5 | #if (defined (_MSC_VER) && _MSC_VER >= 1900) || (defined(__cplusplus) && __cplusplus>= 201103L) 6 | #define __STDC_FORMAT_MACROS 7 | #include 8 | #endif 9 | 10 | #ifdef PhoneNetSDK_IOS 11 | #include 12 | 13 | extern int PhoneNetSDK_IOS_LOG_LEVEL; 14 | extern int PhoneNetSDK_IOS_FLAG_FATAL; 15 | extern int PhoneNetSDK_IOS_FLAG_ERROR; 16 | extern int PhoneNetSDK_IOS_FLAG_WARN; 17 | extern int PhoneNetSDK_IOS_FLAG_INFO; 18 | extern int PhoneNetSDK_IOS_FLAG_DEBUG; 19 | 20 | #define log4cplus_fatal(category, logFmt, ...) \ 21 | do { \ 22 | if(PhoneNetSDK_IOS_LOG_LEVEL & PhoneNetSDK_IOS_FLAG_FATAL) \ 23 | syslog(LOG_CRIT, "%s:" logFmt, #category,##__VA_ARGS__); \ 24 | }while(0) 25 | 26 | #define log4cplus_error(category, logFmt, ...) \ 27 | do { \ 28 | if(PhoneNetSDK_IOS_LOG_LEVEL & PhoneNetSDK_IOS_FLAG_ERROR) \ 29 | syslog(LOG_ERR, "%s:" logFmt, #category,##__VA_ARGS__); \ 30 | }while(0) 31 | 32 | #define log4cplus_warn(category, logFmt, ...) \ 33 | do { \ 34 | if(PhoneNetSDK_IOS_LOG_LEVEL & PhoneNetSDK_IOS_FLAG_WARN) \ 35 | syslog(LOG_WARNING, "%s:" logFmt, #category,##__VA_ARGS__); \ 36 | }while(0) 37 | 38 | #define log4cplus_info(category, logFmt, ...) \ 39 | do { \ 40 | if(PhoneNetSDK_IOS_LOG_LEVEL & PhoneNetSDK_IOS_FLAG_INFO) \ 41 | syslog(LOG_WARNING, "%s:" logFmt, #category,##__VA_ARGS__); \ 42 | }while(0) 43 | 44 | #define log4cplus_debug(category, logFmt, ...) \ 45 | do { \ 46 | if(PhoneNetSDK_IOS_LOG_LEVEL & PhoneNetSDK_IOS_FLAG_DEBUG) \ 47 | syslog(LOG_WARNING, "%s:" logFmt, #category,##__VA_ARGS__); \ 48 | }while(0) 49 | 50 | 51 | #endif 52 | 53 | -------------------------------------------------------------------------------- /PhoneNetSDK/PhoneNetSDK/netInfo/PNetReachability.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 2016 Apple Inc. All Rights Reserved. 3 | See LICENSE.txt for this sample’s licensing information 4 | 5 | Abstract: 6 | Basic demonstration of how to use the SystemConfiguration Reachablity APIs. 7 | */ 8 | 9 | #import 10 | #import 11 | #import 12 | 13 | typedef enum : NSInteger { 14 | PNetReachable_None = 0, 15 | PNetReachable_WiFi, 16 | PNetReachable_WWAN 17 | } PNetNetStatus; 18 | 19 | #pragma mark IPv6 Support 20 | //PNetReachability fully support IPv6. For full details, see ReadMe.md. 21 | 22 | 23 | extern NSString *kPNetReachabilityChangedNotification; 24 | 25 | 26 | @interface PNetReachability : NSObject 27 | 28 | /*! 29 | * Use to check the reachability of a given host name. 30 | */ 31 | + (instancetype)reachabilityWithHostName:(NSString *)hostName; 32 | 33 | /*! 34 | * Use to check the reachability of a given IP address. 35 | */ 36 | + (instancetype)reachabilityWithAddress:(const struct sockaddr *)hostAddress; 37 | 38 | /*! 39 | * Checks whether the default route is available. Should be used by applications that do not connect to a particular host. 40 | */ 41 | + (instancetype)reachabilityForInternetConnection; 42 | 43 | 44 | #pragma mark reachabilityForLocalWiFi 45 | //reachabilityForLocalWiFi has been removed from the sample. See ReadMe.md for more information. 46 | //+ (instancetype)reachabilityForLocalWiFi; 47 | 48 | /*! 49 | * Start listening for reachability notifications on the current run loop. 50 | */ 51 | - (BOOL)startNotifier; 52 | - (void)stopNotifier; 53 | 54 | - (PNetNetStatus)currentReachabilityStatus; 55 | 56 | /*! 57 | * WWAN may be available, but not active until a connection has been established. WiFi may require a connection for VPN on Demand. 58 | */ 59 | - (BOOL)connectionRequired; 60 | 61 | @end 62 | 63 | 64 | -------------------------------------------------------------------------------- /PhoneNetSDK/PhoneNetSDK/tools/PNetQueue.m: -------------------------------------------------------------------------------- 1 | // 2 | // PNetQueue.m 3 | // UNetAnalysisSDK 4 | // 5 | // Created by mediaios on 2019/1/22. 6 | // Copyright © 2019 mediaios. All rights reserved. 7 | // 8 | 9 | #import "PNetQueue.h" 10 | 11 | @interface PNetQueue() 12 | + (instancetype)shareInstance; 13 | 14 | @property (nonatomic) dispatch_queue_t pingQueue; 15 | @property (nonatomic) dispatch_queue_t quickPingQueue; 16 | @property (nonatomic) dispatch_queue_t traceQueue; 17 | @property (nonatomic) dispatch_queue_t asyncQueue; 18 | 19 | @end 20 | 21 | @implementation PNetQueue 22 | 23 | + (instancetype)shareInstance 24 | { 25 | static PNetQueue *unetQueue = nil; 26 | 27 | static dispatch_once_t onceToken; 28 | dispatch_once(&onceToken, ^{ 29 | unetQueue = [[self alloc] init]; 30 | }); 31 | return unetQueue; 32 | } 33 | 34 | - (instancetype)init 35 | { 36 | if (self = [super init]) { 37 | _pingQueue = dispatch_queue_create("pnet_ping_queue", DISPATCH_QUEUE_SERIAL); 38 | _quickPingQueue = dispatch_queue_create("pnet_qping_queue", DISPATCH_QUEUE_SERIAL); 39 | _traceQueue = dispatch_queue_create("pnet_trace_queue", DISPATCH_QUEUE_SERIAL); 40 | _asyncQueue = dispatch_queue_create("Pnet_async_queue", DISPATCH_QUEUE_SERIAL); 41 | } 42 | return self; 43 | } 44 | 45 | + (void)pnet_ping_async:(dispatch_block_t)block 46 | { 47 | dispatch_async([PNetQueue shareInstance].pingQueue, ^{ 48 | block(); 49 | }); 50 | } 51 | 52 | + (void)pnet_quick_ping_async:(dispatch_block_t)block 53 | { 54 | dispatch_async([PNetQueue shareInstance].quickPingQueue, ^{ 55 | block(); 56 | }); 57 | } 58 | 59 | + (void)pnet_trace_async:(dispatch_block_t)block 60 | { 61 | dispatch_async([PNetQueue shareInstance].traceQueue , ^{ 62 | block(); 63 | }); 64 | } 65 | 66 | + (void)pnet_async:(dispatch_block_t)block 67 | { 68 | dispatch_async([PNetQueue shareInstance].asyncQueue, ^{ 69 | block(); 70 | }); 71 | } 72 | @end 73 | -------------------------------------------------------------------------------- /PhoneNetSDK/PhoneNetSDKTests/PhoneNetSDKTests.m: -------------------------------------------------------------------------------- 1 | // 2 | // PhoneNetSDKTests.m 3 | // PhoneNetSDKTests 4 | // 5 | // Created by mediaios on 2018/10/15. 6 | // Copyright © 2018 mediaios. All rights reserved. 7 | // 8 | 9 | #import 10 | #import 11 | 12 | 13 | @interface PhoneNetSDKTests : XCTestCase 14 | @end 15 | 16 | @implementation PhoneNetSDKTests 17 | 18 | - (void)setUp { 19 | [super setUp]; 20 | // Put setup code here. This method is called before the invocation of each test method in the class. 21 | 22 | 23 | } 24 | 25 | - (void)tearDown { 26 | // Put teardown code here. This method is called after the invocation of each test method in the class. 27 | [super tearDown]; 28 | } 29 | 30 | - (void)testExample { 31 | // This is an example of a functional test case. 32 | // Use XCTAssert and related functions to verify your tests produce the correct results. 33 | } 34 | 35 | - (void)testping 36 | { 37 | 38 | } 39 | 40 | - (void)testDomainLookup 41 | { 42 | [[PhoneNetManager shareInstance] netLookupDomain:@"www.google.com" completeHandler:^(NSMutableArray * _Nullable lookupRes, PNError * _Nullable sdkError) { 43 | if (sdkError) { 44 | NSLog(@"%@",sdkError.error.description); 45 | }else{ 46 | for (DomainLookUpRes *res in lookupRes) { 47 | NSLog(@"%@->%@",res.name,res.ip); 48 | } 49 | } 50 | }]; 51 | } 52 | 53 | - (void)testPortScan 54 | { 55 | [[PhoneNetManager shareInstance] netPortScan:@"www.baidu.com" beginPort:8000 endPort:9000 completeHandler:^(NSString * _Nullable port, BOOL isOpen, PNError * _Nullable sdkError) { 56 | if (sdkError) { 57 | NSLog(@"正在扫描---%@",port); 58 | }else{ 59 | if (isOpen) { 60 | NSLog(@"正在扫描---%@ ,已打开",port); 61 | }else{ 62 | NSLog(@"正在扫描---%@",port); 63 | } 64 | } 65 | }]; 66 | } 67 | 68 | - (void)testPerformanceExample { 69 | // This is an example of a performance test case. 70 | [self measureBlock:^{ 71 | // Put the code you want to measure the time of here. 72 | }]; 73 | } 74 | 75 | @end 76 | -------------------------------------------------------------------------------- /PhoneNetSDK/PhoneNetSDK/uping/model/PPingResModel.m: -------------------------------------------------------------------------------- 1 | // 2 | // UPingResModel.m 3 | // PingDemo 4 | // 5 | // Created by mediaios on 31/07/2018. 6 | // Copyright © 2018 mediaios. All rights reserved. 7 | // 8 | 9 | #import "PPingResModel.h" 10 | 11 | @implementation PPingResModel 12 | 13 | - (NSString *)description { 14 | return [NSString stringWithFormat:@"ICMPSequence:%d , originalAddress:%@ , IPAddress:%@ , dateBytesLength:%d , timeMilliseconds:%.3fms , timeToLive:%d , tracertCount:%d , status:%d",(int)_ICMPSequence,_originalAddress,_IPAddress,(int)_dateBytesLength,_timeMilliseconds,(int)_timeToLive,(int)_tracertCount,(int)_status]; 15 | } 16 | 17 | + (NSDictionary *)pingResultWithPingItems:(NSArray *)pingItems 18 | { 19 | 20 | NSString *address = [pingItems.firstObject originalAddress]; 21 | NSString *dst = [pingItems.firstObject IPAddress]; 22 | __block NSInteger receivedCount = 0, allCount = 0; 23 | __block NSInteger ttlSum = 0; 24 | __block double timeSum = 0; 25 | [pingItems enumerateObjectsUsingBlock:^(PPingResModel *obj, NSUInteger idx, BOOL *stop) { 26 | if (obj.status != PhoneNetPingStatusFinished && obj.status != PhoneNetPingStatusError) { 27 | allCount ++; 28 | if (obj.status == PhoneNetPingStatusDidReceivePacket) { 29 | receivedCount ++; 30 | ttlSum += obj.timeToLive; 31 | timeSum += obj.timeMilliseconds; 32 | } 33 | } 34 | }]; 35 | 36 | float lossPercent = (allCount - receivedCount) / MAX(1.0, allCount) * 100; 37 | double avgTime = 0; NSInteger avgTTL = 0; 38 | int allPacketCount = (int)allCount; 39 | if (receivedCount > 0) { 40 | avgTime = timeSum/receivedCount; 41 | avgTTL = ttlSum/receivedCount; 42 | }else{ 43 | avgTime = 0; 44 | avgTTL = 0; 45 | } 46 | // NSLog(@"address:%@ ,loss:%f,ttl:%ld, time:%f",address,lossPercent,avgTTL,avgTime); 47 | 48 | if (address == NULL) { 49 | address = @"null"; 50 | } 51 | 52 | NSDictionary *dict = @{@"src_ip":address,@"dst_ip":dst,@"totolPackets":[NSNumber numberWithInt:allPacketCount], @"loss":[NSNumber numberWithFloat:lossPercent],@"delay":[NSNumber numberWithDouble:avgTime],@"ttl":[NSNumber numberWithLong:avgTTL]}; 53 | return dict; 54 | 55 | return NULL; 56 | } 57 | @end 58 | -------------------------------------------------------------------------------- /PhoneNetSDK/PhoneNetSDK/public/bean/PNetModel.h: -------------------------------------------------------------------------------- 1 | // 2 | // PNetModel.h 3 | // PhoneNetSDK 4 | // 5 | // Created by mediaios on 2019/2/15. 6 | // Copyright © 2019 mediaios. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | NS_ASSUME_NONNULL_BEGIN 12 | 13 | @interface PNError : NSObject 14 | 15 | /** 16 | * 系统错误信息 17 | */ 18 | @property (nonatomic,readonly) NSError *error; 19 | 20 | 21 | /** 22 | @brief 构造错误(参数错误,内部使用) 23 | 24 | @param desc 错误信息 25 | @return 错误实例 26 | */ 27 | + (instancetype)errorWithInvalidArgument:(NSString *)desc; 28 | 29 | /** 30 | @brief 构造错误(容器中的元素非法,内部使用) 31 | 32 | @param desc 错误描述 33 | @return 错误实例 34 | */ 35 | + (instancetype)errorWithInvalidElements:(NSString *)desc; 36 | 37 | /** 38 | @brief 构造错误(调用SDK中的方法时,条件不满足。内部使用) 39 | 40 | @param desc 错误描述 41 | @return 错误实例 42 | */ 43 | + (instancetype)errorWithInvalidCondition:(NSString *)desc; 44 | 45 | /** 46 | @brief 构造错误(内部使用) 47 | 48 | @param error 系统错误实例 49 | @return 错误实例 50 | */ 51 | + (instancetype)errorWithError:(NSError *)error; 52 | @end 53 | 54 | 55 | @interface DomainLookUpRes : NSObject 56 | @property (nonatomic,copy) NSString * name; 57 | @property (nonatomic,copy) NSString * ip; 58 | 59 | + (instancetype)instanceWithName:(NSString *)name address:(NSString *)address; 60 | @end 61 | 62 | 63 | @interface PDeviceNetInfo : NSObject 64 | @property (nonatomic,readonly) NSString *netType; 65 | @property (nonatomic,readonly) NSString *wifiSSID; 66 | @property (nonatomic,readonly) NSString *wifiBSSID; 67 | @property (nonatomic,readonly) NSString *wifiIPV4; 68 | @property (nonatomic,readonly) NSString *wifiNetmask; 69 | @property (nonatomic,readonly) NSString *wifiIPV6; 70 | @property (nonatomic,readonly) NSString *cellIPV4; 71 | 72 | + (instancetype)deviceNetInfo; 73 | @end 74 | 75 | 76 | @interface PIpInfoModel : NSObject 77 | @property (nonatomic,readonly) NSString *ip; 78 | @property (nonatomic,readonly) NSString *city; 79 | @property (nonatomic,readonly) NSString *region; 80 | @property (nonatomic,readonly) NSString *country; 81 | @property (nonatomic,readonly) NSString *location; 82 | @property (nonatomic,readonly) NSString *org; 83 | 84 | + (instancetype)uIpInfoModelWithDict:(NSDictionary *)dict; 85 | - (NSDictionary *)objConvertToDict; 86 | @end 87 | 88 | @interface NetWorkInfo : NSObject 89 | @property (nonatomic,strong) PDeviceNetInfo *deviceNetInfo; 90 | @property (nonatomic,strong) PIpInfoModel *ipInfoModel; 91 | @end 92 | 93 | 94 | NS_ASSUME_NONNULL_END 95 | -------------------------------------------------------------------------------- /PhoneNetSDK/PhoneNetSDK/tools/PNetLog.mm: -------------------------------------------------------------------------------- 1 | // 2 | // PNetLog.m 3 | // PhoneNetSDK 4 | // 5 | // Created by mediaios on 2019/2/27. 6 | // Copyright © 2019 mediaios. All rights reserved. 7 | // 8 | 9 | #import "PNetLog.h" 10 | #import "PhoneNetSDKConst.h" 11 | #include "log4cplus_pn.h" 12 | 13 | 14 | /* define log level */ 15 | int PhoneNetSDK_IOS_FLAG_FATAL = 0x10; 16 | int PhoneNetSDK_IOS_FLAG_ERROR = 0x08; 17 | int PhoneNetSDK_IOS_FLAG_WARN = 0x04; 18 | int PhoneNetSDK_IOS_FLAG_INFO = 0x02; 19 | int PhoneNetSDK_IOS_FLAG_DEBUG = 0x01; 20 | int PhoneNetSDK_IOS_LOG_LEVEL = PhoneNetSDK_IOS_LOG_LEVEL = PhoneNetSDK_IOS_FLAG_FATAL|PhoneNetSDK_IOS_FLAG_ERROR; 21 | 22 | @implementation PNetLog 23 | 24 | + (void)setSDKLogLevel:(PhoneNetSDKLogLevel)logLevel 25 | { 26 | switch (logLevel) { 27 | case PhoneNetSDKLogLevel_FATAL: 28 | { 29 | PhoneNetSDK_IOS_LOG_LEVEL = PhoneNetSDK_IOS_FLAG_FATAL; 30 | log4cplus_fatal("PhoneNetSDK", "setting UCSDK log level ,PhoneNetSDK_IOS_FLAG_FATAL...\n"); 31 | } 32 | break; 33 | case PhoneNetSDKLogLevel_ERROR: 34 | { 35 | PhoneNetSDK_IOS_LOG_LEVEL = PhoneNetSDK_IOS_FLAG_FATAL|PhoneNetSDK_IOS_FLAG_ERROR; 36 | log4cplus_error("PhoneNetSDK", "setting UCSDK log level ,PhoneNetSDK_IOS_FLAG_ERROR...\n"); 37 | } 38 | break; 39 | case PhoneNetSDKLogLevel_WARN: 40 | { 41 | PhoneNetSDK_IOS_LOG_LEVEL = PhoneNetSDK_IOS_FLAG_FATAL|PhoneNetSDK_IOS_FLAG_ERROR|PhoneNetSDK_IOS_FLAG_WARN; 42 | log4cplus_warn("PhoneNetSDK", "setting UCSDK log level ,PhoneNetSDK_IOS_FLAG_WARN...\n"); 43 | } 44 | break; 45 | case PhoneNetSDKLogLevel_INFO: 46 | { 47 | PhoneNetSDK_IOS_LOG_LEVEL = PhoneNetSDK_IOS_FLAG_FATAL|PhoneNetSDK_IOS_FLAG_ERROR|PhoneNetSDK_IOS_FLAG_WARN|PhoneNetSDK_IOS_FLAG_INFO; 48 | log4cplus_info("PhoneNetSDK", "setting UCSDK log level ,PhoneNetSDK_IOS_FLAG_INFO...\n"); 49 | } 50 | break; 51 | case PhoneNetSDKLogLevel_DEBUG: 52 | { 53 | PhoneNetSDK_IOS_LOG_LEVEL = PhoneNetSDK_IOS_FLAG_FATAL|PhoneNetSDK_IOS_FLAG_ERROR|PhoneNetSDK_IOS_FLAG_WARN|PhoneNetSDK_IOS_FLAG_INFO|PhoneNetSDK_IOS_FLAG_DEBUG; 54 | log4cplus_debug("PhoneNetSDK", "setting UCSDK log level ,UCNetAnalysisSDKLogLevel_DEBUG...\n"); 55 | } 56 | break; 57 | 58 | default: 59 | break; 60 | } 61 | } 62 | @end 63 | -------------------------------------------------------------------------------- /PhoneNetSDK/PhoneNetSDK/lookup/PNDomainLookup.mm: -------------------------------------------------------------------------------- 1 | // 2 | // PNDomainLook.m 3 | // PhoneNetSDK 4 | // 5 | // Created by mediaios on 2019/2/28. 6 | // Copyright © 2019 mediaios. All rights reserved. 7 | // 8 | 9 | #import "PNDomainLookup.h" 10 | #import "PhoneNetSDKConst.h" 11 | #include "log4cplus_pn.h" 12 | #import "PhoneNetDiagnosisHelper.h" 13 | #import "PNetTools.h" 14 | 15 | @interface PNDomainLookup() 16 | { 17 | int socket_client; 18 | struct sockaddr_in remote_addr; 19 | } 20 | 21 | @end 22 | 23 | @implementation PNDomainLookup 24 | 25 | static PNDomainLookup *pnDomainLookup_instance = NULL; 26 | - (instancetype)init 27 | { 28 | if (self = [super init]) {} 29 | return self; 30 | } 31 | 32 | + (instancetype)shareInstance 33 | { 34 | if (pnDomainLookup_instance == NULL) { 35 | pnDomainLookup_instance = [[PNDomainLookup alloc] init]; 36 | } 37 | return pnDomainLookup_instance; 38 | } 39 | 40 | - (void)lookupDomain:(NSString * _Nonnull)domain completeHandler:(NetLookupResultHandler _Nonnull)handler; 41 | { 42 | if (![PNetTools validDomain:domain]) { 43 | log4cplus_warn("PhoneNetSDKLookup", "your setting domain invalid..\n"); 44 | handler(nil,[PNError errorWithInvalidArgument:@"domain invalid"]); 45 | return; 46 | } 47 | const char *hostaddr = [domain UTF8String]; 48 | memset(&remote_addr, 0, sizeof(remote_addr)); 49 | remote_addr.sin_addr.s_addr = inet_addr(hostaddr); 50 | 51 | if (remote_addr.sin_addr.s_addr == INADDR_NONE) { 52 | struct hostent *remoteHost = gethostbyname(hostaddr); 53 | if (remoteHost == NULL || remoteHost->h_addr == NULL) { 54 | log4cplus_warn("PhoneNetSDKLookup", "DNS parsing error...\n"); 55 | handler(nil,[PNError errorWithInvalidCondition:[NSString stringWithFormat:@"DNS Parsing failure"]]); 56 | return; 57 | } 58 | 59 | NSMutableArray *mutArray = [NSMutableArray array]; 60 | for (int i = 0; remoteHost->h_addr_list[i]; i++) { 61 | log4cplus_debug("PhoneNetSDKLookup", "IP addr %d , name: %s , addr:%s \n",i+1,remoteHost->h_name,inet_ntoa(*(struct in_addr*)remoteHost->h_addr_list[i])); 62 | [mutArray addObject:[DomainLookUpRes instanceWithName:[NSString stringWithUTF8String:remoteHost->h_name] address:[NSString stringWithUTF8String:inet_ntoa(*(struct in_addr*)remoteHost->h_addr_list[i])]]]; 63 | } 64 | handler(mutArray,nil); 65 | return; 66 | } 67 | 68 | log4cplus_warn("PhoneNetSDKLookup", "your setting domain error..\n"); 69 | handler(nil,[PNError errorWithInvalidCondition:@"domain error"]); 70 | return; 71 | } 72 | @end 73 | -------------------------------------------------------------------------------- /PhoneNetSDK/PhoneNetSDK/utracert/control/PhoneTraceRouteService.m: -------------------------------------------------------------------------------- 1 | // 2 | // PhoneTraceRouteService.m 3 | // PingDemo 4 | // 5 | // Created by mediaios on 08/08/2018. 6 | // Copyright © 2018 mediaios. All rights reserved. 7 | // 8 | 9 | #import "PhoneTraceRouteService.h" 10 | 11 | @interface PhoneTraceRouteService() 12 | @property (nonatomic,strong) PhoneTraceRoute *ucTraceroute; 13 | @property (nonatomic,copy,readonly) NetTracerouteResultHandler tracertResultHandler; 14 | @end 15 | 16 | @implementation PhoneTraceRouteService 17 | 18 | static PhoneTraceRouteService *ucTraceRouteService_instance = NULL; 19 | 20 | - (instancetype)init 21 | { 22 | self = [super init]; 23 | if (self) { 24 | 25 | } 26 | return self; 27 | } 28 | 29 | + (instancetype)shareInstance 30 | { 31 | if (ucTraceRouteService_instance == NULL) { 32 | ucTraceRouteService_instance = [[PhoneTraceRouteService alloc] init]; 33 | } 34 | return ucTraceRouteService_instance; 35 | } 36 | 37 | - (void)uStopTracert 38 | { 39 | [self.ucTraceroute stopTracert]; 40 | } 41 | 42 | - (BOOL)uIsTracert 43 | { 44 | return [self.ucTraceroute isTracert]; 45 | } 46 | 47 | - (void)startTracerouteHost:(NSString *)host resultHandler:(NetTracerouteResultHandler)handler 48 | { 49 | if (_ucTraceroute) { 50 | _ucTraceroute = nil; 51 | } 52 | _tracertResultHandler = handler; 53 | _ucTraceroute = [[PhoneTraceRoute alloc] init]; 54 | _ucTraceroute.delegate = self; 55 | [_ucTraceroute startTracerouteHost:host]; 56 | } 57 | 58 | #pragma mark -PhoneTraceRouteDelegate 59 | - (void)tracerouteWithUCTraceRoute:(PhoneTraceRoute *)ucTraceRoute tracertResult:(PTracerRouteResModel *)tracertRes 60 | { 61 | NSMutableString *tracertTimeoutRes = [NSMutableString string]; 62 | NSMutableString *mutableDurations = [NSMutableString string]; 63 | for (int i = 0; i < tracertRes.count; i++) { 64 | if (tracertRes.durations[i] <= 0) { 65 | [tracertTimeoutRes appendString:@" *"]; 66 | }else{ 67 | [mutableDurations appendString:[NSString stringWithFormat:@" %.3fms",tracertRes.durations[i] * 1000]]; 68 | } 69 | } 70 | NSMutableString *tracertDetail = [NSMutableString string]; 71 | if (tracertTimeoutRes.length > 0) { 72 | [tracertDetail appendString:[NSString stringWithFormat:@"%d %@",(int)tracertRes.hop,tracertTimeoutRes]]; 73 | _tracertResultHandler(tracertDetail,tracertRes.dstIp); 74 | return; 75 | } 76 | 77 | NSString *tracertNormalDetail = [NSString stringWithFormat:@"%d %@(%@) %@",(int)tracertRes.hop,tracertRes.ip,tracertRes.ip,mutableDurations]; 78 | [tracertDetail appendString:tracertNormalDetail]; 79 | _tracertResultHandler(tracertDetail,tracertRes.dstIp); 80 | 81 | } 82 | 83 | - (void)tracerouteFinishedWithUCTraceRoute:(PhoneTraceRoute *)ucTraceRoute 84 | { 85 | 86 | } 87 | 88 | @end 89 | -------------------------------------------------------------------------------- /PhoneNetSDK/PhoneNetSDK/portscan/PNPortScan.mm: -------------------------------------------------------------------------------- 1 | // 2 | // PNPortScan.m 3 | // PhoneNetSDK 4 | // 5 | // Created by mediaios on 2019/2/28. 6 | // Copyright © 2019 mediaios. All rights reserved. 7 | // 8 | 9 | #import "PNPortScan.h" 10 | #import "PhoneNetSDKConst.h" 11 | #include "log4cplus_pn.h" 12 | #import "PhoneNetDiagnosisHelper.h" 13 | #import "PNetQueue.h" 14 | @interface PNPortScan() 15 | { 16 | int socket_client; 17 | } 18 | 19 | @property (nonatomic,assign) BOOL isStopPortScan; 20 | 21 | @end 22 | 23 | @implementation PNPortScan 24 | static PNPortScan *pnPortScan_instance = NULL; 25 | - (instancetype)init 26 | { 27 | if (self = [super init]) { 28 | _isStopPortScan = YES; 29 | } 30 | return self; 31 | } 32 | 33 | + (instancetype)shareInstance 34 | { 35 | if (pnPortScan_instance == NULL) { 36 | pnPortScan_instance = [[PNPortScan alloc] init]; 37 | } 38 | return pnPortScan_instance; 39 | } 40 | 41 | - (void)startPortScan:(NSString *)host beginPort:(NSUInteger)beginPort endPort:(NSUInteger)endPort completeHandler:(NetPortScanHandler)handler 42 | { 43 | // 获取 IP 地址 44 | struct hostent * remoteHostEnt = gethostbyname([host UTF8String]); 45 | if (NULL == remoteHostEnt) { 46 | log4cplus_warn("PhoneNetSDKPortScan", "Unable to parse host"); 47 | handler(nil,NO,[PNError errorWithInvalidCondition:@"Unable to parse host"]); 48 | return; 49 | } 50 | struct in_addr * remoteInAddr = (struct in_addr *)remoteHostEnt->h_addr_list[0]; 51 | self.isStopPortScan = NO; 52 | NSUInteger port = beginPort; 53 | do { 54 | if (port > endPort) { 55 | break; 56 | } 57 | socket_client = socket(AF_INET, SOCK_STREAM, 0); 58 | if (-1 == socket_client) { 59 | return; 60 | } 61 | // 设置 socket 参数 62 | struct sockaddr_in socketParameters; 63 | socketParameters.sin_family = AF_INET; 64 | socketParameters.sin_addr = *remoteInAddr; 65 | socketParameters.sin_port = htons(port); 66 | int ret = connect(socket_client, (struct sockaddr *) &socketParameters, sizeof(socketParameters)); 67 | if (-1 == ret) { 68 | close(socket_client); 69 | handler([NSString stringWithFormat:@"%lu",port],NO,nil); 70 | continue; 71 | } 72 | handler([NSString stringWithFormat:@"%lu",port],YES,nil); 73 | close(socket_client); 74 | } while (!self.isStopPortScan && port++ <= endPort); 75 | 76 | self.isStopPortScan = YES; 77 | } 78 | 79 | - (void)portScan:(NSString *)host beginPort:(NSUInteger)beginPort endPort:(NSUInteger)endPort completeHandler:(NetPortScanHandler)handler 80 | { 81 | [PNetQueue pnet_async:^{ 82 | [self startPortScan:host beginPort:beginPort endPort:endPort completeHandler:handler]; 83 | }]; 84 | } 85 | 86 | - (BOOL)isDoingScanPort 87 | { 88 | return !self.isStopPortScan; 89 | } 90 | 91 | - (void)stopPortScan 92 | { 93 | self.isStopPortScan = YES; 94 | } 95 | @end 96 | -------------------------------------------------------------------------------- /PhoneNetSDK/PhoneNetSDK/public/PhoneNetManager.h: -------------------------------------------------------------------------------- 1 | // 2 | // PhoneNetManager.h 3 | // PhoneNetSDK 4 | // 5 | // Created by mediaios on 2018/10/15. 6 | // Copyright © 2018 mediaios. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "PNetModel.h" 11 | #import "PhoneNetSDKHelper.h" 12 | 13 | 14 | @interface PhoneNetManager : NSObject 15 | 16 | + (instancetype _Nonnull)shareInstance; 17 | 18 | /** 19 | @brief setting sdk log level 20 | @discussion If not set, the default log level is `PhoneNetSDKLogLevel_ERROR` 21 | @param logLevel Log level, type is an enumeration `PhoneNetSDKLogLevel` 22 | */ 23 | - (void)settingSDKLogLevel:(PhoneNetSDKLogLevel)logLevel; 24 | 25 | - (void)registPhoneNetSDK; 26 | 27 | 28 | /** 29 | @brief get SDK version 30 | @return sdk version 31 | */ 32 | - (NSString * _Nonnull)sdkVersion; 33 | 34 | #pragma mark - about ping 35 | /*! 36 | @description 37 | ping function 38 | 39 | @param host ip address or domain name 40 | @param count send ping packet count 41 | @param handler ping detail information 42 | */ 43 | - (void)netStartPing:(NSString *_Nonnull)host packetCount:(int)count pingResultHandler:(NetPingResultHandler _Nonnull)handler; 44 | 45 | 46 | /*! 47 | @description 48 | stop ping 49 | */ 50 | - (void)netStopPing; 51 | 52 | 53 | /*! 54 | @description 55 | get the ping status 56 | 57 | @return YES: now is doing ping; NO: not pinging at the moment 58 | */ 59 | - (BOOL)isDoingPing; 60 | 61 | 62 | #pragma mark - About traceroute 63 | /*! 64 | @description 65 | 66 | @param host ip address or domain name 67 | @param handler traceroute detail information 68 | */ 69 | - (void)netStartTraceroute:(NSString *_Nonnull)host tracerouteResultHandler:(NetTracerouteResultHandler _Nonnull)handler; 70 | 71 | 72 | /*! 73 | @description 74 | stop traceroute 75 | */ 76 | - (void)netStopTraceroute; 77 | 78 | 79 | /*! 80 | @description 81 | get the traceroute status 82 | 83 | @return YES: now is doing traceroute; NO: not doing traceroute at the moment 84 | */ 85 | - (BOOL)isDoingTraceroute; 86 | 87 | #pragma mark - nslookup 88 | /** 89 | @description 90 | lookup host 91 | 92 | @param domain domain 93 | @param handler nslookup results 94 | */ 95 | - (void)netLookupDomain:(NSString * _Nonnull)domain completeHandler:(NetLookupResultHandler _Nonnull)handler; 96 | 97 | #pragma mark - port scan 98 | 99 | 100 | /** 101 | @description 102 | port scan host 103 | 104 | @param host host address 105 | @param beginPort begin port 106 | @param endPort end port 107 | @param handler port scan result handler 108 | */ 109 | - (void)netPortScan:(NSString * _Nonnull)host 110 | beginPort:(NSUInteger)beginPort 111 | endPort:(NSUInteger)endPort 112 | completeHandler:(NetPortScanHandler _Nonnull)handler; 113 | 114 | 115 | /** 116 | @description is doing port scan or not 117 | 118 | @return YES: doing NO: not doing 119 | */ 120 | - (BOOL)isDoingPortScan; 121 | 122 | 123 | /** 124 | @description 125 | stop port scan 126 | */ 127 | - (void)netStopPortScan; 128 | #pragma mark -About network info 129 | - (NetWorkInfo * _Nullable)netGetNetworkInfo; 130 | 131 | @end 132 | -------------------------------------------------------------------------------- /PhoneNetSDK/PhoneNetSDK/common/PhoneNetDiagnosisHelper.h: -------------------------------------------------------------------------------- 1 | // 2 | // PhoneNetDiagnosisHelper.h 3 | // PingDemo 4 | // 5 | // Created by mediaios on 08/08/2018. 6 | // Copyright © 2018 mediaios. All rights reserved. 7 | // 8 | 9 | #import 10 | #include 11 | #import 12 | #import 13 | #import 14 | #import 15 | #import 16 | 17 | #import 18 | #import 19 | 20 | 21 | #define kPhoneNetPingTimeout 500 // 500 millisecond 22 | #define kPhoneNetPingPackets 5 23 | 24 | 25 | 26 | typedef struct PNetIPHeader { 27 | uint8_t versionAndHeaderLength; 28 | uint8_t differentiatedServices; 29 | uint16_t totalLength; 30 | uint16_t identification; 31 | uint16_t flagsAndFragmentOffset; 32 | uint8_t timeToLive; 33 | uint8_t protocol; 34 | uint16_t headerChecksum; 35 | uint8_t sourceAddress[4]; 36 | uint8_t destinationAddress[4]; 37 | // options... 38 | // data... 39 | }PNetIPHeader; 40 | 41 | __Check_Compile_Time(sizeof(PNetIPHeader) == 20); 42 | __Check_Compile_Time(offsetof(PNetIPHeader, versionAndHeaderLength) == 0); 43 | __Check_Compile_Time(offsetof(PNetIPHeader, differentiatedServices) == 1); 44 | __Check_Compile_Time(offsetof(PNetIPHeader, totalLength) == 2); 45 | __Check_Compile_Time(offsetof(PNetIPHeader, identification) == 4); 46 | __Check_Compile_Time(offsetof(PNetIPHeader, flagsAndFragmentOffset) == 6); 47 | __Check_Compile_Time(offsetof(PNetIPHeader, timeToLive) == 8); 48 | __Check_Compile_Time(offsetof(PNetIPHeader, protocol) == 9); 49 | __Check_Compile_Time(offsetof(PNetIPHeader, headerChecksum) == 10); 50 | __Check_Compile_Time(offsetof(PNetIPHeader, sourceAddress) == 12); 51 | __Check_Compile_Time(offsetof(PNetIPHeader, destinationAddress) == 16); 52 | 53 | /* 54 | use linux style . totals 64B 55 | */ 56 | typedef struct UICMPPacket 57 | { 58 | uint8_t type; 59 | uint8_t code; 60 | uint16_t checksum; 61 | uint16_t identifier; 62 | uint16_t seq; 63 | char fills[56]; // data 64 | }UICMPPacket; 65 | 66 | typedef enum ENU_U_ICMPType 67 | { 68 | ENU_U_ICMPType_EchoReplay = 0, 69 | ENU_U_ICMPType_EchoRequest = 8, 70 | ENU_U_ICMPType_TimeOut = 11 71 | }ENU_U_ICMPType; 72 | 73 | __Check_Compile_Time(sizeof(UICMPPacket) == 64); 74 | //__Check_Compile_Time(sizeof(UICMPPacket) == 8); 75 | __Check_Compile_Time(offsetof(UICMPPacket, type) == 0); 76 | __Check_Compile_Time(offsetof(UICMPPacket, code) == 1); 77 | __Check_Compile_Time(offsetof(UICMPPacket, checksum) == 2); 78 | __Check_Compile_Time(offsetof(UICMPPacket, identifier) == 4); 79 | __Check_Compile_Time(offsetof(UICMPPacket, seq) == 6); 80 | 81 | 82 | 83 | typedef struct PICMPPacket_Tracert 84 | { 85 | uint8_t type; 86 | uint8_t code; 87 | uint16_t checksum; 88 | uint16_t identifier; 89 | uint16_t seq; 90 | }PICMPPacket_Tracert; 91 | 92 | __Check_Compile_Time(sizeof(PICMPPacket_Tracert) == 8); 93 | __Check_Compile_Time(offsetof(PICMPPacket_Tracert, type) == 0); 94 | __Check_Compile_Time(offsetof(PICMPPacket_Tracert, code) == 1); 95 | __Check_Compile_Time(offsetof(PICMPPacket_Tracert, checksum) == 2); 96 | __Check_Compile_Time(offsetof(PICMPPacket_Tracert, identifier) == 4); 97 | __Check_Compile_Time(offsetof(PICMPPacket_Tracert, seq) == 6); 98 | 99 | @interface PhoneNetDiagnosisHelper : NSObject 100 | 101 | + (uint16_t) in_cksumWithBuffer:(const void *)buffer andSize:(size_t)bufferLen; 102 | + (BOOL)isValidPingResponseWithBuffer:(char *)buffer len:(int)len seq:(int)seq identifier:(int)identifier; 103 | + (BOOL)isValidPingResponseWithBuffer:(char *)buffer len:(int)len; 104 | + (char *)icmpInpacket:(char *)packet andLen:(int)len; 105 | + (UICMPPacket *)constructPacketWithSeq:(uint16_t)seq andIdentifier:(uint16_t)identifier; 106 | 107 | 108 | + (NSArray *)resolveHost:(NSString *)hostname; 109 | + (struct sockaddr *)createSockaddrWithAddress:(NSString *)address; 110 | + (BOOL)isTimeoutPacket:(char *)packet len:(int)len; 111 | + (BOOL)isEchoReplayPacket:(char *)packet len:(int)len; 112 | + (PICMPPacket_Tracert *)constructTracertICMPPacketWithSeq:(uint16_t)seq andIdentifier:(uint16_t)identifier; 113 | @end 114 | -------------------------------------------------------------------------------- /PhoneNetSDK/PhoneNetSDK/uping/control/PhonePingService.mm: -------------------------------------------------------------------------------- 1 | // 2 | // UCPingService.m 3 | // PingDemo 4 | // 5 | // Created by mediaios on 06/08/2018. 6 | // Copyright © 2018 mediaios. All rights reserved. 7 | // 8 | 9 | #import "PhonePingService.h" 10 | #import "PhoneNetSDKConst.h" 11 | #include "log4cplus_pn.h" 12 | 13 | 14 | @interface PhonePingService() 15 | @property (nonatomic,strong) PhonePing *uPing; 16 | @property (nonatomic,strong) NSMutableDictionary *pingResDic; 17 | @property (nonatomic,copy,readonly) NetPingResultHandler pingResultHandler; 18 | 19 | @end 20 | 21 | @implementation PhonePingService 22 | 23 | static PhonePingService *ucPingservice_instance = NULL; 24 | 25 | - (instancetype)init 26 | { 27 | self = [super init]; 28 | if (self) { 29 | 30 | } 31 | return self; 32 | } 33 | 34 | - (NSMutableDictionary *)pingResDic 35 | { 36 | if (!_pingResDic) { 37 | _pingResDic = [NSMutableDictionary dictionary]; 38 | } 39 | return _pingResDic; 40 | } 41 | 42 | + (instancetype)shareInstance 43 | { 44 | if (ucPingservice_instance == NULL) { 45 | ucPingservice_instance = [[PhonePingService alloc] init]; 46 | } 47 | return ucPingservice_instance; 48 | } 49 | 50 | - (void)uStopPing 51 | { 52 | [self.uPing stopPing]; 53 | } 54 | 55 | - (BOOL)uIsPing 56 | { 57 | return [self.uPing isPing]; 58 | } 59 | 60 | - (void)addPingResToPingResContainer:(PPingResModel *)pingItem andHost:(NSString *)host 61 | { 62 | if (host == NULL || pingItem == NULL) { 63 | return; 64 | } 65 | 66 | NSMutableArray *pingItems = [self.pingResDic objectForKey:host]; 67 | if (pingItems == NULL) { 68 | pingItems = [NSMutableArray arrayWithArray:@[pingItem]]; 69 | }else{ 70 | 71 | try { 72 | [pingItems addObject:pingItem]; 73 | } catch (NSException *exception) { 74 | log4cplus_warn("PhoneNetPing", "func: %s, exception info: %s , line: %d",__func__,[exception.description UTF8String],__LINE__); 75 | } 76 | } 77 | 78 | [self.pingResDic setObject:pingItems forKey:host]; 79 | // NSLog(@"%@",self.pingResDic); 80 | 81 | if (pingItem.status == PhoneNetPingStatusFinished) { 82 | NSArray *pingItems = [self.pingResDic objectForKey:host]; 83 | NSDictionary *dict = [PPingResModel pingResultWithPingItems:pingItems]; 84 | // NSLog(@"dict----res:%@, pingRes:%@",dict,self.pingResDic); 85 | PReportPingModel *reportPingModel = [PReportPingModel uReporterPingmodelWithDict:dict]; 86 | 87 | NSString *pingSummary = [NSString stringWithFormat:@"%d packets transmitted , loss:%d , delay:%0.3fms , ttl:%d",reportPingModel.totolPackets,reportPingModel.loss,reportPingModel.delay,reportPingModel.ttl]; 88 | self.pingResultHandler(pingSummary); 89 | 90 | [self removePingResFromPingResContainerWithHostName:host]; 91 | } 92 | } 93 | 94 | - (void)removePingResFromPingResContainerWithHostName:(NSString *)host 95 | { 96 | if (host == NULL) { 97 | return; 98 | } 99 | [self.pingResDic removeObjectForKey:host]; 100 | } 101 | 102 | - (void)startPingHost:(NSString *)host packetCount:(int)count resultHandler:(NetPingResultHandler)handler 103 | { 104 | if (_uPing) { 105 | _uPing = nil; 106 | _uPing = [[PhonePing alloc] init]; 107 | 108 | }else{ 109 | _uPing = [[PhonePing alloc] init]; 110 | } 111 | _pingResultHandler = handler; 112 | _uPing.delegate = self; 113 | [_uPing startPingHosts:host packetCount:count]; 114 | 115 | } 116 | 117 | #pragma mark-UCPingDelegate 118 | - (void)pingResultWithUCPing:(PhonePing *)ucPing pingResult:(PPingResModel *)pingRes pingStatus:(PhoneNetPingStatus)status 119 | { 120 | 121 | [self addPingResToPingResContainer:pingRes andHost:pingRes.IPAddress]; 122 | 123 | if (status == PhoneNetPingStatusFinished) { 124 | return; 125 | } 126 | 127 | NSString *pingDetail = [NSString stringWithFormat:@"%d bytes form %@: icmp_seq=%d ttl=%d time=%.3fms",(int)pingRes.dateBytesLength,pingRes.IPAddress,(int)pingRes.ICMPSequence,(int)pingRes.timeToLive,pingRes.timeMilliseconds]; 128 | _pingResultHandler(pingDetail); 129 | } 130 | 131 | 132 | @end 133 | -------------------------------------------------------------------------------- /PhoneNetSDK/PhoneNetSDK/public/bean/PNetModel.m: -------------------------------------------------------------------------------- 1 | // 2 | // PNetModel.m 3 | // PhoneNetSDK 4 | // 5 | // Created by mediaios on 2019/2/15. 6 | // Copyright © 2019 mediaios. All rights reserved. 7 | // 8 | 9 | #import "PNetModel.h" 10 | #import "PNetInfoTool.h" 11 | 12 | 13 | static NSString *domain = @"mediaios.sdk"; 14 | static const int KPNInvalidArguments = -2; 15 | static const int KPNInvalidElements = -3; 16 | static const int KPNInvalidCondition = -4; 17 | 18 | @implementation PNError 19 | 20 | - (instancetype)initWithSysError:(NSError *)error 21 | { 22 | if (self = [super init]) { 23 | _error = error; 24 | } 25 | return self; 26 | } 27 | 28 | + (instancetype)errorWithInvalidArgument:(NSString *)desc 29 | { 30 | NSError *error = [[NSError alloc] initWithDomain:domain code:KPNInvalidArguments userInfo:@{@"error":desc}]; 31 | return [[self alloc] initWithSysError:error]; 32 | } 33 | 34 | + (instancetype)errorWithInvalidElements:(NSString *)desc 35 | { 36 | NSError *error = [[NSError alloc] initWithDomain:domain code:KPNInvalidElements userInfo:@{@"error":desc}]; 37 | return [[self alloc] initWithSysError:error]; 38 | } 39 | 40 | + (instancetype)errorWithInvalidCondition:(NSString *)desc 41 | { 42 | NSError *error = [[NSError alloc] initWithDomain:domain code:KPNInvalidCondition userInfo:@{@"error":desc}]; 43 | return [[self alloc] initWithSysError:error]; 44 | } 45 | 46 | + (instancetype)errorWithError:(NSError *)error 47 | { 48 | return [[self alloc] initWithSysError:error]; 49 | } 50 | 51 | @end 52 | 53 | 54 | @implementation DomainLookUpRes 55 | 56 | - (instancetype)initWithName:(NSString *)name address:(NSString *)address 57 | { 58 | if (self = [super init]) { 59 | _name = name; 60 | _ip = address; 61 | } 62 | return self; 63 | } 64 | 65 | + (instancetype)instanceWithName:(NSString *)name address:(NSString *)address 66 | { 67 | return [[self alloc] initWithName:name address:address]; 68 | } 69 | 70 | @end 71 | 72 | 73 | @implementation PDeviceNetInfo 74 | 75 | - (instancetype)init 76 | { 77 | if (self = [super init]) { 78 | PNetInfoTool *phoneNetTool = [PNetInfoTool shareInstance]; 79 | [phoneNetTool refreshNetInfo]; 80 | _netType = [phoneNetTool pGetNetworkType]; 81 | _wifiSSID = [phoneNetTool pGetSSID]; 82 | _wifiBSSID = [phoneNetTool pGetBSSID]; 83 | _wifiIPV4 = [phoneNetTool pGetWifiIpv4]; 84 | _wifiIPV6 = [phoneNetTool pGetWifiIpv6]; 85 | _wifiNetmask = [phoneNetTool pGetSubNetMask]; 86 | _cellIPV4 = [phoneNetTool pGetCellIpv4]; 87 | } 88 | return self; 89 | } 90 | 91 | + (instancetype)deviceNetInfo 92 | { 93 | return [[self alloc] init]; 94 | } 95 | 96 | - (NSString *)description 97 | { 98 | return [NSString stringWithFormat:@"netType:%@ , wifiSSID:%@ , wifiBSSID:%@, wifiIPV4:%@, wifiIPV6:%@, wifiNetmask:%@, cellIPV4:%@",self.netType,self.wifiSSID,self.wifiBSSID,self.wifiIPV4,self.wifiIPV6,self.wifiNetmask,self.cellIPV4]; 99 | } 100 | 101 | @end 102 | 103 | 104 | @implementation PIpInfoModel 105 | 106 | - (instancetype)initWithDict:(NSDictionary *)dict 107 | { 108 | if (self = [super init]) { 109 | if (dict[@"ip"]) { 110 | _ip = dict[@"ip"]; 111 | } 112 | if (dict[@"city"]) { 113 | _city = dict[@"city"]; 114 | } 115 | if (dict[@"region"]) { 116 | _region = dict[@"region"]; 117 | } 118 | if (dict[@"country"]) { 119 | _country = dict[@"country"]; 120 | } 121 | if (dict[@"loc"]) { 122 | _location = dict[@"loc"]; 123 | } 124 | if (dict[@"org"]) { 125 | _org = dict[@"org"]; 126 | } 127 | 128 | } 129 | return self; 130 | } 131 | 132 | + (instancetype)uIpInfoModelWithDict:(NSDictionary *)dict 133 | { 134 | return [[self alloc] initWithDict:dict]; 135 | } 136 | 137 | - (NSDictionary *)objConvertToDict 138 | { 139 | return @{@"ip":self.ip,@"city":self.city,@"region":self.region,@"country":self.country,@"location":self.location,@"org":self.org}; 140 | } 141 | 142 | - (NSString *)description 143 | { 144 | return [NSString stringWithFormat:@"ip:%@ , city:%@ , region:%@ , country:%@ , location:%@ , org:%@",self.ip,self.city,self.region,self.country,self.location,self.org]; 145 | } 146 | @end 147 | 148 | @implementation NetWorkInfo 149 | 150 | @end 151 | 152 | -------------------------------------------------------------------------------- /PhoneNetSDK/PhoneNetSDK/lanscan/PNSamplePing.mm: -------------------------------------------------------------------------------- 1 | // 2 | // PNSamplePing.h 3 | // PhoneNetSDK 4 | // 5 | // Created by mediaios on 2019/6/5. 6 | // Copyright © 2019年 mediaios. All rights reserved. 7 | // 8 | 9 | #import "PNSamplePing.h" 10 | #import "PhoneNetSDKConst.h" 11 | #include "log4cplus_pn.h" 12 | #import "PNetQueue.h" 13 | 14 | 15 | @interface PNSamplePing() 16 | { 17 | int lan_scan_socket_client; 18 | struct sockaddr_in lan_scan_remote_addr; 19 | } 20 | 21 | @property (nonatomic,assign) BOOL isStopPingThread; 22 | @property (nonatomic,strong) NSString *scanIp; 23 | @property (nonatomic,assign) int sendPacketCount; 24 | @end 25 | 26 | @implementation PNSamplePing 27 | 28 | - (instancetype)init 29 | { 30 | if ([super init]) { 31 | 32 | _isStopPingThread = NO; 33 | } 34 | return self; 35 | } 36 | 37 | - (void)stopPing 38 | { 39 | self.isStopPingThread = YES; 40 | shutdown(lan_scan_socket_client, SHUT_RDWR); 41 | close(lan_scan_socket_client); 42 | [self.delegate simplePing:self finished:self.scanIp]; 43 | log4cplus_debug("PhoneNetSDK-LanScanner", "scan ip %s end...",[self.scanIp UTF8String]); 44 | } 45 | 46 | - (BOOL)isPing 47 | { 48 | return !self.isStopPingThread; 49 | } 50 | 51 | - (BOOL)settingUHostSocketAddressWithIp:(NSString *)host 52 | { 53 | const char *hostaddr = [host UTF8String]; 54 | memset(&lan_scan_remote_addr, 0, sizeof(lan_scan_remote_addr)); 55 | lan_scan_remote_addr.sin_addr.s_addr = inet_addr(hostaddr); 56 | struct timeval timeout; 57 | timeout.tv_sec = 0; 58 | timeout.tv_usec = 1000*200; 59 | lan_scan_socket_client = socket(AF_INET,SOCK_DGRAM,IPPROTO_ICMP); 60 | int nZero=0; 61 | setsockopt(lan_scan_socket_client,SOL_SOCKET,SO_SNDBUF,(char *)&nZero,sizeof(nZero)); 62 | int res = setsockopt(lan_scan_socket_client, SOL_SOCKET, SO_RCVTIMEO, &timeout, sizeof(timeout)); 63 | if (res < 0) { 64 | log4cplus_warn("PhoneNetSimplePing", "ping %s , set timeout error..\n",[host UTF8String]); 65 | return YES; 66 | } 67 | lan_scan_remote_addr.sin_family = AF_INET; 68 | 69 | return YES; 70 | } 71 | 72 | - (void)startPingIp:(NSString *)ip packetCount:(int)count 73 | { 74 | log4cplus_debug("PhoneNetSDK-LanScanner", "scan ip %s begin...",[ip UTF8String]); 75 | if ([self settingUHostSocketAddressWithIp:ip]) { 76 | self.scanIp = ip; 77 | } 78 | 79 | if (self.scanIp == NULL) { 80 | self.isStopPingThread = YES; 81 | log4cplus_warn("PhoneNetSDK-LanScanner", "There is no valid ip...\n"); 82 | return; 83 | } 84 | 85 | if (count > 0) { 86 | _sendPacketCount = count; 87 | } 88 | [PNetQueue pnet_quick_ping_async:^{ 89 | [self sendAndrecevPingPacket]; 90 | }]; 91 | } 92 | 93 | - (void)sendAndrecevPingPacket 94 | { 95 | int index = 0; 96 | do { 97 | if (self.isStopPingThread) { 98 | return; 99 | } 100 | uint16_t identifier = (uint16_t)(KPingIcmpIdBeginNum + index); 101 | UICMPPacket *packet = [PhoneNetDiagnosisHelper constructPacketWithSeq:index andIdentifier:identifier]; 102 | ssize_t sent = sendto(lan_scan_socket_client, packet, sizeof(UICMPPacket), 0, (struct sockaddr *)&lan_scan_remote_addr, (socklen_t)sizeof(struct sockaddr)); 103 | if (sent < 0) { 104 | log4cplus_warn("PhoneNetSDK-LanScanner", "ping %s , error code:%d, send icmp packet error..\n",[self.scanIp UTF8String],(int)sent); 105 | [self stopPing]; 106 | break; 107 | } 108 | 109 | BOOL res = NO; 110 | struct sockaddr_storage ret_addr; 111 | socklen_t addrLen = sizeof(ret_addr); 112 | void *buffer = malloc(65535); 113 | 114 | size_t bytesRead = recvfrom(lan_scan_socket_client, buffer, 65535, 0, (struct sockaddr *)&ret_addr, &addrLen); 115 | 116 | if ((int)bytesRead < 0) { 117 | [self.delegate simplePing:self didTimeOut:self.scanIp]; 118 | res = YES; 119 | }else if(bytesRead == 0){ 120 | log4cplus_warn("PhoneNetSDK-LanScanner", "ping %s , receive icmp packet error , bytesRead=0",[self.scanIp UTF8String]); 121 | }else{ 122 | 123 | if ([PhoneNetDiagnosisHelper isValidPingResponseWithBuffer:(char *)buffer len:(int)bytesRead]) { 124 | [self.delegate simplePing:self receivedPacket:self.scanIp]; 125 | [self stopPing]; 126 | break; 127 | } 128 | } 129 | 130 | if (res) { 131 | index++; 132 | } 133 | usleep(1000); 134 | } while (!self.isStopPingThread && index < _sendPacketCount); 135 | 136 | if (index == _sendPacketCount) { 137 | [self stopPing]; 138 | } 139 | 140 | } 141 | @end 142 | -------------------------------------------------------------------------------- /README_CN.md: -------------------------------------------------------------------------------- 1 | # iOS网络诊断SDK 2 | 3 | ## [README of English](https://github.com/mediaios/net-diagnosis) 4 | 5 | ## 介绍 6 | 7 | 通过集成“iOS网络诊断sdk”,您可以轻松地在iOS上实现ping / traceroute /移动公共网络信息/端口扫描等网络诊断相关的功能。 8 | 9 | 利用该sdk开发的网络诊断app截图: 10 | 11 |
12 | 图片说明图片说明 图片说明 13 |
14 | 15 |
16 | 图片说明图片说明 图片说明 17 |
18 | 19 |
20 | 图片说明图片说明图片说明 21 |
22 | 23 | * [在App Store中下载 UNetState](https://apps.apple.com/us/app/unetstate/id1489314289?l=zh&ls=1) 24 | * 欢迎 star & fork 25 | 26 | ## 环境要求 27 | 28 | * iOS >= 9.0 29 | * Xcode >= 7.0 30 | * 设置 `Enable Bitcode` 为 `NO` 31 | 32 | ## 安装使用 33 | 34 | ### 通过pod方式 35 | 36 | 在你工程的`Podfile`中添加以下依赖: 37 | 38 | ``` 39 | pod 'PhoneNetSDK' 40 | ``` 41 | 42 | ### 快速开始 43 | 44 | 首先需要在你的项目中导入`SDK`头文件: 45 | 46 | ``` 47 | #import 48 | ``` 49 | 50 | 另外,你需要将`-lc++`,`-ObjC`,`$(inherited)`添加到项目的`Build Setting`->`other links flags`中。 如下所示: 51 | 52 | ![](https://ws2.sinaimg.cn/large/006tKfTcly1g0l5g4kt38j30og0e7q45.jpg) 53 | 54 | ### ping 55 | 56 | ``` 57 | [[PhoneNetManager shareInstance] netStartPing:@"www.baidu.com" packetCount:10 pingResultHandler:^(NSString * _Nullable pingres) { 58 | // your processing logic 59 | }]; 60 | ``` 61 | 62 | ### TCP ping 63 | 64 | ``` 65 | _tcpPing = [PNTcpPing start:hostDomain port:portNum.integerValue count:3 complete:^(NSMutableString *pingres) { 66 | // your processing logic 67 | }]; 68 | ``` 69 | 70 | ### UDP traceroute 71 | 72 | 73 | 在命令行中默认的traceroute命令发的是UDP的包(简称 udp traceroute): 74 | 75 | ``` 76 | _udpTraceroute = [PNUdpTraceroute start:ip complete:^(NSMutableString *res) { 77 | // your processinig logic 78 | }]; 79 | ``` 80 | 81 | ### ICMP traceroute 82 | 83 | 在mac的terminal中,输入`traceroute -I baidu.com` 就是采用ICMP协议的方式做traceroute. sdk中提供了这种功能: 84 | 85 | ``` 86 | [[PhoneNetManager shareInstance] netStartTraceroute:@"www.baidu.com" tracerouteResultHandler:^(NSString * _Nullable tracertRes, NSString * _Nullable destIp) { 87 | // your processing logic 88 | }]; 89 | ``` 90 | 91 | 92 | ### 根据域名查ip(nslookup) 93 | 94 | ``` 95 | [[PhoneNetManager shareInstance] netLookupDomain:@"www.google.com" completeHandler:^(NSMutableArray * _Nullable lookupRes, PNError * _Nullable sdkError) { 96 | // your processing logic 97 | }]; 98 | ``` 99 | 100 | ### 端口扫描 101 | 102 | ``` 103 | [[PhoneNetManager shareInstance] netPortScan:@"www.baidu.com" beginPort:8000 endPort:9000 completeHandler:^(NSString * _Nullable port, BOOL isOpen, PNError * _Nullable sdkError) { 104 | // your processing logic 105 | }]; 106 | ``` 107 | 108 | ### 局域网ip扫描 109 | 110 | 如果你要做局域网活跃ip扫描功能的话,那么利用该SDK你可以很快的监听到每个活跃的ip,并且SDK还会返回给你扫描进度。 111 | 112 | 具体步骤如下: 113 | 114 | 1. 创建对象并设置代理`PNetMLanScannerDelegate` 115 | 2. 启动扫描,并通过其代理方法处理活跃的ip 116 | 3. 监听扫描进度(可选) 117 | 118 | ``` 119 | PNetMLanScanner *lanScanner = [PNetMLanScanner shareInstance]; 120 | lanScanner.delegate = self; 121 | [lanScanner scan]; 122 | ``` 123 | 124 | ### 其它功能 125 | 126 | * 设置SDK的日志级别 127 | * 获取设备的公网ip信息 128 | * 随着版本的迭代,会提供更多高级功能 129 | 130 | 131 | ## NetPinger-Example 132 | 133 | ios平台网络诊断APP(使用的是该SDK),支持对ip和域名的ping,traceroute(udp,icmp协议),支持tcp ping, 端口扫描,nslookup等功能。 134 | 135 | 直接进入到`Podfile`文件所在目录安装该SDK即可成功运行。 136 | 137 | ``` 138 | macdeiMac:NetPinger ethan$ pod install 139 | Analyzing dependencies 140 | Downloading dependencies 141 | Installing PhoneNetSDK (1.0.7) 142 | Generating Pods project 143 | Integrating client project 144 | 145 | [!] Please close any current Xcode sessions and use `NetPinger.xcworkspace` for this project from now on. 146 | Sending stats 147 | Pod installation complete! There is 1 dependency from the Podfile and 1 total pod installed. 148 | ``` 149 | 150 | 151 | ### 项目由来 152 | 153 | 在开发中,经常会遇到接口出问题(DNS解析出错等)所以需要检测手机终端到服务端的网络是不是通,所以就需要在手机中断`ping`一下,但是市场上的免费的网络检测工具大都有弹出广告影响体验(eg:iNetTools),所以有必要自己开发一款网络剧检测app。 154 | 155 | ### 实现 156 | 157 | 所有的功能都是利用该SDK提供的功能实现的,页面和图标主要是模仿MAC上的`NetWork Utility`,希望对你的应用提供有价值的参考。 158 | 159 | 160 | ## 联系我们 161 | 162 | * 如果你有任何问题或需求,请提交[issue](https://github.com/mediaios/net-diagnosis/issues) 163 | * 如果你要提交代码,欢迎提交 pull request 164 | * 欢迎 `star` & `fork` 165 | -------------------------------------------------------------------------------- /PhoneNetSDK/PhoneNetSDK/lanscan/PNetMLanScanner.mm: -------------------------------------------------------------------------------- 1 | // 2 | // PNetMLanScanner.m 3 | // PhoneNetSDK 4 | // 5 | // Created by mediaios on 2019/6/5. 6 | // Copyright © 2019年 mediaios. All rights reserved. 7 | // 8 | 9 | #import "PNetMLanScanner.h" 10 | #import "PReportPingModel.h" 11 | #import "PNetInfoTool.h" 12 | #import "PNetModel.h" 13 | #import "PNetworkCalculator.h" 14 | #import "PNSamplePing.h" 15 | #import "PhoneNetSDKConst.h" 16 | #include "log4cplus_pn.h" 17 | 18 | @interface PNetMLanScanner() 19 | @property (nonatomic,assign) int cursor; 20 | @property (nonatomic,copy) NSArray *ipList; 21 | @property (nonatomic,strong) NSMutableArray *activedIps; 22 | @property (nonatomic,strong) PNSamplePing *samplePing; 23 | @property (nonatomic,assign,getter=isStopLanScan) BOOL stopLanScan; 24 | @end 25 | 26 | @implementation PNetMLanScanner 27 | 28 | 29 | - (NSMutableArray *)activedIps 30 | { 31 | if (!_activedIps) { 32 | _activedIps = [NSMutableArray array]; 33 | } 34 | return _activedIps; 35 | } 36 | 37 | - (PNSamplePing *)samplePing 38 | { 39 | if (!_samplePing) { 40 | _samplePing = [[PNSamplePing alloc] init]; 41 | _samplePing.delegate = self; 42 | } 43 | return _samplePing; 44 | } 45 | 46 | - (BOOL)isScanning 47 | { 48 | return !(self.isStopLanScan); 49 | } 50 | 51 | - (instancetype)init 52 | { 53 | if (self = [super init]) { 54 | _cursor = 0; 55 | [self addObserver:self forKeyPath:@"cursor" options:NSKeyValueObservingOptionNew context:NULL]; 56 | } 57 | return self; 58 | } 59 | 60 | 61 | static PNetMLanScanner *lanScanner_instance = nil; 62 | + (instancetype)shareInstance 63 | { 64 | if (!lanScanner_instance) { 65 | lanScanner_instance = [[PNetMLanScanner alloc] init]; 66 | } 67 | return lanScanner_instance; 68 | } 69 | 70 | - (void)scan 71 | { 72 | _stopLanScan = NO; 73 | PNetInfoTool *phoneNetTool = [PNetInfoTool shareInstance]; 74 | [phoneNetTool refreshNetInfo]; 75 | if ([phoneNetTool.pGetNetworkType isEqualToString:@"WIFI"]) { 76 | PDeviceNetInfo *device = [PDeviceNetInfo deviceNetInfo]; 77 | 78 | NSString *ip = device.wifiIPV4; 79 | NSString *netMask = device.wifiNetmask; 80 | if (ip && netMask) { 81 | log4cplus_debug("PhoneNetSDK-LanScanner", "now device ip :%s , netMask:%s \n",[ip UTF8String],[netMask UTF8String]); 82 | _ipList = [PNetworkCalculator getAllHostsForIP:ip andSubnet:netMask]; 83 | if (!_ipList && _ipList.count <= 0) { 84 | log4cplus_error("PhoneNetSDK-LanScanner", "caculating the ip list in the current LAN failed...\n"); 85 | return; 86 | } 87 | log4cplus_debug("PhoneNetSDK-LanScanner", "scan ip %s begin...",[self.ipList[self.cursor] UTF8String]); 88 | [self.samplePing startPingIp:self.ipList[self.cursor] packetCount:3]; 89 | self.cursor++; 90 | } 91 | } 92 | } 93 | 94 | - (void)stop 95 | { 96 | _stopLanScan = YES; 97 | if ([_samplePing isPing]) { 98 | [_samplePing stopPing]; 99 | _activedIps = nil; 100 | _ipList = nil; 101 | _cursor = 0; 102 | } 103 | 104 | } 105 | 106 | #pragma mark - PNSamplePingDelegate 107 | - (void)simplePing:(PNSamplePing *)samplePing didTimeOut:(NSString *)ip 108 | { 109 | 110 | } 111 | 112 | - (void)simplePing:(PNSamplePing *)samplePing receivedPacket:(NSString *)ip 113 | { 114 | log4cplus_debug("PhoneNetSDK-LanScanner", " %s active",[ip UTF8String]); 115 | [self.delegate scanMLan:self activeIp:ip]; 116 | } 117 | 118 | - (void)simplePing:(PNSamplePing *)samplePing pingError:(NSException *)exception 119 | { 120 | 121 | } 122 | 123 | - (void)simplePing:(PNSamplePing *)samplePing finished:(NSString *)ip 124 | { 125 | if (self.isStopLanScan) { 126 | _samplePing = nil; 127 | return; 128 | } 129 | _samplePing = nil; 130 | _samplePing = [[PNSamplePing alloc] init]; 131 | _samplePing.delegate = self; 132 | if (self.cursor < self.ipList.count) { 133 | [_samplePing startPingIp:self.ipList[self.cursor] packetCount:2]; 134 | } 135 | self.cursor++; 136 | } 137 | 138 | - (void)resetPropertys 139 | { 140 | _cursor = 0; 141 | _ipList = nil; 142 | _activedIps = nil; 143 | log4cplus_debug("PhoneNetSDK-LanScanner", "reseter propertys...\n"); 144 | } 145 | 146 | #pragma mark - use KVO to observer progress 147 | - (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context 148 | { 149 | float newCursor = [[change objectForKey:@"new"] floatValue]; 150 | if ([keyPath isEqualToString:@"cursor"]) { 151 | float percent = self.ipList.count == 0 ? 0.0f : ((float)newCursor/self.ipList.count); 152 | [self.delegate scanMlan:self percent:percent]; 153 | log4cplus_debug("PhoneNetSDK-LanScanner", "percent: %f \n",percent); 154 | if (newCursor == self.ipList.count) { 155 | _stopLanScan = YES; 156 | log4cplus_debug("PhoneNetSDK-LanScanner", "finish MLAN scan...\n"); 157 | [self.delegate finishedScanMlan:self]; 158 | [self resetPropertys]; 159 | } 160 | } 161 | } 162 | @end 163 | -------------------------------------------------------------------------------- /PhoneNetSDK.podspec: -------------------------------------------------------------------------------- 1 | # 2 | # Be sure to run `pod spec lint UNetAnalysis.podspec' to ensure this is a 3 | # valid spec and to remove all comments including this before submitting the spec. 4 | # 5 | # To learn more about Podspec attributes see https://docs.cocoapods.org/specification.html 6 | # To see working Podspecs in the CocoaPods repo see https://github.com/CocoaPods/Specs/ 7 | # 8 | 9 | Pod::Spec.new do |spec| 10 | 11 | # ――― Spec Metadata ―――――――――――――――――――――――――――――――――――――――――――――――――――――――――― # 12 | # 13 | # These will help people to find your library, and whilst it 14 | # can feel like a chore to fill in it's definitely to your advantage. The 15 | # summary should be tweet-length, and the description more in depth. 16 | # 17 | 18 | spec.name = "PhoneNetSDK" 19 | spec.version = "1.0.12" 20 | spec.summary = "Phone net analysis SDK for iOS" 21 | 22 | # This description is used to generate tags and improve search results. 23 | # * Think: What does it do? Why did you write it? What is the focus? 24 | # * Try to keep it short, snappy and to the point. 25 | # * Write the description between the DESC delimiters below. 26 | # * Finally, don't worry about the indent, CocoaPods strips it! 27 | spec.description = <<-DESC 28 | "Phone net analysis SDK for iOS,You can do Ping and tracert to check your phone network status" 29 | DESC 30 | 31 | spec.homepage = "https://github.com/mediaios/net-diagnosis.git" 32 | # spec.screenshots = "www.example.com/screenshots_1.gif", "www.example.com/screenshots_2.gif" 33 | 34 | 35 | # ――― Spec License ――――――――――――――――――――――――――――――――――――――――――――――――――――――――――― # 36 | # 37 | # Licensing your code is important. See https://choosealicense.com for more info. 38 | # CocoaPods will detect a license file if there is a named LICENSE* 39 | # Popular ones are 'MIT', 'BSD' and 'Apache License, Version 2.0'. 40 | # 41 | 42 | # spec.license = "MIT (example)" 43 | spec.license = { :type => "MIT", :file => "LICENSE" } 44 | 45 | 46 | # ――― Author Metadata ――――――――――――――――――――――――――――――――――――――――――――――――――――――――― # 47 | # 48 | # Specify the authors of the library, with email addresses. Email addresses 49 | # of the authors are extracted from the SCM log. E.g. $ git log. CocoaPods also 50 | # accepts just a name if you'd rather not provide an email address. 51 | # 52 | # Specify a social_media_url where others can refer to, for example a twitter 53 | # profile URL. 54 | # 55 | 56 | spec.author = { "mediaios" => "iosmediadev@gmail.com" } 57 | # Or just: spec.author = "mediaios" 58 | # spec.authors = { "mediaios" => "iosmediadev@gmail.com" } 59 | 60 | # ――― Platform Specifics ――――――――――――――――――――――――――――――――――――――――――――――――――――――― # 61 | # 62 | # If this Pod runs only on iOS or OS X, then specify the platform and 63 | # the deployment target. You can optionally include the target after the platform. 64 | # 65 | 66 | # spec.platform = :ios 67 | spec.platform = :ios, "9.0" 68 | 69 | # When using multiple platforms 70 | # spec.ios.deployment_target = "5.0" 71 | # spec.osx.deployment_target = "10.7" 72 | # spec.watchos.deployment_target = "2.0" 73 | # spec.tvos.deployment_target = "9.0" 74 | 75 | 76 | # ――― Source Location ―――――――――――――――――――――――――――――――――――――――――――――――――――――――――― # 77 | # 78 | # Specify the location from where the source should be retrieved. 79 | # Supports git, hg, bzr, svn and HTTP. 80 | # 81 | 82 | spec.source = { :git => "https://github.com/mediaios/net-diagnosis.git", :tag => "#{spec.version}" } 83 | 84 | 85 | # ――― Source Code ―――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――― # 86 | # 87 | # CocoaPods is smart about how it includes source code. For source files 88 | # giving a folder will include any swift, h, m, mm, c & cpp files. 89 | # For header files it will include any header in the folder. 90 | # Not including the public_header_files will make all headers public. 91 | # 92 | 93 | spec.source_files = "PhoneNetSDK/PhoneNetSDK/**/*.{h,m,mm}" 94 | # spec.exclude_files = "Classes/Exclude" 95 | 96 | # spec.public_header_files = "Classes/**/*.h" 97 | 98 | 99 | # ――― Resources ―――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――― # 100 | # 101 | # A list of resources included with the Pod. These are copied into the 102 | # target bundle with a build phase script. Anything else will be cleaned. 103 | # You can preserve files from being cleaned, please don't preserve 104 | # non-essential files like tests, examples and documentation. 105 | # 106 | 107 | # spec.resource = "icon.png" 108 | # spec.resources = "Resources/*.png" 109 | 110 | # spec.preserve_paths = "FilesToSave", "MoreFilesToSave" 111 | 112 | 113 | # ――― Project Linking ―――――――――――――――――――――――――――――――――――――――――――――――――――――――――― # 114 | # 115 | # Link your library with frameworks, or libraries. Libraries do not include 116 | # the lib prefix of their name. 117 | # 118 | 119 | # spec.framework = "SomeFramework" 120 | # spec.frameworks = "SomeFramework", "AnotherFramework" 121 | 122 | # spec.library = "iconv" 123 | # spec.libraries = "iconv", "xml2" 124 | 125 | 126 | # ――― Project Settings ――――――――――――――――――――――――――――――――――――――――――――――――――――――――― # 127 | # 128 | # If your library depends on compiler flags you can set them in the xcconfig hash 129 | # where they will only apply to your library. If you depend on other Podspecs 130 | # you can include multiple dependencies to ensure it works. 131 | 132 | spec.requires_arc = true 133 | 134 | # spec.xcconfig = { "HEADER_SEARCH_PATHS" => "$(SDKROOT)/usr/include/libxml2" } 135 | # spec.dependency "JSONKit", "~> 1.4" 136 | 137 | end 138 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # iOS network diagnostics sdk 2 | 3 | ## [阅读中文文档](https://github.com/mediaios/net-diagnosis/blob/master/README_CN.md) 4 | 5 | ## Introduction 6 | 7 | 8 | By ingegrating `iOS network diagnostics sdk` you can easily do ping/traceroute/mobile public network information/port scanning on IPhone. 9 | 10 | Take a screenshot of the network diagnostic app developed with this sdk: 11 | 12 |
13 | 图片说明图片说明 图片说明 14 |
15 | 16 |
17 | 图片说明图片说明 图片说明 18 |
19 | 20 |
21 | 图片说明图片说明图片说明 22 |
23 | 24 | * [Download UNetState in App Store](https://apps.apple.com/us/app/unetstate/id1489314289?l=zh&ls=1) 25 | * Welcome star & fork 26 | 27 | ## Environment 28 | 29 | * iOS >= 9.0 30 | * Xcode >= 7.0 31 | * Setting `Enable Bitcode` to `NO` 32 | 33 | ## Installation and use 34 | 35 | ### Pod dependency 36 | 37 | Add the following dependencies to your project's `Podfile`: 38 | 39 | ``` 40 | pod 'PhoneNetSDK' 41 | ``` 42 | 43 | ### Quick start 44 | 45 | Import the SDK header file to the project: 46 | 47 | ``` 48 | #import 49 | ``` 50 | 51 | In addition, you need to add `-lc++`,`-ObjC`,`$(inherited)` to the project's `Build Setting`->`other link flags`. As shown below: 52 | 53 | ![](https://ws2.sinaimg.cn/large/006tKfTcly1g0l5g4kt38j30og0e7q45.jpg) 54 | 55 | ### ping 56 | 57 | ``` 58 | [[PhoneNetManager shareInstance] netStartPing:@"www.baidu.com" packetCount:10 pingResultHandler:^(NSString * _Nullable pingres) { 59 | // your processing logic 60 | }]; 61 | ``` 62 | 63 | ### TCP ping 64 | 65 | ``` 66 | _tcpPing = [PNTcpPing start:hostDomain port:portNum.integerValue count:3 complete:^(NSMutableString *pingres) { 67 | // your processing logic 68 | }]; 69 | ``` 70 | 71 | ### UDP traceroute 72 | 73 | The default traceroute command on the command line sends a UDP packet (referred to as udp traceroute): 74 | 75 | ``` 76 | _udpTraceroute = [PNUdpTraceroute start:ip complete:^(NSMutableString *res) { 77 | // your processinig logic 78 | }]; 79 | ``` 80 | 81 | ### ICMP traceroute 82 | 83 | In the terminal of mac, enter `traceroute -I baidu.com` to use the ICMP protocol to do traceroute. This function is provided in sdk: 84 | 85 | ``` 86 | [[PhoneNetManager shareInstance] netStartTraceroute:@"www.baidu.com" tracerouteResultHandler:^(NSString * _Nullable tracertRes, NSString * _Nullable destIp) { 87 | // your processing logic 88 | }]; 89 | ``` 90 | 91 | ### nslookup 92 | 93 | ``` 94 | [[PhoneNetManager shareInstance] netLookupDomain:@"www.google.com" completeHandler:^(NSMutableArray * _Nullable lookupRes, PNError * _Nullable sdkError) { 95 | // your processing logic 96 | }]; 97 | ``` 98 | 99 | ### port scan 100 | 101 | ``` 102 | [[PhoneNetManager shareInstance] netPortScan:@"www.baidu.com" beginPort:8000 endPort:9000 completeHandler:^(NSString * _Nullable port, BOOL isOpen, PNError * _Nullable sdkError) { 103 | // your processing logic 104 | }]; 105 | ``` 106 | 107 | ### LAN Scanning 108 | 109 | If you want to do the LAN active ip scanning function, then you can quickly monitor every active ip with the SDK, and the SDK will return to you the scanning progress. 110 | 111 | Specific steps are as follows: 112 | 113 | 1. Create an object and set the proxy `PNetMLanScannerDelegate` 114 | 2. Start the scan and process the active ip through its delegate method 115 | 3. Monitor scan progress (optional) 116 | 117 | ``` 118 | PNetMLanScanner *lanScanner = [PNetMLanScanner shareInstance]; 119 | lanScanner.delegate = self; 120 | [lanScanner scan]; 121 | ``` 122 | 123 | 124 | ### Ohter functions 125 | 126 | * Setting SDK log level 127 | * Get device public ip info 128 | 129 | ## NetPinger-Example 130 | 131 | Ios platform network diagnostic APP (using the SDK), support ping and domain name ping, traceroute (udp, icmp protocol), support tcp ping, port scan, nslookup and other functions. 132 | 133 | Simply go to the directory where the `Podfile` file is located and install the SDK to run successfully. 134 | 135 | 136 | ``` 137 | macdeiMac:NetPinger ethan$ pod install 138 | Analyzing dependencies 139 | Downloading dependencies 140 | Installing PhoneNetSDK (1.0.7) 141 | Generating Pods project 142 | Integrating client project 143 | 144 | [!] Please close any current Xcode sessions and use `NetPinger.xcworkspace` for this project from now on. 145 | Sending stats 146 | Pod installation complete! There is 1 dependency from the Podfile and 1 total pod installed. 147 | ``` 148 | 149 | ### Project origin 150 | 151 | In development, you often encounter problems with the interface (DNS resolution error, etc.), so you need to detect whether the mobile terminal to the server's network is not connected, so you need to interrupt `ping` on the mobile phone, but the free network detection tool on the market. Most have pop-up ads affecting the experience (eg: iNetTools), so it is necessary to develop a web drama detection app. 152 | 153 | ### Implementation 154 | 155 | All functions are implemented using the functions provided by the SDK. The pages and icons are mainly imitating the `NetWork Utility` on the MAC, and hope to provide a valuable reference for your application. 156 | 157 | 158 | ## Contact us 159 | 160 | * If you have any questions or need any feature, please submit [issue](https://github.com/mediaios/net-diagnosis/issues) 161 | * If you want to contribute, please submit pull request 162 | * Welcome `star` & `fork` 163 | 164 | -------------------------------------------------------------------------------- /PhoneNetSDK/PhoneNetSDK/public/PhoneNetManager.mm: -------------------------------------------------------------------------------- 1 | // 2 | // PhoneNetManager.m 3 | // PhoneNetSDK 4 | // 5 | // Created by mediaios on 2018/10/15. 6 | // Copyright © 2018 mediaios. All rights reserved. 7 | // 8 | 9 | #import "PhoneNetManager.h" 10 | #import "PhonePingService.h" 11 | #import "PhoneTraceRouteService.h" 12 | #import "PNetReachability.h" 13 | #import "UCNetworkService.h" 14 | #import "PhoneNetSDKConst.h" 15 | #import "PNetModel.h" 16 | #import "PNetInfoTool.h" 17 | #import "PNetLog.h" 18 | #include "log4cplus_pn.h" 19 | #import "PNDomainLookup.h" 20 | #import "PNPortScan.h" 21 | 22 | 23 | @interface PhoneNetManager() 24 | @property (nonatomic,strong) PIpInfoModel *devicePublicIpInfo; 25 | @property (nonatomic,strong) PNetReachability *reachability; 26 | @end 27 | 28 | @implementation PhoneNetManager 29 | 30 | static PhoneNetManager *sdkManager_instance = nil; 31 | 32 | + (instancetype)shareInstance 33 | { 34 | static dispatch_once_t pNetNetAnalysis_onceToken; 35 | dispatch_once(&pNetNetAnalysis_onceToken, ^{ 36 | sdkManager_instance = [[super allocWithZone:NULL] init]; 37 | }); 38 | return sdkManager_instance; 39 | } 40 | 41 | - (void)settingSDKLogLevel:(PhoneNetSDKLogLevel)logLevel 42 | { 43 | [PNetLog setSDKLogLevel:logLevel]; 44 | } 45 | 46 | - (void)registPhoneNetSDK 47 | { 48 | [PhoneNotification addObserver:self selector:@selector(networkChange:) name:kPNetReachabilityChangedNotification object:nil]; 49 | self.reachability = [PNetReachability reachabilityForInternetConnection]; 50 | [self.reachability startNotifier]; 51 | [self checkNetworkStatusWithReachability:self.reachability]; 52 | } 53 | 54 | - (NSString * _Nonnull)sdkVersion 55 | { 56 | return PhoneNetSDKVersion; 57 | } 58 | 59 | +(id)allocWithZone:(struct _NSZone *)zone 60 | { 61 | return [PhoneNetManager shareInstance]; 62 | } 63 | 64 | - (id)copyWithZone:(struct _NSZone *)zone 65 | { 66 | return [PhoneNetManager shareInstance]; 67 | } 68 | 69 | - (void)netStopPing 70 | { 71 | [[PhonePingService shareInstance] uStopPing]; 72 | } 73 | 74 | - (BOOL)isDoingPing 75 | { 76 | return [[PhonePingService shareInstance] uIsPing]; 77 | } 78 | 79 | - (void)netStartPing:(NSString *_Nonnull)host packetCount:(int)count pingResultHandler:(NetPingResultHandler _Nonnull)handler 80 | { 81 | if (!handler) { 82 | @throw [NSException exceptionWithName:NSInvalidArgumentException reason:@"no pingResultHandler" userInfo:nil]; 83 | return; 84 | } 85 | [[PhonePingService shareInstance] startPingHost:host packetCount:count resultHandler:handler]; 86 | } 87 | 88 | 89 | - (void)netStartTraceroute:(NSString *_Nonnull)host tracerouteResultHandler:(NetTracerouteResultHandler _Nonnull)handler 90 | { 91 | if (!handler) { 92 | @throw [NSException exceptionWithName:NSInvalidArgumentException reason:@"no tracerouteResultHandler" userInfo:nil]; 93 | return; 94 | } 95 | [[PhoneTraceRouteService shareInstance] startTracerouteHost:host resultHandler:handler]; 96 | } 97 | 98 | - (void)netStopTraceroute 99 | { 100 | [[PhoneTraceRouteService shareInstance] uStopTracert]; 101 | } 102 | 103 | - (BOOL)isDoingTraceroute 104 | { 105 | return [[PhoneTraceRouteService shareInstance] uIsTracert]; 106 | } 107 | 108 | - (void)netLookupDomain:(NSString * _Nonnull)domain completeHandler:(NetLookupResultHandler _Nonnull)handler 109 | { 110 | if (!handler) { 111 | @throw [NSException exceptionWithName:NSInvalidArgumentException reason:@"no lookup complete Handler" userInfo:nil]; 112 | return; 113 | } 114 | [[PNDomainLookup shareInstance] lookupDomain:domain completeHandler:handler]; 115 | } 116 | 117 | - (void)netPortScan:(NSString * _Nonnull)host 118 | beginPort:(NSUInteger)beginPort 119 | endPort:(NSUInteger)endPort 120 | completeHandler:(NetPortScanHandler)handler 121 | { 122 | if (!handler) { 123 | @throw [NSException exceptionWithName:NSInvalidArgumentException reason:@"no port scan complete Handler" userInfo:nil]; 124 | return; 125 | } 126 | [[PNPortScan shareInstance] portScan:host beginPort:beginPort endPort:endPort completeHandler:handler]; 127 | } 128 | 129 | - (BOOL)isDoingPortScan 130 | { 131 | return [[PNPortScan shareInstance] isDoingScanPort]; 132 | } 133 | 134 | - (void)netStopPortScan 135 | { 136 | [[PNPortScan shareInstance] stopPortScan]; 137 | } 138 | 139 | - (void)networkChange:(NSNotification *)noti 140 | { 141 | PNetReachability *reachability = [noti object]; 142 | [self checkNetworkStatusWithReachability:reachability]; 143 | } 144 | 145 | - (void)checkNetworkStatusWithReachability:(PNetReachability *)reachability 146 | { 147 | PNetNetStatus status = [reachability currentReachabilityStatus]; 148 | switch (status) { 149 | case PNetReachable_None: 150 | { 151 | log4cplus_debug("PhoneNetSDK", "none network..."); 152 | } 153 | break; 154 | case PNetReachable_WiFi: 155 | { 156 | log4cplus_debug("PhoneNetSDK", "network type is WIFI..."); 157 | [self netGetDevicePublicIpInfo]; 158 | } 159 | break; 160 | case PNetReachable_WWAN: 161 | { 162 | log4cplus_debug("PhoneNetSDK", "network type is WWAN..."); 163 | [self netGetDevicePublicIpInfo]; 164 | } 165 | break; 166 | 167 | 168 | default: 169 | break; 170 | } 171 | } 172 | 173 | - (void)netGetDevicePublicIpInfo 174 | { 175 | [UCNetworkService uHttpGetRequestWithUrl:PhoneNet_Get_Public_Ip_Url functionModule:@"GetDevicePublicIpInfo" timeout:10.0 completionHandler:^(NSData * _Nullable data, NSError * _Nullable error) { 176 | NSDictionary *dict = [NSJSONSerialization JSONObjectWithData:data options:kNilOptions error:&error]; 177 | if (error || dict == nil) { 178 | log4cplus_warn("PhoneNetSDK", "get public ip error , content is nil.."); 179 | }else{ 180 | PIpInfoModel *ipModel = [PIpInfoModel uIpInfoModelWithDict:dict]; 181 | 182 | self.devicePublicIpInfo = ipModel; 183 | } 184 | }]; 185 | } 186 | 187 | #pragma mark -About network info 188 | - (NetWorkInfo *)netGetNetworkInfo 189 | { 190 | PNetInfoTool *phoneNetTool = [PNetInfoTool shareInstance]; 191 | [phoneNetTool refreshNetInfo]; 192 | NetWorkInfo *networkInfo = [[NetWorkInfo alloc] init]; 193 | networkInfo.deviceNetInfo = [PDeviceNetInfo deviceNetInfo]; 194 | networkInfo.ipInfoModel = self.devicePublicIpInfo; 195 | return networkInfo; 196 | } 197 | 198 | @end 199 | -------------------------------------------------------------------------------- /PhoneNetSDK/PhoneNetSDK/netInfo/PNetInfoTool.m: -------------------------------------------------------------------------------- 1 | // 2 | // PNetInfoTool.m 3 | // PhoneNetSDK 4 | // 5 | // Created by mediaios on 2018/10/16. 6 | // Copyright © 2018 mediaios. All rights reserved. 7 | // 8 | 9 | #import "PNetInfoTool.h" 10 | #import 11 | #import 12 | #import 13 | 14 | #import "PNetReachability.h" 15 | #import 16 | #import 17 | 18 | #import 19 | #import 20 | #import 21 | 22 | #define IOS_CELLULAR @"pdp_ip0" 23 | #define IOS_WIFI @"en0" 24 | #define IOS_VPN @"utun0" 25 | #define IP_ADDR_IPv4 @"ipv4" 26 | #define IP_ADDR_IPv6 @"ipv6" 27 | 28 | static NSString * const U_NO_NETWORK = @"NO NETWORK"; 29 | static NSString * const U_WIFI = @"WIFI"; 30 | static NSString * const U_GPRS = @"GPRS"; 31 | static NSString * const U_2G = @"2G"; 32 | static NSString * const U_2_75G_EDGE = @"2.75G EDGE"; 33 | static NSString * const U_3G = @"3G"; 34 | static NSString * const U_3_5G_HSDPA = @"3.5G HSDPA"; 35 | static NSString * const U_3_5G_HSUPA = @"3.5G HSUPA"; 36 | static NSString * const U_HRPD = @"HRPD"; 37 | static NSString * const U_4G = @"4G"; 38 | 39 | @interface PNetInfoTool() 40 | @property (nonatomic,copy) NSDictionary *ipInfoDict; 41 | @property (nonatomic,copy) NSDictionary *wifiDict; 42 | @end 43 | 44 | 45 | @implementation PNetInfoTool 46 | 47 | 48 | static PNetInfoTool *pNetInfoTool_instance = NULL; 49 | 50 | + (instancetype)shareInstance 51 | { 52 | if (pNetInfoTool_instance == NULL) { 53 | pNetInfoTool_instance = [[PNetInfoTool alloc] init]; 54 | } 55 | return pNetInfoTool_instance; 56 | } 57 | 58 | - (void)refreshNetInfo 59 | { 60 | // net info 61 | self.ipInfoDict = [PNetInfoTool getIPAddresses]; 62 | 63 | // wifi info 64 | NSArray *ifs = (__bridge_transfer id)CNCopySupportedInterfaces(); 65 | NSString *ifsEle = (NSString *)ifs[0]; 66 | self.wifiDict = (__bridge_transfer id)CNCopyCurrentNetworkInfo((__bridge CFStringRef)ifsEle); 67 | 68 | // NSLog(@"%@",[self getLocalInfoForCurrentWiFi]); 69 | } 70 | 71 | #pragma mark - for wifi 72 | - (NSString *)pGetSSID 73 | { 74 | return [self.wifiDict objectForKey:@"SSID"]; 75 | } 76 | 77 | - (NSString *)pGetBSSID 78 | { 79 | return [self.wifiDict objectForKey:@"BSSID"]; 80 | } 81 | 82 | - (NSString *)pGetWifiIpv4 83 | { 84 | return [self.ipInfoDict objectForKey:@"en0/ipv4"]; 85 | } 86 | 87 | - (NSString *)pGetSubNetMask 88 | { 89 | return [self.ipInfoDict objectForKey:@"netmask"]; 90 | } 91 | 92 | - (NSString *)pGetWifiIpv6 93 | { 94 | return [self.ipInfoDict objectForKey:@"en0/ipv6"]; 95 | } 96 | 97 | - (NSString *)pGetCellIpv4 98 | { 99 | return [self.ipInfoDict objectForKey:@"pdp_ip0/ipv4"]; 100 | } 101 | 102 | - (NSString*)pGetNetworkType 103 | { 104 | NSString *netType = @""; 105 | PNetReachability *reachNet = [PNetReachability reachabilityWithHostName:@"www.apple.com"]; 106 | PNetNetStatus net_status = [reachNet currentReachabilityStatus]; 107 | switch (net_status) { 108 | case PNetReachable_None: 109 | netType = U_NO_NETWORK; 110 | break; 111 | case PNetReachable_WiFi: 112 | netType = U_WIFI; 113 | break; 114 | case PNetReachable_WWAN: 115 | { 116 | CTTelephonyNetworkInfo *netInfo = [[CTTelephonyNetworkInfo alloc] init]; 117 | NSString *curreNetType = netInfo.currentRadioAccessTechnology; 118 | if ([curreNetType isEqualToString:CTRadioAccessTechnologyGPRS]) { 119 | netType = U_GPRS; 120 | }else if([curreNetType isEqualToString:CTRadioAccessTechnologyEdge]){ 121 | netType = U_2_75G_EDGE; 122 | }else if([curreNetType isEqualToString:CTRadioAccessTechnologyWCDMA] || 123 | [curreNetType isEqualToString:CTRadioAccessTechnologyCDMAEVDORev0] || 124 | [curreNetType isEqualToString:CTRadioAccessTechnologyCDMAEVDORevA] || 125 | [curreNetType isEqualToString:CTRadioAccessTechnologyCDMAEVDORevB]){ 126 | netType = U_3G; 127 | }else if([curreNetType isEqualToString:CTRadioAccessTechnologyHSDPA]){ 128 | netType = U_3_5G_HSDPA; 129 | }else if([curreNetType isEqualToString:CTRadioAccessTechnologyHSUPA]){ 130 | netType = U_3_5G_HSUPA; 131 | }else if([curreNetType isEqualToString:CTRadioAccessTechnologyeHRPD]){ 132 | netType = U_HRPD; 133 | }else if([curreNetType isEqualToString:CTRadioAccessTechnologyLTE]){ 134 | netType = U_4G; 135 | } 136 | } 137 | break; 138 | 139 | default: 140 | break; 141 | } 142 | 143 | return netType; 144 | } 145 | 146 | 147 | + (NSDictionary *)getIPAddresses 148 | { 149 | NSMutableDictionary *addresses = [NSMutableDictionary dictionaryWithCapacity:8]; 150 | 151 | // retrieve the current interfaces - returns 0 on success 152 | struct ifaddrs *interfaces; 153 | if(!getifaddrs(&interfaces)) { 154 | // Loop through linked list of interfaces 155 | struct ifaddrs *interface; 156 | for(interface=interfaces; interface; interface=interface->ifa_next) { 157 | if(!(interface->ifa_flags & IFF_UP) /* || (interface->ifa_flags & IFF_LOOPBACK) */ ) { 158 | continue; // deeply nested code harder to read 159 | } 160 | const struct sockaddr_in *addr = (const struct sockaddr_in*)interface->ifa_addr; 161 | char addrBuf[ MAX(INET_ADDRSTRLEN, INET6_ADDRSTRLEN) ]; 162 | if(addr && (addr->sin_family==AF_INET || addr->sin_family==AF_INET6)) { 163 | NSString *name = [NSString stringWithUTF8String:interface->ifa_name]; 164 | NSString *type; 165 | if(addr->sin_family == AF_INET) { 166 | if(inet_ntop(AF_INET, &addr->sin_addr, addrBuf, INET_ADDRSTRLEN)) { 167 | type = IP_ADDR_IPv4; 168 | } 169 | 170 | if([[NSString stringWithUTF8String:interface->ifa_name] isEqualToString:@"en0"]) { 171 | NSString *netmask = [NSString stringWithUTF8String:inet_ntoa(((struct sockaddr_in *)interface->ifa_netmask)->sin_addr)]; 172 | if (netmask) { 173 | [addresses setObject:netmask forKey:@"netmask"]; 174 | } 175 | } 176 | 177 | } else { 178 | const struct sockaddr_in6 *addr6 = (const struct sockaddr_in6*)interface->ifa_addr; 179 | if(inet_ntop(AF_INET6, &addr6->sin6_addr, addrBuf, INET6_ADDRSTRLEN)) { 180 | type = IP_ADDR_IPv6; 181 | } 182 | } 183 | if(type) { 184 | NSString *key = [NSString stringWithFormat:@"%@/%@", name, type]; 185 | addresses[key] = [NSString stringWithUTF8String:addrBuf]; 186 | } 187 | } 188 | } 189 | 190 | // Free memory 191 | freeifaddrs(interfaces); 192 | } 193 | return [addresses count] ? addresses : nil; 194 | } 195 | 196 | @end 197 | -------------------------------------------------------------------------------- /PhoneNetSDK/PhoneNetSDK/netInfo/PNetReachability.m: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 2016 Apple Inc. All Rights Reserved. 3 | See LICENSE.txt for this sample’s licensing information 4 | 5 | Abstract: 6 | Basic demonstration of how to use the SystemConfiguration Reachablity APIs. 7 | */ 8 | 9 | #import 10 | #import 11 | #import 12 | #import 13 | #import 14 | 15 | #import 16 | 17 | #import "PNetReachability.h" 18 | 19 | #pragma mark IPv6 Support 20 | //Reachability fully support IPv6. For full details, see ReadMe.md. 21 | 22 | 23 | NSString *kPNetReachabilityChangedNotification = @"kNetworkReachabilityChangedNotification"; 24 | 25 | 26 | #pragma mark - Supporting functions 27 | 28 | #define kShouldPrintReachabilityFlags 1 29 | 30 | static void PrintReachabilityFlags(SCNetworkReachabilityFlags flags, const char* comment) 31 | { 32 | #if kShouldPrintReachabilityFlags 33 | 34 | NSLog(@"Reachability Flag Status: %c%c %c%c%c%c%c%c%c %s\n", 35 | (flags & kSCNetworkReachabilityFlagsIsWWAN) ? 'W' : '-', 36 | (flags & kSCNetworkReachabilityFlagsReachable) ? 'R' : '-', 37 | 38 | (flags & kSCNetworkReachabilityFlagsTransientConnection) ? 't' : '-', 39 | (flags & kSCNetworkReachabilityFlagsConnectionRequired) ? 'c' : '-', 40 | (flags & kSCNetworkReachabilityFlagsConnectionOnTraffic) ? 'C' : '-', 41 | (flags & kSCNetworkReachabilityFlagsInterventionRequired) ? 'i' : '-', 42 | (flags & kSCNetworkReachabilityFlagsConnectionOnDemand) ? 'D' : '-', 43 | (flags & kSCNetworkReachabilityFlagsIsLocalAddress) ? 'l' : '-', 44 | (flags & kSCNetworkReachabilityFlagsIsDirect) ? 'd' : '-', 45 | comment 46 | ); 47 | #endif 48 | } 49 | 50 | 51 | static void ReachabilityCallback(SCNetworkReachabilityRef target, SCNetworkReachabilityFlags flags, void* info) 52 | { 53 | #pragma unused (target, flags) 54 | NSCAssert(info != NULL, @"info was NULL in ReachabilityCallback"); 55 | NSCAssert([(__bridge NSObject*) info isKindOfClass: [PNetReachability class]], @"info was wrong class in ReachabilityCallback"); 56 | 57 | PNetReachability* noteObject = (__bridge PNetReachability *)info; 58 | // Post a notification to notify the client that the network reachability changed. 59 | [[NSNotificationCenter defaultCenter] postNotificationName: kPNetReachabilityChangedNotification object: noteObject]; 60 | } 61 | 62 | 63 | #pragma mark - Reachability implementation 64 | 65 | @implementation PNetReachability 66 | { 67 | SCNetworkReachabilityRef _reachabilityRef; 68 | } 69 | 70 | + (instancetype)reachabilityWithHostName:(NSString *)hostName 71 | { 72 | PNetReachability* returnValue = NULL; 73 | SCNetworkReachabilityRef reachability = SCNetworkReachabilityCreateWithName(NULL, [hostName UTF8String]); 74 | if (reachability != NULL) 75 | { 76 | returnValue= [[self alloc] init]; 77 | if (returnValue != NULL) 78 | { 79 | returnValue->_reachabilityRef = reachability; 80 | } 81 | else { 82 | CFRelease(reachability); 83 | } 84 | } 85 | return returnValue; 86 | } 87 | 88 | 89 | + (instancetype)reachabilityWithAddress:(const struct sockaddr *)hostAddress 90 | { 91 | SCNetworkReachabilityRef reachability = SCNetworkReachabilityCreateWithAddress(kCFAllocatorDefault, hostAddress); 92 | 93 | PNetReachability* returnValue = NULL; 94 | 95 | if (reachability != NULL) 96 | { 97 | returnValue = [[self alloc] init]; 98 | if (returnValue != NULL) 99 | { 100 | returnValue->_reachabilityRef = reachability; 101 | } 102 | else { 103 | CFRelease(reachability); 104 | } 105 | } 106 | return returnValue; 107 | } 108 | 109 | 110 | + (instancetype)reachabilityForInternetConnection 111 | { 112 | struct sockaddr_in zeroAddress; 113 | bzero(&zeroAddress, sizeof(zeroAddress)); 114 | zeroAddress.sin_len = sizeof(zeroAddress); 115 | zeroAddress.sin_family = AF_INET; 116 | 117 | return [self reachabilityWithAddress: (const struct sockaddr *) &zeroAddress]; 118 | } 119 | 120 | #pragma mark reachabilityForLocalWiFi 121 | //reachabilityForLocalWiFi has been removed from the sample. See ReadMe.md for more information. 122 | //+ (instancetype)reachabilityForLocalWiFi 123 | 124 | 125 | 126 | #pragma mark - Start and stop notifier 127 | 128 | - (BOOL)startNotifier 129 | { 130 | BOOL returnValue = NO; 131 | SCNetworkReachabilityContext context = {0, (__bridge void *)(self), NULL, NULL, NULL}; 132 | 133 | if (SCNetworkReachabilitySetCallback(_reachabilityRef, ReachabilityCallback, &context)) 134 | { 135 | if (SCNetworkReachabilityScheduleWithRunLoop(_reachabilityRef, CFRunLoopGetCurrent(), kCFRunLoopDefaultMode)) 136 | { 137 | returnValue = YES; 138 | } 139 | } 140 | 141 | return returnValue; 142 | } 143 | 144 | 145 | - (void)stopNotifier 146 | { 147 | if (_reachabilityRef != NULL) 148 | { 149 | SCNetworkReachabilityUnscheduleFromRunLoop(_reachabilityRef, CFRunLoopGetCurrent(), kCFRunLoopDefaultMode); 150 | } 151 | } 152 | 153 | 154 | - (void)dealloc 155 | { 156 | [self stopNotifier]; 157 | if (_reachabilityRef != NULL) 158 | { 159 | CFRelease(_reachabilityRef); 160 | } 161 | } 162 | 163 | 164 | #pragma mark - Network Flag Handling 165 | 166 | - (PNetNetStatus)networkStatusForFlags:(SCNetworkReachabilityFlags)flags 167 | { 168 | PrintReachabilityFlags(flags, "networkStatusForFlags"); 169 | if ((flags & kSCNetworkReachabilityFlagsReachable) == 0) 170 | { 171 | // The target host is not reachable. 172 | return PNetReachable_None; 173 | } 174 | 175 | PNetNetStatus returnValue = PNetReachable_None; 176 | 177 | if ((flags & kSCNetworkReachabilityFlagsConnectionRequired) == 0) 178 | { 179 | /* 180 | If the target host is reachable and no connection is required then we'll assume (for now) that you're on Wi-Fi... 181 | */ 182 | returnValue = PNetReachable_WiFi; 183 | } 184 | 185 | if ((((flags & kSCNetworkReachabilityFlagsConnectionOnDemand ) != 0) || 186 | (flags & kSCNetworkReachabilityFlagsConnectionOnTraffic) != 0)) 187 | { 188 | /* 189 | ... and the connection is on-demand (or on-traffic) if the calling application is using the CFSocketStream or higher APIs... 190 | */ 191 | 192 | if ((flags & kSCNetworkReachabilityFlagsInterventionRequired) == 0) 193 | { 194 | /* 195 | ... and no [user] intervention is needed... 196 | */ 197 | returnValue = PNetReachable_WiFi; 198 | } 199 | } 200 | 201 | if ((flags & kSCNetworkReachabilityFlagsIsWWAN) == kSCNetworkReachabilityFlagsIsWWAN) 202 | { 203 | /* 204 | ... but WWAN connections are OK if the calling application is using the CFNetwork APIs. 205 | */ 206 | returnValue = PNetReachable_WWAN; 207 | } 208 | 209 | return returnValue; 210 | } 211 | 212 | 213 | - (BOOL)connectionRequired 214 | { 215 | NSAssert(_reachabilityRef != NULL, @"connectionRequired called with NULL reachabilityRef"); 216 | SCNetworkReachabilityFlags flags; 217 | 218 | if (SCNetworkReachabilityGetFlags(_reachabilityRef, &flags)) 219 | { 220 | return (flags & kSCNetworkReachabilityFlagsConnectionRequired); 221 | } 222 | 223 | return NO; 224 | } 225 | 226 | 227 | - (PNetNetStatus)currentReachabilityStatus 228 | { 229 | NSAssert(_reachabilityRef != NULL, @"currentNetworkStatus called with NULL SCNetworkReachabilityRef"); 230 | PNetNetStatus returnValue = PNetReachable_None; 231 | SCNetworkReachabilityFlags flags; 232 | 233 | if (SCNetworkReachabilityGetFlags(_reachabilityRef, &flags)) 234 | { 235 | returnValue = [self networkStatusForFlags:flags]; 236 | } 237 | 238 | return returnValue; 239 | } 240 | 241 | 242 | @end 243 | -------------------------------------------------------------------------------- /PhoneNetSDK/PhoneNetSDK/common/PhoneNetDiagnosisHelper.m: -------------------------------------------------------------------------------- 1 | // 2 | // PhoneNetDiagnosisHelper.m 3 | // PingDemo 4 | // 5 | // Created by mediaios on 08/08/2018. 6 | // Copyright © 2018 mediaios. All rights reserved. 7 | // 8 | 9 | #import "PhoneNetDiagnosisHelper.h" 10 | #import "PhoneNetSDKConst.h" 11 | 12 | @implementation PhoneNetDiagnosisHelper 13 | 14 | 15 | + (uint16_t) in_cksumWithBuffer:(const void *)buffer andSize:(size_t)bufferLen 16 | { 17 | /* 18 | 将数据以字(16位)为单位累加到一个双字中 19 | 如果数据长度为奇数,最后一个字节将被扩展到字,累加的结果是一个双字, 20 | 最后将这个双字的高16位和低16位相加后取反 21 | */ 22 | size_t bytesLeft; 23 | int32_t sum; 24 | const uint16_t * cursor; 25 | union { 26 | uint16_t us; 27 | uint8_t uc[2]; 28 | } last; 29 | uint16_t answer; 30 | 31 | bytesLeft = bufferLen; 32 | sum = 0; 33 | cursor = (uint16_t*)buffer; 34 | 35 | while (bytesLeft > 1) { 36 | sum += *cursor; 37 | cursor += 1; 38 | bytesLeft -= 2; 39 | } 40 | 41 | /* mop up an odd byte, if necessary */ 42 | if (bytesLeft == 1) { 43 | last.uc[0] = * (const uint8_t *) cursor; 44 | last.uc[1] = 0; 45 | sum += last.us; 46 | } 47 | 48 | /* add back carry outs from top 16 bits to low 16 bits */ 49 | sum = (sum >> 16) + (sum & 0xffff); /* add hi 16 to low 16 */ 50 | sum += (sum >> 16); /* add carry */ 51 | answer = (uint16_t) ~sum; /* truncate to 16 bits */ 52 | 53 | return answer; 54 | } 55 | 56 | + (BOOL)isValidPingResponseWithBuffer:(char *)buffer len:(int)len seq:(int)seq identifier:(int)identifier 57 | { 58 | UICMPPacket *icmpPtr = (UICMPPacket *)[self icmpInpacket:buffer andLen:len]; 59 | if (icmpPtr == NULL) { 60 | return NO; 61 | } 62 | uint16_t receivedChecksum = icmpPtr->checksum; 63 | icmpPtr->checksum = 0; 64 | uint16_t calculatedChecksum = [self in_cksumWithBuffer:icmpPtr andSize:len-((char*)icmpPtr - buffer)]; 65 | 66 | return receivedChecksum == calculatedChecksum && 67 | icmpPtr->type == ENU_U_ICMPType_EchoReplay && 68 | icmpPtr->code == 0 && 69 | OSSwapBigToHostInt16(icmpPtr->identifier) == identifier && 70 | OSSwapBigToHostInt16(icmpPtr->seq) <= seq; 71 | } 72 | 73 | + (BOOL)isValidPingResponseWithBuffer:(char *)buffer len:(int)len 74 | { 75 | UICMPPacket *icmpPtr = (UICMPPacket *)[self icmpInpacket:buffer andLen:len]; 76 | if (icmpPtr == NULL) { 77 | return NO; 78 | } 79 | 80 | // NSLog(@"debug----name:%@,id:%d,packet->id:%d,seq:%d,packet->seq:%d",self.name ,identifier,OSSwapBigToHostInt16(icmpPtr->identifier),seq,OSSwapBigToHostInt16(icmpPtr->seq)); 81 | 82 | uint16_t receivedChecksum = icmpPtr->checksum; 83 | icmpPtr->checksum = 0; 84 | uint16_t calculatedChecksum = [self in_cksumWithBuffer:icmpPtr andSize:len-((char*)icmpPtr - buffer)]; 85 | 86 | return receivedChecksum == calculatedChecksum && 87 | icmpPtr->type == ENU_U_ICMPType_EchoReplay && 88 | icmpPtr->code == 0 && 89 | OSSwapBigToHostInt16(icmpPtr->identifier)>=KPingIcmpIdBeginNum;; 90 | } 91 | 92 | /* 从 ipv4 数据包中解析出icmp */ 93 | + (char *)icmpInpacket:(char *)packet andLen:(int)len 94 | { 95 | if (len < (sizeof(PNetIPHeader) + sizeof(UICMPPacket))) { 96 | return NULL; 97 | } 98 | const struct PNetIPHeader *ipPtr = (const PNetIPHeader *)packet; 99 | if ((ipPtr->versionAndHeaderLength & 0xF0) != 0x40 // IPv4 100 | || 101 | ipPtr->protocol != 1) { //ICMP 102 | return NULL; 103 | } 104 | size_t ipHeaderLength = (ipPtr->versionAndHeaderLength & 0x0F) * sizeof(uint32_t); 105 | 106 | if (len < ipHeaderLength + sizeof(UICMPPacket)) { 107 | return NULL; 108 | } 109 | 110 | return (char *)packet + ipHeaderLength; 111 | } 112 | 113 | + (char *)tracertICMPInPacket:(char *)packet andLen:(int)len 114 | { 115 | if (len < (sizeof(PNetIPHeader) + sizeof(PICMPPacket_Tracert))) { 116 | return NULL; 117 | } 118 | const struct PNetIPHeader *ipPtr = (const PNetIPHeader *)packet; 119 | if ((ipPtr->versionAndHeaderLength & 0xF0) != 0x40 // IPv4 120 | || 121 | ipPtr->protocol != 1) { //ICMP 122 | return NULL; 123 | } 124 | size_t ipHeaderLength = (ipPtr->versionAndHeaderLength & 0x0F) * sizeof(uint32_t); 125 | 126 | if (len < ipHeaderLength + sizeof(PICMPPacket_Tracert)) { 127 | return NULL; 128 | } 129 | 130 | return (char *)packet + ipHeaderLength; 131 | } 132 | 133 | + (UICMPPacket *)constructPacketWithSeq:(uint16_t)seq andIdentifier:(uint16_t)identifier 134 | { 135 | UICMPPacket *packet = (UICMPPacket *)malloc(sizeof(UICMPPacket)); 136 | packet->type = ENU_U_ICMPType_EchoRequest; 137 | packet->code = 0; 138 | packet->checksum = 0; 139 | packet->identifier = OSSwapHostToBigInt16(identifier); 140 | packet->seq = OSSwapHostToBigInt16(seq); 141 | memset(packet->fills, 65, 56); 142 | packet->checksum = [self in_cksumWithBuffer:packet andSize:sizeof(UICMPPacket)]; 143 | return packet; 144 | } 145 | 146 | + (PICMPPacket_Tracert *)constructTracertICMPPacketWithSeq:(uint16_t)seq andIdentifier:(uint16_t)identifier 147 | { 148 | PICMPPacket_Tracert *packet = (PICMPPacket_Tracert *)malloc(sizeof(PICMPPacket_Tracert)); 149 | packet->type = ENU_U_ICMPType_EchoRequest; 150 | packet->code = 0; 151 | packet->checksum = 0; 152 | packet->identifier = OSSwapHostToBigInt16(identifier); 153 | packet->seq = OSSwapHostToBigInt16(seq); 154 | packet->checksum = [self in_cksumWithBuffer:packet andSize:sizeof(PICMPPacket_Tracert)]; 155 | return packet; 156 | } 157 | 158 | 159 | /******* for traceroute *********/ 160 | + (NSArray *)resolveHost:(NSString *)hostname { 161 | NSMutableArray *resolve = [NSMutableArray array]; 162 | CFHostRef hostRef = CFHostCreateWithName(kCFAllocatorDefault, (__bridge CFStringRef)hostname); 163 | if (hostRef != NULL) { 164 | Boolean result = CFHostStartInfoResolution(hostRef, kCFHostAddresses, NULL); // 开始DNS解析 165 | if (result == true) { 166 | CFArrayRef addresses = CFHostGetAddressing(hostRef, &result); 167 | for(int i = 0; i < CFArrayGetCount(addresses); i++){ 168 | CFDataRef saData = (CFDataRef)CFArrayGetValueAtIndex(addresses, i); 169 | struct sockaddr *addressGeneric = (struct sockaddr *)CFDataGetBytePtr(saData); 170 | 171 | if (addressGeneric != NULL) { 172 | struct sockaddr_in *remoteAddr = (struct sockaddr_in *)CFDataGetBytePtr(saData); 173 | [resolve addObject:[self formatIPv4Address:remoteAddr->sin_addr]]; 174 | } 175 | } 176 | } 177 | } 178 | 179 | return [resolve copy]; 180 | } 181 | 182 | + (NSString *)formatIPv4Address:(struct in_addr)ipv4Addr { 183 | NSString *address = nil; 184 | 185 | char dstStr[INET_ADDRSTRLEN]; 186 | char srcStr[INET_ADDRSTRLEN]; 187 | memcpy(srcStr, &ipv4Addr, sizeof(struct in_addr)); 188 | if(inet_ntop(AF_INET, srcStr, dstStr, INET_ADDRSTRLEN) != NULL) { 189 | address = [NSString stringWithUTF8String:dstStr]; 190 | } 191 | 192 | return address; 193 | } 194 | 195 | + (struct sockaddr *)createSockaddrWithAddress:(NSString *)address 196 | { 197 | NSData *addrData = nil; 198 | struct sockaddr_in addr; 199 | memset(&addr, 0, sizeof(addr)); 200 | addr.sin_len = sizeof(addr); 201 | addr.sin_family = AF_INET; 202 | addr.sin_port = htons(20000); 203 | if (inet_pton(AF_INET, address.UTF8String, &addr.sin_addr.s_addr) < 0) { 204 | NSLog(@"create sockaddr failed"); 205 | return NULL; 206 | } 207 | addrData = [NSData dataWithBytes:&addr length:sizeof(addr)]; 208 | return (struct sockaddr *)[addrData bytes]; 209 | } 210 | 211 | + (BOOL)isTimeoutPacket:(char *)packet len:(int)len 212 | { 213 | PICMPPacket_Tracert *icmpPacket = NULL; 214 | icmpPacket = (PICMPPacket_Tracert *)[self tracertICMPInPacket:packet andLen:len]; 215 | if (icmpPacket != NULL && icmpPacket->type == ENU_U_ICMPType_TimeOut) { 216 | return YES; 217 | } 218 | return NO; 219 | } 220 | 221 | + (BOOL)isEchoReplayPacket:(char *)packet len:(int)len 222 | { 223 | PICMPPacket_Tracert *icmpPacket = NULL; 224 | icmpPacket = (PICMPPacket_Tracert *)[self tracertICMPInPacket:packet andLen:len]; 225 | 226 | if (icmpPacket != NULL && icmpPacket->type == ENU_U_ICMPType_EchoReplay) { 227 | return YES; 228 | } 229 | return NO; 230 | } 231 | 232 | @end 233 | -------------------------------------------------------------------------------- /PhoneNetSDK/PhoneNetSDK/tcpping/PNTcpPing.m: -------------------------------------------------------------------------------- 1 | // 2 | // PNTcpPing.m 3 | // PhoneNetSDK 4 | // 5 | // Created by mediaios on 2019/3/11. 6 | // Copyright © 2019 mediaios. All rights reserved. 7 | // 8 | 9 | #import "PNTcpPing.h" 10 | #import 11 | #import 12 | #import 13 | #import 14 | #import 15 | 16 | #include 17 | #include 18 | 19 | @interface PNTcpPingResult() 20 | 21 | - (instancetype)init:(NSString *)ip 22 | loss:(NSUInteger)loss 23 | count:(NSUInteger)count 24 | max:(NSTimeInterval)maxTime 25 | min:(NSTimeInterval)minTime 26 | avg:(NSTimeInterval)avgTime; 27 | 28 | @end 29 | 30 | @implementation PNTcpPingResult 31 | 32 | - (instancetype)init:(NSString *)ip 33 | loss:(NSUInteger)loss 34 | count:(NSUInteger)count 35 | max:(NSTimeInterval)maxTime 36 | min:(NSTimeInterval)minTime 37 | avg:(NSTimeInterval)avgTime 38 | { 39 | if (self = [super init]) { 40 | _ip = ip; 41 | _loss = loss; 42 | _count = count; 43 | _max_time = maxTime; 44 | _avg_time = avgTime; 45 | _min_time = minTime; 46 | } 47 | return self; 48 | } 49 | 50 | - (NSString *)description 51 | { 52 | return [NSString stringWithFormat:@"TCP conn loss=%lu, min/avg/max = %.2f/%.2f/%.2fms",(unsigned long)self.loss,self.min_time,self.avg_time,self.max_time]; 53 | } 54 | 55 | @end 56 | 57 | 58 | static PNTcpPing *g_tcpPing = nil; 59 | void tcp_conn_handler() 60 | { 61 | if (g_tcpPing) { 62 | [g_tcpPing processLongConn]; 63 | } 64 | } 65 | 66 | 67 | @interface PNTcpPing() 68 | { 69 | struct sockaddr_in addr; 70 | int sock; 71 | } 72 | @property (nonatomic,readonly) NSString *host; 73 | @property (nonatomic,readonly) NSUInteger port; 74 | @property (nonatomic,readonly) NSUInteger count; 75 | @property (copy,readonly) PNTcpPingHandler complete; 76 | @property (atomic) BOOL isStop; 77 | @property (nonatomic,assign) BOOL isSucc; 78 | 79 | @property (nonatomic,copy) NSMutableString *pingDetails; 80 | @end 81 | 82 | @implementation PNTcpPing 83 | 84 | - (instancetype)init:(NSString *)host 85 | port:(NSUInteger)port 86 | count:(NSUInteger)count 87 | complete:(PNTcpPingHandler)complete 88 | { 89 | if (self = [super init]) { 90 | _host = host; 91 | _port = port; 92 | _count = count; 93 | _complete = complete; 94 | _isStop = NO; 95 | _isSucc = YES; 96 | } 97 | return self; 98 | } 99 | 100 | + (instancetype)start:(NSString * _Nonnull)host 101 | complete:(PNTcpPingHandler _Nonnull)complete 102 | { 103 | return [[self class] start:host port:80 count:3 complete:complete]; 104 | } 105 | 106 | + (instancetype)start:(NSString * _Nonnull)host 107 | port:(NSUInteger)port 108 | count:(NSUInteger)count 109 | complete:(PNTcpPingHandler _Nonnull)complete 110 | { 111 | PNTcpPing *tcpPing = [[PNTcpPing alloc] init:host port:port count:count complete:complete]; 112 | g_tcpPing = tcpPing; 113 | dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{ 114 | [tcpPing sendAndRec]; 115 | }); 116 | return tcpPing; 117 | } 118 | 119 | - (BOOL)isTcpPing 120 | { 121 | return !_isStop; 122 | } 123 | - (void)stopTcpPing 124 | { 125 | _isStop = YES; 126 | } 127 | 128 | - (void)sendAndRec 129 | { 130 | _pingDetails = [NSMutableString stringWithString:@"\n"]; 131 | NSString *ip = [self convertDomainToIp:_host]; 132 | if (ip == NULL) { 133 | return; 134 | } 135 | NSTimeInterval *intervals = (NSTimeInterval *)malloc(sizeof(NSTimeInterval) * _count); 136 | int index = 0; 137 | int r = 0; 138 | int loss = 0; 139 | do { 140 | NSDate *t_begin = [NSDate date]; 141 | r = [self connect:&addr]; 142 | NSTimeInterval conn_time = [[NSDate date] timeIntervalSinceDate:t_begin]; 143 | intervals[index] = conn_time * 1000; 144 | if (r == 0) { 145 | // NSLog(@"connected to %s:%lu, %f ms\n",inet_ntoa(addr.sin_addr), (unsigned long)_port, conn_time * 1000); 146 | [_pingDetails appendString:[NSString stringWithFormat:@"conn to %@:%lu, %.2f ms \n",ip,_port,conn_time * 1000]]; 147 | } else { 148 | NSLog(@"connect failed to %s:%lu, %f ms, error %d\n",inet_ntoa(addr.sin_addr), (unsigned long)_port, conn_time * 1000, r); 149 | [_pingDetails appendString:[NSString stringWithFormat:@"connect failed to %s:%lu, %f ms, error %d\n",inet_ntoa(addr.sin_addr), (unsigned long)_port, conn_time * 1000, r]]; 150 | loss++; 151 | } 152 | _complete(_pingDetails); 153 | if (index < _count && !_isStop && r == 0) { 154 | usleep(1000*100); 155 | } 156 | } while (++index < _count && !_isStop && r == 0); 157 | 158 | NSInteger code = r; 159 | if (_isStop) { 160 | code = -5; 161 | }else{ 162 | _isStop = YES; 163 | } 164 | 165 | dispatch_async(dispatch_get_main_queue(), ^(void) { 166 | 167 | if (self.isSucc) { 168 | PNTcpPingResult *pingRes = [self constPingRes:code ip:ip durations:intervals loss:loss count:index]; 169 | [self.pingDetails appendString:pingRes.description]; 170 | } 171 | self.complete(self.pingDetails); 172 | free(intervals); 173 | }); 174 | } 175 | 176 | 177 | - (void)processLongConn 178 | { 179 | close(sock); 180 | _isStop = YES; 181 | _isSucc = NO; 182 | } 183 | 184 | - (int)connect:(struct sockaddr_in *)addr{ 185 | sock = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP); 186 | if (sock == -1) { 187 | return errno; 188 | } 189 | int on = 1; 190 | setsockopt(sock, SOL_SOCKET, SO_NOSIGPIPE, &on, sizeof(on)); 191 | setsockopt(sock, IPPROTO_TCP, TCP_NODELAY, (char *)&on, sizeof(on)); 192 | 193 | struct timeval timeout; 194 | timeout.tv_sec = 10; 195 | timeout.tv_usec = 0; 196 | setsockopt(sock, SOL_SOCKET, SO_RCVTIMEO, (char *)&timeout, sizeof(timeout)); 197 | setsockopt(sock, SOL_SOCKET, SO_SNDTIMEO, (char *)&timeout, sizeof(timeout)); 198 | 199 | sigset(SIGALRM, tcp_conn_handler); 200 | alarm(1); 201 | int conn_res = connect(sock, (struct sockaddr *)addr, sizeof(struct sockaddr)); 202 | alarm(0); 203 | sigrelse(SIGALRM); 204 | 205 | if (conn_res < 0) { 206 | int err = errno; 207 | close(sock); 208 | return err; 209 | } 210 | close(sock); 211 | return 0; 212 | } 213 | 214 | - (NSString *)convertDomainToIp:(NSString *)host 215 | { 216 | const char *hostaddr = [host UTF8String]; 217 | memset(&addr, 0, sizeof(addr)); 218 | addr.sin_len = sizeof(addr); 219 | addr.sin_family = AF_INET; 220 | addr.sin_port = htons(_port); 221 | if (hostaddr == NULL) { 222 | hostaddr = "\0"; 223 | } 224 | addr.sin_addr.s_addr = inet_addr(hostaddr); 225 | 226 | if (addr.sin_addr.s_addr == INADDR_NONE) { 227 | struct hostent *remoteHost = gethostbyname(hostaddr); 228 | if (remoteHost == NULL || remoteHost->h_addr == NULL) { 229 | [_pingDetails appendString:[NSString stringWithFormat:@"access %@ DNS error..\n",host]]; 230 | _complete(_pingDetails); 231 | return NULL; 232 | } 233 | addr.sin_addr = *(struct in_addr *)remoteHost->h_addr; 234 | return [NSString stringWithFormat:@"%s",inet_ntoa(addr.sin_addr)]; 235 | } 236 | return host; 237 | } 238 | 239 | - (PNTcpPingResult *)constPingRes:(NSInteger)code 240 | ip:(NSString *)ip 241 | durations:(NSTimeInterval *)durations 242 | loss:(NSUInteger)loss 243 | count:(NSUInteger)count 244 | { 245 | if (code != 0 && code != -5) { 246 | return [[PNTcpPingResult alloc] init:ip loss:1 count:1 max:0 min:0 avg:0]; 247 | } 248 | 249 | NSTimeInterval max = 0; 250 | NSTimeInterval min = 10000000; 251 | NSTimeInterval sum = 0; 252 | for (int i= 0; i < count; i++) { 253 | if (durations[i] > max) { 254 | max = durations[i]; 255 | } 256 | if (durations[i] < min) { 257 | min = durations[i]; 258 | } 259 | sum += durations[i]; 260 | } 261 | 262 | NSTimeInterval avg = sum/count; 263 | return [[PNTcpPingResult alloc] init:ip loss:loss count:count max:max min:min avg:avg]; 264 | } 265 | @end 266 | -------------------------------------------------------------------------------- /PhoneNetSDK/PhoneNetSDK/utracert/control/PhoneTraceRoute.mm: -------------------------------------------------------------------------------- 1 | // 2 | // UTraceRoute.m 3 | // PingDemo 4 | // 5 | // Created by mediaios on 08/08/2018. 6 | // Copyright © 2018 mediaios. All rights reserved. 7 | // 8 | 9 | #import "PhoneTraceRoute.h" 10 | #import "PhoneNetSDKConst.h" 11 | #import "PNetQueue.h" 12 | #include "log4cplus_pn.h" 13 | 14 | typedef enum PNetRecTracertIcmpType{ 15 | PNetRecTracertIcmpType_None = 0, 16 | PNetRecTracertIcmpType_noReply, 17 | PNetRecTracertIcmpType_routeReceive, 18 | PNetRecTracertIcmpType_Dest 19 | }PNetRecTracertIcmpType; 20 | 21 | @interface PhoneTraceRoute() 22 | { 23 | int socket_client; 24 | struct sockaddr_in remote_addr; // server address 25 | } 26 | 27 | @property (nonatomic,strong) NSString *host; 28 | @property (nonatomic,assign) BOOL isStopTracert; 29 | @property (nonatomic,assign) PNetRecTracertIcmpType lastRecTracertIcmpType; 30 | @property (nonatomic,strong) NSDate *sendDate; 31 | @end 32 | 33 | @implementation PhoneTraceRoute 34 | 35 | - (instancetype)init 36 | { 37 | if ([super init]) { 38 | _isStopTracert = NO; 39 | _lastRecTracertIcmpType = PNetRecTracertIcmpType_None; 40 | } 41 | return self; 42 | } 43 | 44 | - (void)stopTracert 45 | { 46 | self.isStopTracert = YES; 47 | } 48 | 49 | - (BOOL)isTracert 50 | { 51 | return !self.isStopTracert; 52 | } 53 | 54 | -(void)settingUHostSocketAddressWithHost: (NSString *)host 55 | { 56 | const char *hostaddr = [host UTF8String]; 57 | memset(&remote_addr, 0, sizeof(remote_addr)); 58 | remote_addr.sin_addr.s_addr = inet_addr(hostaddr); 59 | 60 | if (remote_addr.sin_addr.s_addr == INADDR_NONE) { 61 | struct hostent *remoteHost = gethostbyname(hostaddr); 62 | remote_addr.sin_addr = *(struct in_addr *)remoteHost->h_addr; 63 | } 64 | 65 | struct timeval timeout; 66 | timeout.tv_sec = 1; 67 | // timeout.tv_sec = 0; 68 | // timeout.tv_usec = 1000*kIcmpPacketTimeoutTime; 69 | timeout.tv_usec = 0; 70 | 71 | socket_client = socket(AF_INET, SOCK_DGRAM, IPPROTO_ICMP); 72 | int res = setsockopt(socket_client, SOL_SOCKET, SO_RCVTIMEO, &timeout, sizeof(timeout)); 73 | if (res < 0) { 74 | log4cplus_warn("PhoneNetTracert", "tracert %s , set timeout error..\n", [host UTF8String]); 75 | } 76 | remote_addr.sin_family = AF_INET; 77 | } 78 | 79 | - (BOOL)verificationHost:(NSString *)host 80 | { 81 | NSArray *address = [PhoneNetDiagnosisHelper resolveHost:host]; 82 | if (address.count > 0) { 83 | NSString *ipAddress = [address firstObject]; 84 | _host = ipAddress; 85 | }else{ 86 | log4cplus_warn("PhoneNetTracert", "access %s DNS error , remove this ip..\n",[host UTF8String]); 87 | } 88 | 89 | if (_host == NULL) { 90 | return NO; 91 | } 92 | return YES; 93 | } 94 | 95 | - (void)startTracerouteHost:(NSString *)host 96 | { 97 | if (![self verificationHost:host]) { 98 | self.isStopTracert = YES; 99 | log4cplus_warn("PhoneNetTracert", "there is no valid domain in the domain list , traceroute complete..\n"); 100 | return; 101 | } 102 | 103 | [PNetQueue pnet_trace_async:^{ 104 | [self settingUHostSocketAddressWithHost:self.host]; 105 | [self startTracert:self->socket_client andRemoteAddr:self->remote_addr]; 106 | }]; 107 | } 108 | 109 | -(void)startTracert: (int)socketClient andRemoteAddr: (struct sockaddr_in)remoteAddr 110 | { 111 | if (self.isStopTracert) { 112 | return; 113 | } 114 | 115 | int ttl = 1; 116 | int continuousLossPacketRoute = 0; 117 | PNetRecTracertIcmpType rec = PNetRecTracertIcmpType_noReply; 118 | log4cplus_debug("PhoneNetTracert", "begin tracert ip: %s \n", [self.host UTF8String]); 119 | do { 120 | int setTtlRes = setsockopt(socketClient, 121 | IPPROTO_IP, 122 | IP_TTL, 123 | &ttl, sizeof(ttl)); 124 | if (setTtlRes < 0) { 125 | log4cplus_debug("PhoneNetTracert", "set TTL for icmp packet error..\n"); 126 | } 127 | 128 | uint16_t identifier = (uint16_t)(5000 + ttl); 129 | PICMPPacket_Tracert *packet = [PhoneNetDiagnosisHelper constructTracertICMPPacketWithSeq:ttl andIdentifier:identifier]; 130 | 131 | PTracerRouteResModel *record = [[PTracerRouteResModel alloc] init:ttl count:kTracertSendIcmpPacketTimes]; 132 | 133 | for (int trytime = 0; trytime < kTracertSendIcmpPacketTimes; trytime++) { 134 | _sendDate = [NSDate date]; 135 | size_t sent = sendto(socketClient, packet, sizeof(PICMPPacket_Tracert), 0, (struct sockaddr *)&remoteAddr, sizeof(struct sockaddr_in)); 136 | if ((int)sent < 0) { 137 | log4cplus_debug("PhoneNetTracert", "send icmp packet failed, error info :%s\n", strerror(errno)); 138 | break; 139 | } 140 | rec = PNetRecTracertIcmpType_noReply; 141 | rec = [self receiverRemoteIpTracertRes:ttl packetSeq:trytime record:record]; 142 | 143 | if (self.lastRecTracertIcmpType == PNetRecTracertIcmpType_None) { 144 | self.lastRecTracertIcmpType = rec; 145 | } 146 | 147 | // NSLog(@"rec:%d , last rec:%d",(int)rec,(int)self.lastRecTracertIcmpType); 148 | if (rec == PNetRecTracertIcmpType_noReply && self.lastRecTracertIcmpType == PNetRecTracertIcmpType_noReply) { 149 | continuousLossPacketRoute++; 150 | if (continuousLossPacketRoute == kTracertRouteCount_noRes * kTracertSendIcmpPacketTimes) { 151 | log4cplus_debug("PhoneNetTracert", "%d consecutive routes are not responding ,and end the tracert ip: %s\n", kTracertRouteCount_noRes, [self.host UTF8String]); 152 | rec = PNetRecTracertIcmpType_Dest; 153 | 154 | record.dstIp = self.host; 155 | record.status = Enum_Traceroute_Status_finish; 156 | break; 157 | } 158 | } else { 159 | continuousLossPacketRoute = 0; 160 | } 161 | self.lastRecTracertIcmpType = rec; 162 | 163 | if (self.isStopTracert) { 164 | break; 165 | } 166 | } 167 | 168 | [self.delegate tracerouteWithUCTraceRoute: self tracertResult: record]; 169 | } while (++ttl <= kTracertMaxTTL && (rec == PNetRecTracertIcmpType_routeReceive || rec == PNetRecTracertIcmpType_noReply) && !self.isStopTracert); 170 | 171 | if (rec == PNetRecTracertIcmpType_Dest) { 172 | log4cplus_debug("PhoneNetTracert", "done tracert , ip :%s \n", [self.host UTF8String]); 173 | shutdown(socket_client, SHUT_RDWR); 174 | self.isStopTracert = YES; 175 | [self.delegate tracerouteFinishedWithUCTraceRoute: self]; 176 | } 177 | } 178 | 179 | -(PNetRecTracertIcmpType)receiverRemoteIpTracertRes: (int)ttl packetSeq: (int)seq record: (PTracerRouteResModel *)record 180 | { 181 | PNetRecTracertIcmpType res = PNetRecTracertIcmpType_routeReceive; 182 | char buff[200]; 183 | socklen_t addrLen = sizeof(struct sockaddr_in); 184 | record.dstIp = self.host; 185 | size_t resultLen = recvfrom(socket_client, buff, sizeof(buff), 0, (struct sockaddr *)&remote_addr, &addrLen); 186 | if ((int)resultLen < 0) { 187 | res = PNetRecTracertIcmpType_noReply; 188 | } else { 189 | NSString *remoteAddress = nil; 190 | char ip[INET_ADDRSTRLEN] = { 0 }; 191 | inet_ntop(AF_INET, &((struct sockaddr_in *)&remote_addr)->sin_addr.s_addr, ip, sizeof(ip)); 192 | remoteAddress = [NSString stringWithUTF8String:ip]; 193 | 194 | if ([PhoneNetDiagnosisHelper isTimeoutPacket: buff len:(int)resultLen] && ![remoteAddress isEqualToString: self.host]) { 195 | NSTimeInterval duration = [[NSDate date] timeIntervalSinceDate:_sendDate]; 196 | 197 | // Arriving at the intermediate routing node 198 | record.durations[seq] = duration; 199 | record.ip = remoteAddress; 200 | } else if ([PhoneNetDiagnosisHelper isEchoReplayPacket: buff len:(int)resultLen] && [remoteAddress isEqualToString: self.host]) { 201 | // to dst server 202 | NSTimeInterval duration = [[NSDate date] timeIntervalSinceDate:_sendDate]; 203 | record.durations[seq] = duration; 204 | record.ip = remoteAddress; 205 | record.status = Enum_Traceroute_Status_finish; 206 | // NSLog(@"PhoneNetTracert , tracert %s , duration:%f",[remoteAddress UTF8String],duration*1000); 207 | res = PNetRecTracertIcmpType_Dest; 208 | } 209 | } 210 | return res; 211 | } 212 | @end 213 | -------------------------------------------------------------------------------- /PhoneNetSDK/PhoneNetSDK/uping/control/PhonePing.mm: -------------------------------------------------------------------------------- 1 | // 2 | // PhonePing.m 3 | // PingDemo 4 | // 5 | // Created by mediaios on 03/08/2018. 6 | // Copyright © 2018 mediaios. All rights reserved. 7 | // 8 | 9 | #import "PhonePing.h" 10 | #import "PhoneNetSDKConst.h" 11 | #include "log4cplus_pn.h" 12 | #import "PNetQueue.h" 13 | 14 | 15 | @interface PhonePing() 16 | { 17 | int socket_client; 18 | struct sockaddr_in remote_addr; 19 | } 20 | @property (nonatomic,assign) BOOL isPing; 21 | 22 | @property (nonatomic,assign) BOOL isStopPingThread; 23 | @property (nonatomic,strong) NSString *host; 24 | @property (nonatomic,strong) NSDate *sendDate; 25 | @property (nonatomic,assign) int pingPacketCount; 26 | @end 27 | 28 | @implementation PhonePing 29 | 30 | - (instancetype)init 31 | { 32 | if ([super init]) { 33 | 34 | _isStopPingThread = NO; 35 | } 36 | return self; 37 | } 38 | 39 | - (void)stopPing 40 | { 41 | self.isStopPingThread = YES; 42 | [self reporterPingResWithSorceIp:self.host ttl:0 timeMillSecond:0 seq:0 icmpId:0 dataSize:0 pingStatus:PhoneNetPingStatusFinished]; 43 | } 44 | 45 | - (BOOL)isPing 46 | { 47 | return !self.isStopPingThread; 48 | } 49 | 50 | - (BOOL)settingUHostSocketAddressWithHost:(NSString *)host 51 | { 52 | const char *hostaddr = [host UTF8String]; 53 | memset(&remote_addr, 0, sizeof(remote_addr)); 54 | remote_addr.sin_addr.s_addr = inet_addr(hostaddr); 55 | 56 | if (remote_addr.sin_addr.s_addr == INADDR_NONE) { 57 | struct hostent *remoteHost = gethostbyname(hostaddr); 58 | if (remoteHost == NULL || remoteHost->h_addr == NULL) { 59 | log4cplus_warn("PhoneNetPing", "access %s DNS error, remove this ip..\n",[host UTF8String]); 60 | return NO; 61 | } 62 | remote_addr.sin_addr = *(struct in_addr *)remoteHost->h_addr; 63 | } 64 | 65 | struct timeval timeout; 66 | timeout.tv_sec = 1; 67 | timeout.tv_usec = 0; 68 | socket_client = socket(AF_INET,SOCK_DGRAM,IPPROTO_ICMP); 69 | int res = setsockopt(socket_client, SOL_SOCKET, SO_RCVTIMEO, &timeout, sizeof(timeout)); 70 | if (res < 0) { 71 | log4cplus_warn("PhoneNetPing", "ping %s , set timeout error..\n",[host UTF8String]); 72 | } 73 | remote_addr.sin_family = AF_INET; 74 | 75 | return YES; 76 | } 77 | 78 | - (NSString *)convertDomainToIp:(NSString *)host 79 | { 80 | const char *hostaddr = [host UTF8String]; 81 | memset(&remote_addr, 0, sizeof(remote_addr)); 82 | remote_addr.sin_addr.s_addr = inet_addr(hostaddr); 83 | 84 | if (remote_addr.sin_addr.s_addr == INADDR_NONE) { 85 | struct hostent *remoteHost = gethostbyname(hostaddr); 86 | if (remoteHost == NULL || remoteHost->h_addr == NULL) { 87 | log4cplus_warn("PhoneNetPing", "access %s DNS error, remove this ip..\n",[host UTF8String]); 88 | return NULL; 89 | } 90 | remote_addr.sin_addr = *(struct in_addr *)remoteHost->h_addr; 91 | return [NSString stringWithFormat:@"%s",inet_ntoa(remote_addr.sin_addr)]; 92 | } 93 | return host; 94 | } 95 | 96 | - (void)startPingHosts:(NSString *)host packetCount:(int)count 97 | { 98 | if ([self settingUHostSocketAddressWithHost:host]) { 99 | self.host = [self convertDomainToIp:host]; 100 | } 101 | 102 | if (self.host == NULL) { 103 | self.isStopPingThread = YES; 104 | log4cplus_warn("PhoneNetPing", "There is no valid domain...\n"); 105 | return; 106 | } 107 | 108 | if (count > 0) { 109 | _pingPacketCount = count; 110 | } 111 | 112 | [PNetQueue pnet_ping_async:^{ 113 | [self sendAndrecevPingPacket]; 114 | }]; 115 | } 116 | 117 | - (void)sendAndrecevPingPacket 118 | { 119 | [self settingUHostSocketAddressWithHost:self.host]; 120 | int index = 0; 121 | BOOL isReceiverRemoteIpPingRes = NO; 122 | 123 | do { 124 | uint16_t identifier = (uint16_t)(KPingIcmpIdBeginNum + index); 125 | UICMPPacket *packet = [PhoneNetDiagnosisHelper constructPacketWithSeq:index andIdentifier:identifier]; 126 | _sendDate = [NSDate date]; 127 | ssize_t sent = sendto(socket_client, packet, sizeof(UICMPPacket), 0, (struct sockaddr *)&remote_addr, (socklen_t)sizeof(struct sockaddr)); 128 | if (sent < 0) { 129 | log4cplus_warn("PhoneNetPing", "ping %s , send icmp packet error..\n",[self.host UTF8String]); 130 | } 131 | 132 | isReceiverRemoteIpPingRes = [self receiverRemoteIpPingRes]; 133 | 134 | if (isReceiverRemoteIpPingRes) { 135 | index++; 136 | } 137 | usleep(1000*500); 138 | } while (!self.isStopPingThread && index < _pingPacketCount && isReceiverRemoteIpPingRes); 139 | 140 | if (index == _pingPacketCount) { 141 | log4cplus_debug("PhoneNetPing", "ping complete..\n"); 142 | /* 143 | int shutdown(int s, int how); // s is socket descriptor 144 | int how can be: 145 | SHUT_RD or 0 Further receives are disallowed 146 | SHUT_WR or 1 Further sends are disallowed 147 | SHUT_RDWR or 2 Further sends and receives are disallowed 148 | */ 149 | shutdown(socket_client, SHUT_RDWR); // 150 | self.isStopPingThread = YES; 151 | 152 | [self reporterPingResWithSorceIp:self.host ttl:0 timeMillSecond:0 seq:0 icmpId:0 dataSize:0 pingStatus:PhoneNetPingStatusFinished]; 153 | } 154 | 155 | } 156 | 157 | - (BOOL)receiverRemoteIpPingRes 158 | { 159 | BOOL res = NO; 160 | struct sockaddr_storage ret_addr; 161 | socklen_t addrLen = sizeof(ret_addr); 162 | void *buffer = malloc(65535); 163 | 164 | size_t bytesRead = recvfrom(socket_client, buffer, 65535, 0, (struct sockaddr *)&ret_addr, &addrLen); 165 | 166 | if ((int)bytesRead < 0) { 167 | 168 | // NSLog(@"PhoneNetPing , ping %@ , receive icmp packet timeout..\n",self.host ); 169 | [self reporterPingResWithSorceIp:self.host ttl:0 timeMillSecond:0 seq:0 icmpId:0 dataSize:0 pingStatus:PhoneNetPingStatusDidTimeout]; 170 | 171 | res = YES; 172 | }else if(bytesRead == 0){ 173 | log4cplus_warn("PhoneNetPing", "ping %s , receive icmp packet error , bytesRead=0",[self.host UTF8String]); 174 | }else{ 175 | 176 | if ([PhoneNetDiagnosisHelper isValidPingResponseWithBuffer:(char *)buffer len:(int)bytesRead]) { 177 | 178 | UICMPPacket *icmpPtr = (UICMPPacket *)[PhoneNetDiagnosisHelper icmpInpacket:(char *)buffer andLen:(int)bytesRead]; 179 | 180 | int seq = OSSwapBigToHostInt16(icmpPtr->seq); 181 | 182 | NSTimeInterval duration = [[NSDate date] timeIntervalSinceDate:_sendDate]; 183 | 184 | int ttl = ((PNetIPHeader *)buffer)->timeToLive; 185 | int size = (int)(bytesRead-sizeof(PNetIPHeader)); 186 | NSString *sorceIp = self.host; 187 | 188 | 189 | // NSLog(@"PhoneNetPing, ping %@ , receive icmp packet..\n",self.host ); 190 | [self reporterPingResWithSorceIp:sorceIp ttl:ttl timeMillSecond:duration*1000 seq:seq icmpId:OSSwapBigToHostInt16(icmpPtr->identifier) dataSize:size pingStatus:PhoneNetPingStatusDidReceivePacket]; 191 | res = YES; 192 | } 193 | 194 | usleep(500); 195 | } 196 | return res; 197 | } 198 | 199 | - (void)reporterPingResWithSorceIp:(NSString *)sorceIp ttl:(int)ttl timeMillSecond:(float)timeMillSec seq:(int)seq icmpId:(int)icmpId dataSize:(int)size pingStatus:(PhoneNetPingStatus)status 200 | { 201 | PPingResModel *pingResModel = [[PPingResModel alloc] init]; 202 | pingResModel.status = status; 203 | pingResModel.IPAddress = sorceIp; 204 | 205 | switch (status) { 206 | case PhoneNetPingStatusDidReceivePacket: 207 | { 208 | pingResModel.ICMPSequence = seq; 209 | pingResModel.timeToLive = ttl; 210 | pingResModel.timeMilliseconds = timeMillSec; 211 | pingResModel.dateBytesLength = size; 212 | } 213 | break; 214 | case PhoneNetPingStatusFinished: 215 | { 216 | pingResModel.ICMPSequence = _pingPacketCount; 217 | } 218 | break; 219 | case PhoneNetPingStatusDidTimeout: 220 | { 221 | pingResModel.ICMPSequence = seq; 222 | } 223 | break; 224 | 225 | default: 226 | break; 227 | } 228 | 229 | dispatch_async(dispatch_get_main_queue(), ^{ 230 | [self.delegate pingResultWithUCPing:self pingResult:pingResModel pingStatus:status]; 231 | }); 232 | 233 | } 234 | 235 | 236 | @end 237 | -------------------------------------------------------------------------------- /PhoneNetSDK/PhoneNetSDK/tools/PNetworkCalculator.m: -------------------------------------------------------------------------------- 1 | // 2 | // NetworkCalculator.m 3 | // MMLanScanDemo 4 | // 5 | // Created by mediaios on 2019/1/22. 6 | // Copyright © 2019 mediaios. All rights reserved. 7 | // 8 | 9 | #import "PNetworkCalculator.h" 10 | 11 | @implementation PNetworkCalculator 12 | 13 | //Getting all the hosts to ping and returns them as array 14 | +(NSArray*)getAllHostsForIP:(NSString*)ipAddress andSubnet:(NSString*)subnetMask { 15 | 16 | //Check if valid IP 17 | if (![self isValidIPAddress:ipAddress] || ![self isValidIPAddress:subnetMask]) { 18 | return nil; 19 | } 20 | 21 | //Converting IP and Subnet to Binary 22 | NSArray *ipArray = [self ipToBinary:ipAddress]; 23 | NSArray *subnetArray = [self ipToBinary:subnetMask]; 24 | 25 | //Getting the first and last IP as array binary 26 | NSArray *firstIPArray = [self firstIPToPingForIPAddress:ipArray subnetMask:subnetArray]; 27 | NSArray *lastIPArray = [self lastIPToPingForIPAddress:ipArray subnetMask:subnetArray]; 28 | 29 | //Looping through all possible IPs and extracting them as NSString in NSArray 30 | NSMutableArray *ipArr = [[NSMutableArray alloc]init]; 31 | 32 | NSArray *currentIP = [NSArray arrayWithArray:firstIPArray]; 33 | 34 | while (![self isEqualBinary:currentIP :lastIPArray]) { 35 | 36 | [ipArr addObject:[self binaryToIP:currentIP]]; 37 | currentIP = [NSArray arrayWithArray:[self increaseBitArray:currentIP]]; 38 | } 39 | //Adding the last one 40 | [ipArr addObject:[self binaryToIP:currentIP]]; 41 | 42 | return ipArr; 43 | } 44 | 45 | #pragma mark - Helper Methods for Net Calc 46 | +(NSArray*)firstIPToPingForIPAddress:(NSArray*)ipArray subnetMask:(NSArray*)subnetArray{ 47 | 48 | NSMutableArray *firstIPArray = [[NSMutableArray alloc]init]; 49 | 50 | //Performing bitwise AND on the IP and the Subnet to find the Network IP 51 | for (int i=0; i < [ipArray count]-1; i++) { 52 | 53 | [firstIPArray addObject:[NSNumber numberWithInt:[ipArray[i] intValue] & [subnetArray[i] intValue]]]; 54 | } 55 | 56 | //Adding the last digit to 1 in order to get the first 57 | //The first IP 58 | [firstIPArray addObject:[NSNumber numberWithInt:1]]; 59 | 60 | //return [self binaryToIP:firstIPArray]; 61 | 62 | return firstIPArray; 63 | } 64 | 65 | +(NSArray*)lastIPToPingForIPAddress:(NSArray*)ipArray subnetMask:(NSArray*)subnetArray{ 66 | 67 | NSMutableArray *lastIPArray = [[NSMutableArray alloc]init]; 68 | 69 | //Reversing the subnet to wild card 70 | NSArray *wildCard = [self subnetToWildCard:subnetArray]; 71 | 72 | //Performing bit wise OR on Wild card and IP to get the last host 73 | for (int i=0; i < [ipArray count]-1; i++) { 74 | 75 | [lastIPArray addObject:[NSNumber numberWithInt:[ipArray[i] intValue] | [wildCard[i] intValue]]]; 76 | } 77 | 78 | //The Last IP 79 | [lastIPArray addObject:[NSNumber numberWithInt:0]]; 80 | 81 | return lastIPArray; 82 | } 83 | 84 | //Increasing by one the IP on binary representation and returns the IP on string 85 | +(NSString*)increaseBit:(NSArray*)ipArray { 86 | 87 | NSMutableArray *ipArr = [[NSMutableArray alloc]initWithArray:ipArray]; 88 | 89 | int ipCount = (int)[ipArr count]; 90 | 91 | for (int i= ipCount-1; i > 0; i--) { 92 | 93 | if ([ipArr[i] intValue]==0) { 94 | 95 | ipArr[i]=[NSNumber numberWithInt:1]; 96 | break; 97 | } 98 | else { 99 | 100 | ipArr[i]=[NSNumber numberWithInt:0]; 101 | if (ipArray[i-1]==0) { 102 | ipArr[i-1]=[NSNumber numberWithInt:1]; 103 | break; 104 | } 105 | } 106 | } 107 | 108 | return [self binaryToIP:ipArr]; 109 | } 110 | 111 | //Increasing by one the IP on binary representation and returns the IP on NSArray (Binarry) 112 | +(NSArray*)increaseBitArray:(NSArray*)ipArray { 113 | 114 | NSMutableArray *ipArr = [[NSMutableArray alloc]initWithArray:ipArray]; 115 | 116 | int ipCount = (int)[ipArr count]; 117 | 118 | for (int i= ipCount-1; i > 0; i--) { 119 | 120 | if ([ipArr[i] intValue]==0) { 121 | 122 | ipArr[i]=[NSNumber numberWithInt:1]; 123 | break; 124 | } 125 | else { 126 | 127 | ipArr[i]=[NSNumber numberWithInt:0]; 128 | if (ipArray[i-1]==0) { 129 | ipArr[i-1]=[NSNumber numberWithInt:1]; 130 | break; 131 | } 132 | } 133 | } 134 | 135 | return ipArr; 136 | } 137 | //Checks if IP is valid 138 | +(BOOL)isValidIPAddress:(NSString*)ipAddress { 139 | 140 | NSArray *ipArray = [ipAddress componentsSeparatedByString:@"."]; 141 | 142 | if ([ipArray count] != 4) { 143 | 144 | return NO; 145 | } 146 | 147 | for (NSString *sub in ipArray) { 148 | 149 | int part = [sub intValue]; 150 | 151 | if (part<0 || part>255) { 152 | return NO; 153 | } 154 | } 155 | 156 | return YES; 157 | } 158 | 159 | //This function convert decimals to binary 160 | +(NSString *)print01:(int)int11{ 161 | 162 | int n =128; 163 | char array12[8]; 164 | NSString *str; 165 | 166 | if(int11==0) 167 | return str= [NSString stringWithFormat:@"00000000"]; 168 | 169 | for(int j=0;j<8;j++) { 170 | if ((int11-n)>=0){ 171 | array12[j]='1'; 172 | int11-=n; 173 | 174 | } 175 | else 176 | array12[j]='0'; 177 | 178 | n=n/2; 179 | } 180 | 181 | str= [[NSString stringWithFormat:@"%s",array12] substringWithRange:NSMakeRange(0,8)]; 182 | 183 | return str; 184 | }; 185 | 186 | //Converts an IP NSString to binary 187 | +(NSArray*)ipToBinary:(NSString*)ipAddress { 188 | 189 | NSArray *ipArray = [ipAddress componentsSeparatedByString:@"."]; 190 | 191 | //Convert the string to the 4(integer) numbers of IP 192 | int int1 = [ipArray[0] intValue]; 193 | int int2 = [ipArray[1] intValue]; 194 | int int3 = [ipArray[2] intValue]; 195 | int int4 = [ipArray[3] intValue]; 196 | 197 | NSString *t1,*t2,*t3,*t4; 198 | 199 | t1= [self print01:int1]; 200 | t2= [self print01:int2]; 201 | t3= [self print01:int3]; 202 | t4= [self print01:int4]; 203 | 204 | NSMutableArray *ipBinary = [[NSMutableArray alloc]initWithCapacity:32]; 205 | 206 | for(int i=0;i<=7;i++) { 207 | 208 | [ipBinary addObject:[NSNumber numberWithInt:[t1 characterAtIndex:i]- '0']]; 209 | } 210 | 211 | for(int i=0;i<=7;i++) { 212 | 213 | [ipBinary addObject:[NSNumber numberWithInt:[t2 characterAtIndex:i]- '0']]; 214 | } 215 | 216 | for(int i=0;i<=7;i++) { 217 | 218 | [ipBinary addObject:[NSNumber numberWithInt:[t3 characterAtIndex:i]- '0']]; 219 | } 220 | 221 | for(int i=0;i<=7;i++) { 222 | 223 | [ipBinary addObject:[NSNumber numberWithInt:[t4 characterAtIndex:i]- '0']]; 224 | } 225 | 226 | return ipBinary; 227 | 228 | } 229 | 230 | //Converts binary IP to NSString 231 | +(NSString*)binaryToIP:(NSArray*)binaryArray { 232 | 233 | int bits=128; 234 | 235 | int t1=0,t2=0,t3=0,t4=0; 236 | 237 | for(int i=0;i<=7;i++){ 238 | 239 | if ([binaryArray[i] intValue]==1) 240 | t1+=bits; 241 | if ([binaryArray[i+8] intValue]==1) 242 | t2+=bits; 243 | if ([binaryArray[i+16] intValue]==1) 244 | t3+=bits; 245 | if ([binaryArray[i+24] intValue]==1) 246 | t4+=bits; 247 | 248 | bits=bits/2; 249 | } 250 | 251 | return [NSString stringWithFormat:@"%d.%d.%d.%d",t1,t2,t3,t4]; 252 | 253 | } 254 | 255 | //Check if the binary IP is equal with another binary IP 256 | +(BOOL)isEqualBinary:(NSArray*)binArray1 :(NSArray*)binArray2{ 257 | 258 | for (int i=0; i < [binArray1 count]; i++) { 259 | 260 | if ([binArray1[i] intValue]!= [binArray2[i] intValue]) { 261 | 262 | return NO; 263 | } 264 | } 265 | 266 | return YES; 267 | } 268 | 269 | //Converts Subnet to Wild Card 270 | +(NSArray*)subnetToWildCard:(NSArray*)subnetArray { 271 | 272 | NSMutableArray *subArray = [NSMutableArray arrayWithArray:subnetArray]; 273 | 274 | for(int i=0; i < [subArray count]; i++) { 275 | 276 | int intNum = [[subArray objectAtIndex:i] intValue]; 277 | 278 | if (intNum==0) { 279 | 280 | [subArray replaceObjectAtIndex:i withObject:[NSNumber numberWithInt:1]]; 281 | } 282 | else { 283 | 284 | [subArray replaceObjectAtIndex:i withObject:[NSNumber numberWithInt:0]]; 285 | } 286 | } 287 | 288 | return subArray; 289 | } 290 | @end 291 | -------------------------------------------------------------------------------- /PhoneNetSDK/PhoneNetSDK/udptracert/PNUdpTraceroute.m: -------------------------------------------------------------------------------- 1 | // 2 | // PNUdpTraceroute.m 3 | // PhoneNetSDK 4 | // 5 | // Created by mediaios on 2019/3/13. 6 | // Copyright © 2019 mediaios. All rights reserved. 7 | // 8 | 9 | #import "PNUdpTraceroute.h" 10 | #include 11 | #import 12 | #import 13 | #import 14 | #import 15 | #import 16 | 17 | #import 18 | #import 19 | 20 | #import 21 | #import 22 | 23 | #import "PNetQueue.h" 24 | 25 | 26 | #define kUpdTracertSendIcmpPacketTimes 3 // 对一个中间节点,发送3个udp包 27 | #define kUdpTracertMaxTTL 30 // Max 30 hops(最多30跳) 28 | 29 | @interface PNUdpTracerouteDetail:NSObject 30 | @property (readonly) NSUInteger seq; // 第几跳 31 | @property (nonatomic,copy) NSString * routeIp; // 中间路由ip 32 | @property (nonatomic) NSTimeInterval *durations; // 存储时间 33 | @property (readonly) NSUInteger sendTimes; // 每个路由发几个包 34 | 35 | @end 36 | 37 | 38 | @implementation PNUdpTracerouteDetail 39 | 40 | - (instancetype)init:(NSUInteger)seq 41 | sendTimes:(NSUInteger)sendTimes 42 | { 43 | if (self = [super init]) { 44 | _routeIp = nil; 45 | _seq = seq; 46 | _durations = (NSTimeInterval *)calloc(sendTimes, sizeof(NSTimeInterval)); 47 | _sendTimes = sendTimes; 48 | } 49 | return self; 50 | } 51 | 52 | - (NSString*)description { 53 | NSMutableString* routeDetail = [[NSMutableString alloc] initWithCapacity:20]; 54 | [routeDetail appendFormat:@"%ld\t", (long)_seq]; 55 | if (_routeIp == nil) { 56 | [routeDetail appendFormat:@" \t"]; 57 | } else { 58 | [routeDetail appendFormat:@"%@\t", _routeIp]; 59 | } 60 | for (int i = 0; i < _sendTimes; i++) { 61 | if (_durations[i] <= 0) { 62 | [routeDetail appendFormat:@"*\t"]; 63 | } else { 64 | [routeDetail appendFormat:@"%.3f ms\t", _durations[i] * 1000]; 65 | } 66 | } 67 | return routeDetail; 68 | } 69 | 70 | - (void)dealloc 71 | { 72 | free(_durations); 73 | } 74 | 75 | @end 76 | 77 | 78 | 79 | @interface PNUdpTraceroute() 80 | { 81 | int socket_send; 82 | int socket_recv; 83 | struct sockaddr_in remote_addr; 84 | } 85 | 86 | @property (nonatomic,copy) NSString *host; 87 | @property (atomic) BOOL isStop; 88 | @property (readonly) NSInteger maxTtl; 89 | @property (nonatomic,copy) PNUdpTracerouteHandler complete; 90 | @property (nonatomic,strong) NSMutableString *traceDetails; 91 | 92 | @end 93 | 94 | @implementation PNUdpTraceroute 95 | 96 | 97 | - (instancetype)init:(NSString *)host 98 | maxTtl:(NSUInteger)maxTtl 99 | complete:(PNUdpTracerouteHandler)complete 100 | { 101 | if (self = [super init]) { 102 | _host = host == nil ? @"" : host; 103 | _maxTtl = maxTtl; 104 | _complete = complete; 105 | _isStop = NO; 106 | } 107 | return self; 108 | } 109 | 110 | - (void)settingUHostSocketAddressWithHost:(NSString *)host 111 | { 112 | const char *hostaddr = [host UTF8String]; 113 | memset(&remote_addr, 0, sizeof(remote_addr)); 114 | remote_addr.sin_len = sizeof(remote_addr); 115 | remote_addr.sin_addr.s_addr = inet_addr(hostaddr); 116 | remote_addr.sin_family = AF_INET; 117 | remote_addr.sin_port = htons(30006); 118 | if (remote_addr.sin_addr.s_addr == INADDR_NONE) { 119 | struct hostent *remoteHost = gethostbyname(hostaddr); 120 | if (remoteHost == NULL || remoteHost->h_addr == NULL) { 121 | // NSLog(@"access DNS error.."); 122 | [_traceDetails appendString:@"access DNS error..\n"]; 123 | _complete(_traceDetails); 124 | return; 125 | } 126 | 127 | remote_addr.sin_addr = *(struct in_addr *)remoteHost->h_addr; 128 | NSString *remoteIp = [NSString stringWithFormat:@"%s",inet_ntoa(remote_addr.sin_addr)]; 129 | [_traceDetails appendString:[NSString stringWithFormat:@"traceroute to %@ \n",remoteIp]]; 130 | // NSLog(@"traceroute to %@",remoteIp); 131 | } 132 | socket_recv = socket(AF_INET,SOCK_DGRAM,IPPROTO_ICMP); 133 | socket_send = socket(AF_INET, SOCK_DGRAM, 0); 134 | } 135 | 136 | - (void)sendAndRec 137 | { 138 | _traceDetails = [NSMutableString stringWithString:@"\n"]; 139 | [self settingUHostSocketAddressWithHost:_host]; 140 | int ttl = 1; 141 | in_addr_t ip = 0; 142 | static NSUInteger conuntinueUnreachableRoutes = 0; 143 | 144 | // 如果连续5个路由节点无响应,则终止traceroute. 145 | do { 146 | int t = setsockopt(socket_send, IPPROTO_IP, IP_TTL, &ttl, sizeof(ttl)); 147 | if (t < 0) { 148 | NSLog(@"error %s\n",strerror(t)); 149 | } 150 | PNUdpTracerouteDetail *trace = [self sendData:ttl ip:&ip]; 151 | if (trace.routeIp == nil) { 152 | conuntinueUnreachableRoutes++; 153 | }else{ 154 | conuntinueUnreachableRoutes = 0; 155 | } 156 | 157 | } while (++ttl <= _maxTtl && ip != remote_addr.sin_addr.s_addr && !_isStop && conuntinueUnreachableRoutes < 5); 158 | 159 | close(socket_send); 160 | close(socket_recv); 161 | 162 | if (!_isStop) { 163 | _isStop = YES; 164 | } 165 | 166 | [_traceDetails appendString:@"udp traceroute complete...\n"]; 167 | _complete(_traceDetails); 168 | // NSLog(@"udp traceroute complete..."); 169 | } 170 | 171 | 172 | - (PNUdpTracerouteDetail *)sendData:(int)ttl ip:(in_addr_t *)ipOut 173 | { 174 | int err = 0; 175 | struct sockaddr_in storageAddr; 176 | socklen_t n = sizeof(struct sockaddr); 177 | static char msg[24] = {0}; 178 | char buff[100]; 179 | 180 | PNUdpTracerouteDetail *trace = [[PNUdpTracerouteDetail alloc] init:ttl sendTimes:kUpdTracertSendIcmpPacketTimes]; 181 | for (int i = 0; i < 3; i++) { 182 | NSDate* startTime = [NSDate date]; 183 | ssize_t sent = sendto(socket_send, msg, sizeof(msg), 0, (struct sockaddr*)&remote_addr, sizeof(struct sockaddr)); 184 | if (sent != sizeof(msg)) { 185 | NSLog(@"error %s",strerror(err)); 186 | break; 187 | } 188 | 189 | struct timeval tv; 190 | tv.tv_sec = 3; 191 | tv.tv_usec = 0; 192 | 193 | fd_set readfds; 194 | FD_ZERO(&readfds); // 初始化套接字集合(清空套接字集合) ,将readfds清零使集合中不含任何fd 195 | FD_SET(socket_recv,&readfds); // 将readfds加入set集合 196 | 197 | /* 198 | https://zhidao.baidu.com/question/315963155.html 199 | 在编程的过程中,经常会遇到许多阻塞的函数,好像read和网络编程时使用的recv, recvfrom函数都是阻塞的函数,当函数不能成功执行的时候,程序就会一直阻塞在这里,无法执行下面的代码。这是就需要用到非阻塞的编程方式,使用selcet函数就可以实现非阻塞编程。 200 | selcet函数是一个轮循函数,即当循环询问文件节点,可设置超时时间,超时时间到了就跳过代码继续往下执行。 201 | Select的函数格式: 202 | int select(int maxfdp,fd_set *readfds,fd_set *writefds,fd_set *errorfds,struct timeval*timeout); 203 | select函数有5个参数 204 | 第一个是所有文件节点的最大值加1,如果我有三个文件节点1、4、6,那第一个参数就为7(6+1) 205 | 第二个是可读文件节点集,类型为fd_set。通过FD_ZERO(&readfd);初始化节点集;然后通过FD_SET(fd, &readfd);把需要监听是否可读的节点加入节点集 206 | 第三个是可写文件节点集中,类型为fd_set。操作方法和第二个参数一样。 207 | 第四个参数是检查节点错误集。 208 | 第五个参数是超时参数,类型为struct timeval,然后可以设置超时时间,分别可设置秒timeout.tv_sec和微秒timeout.tv_usec。 209 | */ 210 | select(socket_recv + 1, &readfds, NULL, NULL,&tv); 211 | if (FD_ISSET(socket_recv,&readfds) > 0) { 212 | ssize_t res = recvfrom(socket_recv, buff, sizeof(buff), 0, (struct sockaddr*)&storageAddr, &n); 213 | if (res < 0) { 214 | err = errno; 215 | NSLog(@"recv error %s\n",strerror(err)); 216 | break; 217 | }else{ 218 | NSTimeInterval duration = [[NSDate date] timeIntervalSinceDate:startTime]; 219 | char ip[16] = {0}; // 存放ip地址 220 | inet_ntop(AF_INET, &storageAddr.sin_addr.s_addr, ip, sizeof(ip)); 221 | *ipOut = storageAddr.sin_addr.s_addr; 222 | NSString *routeIp = [NSString stringWithFormat:@"%s",ip]; 223 | trace.routeIp = routeIp; 224 | trace.durations[i] = duration; 225 | } 226 | } 227 | 228 | } 229 | // NSLog(@"%@",trace); 230 | 231 | [_traceDetails appendString:trace.description]; 232 | [_traceDetails appendString:@"\n"]; 233 | _complete(_traceDetails); 234 | return trace; 235 | } 236 | 237 | + (instancetype)start:(NSString * _Nonnull)host 238 | complete:(PNUdpTracerouteHandler _Nonnull)complete 239 | { 240 | PNUdpTraceroute *udpTrace = [[PNUdpTraceroute alloc] init:host maxTtl:kUdpTracertMaxTTL complete:complete]; 241 | [PNetQueue pnet_async:^{ 242 | [udpTrace sendAndRec]; 243 | }]; 244 | return udpTrace; 245 | } 246 | 247 | + (instancetype)start:(NSString * _Nonnull)host 248 | maxTtl:(NSUInteger)maxTtl 249 | complete:(PNUdpTracerouteHandler _Nonnull)complete 250 | { 251 | PNUdpTraceroute *udpTrace = [[PNUdpTraceroute alloc] init:host maxTtl:maxTtl complete:complete]; 252 | [PNetQueue pnet_async:^{ 253 | [udpTrace sendAndRec]; 254 | }]; 255 | return udpTrace; 256 | } 257 | 258 | - (void)stopUdpTraceroute 259 | { 260 | _isStop = YES; 261 | } 262 | 263 | - (BOOL)isDoingUdpTraceroute 264 | { 265 | return !_isStop; 266 | } 267 | 268 | @end 269 | -------------------------------------------------------------------------------- /PhoneNetSDK/PhoneNetSDK.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 50; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | 3D874B8122A7FC3D00DA8AA8 /* PhonePing.mm in Sources */ = {isa = PBXBuildFile; fileRef = 3D874B8022A7FC3D00DA8AA8 /* PhonePing.mm */; }; 11 | 3D874B8422A8033900DA8AA8 /* PNSamplePing.h in Headers */ = {isa = PBXBuildFile; fileRef = 3D874B8222A8033900DA8AA8 /* PNSamplePing.h */; }; 12 | 3D874B8522A8033900DA8AA8 /* PNSamplePing.mm in Sources */ = {isa = PBXBuildFile; fileRef = 3D874B8322A8033900DA8AA8 /* PNSamplePing.mm */; }; 13 | AA2B9DA02236649400928AF1 /* PNTcpPing.m in Sources */ = {isa = PBXBuildFile; fileRef = AA2B9D9E2236649400928AF1 /* PNTcpPing.m */; }; 14 | AA2B9DA12236649400928AF1 /* PNTcpPing.h in Headers */ = {isa = PBXBuildFile; fileRef = AA2B9D9F2236649400928AF1 /* PNTcpPing.h */; settings = {ATTRIBUTES = (Public, ); }; }; 15 | AA466F7E221FA113009CD053 /* PhoneNetSDKConst.h in Headers */ = {isa = PBXBuildFile; fileRef = AA466F7D221FA113009CD053 /* PhoneNetSDKConst.h */; }; 16 | AA466F82221FBCD1009CD053 /* PhoneNetDiagnosisHelper.h in Headers */ = {isa = PBXBuildFile; fileRef = AA466F80221FBCD1009CD053 /* PhoneNetDiagnosisHelper.h */; }; 17 | AA466F83221FBCD1009CD053 /* PhoneNetDiagnosisHelper.m in Sources */ = {isa = PBXBuildFile; fileRef = AA466F81221FBCD1009CD053 /* PhoneNetDiagnosisHelper.m */; }; 18 | AA466F8F221FBCDA009CD053 /* PhonePing.h in Headers */ = {isa = PBXBuildFile; fileRef = AA466F86221FBCDA009CD053 /* PhonePing.h */; }; 19 | AA466F91221FBCDA009CD053 /* PhonePingService.h in Headers */ = {isa = PBXBuildFile; fileRef = AA466F88221FBCDA009CD053 /* PhonePingService.h */; }; 20 | AA466F92221FBCDA009CD053 /* PhonePingService.mm in Sources */ = {isa = PBXBuildFile; fileRef = AA466F89221FBCDA009CD053 /* PhonePingService.mm */; }; 21 | AA466F93221FBCDA009CD053 /* PPingResModel.h in Headers */ = {isa = PBXBuildFile; fileRef = AA466F8B221FBCDA009CD053 /* PPingResModel.h */; }; 22 | AA466F94221FBCDA009CD053 /* PPingResModel.m in Sources */ = {isa = PBXBuildFile; fileRef = AA466F8C221FBCDA009CD053 /* PPingResModel.m */; }; 23 | AA466F95221FBCDA009CD053 /* PReportPingModel.h in Headers */ = {isa = PBXBuildFile; fileRef = AA466F8D221FBCDA009CD053 /* PReportPingModel.h */; }; 24 | AA466F96221FBCDA009CD053 /* PReportPingModel.m in Sources */ = {isa = PBXBuildFile; fileRef = AA466F8E221FBCDA009CD053 /* PReportPingModel.m */; }; 25 | AA4DDD852174A188009F138B /* PhoneTraceRoute.h in Headers */ = {isa = PBXBuildFile; fileRef = AA4DDD782174A188009F138B /* PhoneTraceRoute.h */; }; 26 | AA4DDD862174A188009F138B /* PhoneTraceRoute.mm in Sources */ = {isa = PBXBuildFile; fileRef = AA4DDD792174A188009F138B /* PhoneTraceRoute.mm */; }; 27 | AA4DDD872174A188009F138B /* PhoneTraceRouteService.h in Headers */ = {isa = PBXBuildFile; fileRef = AA4DDD7A2174A188009F138B /* PhoneTraceRouteService.h */; }; 28 | AA4DDD882174A188009F138B /* PhoneTraceRouteService.m in Sources */ = {isa = PBXBuildFile; fileRef = AA4DDD7B2174A188009F138B /* PhoneTraceRouteService.m */; }; 29 | AA4DDD892174A188009F138B /* PTracerRouteResModel.h in Headers */ = {isa = PBXBuildFile; fileRef = AA4DDD7D2174A188009F138B /* PTracerRouteResModel.h */; }; 30 | AA4DDD8A2174A188009F138B /* PTracerRouteResModel.m in Sources */ = {isa = PBXBuildFile; fileRef = AA4DDD7E2174A188009F138B /* PTracerRouteResModel.m */; }; 31 | AA4DDD972175F220009F138B /* PNetInfoTool.h in Headers */ = {isa = PBXBuildFile; fileRef = AA4DDD952175F220009F138B /* PNetInfoTool.h */; }; 32 | AA4DDD982175F220009F138B /* PNetInfoTool.m in Sources */ = {isa = PBXBuildFile; fileRef = AA4DDD962175F220009F138B /* PNetInfoTool.m */; }; 33 | AA829BA5223908270007E397 /* PNUdpTraceroute.h in Headers */ = {isa = PBXBuildFile; fileRef = AA829BA3223908270007E397 /* PNUdpTraceroute.h */; settings = {ATTRIBUTES = (Public, ); }; }; 34 | AA829BA6223908270007E397 /* PNUdpTraceroute.m in Sources */ = {isa = PBXBuildFile; fileRef = AA829BA4223908270007E397 /* PNUdpTraceroute.m */; }; 35 | AA99ACC622266F6D0099A2E3 /* PNetLog.h in Headers */ = {isa = PBXBuildFile; fileRef = AA99ACC422266F6D0099A2E3 /* PNetLog.h */; }; 36 | AA99ACC722266F6D0099A2E3 /* PNetLog.mm in Sources */ = {isa = PBXBuildFile; fileRef = AA99ACC522266F6D0099A2E3 /* PNetLog.mm */; }; 37 | AAA1BDE322A7B36D00C0D7F5 /* PNetMLanScanner.h in Headers */ = {isa = PBXBuildFile; fileRef = AAA1BDE122A7B36D00C0D7F5 /* PNetMLanScanner.h */; settings = {ATTRIBUTES = (Public, ); }; }; 38 | AAA1BDE422A7B36D00C0D7F5 /* PNetMLanScanner.mm in Sources */ = {isa = PBXBuildFile; fileRef = AAA1BDE222A7B36D00C0D7F5 /* PNetMLanScanner.mm */; }; 39 | AAA1BE2B22A7C95200C0D7F5 /* PNetworkCalculator.m in Sources */ = {isa = PBXBuildFile; fileRef = AAA1BE2922A7C95100C0D7F5 /* PNetworkCalculator.m */; }; 40 | AAA1BE2C22A7C95200C0D7F5 /* PNetworkCalculator.h in Headers */ = {isa = PBXBuildFile; fileRef = AAA1BE2A22A7C95100C0D7F5 /* PNetworkCalculator.h */; }; 41 | AAA4AC462227AE9E00C8AC65 /* PNDomainLookup.h in Headers */ = {isa = PBXBuildFile; fileRef = AAA4AC442227AE9E00C8AC65 /* PNDomainLookup.h */; }; 42 | AAA4AC472227AE9E00C8AC65 /* PNDomainLookup.mm in Sources */ = {isa = PBXBuildFile; fileRef = AAA4AC452227AE9E00C8AC65 /* PNDomainLookup.mm */; }; 43 | AAA4AC4A2227D18800C8AC65 /* PNetTools.h in Headers */ = {isa = PBXBuildFile; fileRef = AAA4AC482227D18800C8AC65 /* PNetTools.h */; }; 44 | AAA4AC4B2227D18800C8AC65 /* PNetTools.m in Sources */ = {isa = PBXBuildFile; fileRef = AAA4AC492227D18800C8AC65 /* PNetTools.m */; }; 45 | AAA4AC4F2227E05C00C8AC65 /* PNPortScan.h in Headers */ = {isa = PBXBuildFile; fileRef = AAA4AC4D2227E05C00C8AC65 /* PNPortScan.h */; }; 46 | AAA4AC502227E05C00C8AC65 /* PNPortScan.mm in Sources */ = {isa = PBXBuildFile; fileRef = AAA4AC4E2227E05C00C8AC65 /* PNPortScan.mm */; }; 47 | AAA8287122166AAB00440AEE /* UCNetworkService.h in Headers */ = {isa = PBXBuildFile; fileRef = AAA8286F22166AAB00440AEE /* UCNetworkService.h */; }; 48 | AAA8287222166AAB00440AEE /* UCNetworkService.mm in Sources */ = {isa = PBXBuildFile; fileRef = AAA8287022166AAB00440AEE /* UCNetworkService.mm */; }; 49 | AAA82875221670AD00440AEE /* PNetReachability.h in Headers */ = {isa = PBXBuildFile; fileRef = AAA82873221670AD00440AEE /* PNetReachability.h */; }; 50 | AAA82876221670AD00440AEE /* PNetReachability.m in Sources */ = {isa = PBXBuildFile; fileRef = AAA82874221670AD00440AEE /* PNetReachability.m */; }; 51 | AAA8287A221686AE00440AEE /* PNetQueue.m in Sources */ = {isa = PBXBuildFile; fileRef = AAA82878221686AE00440AEE /* PNetQueue.m */; }; 52 | AAA8287B221686AE00440AEE /* PNetQueue.h in Headers */ = {isa = PBXBuildFile; fileRef = AAA82879221686AE00440AEE /* PNetQueue.h */; }; 53 | AAA8287E22168CD000440AEE /* PNetModel.h in Headers */ = {isa = PBXBuildFile; fileRef = AAA8287C22168CD000440AEE /* PNetModel.h */; settings = {ATTRIBUTES = (Public, ); }; }; 54 | AAA8287F22168CD000440AEE /* PNetModel.m in Sources */ = {isa = PBXBuildFile; fileRef = AAA8287D22168CD000440AEE /* PNetModel.m */; }; 55 | AAA828832216C6AE00440AEE /* log4cplus_pn.h in Headers */ = {isa = PBXBuildFile; fileRef = AAA828822216C6AE00440AEE /* log4cplus_pn.h */; }; 56 | AAE53C77222675B500DB23A7 /* PhoneNetSDKHelper.h in Headers */ = {isa = PBXBuildFile; fileRef = AAE53C76222675B500DB23A7 /* PhoneNetSDKHelper.h */; settings = {ATTRIBUTES = (Public, ); }; }; 57 | AAFC675721742DE900044085 /* PhoneNetSDK.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = AAFC674D21742DE900044085 /* PhoneNetSDK.framework */; }; 58 | AAFC675C21742DE900044085 /* PhoneNetSDKTests.m in Sources */ = {isa = PBXBuildFile; fileRef = AAFC675B21742DE900044085 /* PhoneNetSDKTests.m */; }; 59 | AAFC675E21742DE900044085 /* PhoneNetSDK.h in Headers */ = {isa = PBXBuildFile; fileRef = AAFC675021742DE900044085 /* PhoneNetSDK.h */; settings = {ATTRIBUTES = (Public, ); }; }; 60 | AAFC6784217436E200044085 /* PhoneNetManager.h in Headers */ = {isa = PBXBuildFile; fileRef = AAFC6782217436E200044085 /* PhoneNetManager.h */; settings = {ATTRIBUTES = (Public, ); }; }; 61 | AAFC6785217436E200044085 /* PhoneNetManager.mm in Sources */ = {isa = PBXBuildFile; fileRef = AAFC6783217436E200044085 /* PhoneNetManager.mm */; }; 62 | AAFC67CD21743E7B00044085 /* libstdc++.tbd in Frameworks */ = {isa = PBXBuildFile; fileRef = AAFC67CB21743E2A00044085 /* libstdc++.tbd */; }; 63 | /* End PBXBuildFile section */ 64 | 65 | /* Begin PBXContainerItemProxy section */ 66 | AAFC675821742DE900044085 /* PBXContainerItemProxy */ = { 67 | isa = PBXContainerItemProxy; 68 | containerPortal = AAFC674421742DE900044085 /* Project object */; 69 | proxyType = 1; 70 | remoteGlobalIDString = AAFC674C21742DE900044085; 71 | remoteInfo = PhoneNetSDK; 72 | }; 73 | /* End PBXContainerItemProxy section */ 74 | 75 | /* Begin PBXFileReference section */ 76 | 3D874B8022A7FC3D00DA8AA8 /* PhonePing.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = PhonePing.mm; sourceTree = ""; }; 77 | 3D874B8222A8033900DA8AA8 /* PNSamplePing.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = PNSamplePing.h; sourceTree = ""; }; 78 | 3D874B8322A8033900DA8AA8 /* PNSamplePing.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = PNSamplePing.mm; sourceTree = ""; }; 79 | AA2B9D9E2236649400928AF1 /* PNTcpPing.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = PNTcpPing.m; sourceTree = ""; }; 80 | AA2B9D9F2236649400928AF1 /* PNTcpPing.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PNTcpPing.h; sourceTree = ""; }; 81 | AA466F7D221FA113009CD053 /* PhoneNetSDKConst.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PhoneNetSDKConst.h; sourceTree = ""; }; 82 | AA466F80221FBCD1009CD053 /* PhoneNetDiagnosisHelper.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PhoneNetDiagnosisHelper.h; sourceTree = ""; }; 83 | AA466F81221FBCD1009CD053 /* PhoneNetDiagnosisHelper.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = PhoneNetDiagnosisHelper.m; sourceTree = ""; }; 84 | AA466F86221FBCDA009CD053 /* PhonePing.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PhonePing.h; sourceTree = ""; }; 85 | AA466F88221FBCDA009CD053 /* PhonePingService.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PhonePingService.h; sourceTree = ""; }; 86 | AA466F89221FBCDA009CD053 /* PhonePingService.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = PhonePingService.mm; sourceTree = ""; }; 87 | AA466F8B221FBCDA009CD053 /* PPingResModel.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PPingResModel.h; sourceTree = ""; }; 88 | AA466F8C221FBCDA009CD053 /* PPingResModel.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = PPingResModel.m; sourceTree = ""; }; 89 | AA466F8D221FBCDA009CD053 /* PReportPingModel.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PReportPingModel.h; sourceTree = ""; }; 90 | AA466F8E221FBCDA009CD053 /* PReportPingModel.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = PReportPingModel.m; sourceTree = ""; }; 91 | AA4DDD782174A188009F138B /* PhoneTraceRoute.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PhoneTraceRoute.h; sourceTree = ""; }; 92 | AA4DDD792174A188009F138B /* PhoneTraceRoute.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = PhoneTraceRoute.mm; sourceTree = ""; }; 93 | AA4DDD7A2174A188009F138B /* PhoneTraceRouteService.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PhoneTraceRouteService.h; sourceTree = ""; }; 94 | AA4DDD7B2174A188009F138B /* PhoneTraceRouteService.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = PhoneTraceRouteService.m; sourceTree = ""; }; 95 | AA4DDD7D2174A188009F138B /* PTracerRouteResModel.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PTracerRouteResModel.h; sourceTree = ""; }; 96 | AA4DDD7E2174A188009F138B /* PTracerRouteResModel.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = PTracerRouteResModel.m; sourceTree = ""; }; 97 | AA4DDD952175F220009F138B /* PNetInfoTool.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = PNetInfoTool.h; sourceTree = ""; }; 98 | AA4DDD962175F220009F138B /* PNetInfoTool.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = PNetInfoTool.m; sourceTree = ""; }; 99 | AA829BA3223908270007E397 /* PNUdpTraceroute.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PNUdpTraceroute.h; sourceTree = ""; }; 100 | AA829BA4223908270007E397 /* PNUdpTraceroute.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = PNUdpTraceroute.m; sourceTree = ""; }; 101 | AA99ACC422266F6D0099A2E3 /* PNetLog.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = PNetLog.h; sourceTree = ""; }; 102 | AA99ACC522266F6D0099A2E3 /* PNetLog.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = PNetLog.mm; sourceTree = ""; }; 103 | AAA1BDE122A7B36D00C0D7F5 /* PNetMLanScanner.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = PNetMLanScanner.h; sourceTree = ""; }; 104 | AAA1BDE222A7B36D00C0D7F5 /* PNetMLanScanner.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = PNetMLanScanner.mm; sourceTree = ""; }; 105 | AAA1BE2922A7C95100C0D7F5 /* PNetworkCalculator.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = PNetworkCalculator.m; sourceTree = ""; }; 106 | AAA1BE2A22A7C95100C0D7F5 /* PNetworkCalculator.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PNetworkCalculator.h; sourceTree = ""; }; 107 | AAA4AC442227AE9E00C8AC65 /* PNDomainLookup.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = PNDomainLookup.h; sourceTree = ""; }; 108 | AAA4AC452227AE9E00C8AC65 /* PNDomainLookup.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = PNDomainLookup.mm; sourceTree = ""; }; 109 | AAA4AC482227D18800C8AC65 /* PNetTools.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = PNetTools.h; sourceTree = ""; }; 110 | AAA4AC492227D18800C8AC65 /* PNetTools.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = PNetTools.m; sourceTree = ""; }; 111 | AAA4AC4D2227E05C00C8AC65 /* PNPortScan.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = PNPortScan.h; sourceTree = ""; }; 112 | AAA4AC4E2227E05C00C8AC65 /* PNPortScan.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = PNPortScan.mm; sourceTree = ""; }; 113 | AAA8286F22166AAB00440AEE /* UCNetworkService.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = UCNetworkService.h; sourceTree = ""; }; 114 | AAA8287022166AAB00440AEE /* UCNetworkService.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = UCNetworkService.mm; sourceTree = ""; }; 115 | AAA82873221670AD00440AEE /* PNetReachability.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PNetReachability.h; sourceTree = ""; }; 116 | AAA82874221670AD00440AEE /* PNetReachability.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = PNetReachability.m; sourceTree = ""; }; 117 | AAA82878221686AE00440AEE /* PNetQueue.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = PNetQueue.m; sourceTree = ""; }; 118 | AAA82879221686AE00440AEE /* PNetQueue.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PNetQueue.h; sourceTree = ""; }; 119 | AAA8287C22168CD000440AEE /* PNetModel.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = PNetModel.h; sourceTree = ""; }; 120 | AAA8287D22168CD000440AEE /* PNetModel.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = PNetModel.m; sourceTree = ""; }; 121 | AAA828822216C6AE00440AEE /* log4cplus_pn.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = log4cplus_pn.h; sourceTree = ""; }; 122 | AAE53C76222675B500DB23A7 /* PhoneNetSDKHelper.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PhoneNetSDKHelper.h; sourceTree = ""; }; 123 | AAFC674D21742DE900044085 /* PhoneNetSDK.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = PhoneNetSDK.framework; sourceTree = BUILT_PRODUCTS_DIR; }; 124 | AAFC675021742DE900044085 /* PhoneNetSDK.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = PhoneNetSDK.h; sourceTree = ""; }; 125 | AAFC675121742DE900044085 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 126 | AAFC675621742DE900044085 /* PhoneNetSDKTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = PhoneNetSDKTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; 127 | AAFC675B21742DE900044085 /* PhoneNetSDKTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = PhoneNetSDKTests.m; sourceTree = ""; }; 128 | AAFC675D21742DE900044085 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 129 | AAFC6782217436E200044085 /* PhoneNetManager.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = PhoneNetManager.h; sourceTree = ""; }; 130 | AAFC6783217436E200044085 /* PhoneNetManager.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = PhoneNetManager.mm; sourceTree = ""; }; 131 | AAFC67C921743E1E00044085 /* libstdc++.6.tbd */ = {isa = PBXFileReference; lastKnownFileType = "sourcecode.text-based-dylib-definition"; name = "libstdc++.6.tbd"; path = "usr/lib/libstdc++.6.tbd"; sourceTree = SDKROOT; }; 132 | AAFC67CB21743E2A00044085 /* libstdc++.tbd */ = {isa = PBXFileReference; lastKnownFileType = "sourcecode.text-based-dylib-definition"; name = "libstdc++.tbd"; path = "usr/lib/libstdc++.tbd"; sourceTree = SDKROOT; }; 133 | /* End PBXFileReference section */ 134 | 135 | /* Begin PBXFrameworksBuildPhase section */ 136 | AAFC674921742DE900044085 /* Frameworks */ = { 137 | isa = PBXFrameworksBuildPhase; 138 | buildActionMask = 2147483647; 139 | files = ( 140 | ); 141 | runOnlyForDeploymentPostprocessing = 0; 142 | }; 143 | AAFC675321742DE900044085 /* Frameworks */ = { 144 | isa = PBXFrameworksBuildPhase; 145 | buildActionMask = 2147483647; 146 | files = ( 147 | AAFC67CD21743E7B00044085 /* libstdc++.tbd in Frameworks */, 148 | AAFC675721742DE900044085 /* PhoneNetSDK.framework in Frameworks */, 149 | ); 150 | runOnlyForDeploymentPostprocessing = 0; 151 | }; 152 | /* End PBXFrameworksBuildPhase section */ 153 | 154 | /* Begin PBXGroup section */ 155 | AA04BDA12179CA3900792244 /* bean */ = { 156 | isa = PBXGroup; 157 | children = ( 158 | AAA8287C22168CD000440AEE /* PNetModel.h */, 159 | AAA8287D22168CD000440AEE /* PNetModel.m */, 160 | ); 161 | path = bean; 162 | sourceTree = ""; 163 | }; 164 | AA2B9D9D2236646200928AF1 /* tcpping */ = { 165 | isa = PBXGroup; 166 | children = ( 167 | AA2B9D9F2236649400928AF1 /* PNTcpPing.h */, 168 | AA2B9D9E2236649400928AF1 /* PNTcpPing.m */, 169 | ); 170 | path = tcpping; 171 | sourceTree = ""; 172 | }; 173 | AA466F7F221FBCD1009CD053 /* common */ = { 174 | isa = PBXGroup; 175 | children = ( 176 | AA466F80221FBCD1009CD053 /* PhoneNetDiagnosisHelper.h */, 177 | AA466F81221FBCD1009CD053 /* PhoneNetDiagnosisHelper.m */, 178 | ); 179 | path = common; 180 | sourceTree = ""; 181 | }; 182 | AA466F84221FBCDA009CD053 /* uping */ = { 183 | isa = PBXGroup; 184 | children = ( 185 | AA466F85221FBCDA009CD053 /* control */, 186 | AA466F8A221FBCDA009CD053 /* model */, 187 | ); 188 | path = uping; 189 | sourceTree = ""; 190 | }; 191 | AA466F85221FBCDA009CD053 /* control */ = { 192 | isa = PBXGroup; 193 | children = ( 194 | AA466F86221FBCDA009CD053 /* PhonePing.h */, 195 | 3D874B8022A7FC3D00DA8AA8 /* PhonePing.mm */, 196 | AA466F88221FBCDA009CD053 /* PhonePingService.h */, 197 | AA466F89221FBCDA009CD053 /* PhonePingService.mm */, 198 | ); 199 | path = control; 200 | sourceTree = ""; 201 | }; 202 | AA466F8A221FBCDA009CD053 /* model */ = { 203 | isa = PBXGroup; 204 | children = ( 205 | AA466F8B221FBCDA009CD053 /* PPingResModel.h */, 206 | AA466F8C221FBCDA009CD053 /* PPingResModel.m */, 207 | AA466F8D221FBCDA009CD053 /* PReportPingModel.h */, 208 | AA466F8E221FBCDA009CD053 /* PReportPingModel.m */, 209 | ); 210 | path = model; 211 | sourceTree = ""; 212 | }; 213 | AA4DDD762174A188009F138B /* utracert */ = { 214 | isa = PBXGroup; 215 | children = ( 216 | AA4DDD772174A188009F138B /* control */, 217 | AA4DDD7C2174A188009F138B /* model */, 218 | ); 219 | name = utracert; 220 | path = PhoneNetSDK/utracert; 221 | sourceTree = SOURCE_ROOT; 222 | }; 223 | AA4DDD772174A188009F138B /* control */ = { 224 | isa = PBXGroup; 225 | children = ( 226 | AA4DDD782174A188009F138B /* PhoneTraceRoute.h */, 227 | AA4DDD792174A188009F138B /* PhoneTraceRoute.mm */, 228 | AA4DDD7A2174A188009F138B /* PhoneTraceRouteService.h */, 229 | AA4DDD7B2174A188009F138B /* PhoneTraceRouteService.m */, 230 | ); 231 | path = control; 232 | sourceTree = ""; 233 | }; 234 | AA4DDD7C2174A188009F138B /* model */ = { 235 | isa = PBXGroup; 236 | children = ( 237 | AA4DDD7D2174A188009F138B /* PTracerRouteResModel.h */, 238 | AA4DDD7E2174A188009F138B /* PTracerRouteResModel.m */, 239 | ); 240 | path = model; 241 | sourceTree = ""; 242 | }; 243 | AA4DDD942175EFE4009F138B /* netInfo */ = { 244 | isa = PBXGroup; 245 | children = ( 246 | AA4DDD952175F220009F138B /* PNetInfoTool.h */, 247 | AA4DDD962175F220009F138B /* PNetInfoTool.m */, 248 | AAA82873221670AD00440AEE /* PNetReachability.h */, 249 | AAA82874221670AD00440AEE /* PNetReachability.m */, 250 | ); 251 | path = netInfo; 252 | sourceTree = ""; 253 | }; 254 | AA829BA2223907E40007E397 /* udptracert */ = { 255 | isa = PBXGroup; 256 | children = ( 257 | AA829BA3223908270007E397 /* PNUdpTraceroute.h */, 258 | AA829BA4223908270007E397 /* PNUdpTraceroute.m */, 259 | ); 260 | path = udptracert; 261 | sourceTree = ""; 262 | }; 263 | AAA1BDDC22A7A6AD00C0D7F5 /* lanscan */ = { 264 | isa = PBXGroup; 265 | children = ( 266 | AAA1BDE122A7B36D00C0D7F5 /* PNetMLanScanner.h */, 267 | AAA1BDE222A7B36D00C0D7F5 /* PNetMLanScanner.mm */, 268 | 3D874B8222A8033900DA8AA8 /* PNSamplePing.h */, 269 | 3D874B8322A8033900DA8AA8 /* PNSamplePing.mm */, 270 | ); 271 | path = lanscan; 272 | sourceTree = ""; 273 | }; 274 | AAA4AC432227AE3C00C8AC65 /* lookup */ = { 275 | isa = PBXGroup; 276 | children = ( 277 | AAA4AC442227AE9E00C8AC65 /* PNDomainLookup.h */, 278 | AAA4AC452227AE9E00C8AC65 /* PNDomainLookup.mm */, 279 | ); 280 | path = lookup; 281 | sourceTree = ""; 282 | }; 283 | AAA4AC4C2227DEBA00C8AC65 /* portscan */ = { 284 | isa = PBXGroup; 285 | children = ( 286 | AAA4AC4D2227E05C00C8AC65 /* PNPortScan.h */, 287 | AAA4AC4E2227E05C00C8AC65 /* PNPortScan.mm */, 288 | ); 289 | path = portscan; 290 | sourceTree = ""; 291 | }; 292 | AAA8286D22166AAB00440AEE /* net */ = { 293 | isa = PBXGroup; 294 | children = ( 295 | AAA8286E22166AAB00440AEE /* control */, 296 | ); 297 | path = net; 298 | sourceTree = ""; 299 | }; 300 | AAA8286E22166AAB00440AEE /* control */ = { 301 | isa = PBXGroup; 302 | children = ( 303 | AAA8286F22166AAB00440AEE /* UCNetworkService.h */, 304 | AAA8287022166AAB00440AEE /* UCNetworkService.mm */, 305 | ); 306 | path = control; 307 | sourceTree = ""; 308 | }; 309 | AAA828772216868900440AEE /* tools */ = { 310 | isa = PBXGroup; 311 | children = ( 312 | AAA1BE2A22A7C95100C0D7F5 /* PNetworkCalculator.h */, 313 | AAA1BE2922A7C95100C0D7F5 /* PNetworkCalculator.m */, 314 | AAA828822216C6AE00440AEE /* log4cplus_pn.h */, 315 | AAA82879221686AE00440AEE /* PNetQueue.h */, 316 | AAA82878221686AE00440AEE /* PNetQueue.m */, 317 | AA99ACC422266F6D0099A2E3 /* PNetLog.h */, 318 | AA99ACC522266F6D0099A2E3 /* PNetLog.mm */, 319 | AAA4AC482227D18800C8AC65 /* PNetTools.h */, 320 | AAA4AC492227D18800C8AC65 /* PNetTools.m */, 321 | ); 322 | path = tools; 323 | sourceTree = ""; 324 | }; 325 | AAFC674321742DE900044085 = { 326 | isa = PBXGroup; 327 | children = ( 328 | AAFC674F21742DE900044085 /* PhoneNetSDK */, 329 | AAFC675A21742DE900044085 /* PhoneNetSDKTests */, 330 | AAFC674E21742DE900044085 /* Products */, 331 | AAFC67C821743E1E00044085 /* Frameworks */, 332 | ); 333 | sourceTree = ""; 334 | }; 335 | AAFC674E21742DE900044085 /* Products */ = { 336 | isa = PBXGroup; 337 | children = ( 338 | AAFC674D21742DE900044085 /* PhoneNetSDK.framework */, 339 | AAFC675621742DE900044085 /* PhoneNetSDKTests.xctest */, 340 | ); 341 | name = Products; 342 | sourceTree = ""; 343 | }; 344 | AAFC674F21742DE900044085 /* PhoneNetSDK */ = { 345 | isa = PBXGroup; 346 | children = ( 347 | AAFC6781217436B300044085 /* public */, 348 | AA466F7F221FBCD1009CD053 /* common */, 349 | AA466F84221FBCDA009CD053 /* uping */, 350 | AAA1BDDC22A7A6AD00C0D7F5 /* lanscan */, 351 | AA2B9D9D2236646200928AF1 /* tcpping */, 352 | AA4DDD762174A188009F138B /* utracert */, 353 | AA829BA2223907E40007E397 /* udptracert */, 354 | AAA4AC432227AE3C00C8AC65 /* lookup */, 355 | AAA4AC4C2227DEBA00C8AC65 /* portscan */, 356 | AAA828772216868900440AEE /* tools */, 357 | AA4DDD942175EFE4009F138B /* netInfo */, 358 | AAA8286D22166AAB00440AEE /* net */, 359 | AAFC675021742DE900044085 /* PhoneNetSDK.h */, 360 | AA466F7D221FA113009CD053 /* PhoneNetSDKConst.h */, 361 | AAFC675121742DE900044085 /* Info.plist */, 362 | ); 363 | path = PhoneNetSDK; 364 | sourceTree = ""; 365 | }; 366 | AAFC675A21742DE900044085 /* PhoneNetSDKTests */ = { 367 | isa = PBXGroup; 368 | children = ( 369 | AAFC675B21742DE900044085 /* PhoneNetSDKTests.m */, 370 | AAFC675D21742DE900044085 /* Info.plist */, 371 | ); 372 | path = PhoneNetSDKTests; 373 | sourceTree = ""; 374 | }; 375 | AAFC6781217436B300044085 /* public */ = { 376 | isa = PBXGroup; 377 | children = ( 378 | AA04BDA12179CA3900792244 /* bean */, 379 | AAE53C76222675B500DB23A7 /* PhoneNetSDKHelper.h */, 380 | AAFC6782217436E200044085 /* PhoneNetManager.h */, 381 | AAFC6783217436E200044085 /* PhoneNetManager.mm */, 382 | ); 383 | path = public; 384 | sourceTree = ""; 385 | }; 386 | AAFC67C821743E1E00044085 /* Frameworks */ = { 387 | isa = PBXGroup; 388 | children = ( 389 | AAFC67CB21743E2A00044085 /* libstdc++.tbd */, 390 | AAFC67C921743E1E00044085 /* libstdc++.6.tbd */, 391 | ); 392 | name = Frameworks; 393 | sourceTree = ""; 394 | }; 395 | /* End PBXGroup section */ 396 | 397 | /* Begin PBXHeadersBuildPhase section */ 398 | AAFC674A21742DE900044085 /* Headers */ = { 399 | isa = PBXHeadersBuildPhase; 400 | buildActionMask = 2147483647; 401 | files = ( 402 | AAA828832216C6AE00440AEE /* log4cplus_pn.h in Headers */, 403 | AA2B9DA12236649400928AF1 /* PNTcpPing.h in Headers */, 404 | AAE53C77222675B500DB23A7 /* PhoneNetSDKHelper.h in Headers */, 405 | AA466F7E221FA113009CD053 /* PhoneNetSDKConst.h in Headers */, 406 | AAA8287B221686AE00440AEE /* PNetQueue.h in Headers */, 407 | AAA1BDE322A7B36D00C0D7F5 /* PNetMLanScanner.h in Headers */, 408 | AA829BA5223908270007E397 /* PNUdpTraceroute.h in Headers */, 409 | AAA8287E22168CD000440AEE /* PNetModel.h in Headers */, 410 | AAA1BE2C22A7C95200C0D7F5 /* PNetworkCalculator.h in Headers */, 411 | AA466F82221FBCD1009CD053 /* PhoneNetDiagnosisHelper.h in Headers */, 412 | AAA82875221670AD00440AEE /* PNetReachability.h in Headers */, 413 | AAA8287122166AAB00440AEE /* UCNetworkService.h in Headers */, 414 | AAA4AC4A2227D18800C8AC65 /* PNetTools.h in Headers */, 415 | 3D874B8422A8033900DA8AA8 /* PNSamplePing.h in Headers */, 416 | AAFC6784217436E200044085 /* PhoneNetManager.h in Headers */, 417 | AA4DDD852174A188009F138B /* PhoneTraceRoute.h in Headers */, 418 | AAA4AC462227AE9E00C8AC65 /* PNDomainLookup.h in Headers */, 419 | AAA4AC4F2227E05C00C8AC65 /* PNPortScan.h in Headers */, 420 | AA466F95221FBCDA009CD053 /* PReportPingModel.h in Headers */, 421 | AA99ACC622266F6D0099A2E3 /* PNetLog.h in Headers */, 422 | AA466F91221FBCDA009CD053 /* PhonePingService.h in Headers */, 423 | AA466F8F221FBCDA009CD053 /* PhonePing.h in Headers */, 424 | AA4DDD972175F220009F138B /* PNetInfoTool.h in Headers */, 425 | AA4DDD892174A188009F138B /* PTracerRouteResModel.h in Headers */, 426 | AAFC675E21742DE900044085 /* PhoneNetSDK.h in Headers */, 427 | AA466F93221FBCDA009CD053 /* PPingResModel.h in Headers */, 428 | AA4DDD872174A188009F138B /* PhoneTraceRouteService.h in Headers */, 429 | ); 430 | runOnlyForDeploymentPostprocessing = 0; 431 | }; 432 | /* End PBXHeadersBuildPhase section */ 433 | 434 | /* Begin PBXNativeTarget section */ 435 | AAFC674C21742DE900044085 /* PhoneNetSDK */ = { 436 | isa = PBXNativeTarget; 437 | buildConfigurationList = AAFC676121742DE900044085 /* Build configuration list for PBXNativeTarget "PhoneNetSDK" */; 438 | buildPhases = ( 439 | AAFC674821742DE900044085 /* Sources */, 440 | AAFC674921742DE900044085 /* Frameworks */, 441 | AAFC674A21742DE900044085 /* Headers */, 442 | AAFC674B21742DE900044085 /* Resources */, 443 | ); 444 | buildRules = ( 445 | ); 446 | dependencies = ( 447 | ); 448 | name = PhoneNetSDK; 449 | productName = PhoneNetSDK; 450 | productReference = AAFC674D21742DE900044085 /* PhoneNetSDK.framework */; 451 | productType = "com.apple.product-type.framework"; 452 | }; 453 | AAFC675521742DE900044085 /* PhoneNetSDKTests */ = { 454 | isa = PBXNativeTarget; 455 | buildConfigurationList = AAFC676421742DE900044085 /* Build configuration list for PBXNativeTarget "PhoneNetSDKTests" */; 456 | buildPhases = ( 457 | AAFC675221742DE900044085 /* Sources */, 458 | AAFC675321742DE900044085 /* Frameworks */, 459 | AAFC675421742DE900044085 /* Resources */, 460 | ); 461 | buildRules = ( 462 | ); 463 | dependencies = ( 464 | AAFC675921742DE900044085 /* PBXTargetDependency */, 465 | ); 466 | name = PhoneNetSDKTests; 467 | productName = PhoneNetSDKTests; 468 | productReference = AAFC675621742DE900044085 /* PhoneNetSDKTests.xctest */; 469 | productType = "com.apple.product-type.bundle.unit-test"; 470 | }; 471 | /* End PBXNativeTarget section */ 472 | 473 | /* Begin PBXProject section */ 474 | AAFC674421742DE900044085 /* Project object */ = { 475 | isa = PBXProject; 476 | attributes = { 477 | LastUpgradeCheck = 0940; 478 | ORGANIZATIONNAME = ucloud; 479 | TargetAttributes = { 480 | AAFC674C21742DE900044085 = { 481 | CreatedOnToolsVersion = 9.4.1; 482 | }; 483 | AAFC675521742DE900044085 = { 484 | CreatedOnToolsVersion = 9.4.1; 485 | }; 486 | }; 487 | }; 488 | buildConfigurationList = AAFC674721742DE900044085 /* Build configuration list for PBXProject "PhoneNetSDK" */; 489 | compatibilityVersion = "Xcode 9.3"; 490 | developmentRegion = en; 491 | hasScannedForEncodings = 0; 492 | knownRegions = ( 493 | en, 494 | ); 495 | mainGroup = AAFC674321742DE900044085; 496 | productRefGroup = AAFC674E21742DE900044085 /* Products */; 497 | projectDirPath = ""; 498 | projectRoot = ""; 499 | targets = ( 500 | AAFC674C21742DE900044085 /* PhoneNetSDK */, 501 | AAFC675521742DE900044085 /* PhoneNetSDKTests */, 502 | ); 503 | }; 504 | /* End PBXProject section */ 505 | 506 | /* Begin PBXResourcesBuildPhase section */ 507 | AAFC674B21742DE900044085 /* Resources */ = { 508 | isa = PBXResourcesBuildPhase; 509 | buildActionMask = 2147483647; 510 | files = ( 511 | ); 512 | runOnlyForDeploymentPostprocessing = 0; 513 | }; 514 | AAFC675421742DE900044085 /* Resources */ = { 515 | isa = PBXResourcesBuildPhase; 516 | buildActionMask = 2147483647; 517 | files = ( 518 | ); 519 | runOnlyForDeploymentPostprocessing = 0; 520 | }; 521 | /* End PBXResourcesBuildPhase section */ 522 | 523 | /* Begin PBXSourcesBuildPhase section */ 524 | AAFC674821742DE900044085 /* Sources */ = { 525 | isa = PBXSourcesBuildPhase; 526 | buildActionMask = 2147483647; 527 | files = ( 528 | AAA82876221670AD00440AEE /* PNetReachability.m in Sources */, 529 | AA829BA6223908270007E397 /* PNUdpTraceroute.m in Sources */, 530 | AA99ACC722266F6D0099A2E3 /* PNetLog.mm in Sources */, 531 | AA2B9DA02236649400928AF1 /* PNTcpPing.m in Sources */, 532 | AA4DDD982175F220009F138B /* PNetInfoTool.m in Sources */, 533 | AAA4AC4B2227D18800C8AC65 /* PNetTools.m in Sources */, 534 | AA4DDD8A2174A188009F138B /* PTracerRouteResModel.m in Sources */, 535 | 3D874B8522A8033900DA8AA8 /* PNSamplePing.mm in Sources */, 536 | AAA4AC472227AE9E00C8AC65 /* PNDomainLookup.mm in Sources */, 537 | AAA1BDE422A7B36D00C0D7F5 /* PNetMLanScanner.mm in Sources */, 538 | AA466F92221FBCDA009CD053 /* PhonePingService.mm in Sources */, 539 | 3D874B8122A7FC3D00DA8AA8 /* PhonePing.mm in Sources */, 540 | AAFC6785217436E200044085 /* PhoneNetManager.mm in Sources */, 541 | AA466F83221FBCD1009CD053 /* PhoneNetDiagnosisHelper.m in Sources */, 542 | AA4DDD862174A188009F138B /* PhoneTraceRoute.mm in Sources */, 543 | AA466F96221FBCDA009CD053 /* PReportPingModel.m in Sources */, 544 | AAA8287F22168CD000440AEE /* PNetModel.m in Sources */, 545 | AAA1BE2B22A7C95200C0D7F5 /* PNetworkCalculator.m in Sources */, 546 | AAA4AC502227E05C00C8AC65 /* PNPortScan.mm in Sources */, 547 | AAA8287A221686AE00440AEE /* PNetQueue.m in Sources */, 548 | AA466F94221FBCDA009CD053 /* PPingResModel.m in Sources */, 549 | AAA8287222166AAB00440AEE /* UCNetworkService.mm in Sources */, 550 | AA4DDD882174A188009F138B /* PhoneTraceRouteService.m in Sources */, 551 | ); 552 | runOnlyForDeploymentPostprocessing = 0; 553 | }; 554 | AAFC675221742DE900044085 /* Sources */ = { 555 | isa = PBXSourcesBuildPhase; 556 | buildActionMask = 2147483647; 557 | files = ( 558 | AAFC675C21742DE900044085 /* PhoneNetSDKTests.m in Sources */, 559 | ); 560 | runOnlyForDeploymentPostprocessing = 0; 561 | }; 562 | /* End PBXSourcesBuildPhase section */ 563 | 564 | /* Begin PBXTargetDependency section */ 565 | AAFC675921742DE900044085 /* PBXTargetDependency */ = { 566 | isa = PBXTargetDependency; 567 | target = AAFC674C21742DE900044085 /* PhoneNetSDK */; 568 | targetProxy = AAFC675821742DE900044085 /* PBXContainerItemProxy */; 569 | }; 570 | /* End PBXTargetDependency section */ 571 | 572 | /* Begin XCBuildConfiguration section */ 573 | AAFC675F21742DE900044085 /* Debug */ = { 574 | isa = XCBuildConfiguration; 575 | buildSettings = { 576 | ALWAYS_SEARCH_USER_PATHS = NO; 577 | CLANG_ANALYZER_NONNULL = YES; 578 | CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; 579 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; 580 | CLANG_CXX_LIBRARY = "libc++"; 581 | CLANG_ENABLE_MODULES = YES; 582 | CLANG_ENABLE_OBJC_ARC = YES; 583 | CLANG_ENABLE_OBJC_WEAK = YES; 584 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 585 | CLANG_WARN_BOOL_CONVERSION = YES; 586 | CLANG_WARN_COMMA = YES; 587 | CLANG_WARN_CONSTANT_CONVERSION = YES; 588 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; 589 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 590 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 591 | CLANG_WARN_EMPTY_BODY = YES; 592 | CLANG_WARN_ENUM_CONVERSION = YES; 593 | CLANG_WARN_INFINITE_RECURSION = YES; 594 | CLANG_WARN_INT_CONVERSION = YES; 595 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 596 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; 597 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 598 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 599 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 600 | CLANG_WARN_STRICT_PROTOTYPES = YES; 601 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 602 | CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; 603 | CLANG_WARN_UNREACHABLE_CODE = YES; 604 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 605 | CODE_SIGN_IDENTITY = "iPhone Developer"; 606 | COPY_PHASE_STRIP = NO; 607 | CURRENT_PROJECT_VERSION = 1; 608 | DEBUG_INFORMATION_FORMAT = dwarf; 609 | ENABLE_STRICT_OBJC_MSGSEND = YES; 610 | ENABLE_TESTABILITY = YES; 611 | GCC_C_LANGUAGE_STANDARD = gnu11; 612 | GCC_DYNAMIC_NO_PIC = NO; 613 | GCC_NO_COMMON_BLOCKS = YES; 614 | GCC_OPTIMIZATION_LEVEL = 0; 615 | GCC_PREPROCESSOR_DEFINITIONS = ( 616 | "DEBUG=1", 617 | "$(inherited)", 618 | ); 619 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 620 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 621 | GCC_WARN_UNDECLARED_SELECTOR = YES; 622 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 623 | GCC_WARN_UNUSED_FUNCTION = YES; 624 | GCC_WARN_UNUSED_VARIABLE = YES; 625 | IPHONEOS_DEPLOYMENT_TARGET = 11.4; 626 | MTL_ENABLE_DEBUG_INFO = YES; 627 | ONLY_ACTIVE_ARCH = YES; 628 | SDKROOT = iphoneos; 629 | VERSIONING_SYSTEM = "apple-generic"; 630 | VERSION_INFO_PREFIX = ""; 631 | }; 632 | name = Debug; 633 | }; 634 | AAFC676021742DE900044085 /* Release */ = { 635 | isa = XCBuildConfiguration; 636 | buildSettings = { 637 | ALWAYS_SEARCH_USER_PATHS = NO; 638 | CLANG_ANALYZER_NONNULL = YES; 639 | CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; 640 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; 641 | CLANG_CXX_LIBRARY = "libc++"; 642 | CLANG_ENABLE_MODULES = YES; 643 | CLANG_ENABLE_OBJC_ARC = YES; 644 | CLANG_ENABLE_OBJC_WEAK = YES; 645 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 646 | CLANG_WARN_BOOL_CONVERSION = YES; 647 | CLANG_WARN_COMMA = YES; 648 | CLANG_WARN_CONSTANT_CONVERSION = YES; 649 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; 650 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 651 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 652 | CLANG_WARN_EMPTY_BODY = YES; 653 | CLANG_WARN_ENUM_CONVERSION = YES; 654 | CLANG_WARN_INFINITE_RECURSION = YES; 655 | CLANG_WARN_INT_CONVERSION = YES; 656 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 657 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; 658 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 659 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 660 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 661 | CLANG_WARN_STRICT_PROTOTYPES = YES; 662 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 663 | CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; 664 | CLANG_WARN_UNREACHABLE_CODE = YES; 665 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 666 | CODE_SIGN_IDENTITY = "iPhone Developer"; 667 | COPY_PHASE_STRIP = NO; 668 | CURRENT_PROJECT_VERSION = 1; 669 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 670 | ENABLE_NS_ASSERTIONS = NO; 671 | ENABLE_STRICT_OBJC_MSGSEND = YES; 672 | GCC_C_LANGUAGE_STANDARD = gnu11; 673 | GCC_NO_COMMON_BLOCKS = YES; 674 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 675 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 676 | GCC_WARN_UNDECLARED_SELECTOR = YES; 677 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 678 | GCC_WARN_UNUSED_FUNCTION = YES; 679 | GCC_WARN_UNUSED_VARIABLE = YES; 680 | IPHONEOS_DEPLOYMENT_TARGET = 11.4; 681 | MTL_ENABLE_DEBUG_INFO = NO; 682 | SDKROOT = iphoneos; 683 | VALIDATE_PRODUCT = YES; 684 | VERSIONING_SYSTEM = "apple-generic"; 685 | VERSION_INFO_PREFIX = ""; 686 | }; 687 | name = Release; 688 | }; 689 | AAFC676221742DE900044085 /* Debug */ = { 690 | isa = XCBuildConfiguration; 691 | buildSettings = { 692 | CODE_SIGN_IDENTITY = ""; 693 | CODE_SIGN_STYLE = Automatic; 694 | CURRENT_PROJECT_VERSION = 12; 695 | DEAD_CODE_STRIPPING = NO; 696 | DEFINES_MODULE = YES; 697 | DEVELOPMENT_TEAM = CFP9KY4MGC; 698 | DYLIB_COMPATIBILITY_VERSION = 1; 699 | DYLIB_CURRENT_VERSION = 1; 700 | DYLIB_INSTALL_NAME_BASE = "@rpath"; 701 | ENABLE_BITCODE = NO; 702 | GCC_INPUT_FILETYPE = automatic; 703 | HEADER_SEARCH_PATHS = "\"$(SRCROOT)/PhoneNetSDK/tools/log4cplus_pn.h\""; 704 | INFOPLIST_FILE = PhoneNetSDK/Info.plist; 705 | INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; 706 | IPHONEOS_DEPLOYMENT_TARGET = 9.0; 707 | LD_RUNPATH_SEARCH_PATHS = ( 708 | "$(inherited)", 709 | "@executable_path/Frameworks", 710 | "@loader_path/Frameworks", 711 | ); 712 | LINK_WITH_STANDARD_LIBRARIES = NO; 713 | MACH_O_TYPE = staticlib; 714 | OTHER_LDFLAGS = "-lc++"; 715 | PRODUCT_BUNDLE_IDENTIFIER = cn.iosmedia.PhoneNetSDK; 716 | PRODUCT_NAME = "$(TARGET_NAME:c99extidentifier)"; 717 | SKIP_INSTALL = YES; 718 | TARGETED_DEVICE_FAMILY = "1,2"; 719 | VALID_ARCHS = "arm64 armv7 armv7s"; 720 | }; 721 | name = Debug; 722 | }; 723 | AAFC676321742DE900044085 /* Release */ = { 724 | isa = XCBuildConfiguration; 725 | buildSettings = { 726 | CODE_SIGN_IDENTITY = ""; 727 | CODE_SIGN_STYLE = Automatic; 728 | CURRENT_PROJECT_VERSION = 12; 729 | DEAD_CODE_STRIPPING = NO; 730 | DEFINES_MODULE = YES; 731 | DEVELOPMENT_TEAM = CFP9KY4MGC; 732 | DYLIB_COMPATIBILITY_VERSION = 1; 733 | DYLIB_CURRENT_VERSION = 1; 734 | DYLIB_INSTALL_NAME_BASE = "@rpath"; 735 | ENABLE_BITCODE = NO; 736 | GCC_INPUT_FILETYPE = automatic; 737 | HEADER_SEARCH_PATHS = "\"$(SRCROOT)/PhoneNetSDK/tools/log4cplus_pn.h\""; 738 | INFOPLIST_FILE = PhoneNetSDK/Info.plist; 739 | INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; 740 | IPHONEOS_DEPLOYMENT_TARGET = 9.0; 741 | LD_RUNPATH_SEARCH_PATHS = ( 742 | "$(inherited)", 743 | "@executable_path/Frameworks", 744 | "@loader_path/Frameworks", 745 | ); 746 | LINK_WITH_STANDARD_LIBRARIES = NO; 747 | MACH_O_TYPE = staticlib; 748 | OTHER_LDFLAGS = "-lc++"; 749 | PRODUCT_BUNDLE_IDENTIFIER = cn.iosmedia.PhoneNetSDK; 750 | PRODUCT_NAME = "$(TARGET_NAME:c99extidentifier)"; 751 | SKIP_INSTALL = YES; 752 | TARGETED_DEVICE_FAMILY = "1,2"; 753 | VALID_ARCHS = "arm64 armv7 armv7s"; 754 | }; 755 | name = Release; 756 | }; 757 | AAFC676521742DE900044085 /* Debug */ = { 758 | isa = XCBuildConfiguration; 759 | buildSettings = { 760 | CODE_SIGN_STYLE = Automatic; 761 | DEVELOPMENT_TEAM = CFP9KY4MGC; 762 | GCC_INPUT_FILETYPE = automatic; 763 | INFOPLIST_FILE = PhoneNetSDKTests/Info.plist; 764 | LD_RUNPATH_SEARCH_PATHS = ( 765 | "$(inherited)", 766 | "@executable_path/Frameworks", 767 | "@loader_path/Frameworks", 768 | ); 769 | OTHER_LDFLAGS = "-lc++"; 770 | PRODUCT_BUNDLE_IDENTIFIER = cn.ucloud.PhoneNetSDKTests; 771 | PRODUCT_NAME = "$(TARGET_NAME)"; 772 | TARGETED_DEVICE_FAMILY = "1,2"; 773 | }; 774 | name = Debug; 775 | }; 776 | AAFC676621742DE900044085 /* Release */ = { 777 | isa = XCBuildConfiguration; 778 | buildSettings = { 779 | CODE_SIGN_STYLE = Automatic; 780 | DEVELOPMENT_TEAM = CFP9KY4MGC; 781 | GCC_INPUT_FILETYPE = automatic; 782 | INFOPLIST_FILE = PhoneNetSDKTests/Info.plist; 783 | LD_RUNPATH_SEARCH_PATHS = ( 784 | "$(inherited)", 785 | "@executable_path/Frameworks", 786 | "@loader_path/Frameworks", 787 | ); 788 | OTHER_LDFLAGS = "-lc++"; 789 | PRODUCT_BUNDLE_IDENTIFIER = cn.ucloud.PhoneNetSDKTests; 790 | PRODUCT_NAME = "$(TARGET_NAME)"; 791 | TARGETED_DEVICE_FAMILY = "1,2"; 792 | }; 793 | name = Release; 794 | }; 795 | /* End XCBuildConfiguration section */ 796 | 797 | /* Begin XCConfigurationList section */ 798 | AAFC674721742DE900044085 /* Build configuration list for PBXProject "PhoneNetSDK" */ = { 799 | isa = XCConfigurationList; 800 | buildConfigurations = ( 801 | AAFC675F21742DE900044085 /* Debug */, 802 | AAFC676021742DE900044085 /* Release */, 803 | ); 804 | defaultConfigurationIsVisible = 0; 805 | defaultConfigurationName = Release; 806 | }; 807 | AAFC676121742DE900044085 /* Build configuration list for PBXNativeTarget "PhoneNetSDK" */ = { 808 | isa = XCConfigurationList; 809 | buildConfigurations = ( 810 | AAFC676221742DE900044085 /* Debug */, 811 | AAFC676321742DE900044085 /* Release */, 812 | ); 813 | defaultConfigurationIsVisible = 0; 814 | defaultConfigurationName = Release; 815 | }; 816 | AAFC676421742DE900044085 /* Build configuration list for PBXNativeTarget "PhoneNetSDKTests" */ = { 817 | isa = XCConfigurationList; 818 | buildConfigurations = ( 819 | AAFC676521742DE900044085 /* Debug */, 820 | AAFC676621742DE900044085 /* Release */, 821 | ); 822 | defaultConfigurationIsVisible = 0; 823 | defaultConfigurationName = Release; 824 | }; 825 | /* End XCConfigurationList section */ 826 | }; 827 | rootObject = AAFC674421742DE900044085 /* Project object */; 828 | } 829 | --------------------------------------------------------------------------------