︙ | | | ︙ | |
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
|
static OFString *
domainFromHostname(OFString *hostname)
{
if (hostname == nil)
return nil;
@try {
of_socket_address_parse_ip(hostname, 0);
/*
* If we are still here, the host name is a valid IP address.
* We can't use that as local domain.
*/
return nil;
} @catch (OFInvalidFormatException *e) {
/* Not an IP address -> we can use it if it contains a dot. */
size_t pos = [hostname rangeOfString: @"."].location;
if (pos == OF_NOT_FOUND)
return nil;
return [hostname substringFromIndex: pos + 1];
}
}
#endif
|
|
|
|
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
|
static OFString *
domainFromHostname(OFString *hostname)
{
if (hostname == nil)
return nil;
@try {
OFSocketAddressParseIP(hostname, 0);
/*
* If we are still here, the host name is a valid IP address.
* We can't use that as local domain.
*/
return nil;
} @catch (OFInvalidFormatException *e) {
/* Not an IP address -> we can use it if it contains a dot. */
size_t pos = [hostname rangeOfString: @"."].location;
if (pos == OFNotFound)
return nil;
return [hostname substringFromIndex: pos + 1];
}
}
#endif
|
︙ | | | ︙ | |
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
|
static OFArray OF_GENERIC(OFString *) *
parseNetStackArray(OFString *string)
{
if (![string hasPrefix: @"["] || ![string hasSuffix: @"]"])
return nil;
string = [string substringWithRange: of_range(1, string.length - 2)];
return [string componentsSeparatedByString: @"|"];
}
#endif
@implementation OFDNSResolverSettings
- (void)dealloc
|
|
|
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
|
static OFArray OF_GENERIC(OFString *) *
parseNetStackArray(OFString *string)
{
if (![string hasPrefix: @"["] || ![string hasSuffix: @"]"])
return nil;
string = [string substringWithRange: OFRangeMake(1, string.length - 2)];
return [string componentsSeparatedByString: @"|"];
}
#endif
@implementation OFDNSResolverSettings
- (void)dealloc
|
︙ | | | ︙ | |
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
|
while ((line = [file readLine]) != nil) {
OFArray *components, *hosts;
size_t pos;
OFString *address;
pos = [line rangeOfString: @"#"].location;
if (pos != OF_NOT_FOUND)
line = [line substringToIndex: pos];
components = [line
componentsSeparatedByCharactersInSet: whitespaceCharacterSet
options: OF_STRING_SKIP_EMPTY];
if (components.count < 2)
continue;
address = components.firstObject;
hosts = [components objectsInRange:
of_range(1, components.count - 1)];
for (OFString *host in hosts) {
OFMutableArray *addresses =
[staticHosts objectForKey: host];
if (addresses == nil) {
addresses = [OFMutableArray array];
|
|
|
|
|
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
|
while ((line = [file readLine]) != nil) {
OFArray *components, *hosts;
size_t pos;
OFString *address;
pos = [line rangeOfString: @"#"].location;
if (pos != OFNotFound)
line = [line substringToIndex: pos];
components = [line
componentsSeparatedByCharactersInSet: whitespaceCharacterSet
options: OFStringSkipEmptyComponents];
if (components.count < 2)
continue;
address = components.firstObject;
hosts = [components objectsInRange:
OFRangeMake(1, components.count - 1)];
for (OFString *host in hosts) {
OFMutableArray *addresses =
[staticHosts objectForKey: host];
if (addresses == nil) {
addresses = [OFMutableArray array];
|
︙ | | | ︙ | |
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
|
while ((line = [file readLine]) != nil) {
void *pool2 = objc_autoreleasePoolPush();
size_t pos;
OFArray *components, *arguments;
OFString *option;
pos = [line indexOfCharacterFromSet: commentCharacters];
if (pos != OF_NOT_FOUND)
line = [line substringToIndex: pos];
components = [line
componentsSeparatedByCharactersInSet: whitespaceCharacterSet
options: OF_STRING_SKIP_EMPTY];
if (components.count < 2) {
objc_autoreleasePoolPop(pool2);
continue;
}
option = components.firstObject;
arguments = [components objectsInRange:
of_range(1, components.count - 1)];
if ([option isEqual: @"nameserver"]) {
if (arguments.count != 1) {
objc_autoreleasePoolPop(pool2);
continue;
}
|
|
|
|
|
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
|
while ((line = [file readLine]) != nil) {
void *pool2 = objc_autoreleasePoolPush();
size_t pos;
OFArray *components, *arguments;
OFString *option;
pos = [line indexOfCharacterFromSet: commentCharacters];
if (pos != OFNotFound)
line = [line substringToIndex: pos];
components = [line
componentsSeparatedByCharactersInSet: whitespaceCharacterSet
options: OFStringSkipEmptyComponents];
if (components.count < 2) {
objc_autoreleasePoolPop(pool2);
continue;
}
option = components.firstObject;
arguments = [components objectsInRange:
OFRangeMake(1, components.count - 1)];
if ([option isEqual: @"nameserver"]) {
if (arguments.count != 1) {
objc_autoreleasePoolPop(pool2);
continue;
}
|
︙ | | | ︙ | |
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
|
}
# endif
#endif
#ifdef OF_WINDOWS
- (void)obtainWindowsSystemConfig
{
of_string_encoding_t encoding = [OFLocale encoding];
OFMutableArray *nameServers;
/*
* We need more space than FIXED_INFO in case we have more than one
* name server, but we also want it to be properly aligned, meaning we
* can't just get a buffer of bytes. Thus, we just get space for 8.
*/
FIXED_INFO fixedInfo[8];
|
|
|
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
|
}
# endif
#endif
#ifdef OF_WINDOWS
- (void)obtainWindowsSystemConfig
{
OFStringEncoding encoding = [OFLocale encoding];
OFMutableArray *nameServers;
/*
* We need more space than FIXED_INFO in case we have more than one
* name server, but we also want it to be properly aligned, meaning we
* can't just get a buffer of bytes. Thus, we just get space for 8.
*/
FIXED_INFO fixedInfo[8];
|
︙ | | | ︙ | |
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
|
OFArray *hosts;
if (components.count < 2)
continue;
address = components.firstObject;
hosts = [components objectsInRange:
of_range(1, components.count - 1)];
for (OFString *host in hosts) {
OFMutableArray *addresses =
[staticHosts objectForKey: host];
if (addresses == nil) {
addresses = [OFMutableArray array];
|
|
|
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
|
OFArray *hosts;
if (components.count < 2)
continue;
address = components.firstObject;
hosts = [components objectsInRange:
OFRangeMake(1, components.count - 1)];
for (OFString *host in hosts) {
OFMutableArray *addresses =
[staticHosts objectForKey: host];
if (addresses == nil) {
addresses = [OFMutableArray array];
|
︙ | | | ︙ | |
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
|
}
#endif
#ifdef OF_AMIGAOS4
- (void)obtainAmigaOS4SystemConfig
{
OFMutableArray *nameServers = [OFMutableArray array];
of_string_encoding_t encoding = [OFLocale encoding];
struct List *nameServerList = ObtainDomainNameServerList();
char buffer[MAXHOSTNAMELEN];
if (nameServerList == NULL)
@throw [OFOutOfMemoryException exception];
@try {
|
|
|
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
|
}
#endif
#ifdef OF_AMIGAOS4
- (void)obtainAmigaOS4SystemConfig
{
OFMutableArray *nameServers = [OFMutableArray array];
OFStringEncoding encoding = [OFLocale encoding];
struct List *nameServerList = ObtainDomainNameServerList();
char buffer[MAXHOSTNAMELEN];
if (nameServerList == NULL)
@throw [OFOutOfMemoryException exception];
@try {
|
︙ | | | ︙ | |