feat: sync httpdns sdk/platform updates without large binaries
This commit is contained in:
53
HttpDNSSDK/sdk/ios/NewHttpDNS/Model/HttpdnsResult.m
Normal file
53
HttpDNSSDK/sdk/ios/NewHttpDNS/Model/HttpdnsResult.m
Normal file
@@ -0,0 +1,53 @@
|
||||
//
|
||||
// HttpdnsResult.m
|
||||
// TrustHttpDNS
|
||||
//
|
||||
// Created by xuyecan on 2024/5/15.
|
||||
// Copyright © 2024 trustapp.com. All rights reserved.
|
||||
//
|
||||
|
||||
#import "HttpdnsResult.h"
|
||||
|
||||
@implementation HttpdnsResult
|
||||
|
||||
- (BOOL)hasIpv4Address {
|
||||
return self.ips.count > 0;
|
||||
}
|
||||
|
||||
- (BOOL)hasIpv6Address {
|
||||
return self.ipv6s.count > 0;
|
||||
}
|
||||
|
||||
- (nullable NSString *)firstIpv4Address {
|
||||
if (self.ips.count == 0) {
|
||||
return nil;
|
||||
}
|
||||
return self.ips.firstObject;
|
||||
}
|
||||
|
||||
- (nullable NSString *)firstIpv6Address {
|
||||
if (self.ipv6s.count == 0) {
|
||||
return nil;
|
||||
}
|
||||
return self.ipv6s.firstObject;
|
||||
}
|
||||
|
||||
- (NSString *)description {
|
||||
NSMutableString *result = [NSMutableString stringWithFormat:@"Host: %@", self.host];
|
||||
|
||||
if ([self hasIpv4Address]) {
|
||||
[result appendFormat:@", ipv4 Addresses: %@", [self.ips componentsJoinedByString:@", "]];
|
||||
} else {
|
||||
[result appendString:@", ipv4 Addresses: None"];
|
||||
}
|
||||
|
||||
if ([self hasIpv6Address]) {
|
||||
[result appendFormat:@", ipv6 Addresses: %@", [self.ipv6s componentsJoinedByString:@", "]];
|
||||
} else {
|
||||
[result appendString:@", ipv6 Addresses: None"];
|
||||
}
|
||||
|
||||
return [result copy];
|
||||
}
|
||||
|
||||
@end
|
||||
Reference in New Issue
Block a user