︙ | | | ︙ | |
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
|
@public
bool _done;
OFData *_addresses;
id _exception;
}
@end
static const of_run_loop_mode_t resolveRunLoopMode =
@"of_host_address_resolver_resolve_mode";
static bool
isFQDN(OFString *host, unsigned int minNumberOfDotsInAbsoluteName)
{
const char *UTF8String;
size_t length;
unsigned int dots;
|
|
|
|
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
|
@public
bool _done;
OFData *_addresses;
id _exception;
}
@end
static const OFRunLoopMode resolveRunLoopMode =
@"OFHostAddressResolverResolveRunLoopMode";
static bool
isFQDN(OFString *host, unsigned int minNumberOfDotsInAbsoluteName)
{
const char *UTF8String;
size_t length;
unsigned int dots;
|
︙ | | | ︙ | |
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
|
dots++;
return (dots >= minNumberOfDotsInAbsoluteName);
}
static bool
addressForRecord(OF_KINDOF(OFDNSResourceRecord *) record,
const of_socket_address_t **address,
of_socket_address_family_t addressFamily)
{
switch ([record recordType]) {
#ifdef OF_HAVE_IPV6
case OF_DNS_RECORD_TYPE_AAAA:
if (addressFamily != OF_SOCKET_ADDRESS_FAMILY_IPV6 &&
addressFamily != OF_SOCKET_ADDRESS_FAMILY_ANY)
return false;
|
|
<
|
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
|
dots++;
return (dots >= minNumberOfDotsInAbsoluteName);
}
static bool
addressForRecord(OF_KINDOF(OFDNSResourceRecord *) record,
const of_socket_address_t **address, OFSocketAddressFamily addressFamily)
{
switch ([record recordType]) {
#ifdef OF_HAVE_IPV6
case OF_DNS_RECORD_TYPE_AAAA:
if (addressFamily != OF_SOCKET_ADDRESS_FAMILY_IPV6 &&
addressFamily != OF_SOCKET_ADDRESS_FAMILY_ANY)
return false;
|
︙ | | | ︙ | |
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
|
}
*address = [record address];
return true;
}
static void
callDelegateInMode(of_run_loop_mode_t runLoopMode,
id <OFDNSResolverHostDelegate> delegate, OFDNSResolver *resolver,
OFString *host, OFData *addresses, id exception)
{
SEL selector = @selector(resolver:didResolveHost:addresses:exception:);
if ([delegate respondsToSelector: selector]) {
OFTimer *timer = [OFTimer
|
|
|
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
|
}
*address = [record address];
return true;
}
static void
callDelegateInMode(OFRunLoopMode runLoopMode,
id <OFDNSResolverHostDelegate> delegate, OFDNSResolver *resolver,
OFString *host, OFData *addresses, id exception)
{
SEL selector = @selector(resolver:didResolveHost:addresses:exception:);
if ([delegate respondsToSelector: selector]) {
OFTimer *timer = [OFTimer
|
︙ | | | ︙ | |
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
|
[[OFRunLoop currentRunLoop] addTimer: timer
forMode: runLoopMode];
}
}
@implementation OFHostAddressResolver: OFObject
- (instancetype)initWithHost: (OFString *)host
addressFamily: (of_socket_address_family_t)addressFamily
resolver: (OFDNSResolver *)resolver
settings: (OFDNSResolverSettings *)settings
runLoopMode: (of_run_loop_mode_t)runLoopMode
delegate: (id <OFDNSResolverHostDelegate>)delegate
{
self = [super init];
@try {
_host = [host copy];
_addressFamily = addressFamily;
|
|
|
|
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
|
[[OFRunLoop currentRunLoop] addTimer: timer
forMode: runLoopMode];
}
}
@implementation OFHostAddressResolver: OFObject
- (instancetype)initWithHost: (OFString *)host
addressFamily: (OFSocketAddressFamily)addressFamily
resolver: (OFDNSResolver *)resolver
settings: (OFDNSResolverSettings *)settings
runLoopMode: (OFRunLoopMode)runLoopMode
delegate: (id <OFDNSResolverHostDelegate>)delegate
{
self = [super init];
@try {
_host = [host copy];
_addressFamily = addressFamily;
|
︙ | | | ︙ | |