ObjFW  Diff

Differences From Artifact [deccb8b1de]:

To Artifact [90b01a441b]:


195
196
197
198
199
200
201
202

203
204
205
206


207








208



209

210
211





212
213
214
215
216
217
218
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];
	char *domain;
	OFString *domain;

	if (gethostname(hostname, 256) != 0)
		return nil;

	domain = [OFString stringWithCString: hostname
				    encoding: [OFLocale encoding]];
	if ((domain = strchr(hostname, '.')) == NULL)

	@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 [OFString stringWithCString: domain + 1
				  encoding: [OFLocale encoding]];
			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];