195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
|
exception: (id)exception;
@end
static OFString *
domainFromHostname(void)
{
char hostname[256];
char *domain;
if (gethostname(hostname, 256) != 0)
return nil;
if ((domain = strchr(hostname, '.')) == NULL)
return nil;
return [OFString stringWithCString: domain + 1
encoding: [OFLocale encoding]];
}
static bool
isFQDN(OFString *host, OFDNSResolverSettings *settings)
{
const char *UTF8String = [host UTF8String];
size_t length = [host UTF8StringLength];
|
|
>
>
|
>
>
>
>
>
>
>
>
>
>
>
|
|
>
>
>
|
195
196
197
198
199
200
201
202
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
232
233
234
|
exception: (id)exception;
@end
static OFString *
domainFromHostname(void)
{
char hostname[256];
OFString *domain;
if (gethostname(hostname, 256) != 0)
return nil;
domain = [OFString stringWithCString: hostname
encoding: [OFLocale encoding]];
@try {
of_socket_address_parse_ip(domain, 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 = [domain rangeOfString: @"."].location;
if (pos == OF_NOT_FOUND)
return nil;
return [domain substringWithRange:
of_range(pos + 1, [domain length] - pos - 1)];
}
}
static bool
isFQDN(OFString *host, OFDNSResolverSettings *settings)
{
const char *UTF8String = [host UTF8String];
size_t length = [host UTF8StringLength];
|