︙ | | | ︙ | |
109
110
111
112
113
114
115
116
117
118
119
120
121
122
|
/*
* TODO:
*
* - Fallback to TCP
*/
@interface OFDNSResolverSettings: OFObject
{
@public
OFArray OF_GENERIC(OFString *) *_nameServers, *_searchDomains;
of_time_interval_t _timeout;
unsigned int _maxAttempts, _minNumberOfDotsInAbsoluteName;
}
|
>
>
|
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
|
/*
* TODO:
*
* - Fallback to TCP
*/
static of_run_loop_mode_t resolveRunLoopMode = @"of_dns_resolver_resolve_mode";
@interface OFDNSResolverSettings: OFObject
{
@public
OFArray OF_GENERIC(OFString *) *_nameServers, *_searchDomains;
of_time_interval_t _timeout;
unsigned int _maxAttempts, _minNumberOfDotsInAbsoluteName;
}
|
︙ | | | ︙ | |
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
|
nameServersIndex: (size_t)nameServersIndex
searchDomainsIndex: (size_t)searchDomainsIndex
target: (id)target
selector: (SEL)selector
context: (id)context;
@end
@interface OFDNSResolver_ResolveSocketAddressContext: OFObject
{
OFString *_host;
id _target;
SEL _selector;
id _context;
OFMutableArray OF_GENERIC(OF_KINDOF(OFDNSResourceRecord *)) *_records;
OFDNSResolver *_resolver;
|
|
|
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
|
nameServersIndex: (size_t)nameServersIndex
searchDomainsIndex: (size_t)searchDomainsIndex
target: (id)target
selector: (SEL)selector
context: (id)context;
@end
@interface OFDNSResolver_AsyncResolveSocketAddressesContext: OFObject
{
OFString *_host;
id _target;
SEL _selector;
id _context;
OFMutableArray OF_GENERIC(OF_KINDOF(OFDNSResourceRecord *)) *_records;
OFDNSResolver *_resolver;
|
︙ | | | ︙ | |
201
202
203
204
205
206
207
208
209
210
211
212
213
214
|
didResolveDomainName: (OFString *)domainName
answerRecords: (OFDictionary *)answerRecords
authorityRecords: (OFDictionary *)authorityRecords
additionalRecords: (OFDictionary *)additionalRecords
context: (id)context
exception: (id)exception;
@end
@interface OFDNSResolver ()
- (void)of_setDefaults;
- (void)of_obtainSystemConfig;
#if defined(OF_HAVE_FILES) && !defined(OF_NINTENDO_3DS)
- (void)of_parseHosts: (OFString *)path;
# if !defined(OF_WINDOWS) && !defined(OF_AMIGAOS4)
|
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
|
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
|
didResolveDomainName: (OFString *)domainName
answerRecords: (OFDictionary *)answerRecords
authorityRecords: (OFDictionary *)authorityRecords
additionalRecords: (OFDictionary *)additionalRecords
context: (id)context
exception: (id)exception;
@end
@interface OFDNSResolver_ResolveSocketAddressesContext: OFObject
{
@public
bool _done;
OFData *_socketAddresses;
id _exception;
}
- (void)resolver: (OFDNSResolver *)resolver
didResolveDomainName: (OFString *)domainName
socketAddresses: (OFData *)socketAddresses
context: (id)context
exception: (id)exception;
@end
@interface OFDNSResolver ()
- (void)of_setDefaults;
- (void)of_obtainSystemConfig;
#if defined(OF_HAVE_FILES) && !defined(OF_NINTENDO_3DS)
- (void)of_parseHosts: (OFString *)path;
# if !defined(OF_WINDOWS) && !defined(OF_AMIGAOS4)
|
︙ | | | ︙ | |
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
|
[_queryData release];
[_cancelTimer release];
[super dealloc];
}
@end
@implementation OFDNSResolver_ResolveSocketAddressContext
- (instancetype)initWithHost: (OFString *)host
target: (id)target
selector: (SEL)selector
context: (id)context
{
self = [super init];
|
|
|
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
|
[_queryData release];
[_cancelTimer release];
[super dealloc];
}
@end
@implementation OFDNSResolver_AsyncResolveSocketAddressesContext
- (instancetype)initWithHost: (OFString *)host
target: (id)target
selector: (SEL)selector
context: (id)context
{
self = [super init];
|
︙ | | | ︙ | |
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
|
recursion: CNAME_RECURSION
result: _records];
if (_expectedResponses == 0)
[self done];
}
@end
@implementation OFDNSResolver
@synthesize staticHosts = _staticHosts, nameServers = _nameServers;
@synthesize localDomain = _localDomain, searchDomains = _searchDomains;
@synthesize timeout = _timeout, maxAttempts = _maxAttempts;
@synthesize minNumberOfDotsInAbsoluteName = _minNumberOfDotsInAbsoluteName;
@synthesize usesTCP = _usesTCP, configReloadInterval = _configReloadInterval;
|
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
|
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
|
recursion: CNAME_RECURSION
result: _records];
if (_expectedResponses == 0)
[self done];
}
@end
@implementation OFDNSResolver_ResolveSocketAddressesContext
- (void)dealloc
{
[_socketAddresses release];
[_exception release];
[super dealloc];
}
- (void)resolver: (OFDNSResolver *)resolver
didResolveDomainName: (OFString *)domainName
socketAddresses: (OFData *)socketAddresses
context: (id)context
exception: (id)exception
{
_socketAddresses = [socketAddresses retain];
_exception = [exception retain];
_done = true;
}
@end
@implementation OFDNSResolver
@synthesize staticHosts = _staticHosts, nameServers = _nameServers;
@synthesize localDomain = _localDomain, searchDomains = _searchDomains;
@synthesize timeout = _timeout, maxAttempts = _maxAttempts;
@synthesize minNumberOfDotsInAbsoluteName = _minNumberOfDotsInAbsoluteName;
@synthesize usesTCP = _usesTCP, configReloadInterval = _configReloadInterval;
|
︙ | | | ︙ | |
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
|
addressFamily
runLoopMode: (of_run_loop_mode_t)runLoopMode
target: (id)target
selector: (SEL)selector
context: (id)userContext
{
void *pool = objc_autoreleasePoolPush();
OFDNSResolver_ResolveSocketAddressContext *context;
context = [[[OFDNSResolver_ResolveSocketAddressContext alloc]
initWithHost: host
target: target
selector: selector
context: userContext] autorelease];
switch (addressFamily) {
case OF_SOCKET_ADDRESS_FAMILY_IPV4:
|
|
|
|
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
|
addressFamily
runLoopMode: (of_run_loop_mode_t)runLoopMode
target: (id)target
selector: (SEL)selector
context: (id)userContext
{
void *pool = objc_autoreleasePoolPush();
OFDNSResolver_AsyncResolveSocketAddressesContext *context;
context = [[[OFDNSResolver_AsyncResolveSocketAddressesContext alloc]
initWithHost: host
target: target
selector: selector
context: userContext] autorelease];
switch (addressFamily) {
case OF_SOCKET_ADDRESS_FAMILY_IPV4:
|
︙ | | | ︙ | |
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
|
additionalRecords:context:
exception:)
context: [OFNumber numberWithInt:
OF_DNS_RESOURCE_RECORD_TYPE_A]];
objc_autoreleasePoolPop(pool);
}
- (void)close
{
void *pool = objc_autoreleasePoolPush();
OFEnumerator OF_GENERIC(OFDNSResolverQuery *) *enumerator;
OFDNSResolverQuery *query;
|
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
|
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
|
additionalRecords:context:
exception:)
context: [OFNumber numberWithInt:
OF_DNS_RESOURCE_RECORD_TYPE_A]];
objc_autoreleasePoolPop(pool);
}
- (OFData *)resolveSocketAddressesForHost: (OFString *)host
addressFamily: (of_socket_address_family_t)
addressFamily
{
void *pool = objc_autoreleasePoolPush();
OFRunLoop *runLoop = [OFRunLoop currentRunLoop];
OFDNSResolver_ResolveSocketAddressesContext *context;
OFData *ret;
context = [[[OFDNSResolver_ResolveSocketAddressesContext
alloc] init] autorelease];
[self asyncResolveSocketAddressesForHost: host
addressFamily: addressFamily
runLoopMode: resolveRunLoopMode
target: context
selector: @selector(resolver:
didResolveDomainName:
socketAddresses:context:
exception:)
context: nil];
while (!context->_done)
[runLoop runMode: resolveRunLoopMode
beforeDate: nil];
/* Cleanup */
[runLoop runMode: resolveRunLoopMode
beforeDate: [OFDate date]];
if (context->_exception != nil)
@throw context->_exception;
ret = [context->_socketAddresses retain];
objc_autoreleasePoolPop(pool);
return [ret autorelease];
}
- (void)close
{
void *pool = objc_autoreleasePoolPush();
OFEnumerator OF_GENERIC(OFDNSResolverQuery *) *enumerator;
OFDNSResolverQuery *query;
|
︙ | | | ︙ | |