ObjFW  Check-in [a74c5d6a2d]

Overview
Comment:OFDNSResolver: Call back from correct runLoopMode
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: a74c5d6a2dec3b8a5ffeecc28c560b944aa88f91c3c14097cb0ec9f76b40b193
User & Date: js on 2019-01-03 19:05:11
Other Links: manifest | tags
Context
2019-01-03
19:13
Update copyright check-in: 0509d7a844 user: js tags: trunk
19:05
OFDNSResolver: Call back from correct runLoopMode check-in: a74c5d6a2d user: js tags: trunk
2018-12-28
14:58
ofhttp: Allow reading /etc/ssl from the sandbox check-in: 632999a7ab user: js tags: trunk
Changes

Modified src/OFDNSResolver.m from [7b4ba10f06] to [672d41b078].

2069
2070
2071
2072
2073
2074
2075
2076

2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095


2096
2097
2098


2099

2100
2101
2102








2103
2104
2105
2106
2107
2108
2109
2110

2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132


2133
2134
2135
2136
2137
2138
2139
	OFArray OF_GENERIC(OFString *) *aliases;
	void *pool;
	OFDNSResolver_AsyncResolveSocketAddressesContext *context;

	@try {
		of_socket_address_t address =
		    of_socket_address_parse_ip(host, 0);
		OFData *addresses;


		if (addressFamily != OF_SOCKET_ADDRESS_FAMILY_ANY &&
		    address.family != addressFamily) {
			if ([delegate respondsToSelector: @selector(resolver:
			    didResolveDomainName:socketAddresses:exception:)]) {
				OFInvalidArgumentException *exception =
				    [OFInvalidArgumentException exception];

				[delegate	resolver: self
				    didResolveDomainName: host
					 socketAddresses: nil
					       exception: exception];
			}
			return;
		}

		addresses = [OFData dataWithItems: &address
					 itemSize: sizeof(address)
					    count: 1];



		if ([delegate respondsToSelector: @selector(resolver:
		    didResolveDomainName:socketAddresses:exception:)])


			[delegate	resolver: self

			    didResolveDomainName: host
				 socketAddresses: addresses
				       exception: nil];









		return;
	} @catch (OFInvalidFormatException *e) {
	}

	if ((aliases = [_staticHosts objectForKey: host]) != nil) {
		OFMutableData *addresses = [OFMutableData
		    dataWithItemSize: sizeof(of_socket_address_t)];


		for (OFString *alias in aliases) {
			of_socket_address_t address;

			@try {
				address = of_socket_address_parse_ip(alias, 0);
			} @catch (OFInvalidFormatException *e) {
				continue;
			}

			if (addressFamily != OF_SOCKET_ADDRESS_FAMILY_ANY &&
			    address.family != addressFamily)
				continue;

			[addresses addItem: &address];
		}

		[addresses makeImmutable];

		if ([addresses count] == 0) {
			id exception = nil;
			of_dns_resource_record_type_t recordType = 0;



			switch (addressFamily) {
			case OF_SOCKET_ADDRESS_FAMILY_ANY:
				recordType = OF_DNS_RESOURCE_RECORD_TYPE_ALL;
				break;
			case OF_SOCKET_ADDRESS_FAMILY_IPV4:
				recordType = OF_DNS_RESOURCE_RECORD_TYPE_A;







|
>

|
|
<
<
<
<
<
<
<
<
<
<
<
<
<
|
|
|
>
>


|
>
>
|
>
|
|
|
>
>
>
>
>
>
>
>








>




















<

>
>







2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080













2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132

2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
	OFArray OF_GENERIC(OFString *) *aliases;
	void *pool;
	OFDNSResolver_AsyncResolveSocketAddressesContext *context;

	@try {
		of_socket_address_t address =
		    of_socket_address_parse_ip(host, 0);
		OFData *addresses = nil;
		id exception = nil;

		if (addressFamily == OF_SOCKET_ADDRESS_FAMILY_ANY ||
		    addressFamily == address.family)













			addresses = [OFData dataWithItems: &address
						 itemSize: sizeof(address)
						    count: 1];
		else
			exception = [OFInvalidArgumentException exception];

		if ([delegate respondsToSelector: @selector(resolver:
		    didResolveDomainName:socketAddresses:exception:)]) {
			OFTimer *timer = [OFTimer
			    timerWithTimeInterval: 0
					   target: delegate
					 selector: @selector(resolver:
						       didResolveDomainName:
						       socketAddresses:
						       exception:)
					   object: self
					   object: host
					   object: addresses
					   object: exception
					  repeats: false];
			[[OFRunLoop currentRunLoop] addTimer: timer
						     forMode: runLoopMode];
		}

		return;
	} @catch (OFInvalidFormatException *e) {
	}

	if ((aliases = [_staticHosts objectForKey: host]) != nil) {
		OFMutableData *addresses = [OFMutableData
		    dataWithItemSize: sizeof(of_socket_address_t)];
		id exception = nil;

		for (OFString *alias in aliases) {
			of_socket_address_t address;

			@try {
				address = of_socket_address_parse_ip(alias, 0);
			} @catch (OFInvalidFormatException *e) {
				continue;
			}

			if (addressFamily != OF_SOCKET_ADDRESS_FAMILY_ANY &&
			    address.family != addressFamily)
				continue;

			[addresses addItem: &address];
		}

		[addresses makeImmutable];

		if ([addresses count] == 0) {

			of_dns_resource_record_type_t recordType = 0;

			addresses = nil;

			switch (addressFamily) {
			case OF_SOCKET_ADDRESS_FAMILY_ANY:
				recordType = OF_DNS_RESOURCE_RECORD_TYPE_ALL;
				break;
			case OF_SOCKET_ADDRESS_FAMILY_IPV4:
				recordType = OF_DNS_RESOURCE_RECORD_TYPE_A;
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
2180
2181
2182
2183

				exception = [OFResolveHostFailedException
				    exceptionWithHost: host
					  recordClass: recordClass
					   recordType: recordType
						error: error];
			}


			if ([delegate respondsToSelector: @selector(resolver:
			    didResolveDomainName:socketAddresses:exception:)])


				[delegate	resolver: self

				    didResolveDomainName: host
					 socketAddresses: nil
					       exception: exception];
		}

		if ([delegate respondsToSelector: @selector(resolver:
		    didResolveDomainName:socketAddresses:exception:)])
			[delegate	resolver: self
			    didResolveDomainName: host
				 socketAddresses: addresses
				       exception: nil];





		return;
	}

	pool = objc_autoreleasePoolPush();

	context = [[[OFDNSResolver_AsyncResolveSocketAddressesContext alloc]







|
>
|
|
>
>
|
>
|
|
|
<
|
<
<
<
|
|
|
>
>
>
>







2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175

2176



2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190

				exception = [OFResolveHostFailedException
				    exceptionWithHost: host
					  recordClass: recordClass
					   recordType: recordType
						error: error];
			}
		}

		if ([delegate respondsToSelector: @selector(resolver:
		    didResolveDomainName:socketAddresses:exception:)]) {
			OFTimer *timer = [OFTimer
			    timerWithTimeInterval: 0
					   target: delegate
					 selector: @selector(resolver:
						       didResolveDomainName:
						       socketAddresses:
						       exception:)

					   object: self



					   object: host
					   object: addresses
					   object: exception
					  repeats: false];
			[[OFRunLoop currentRunLoop] addTimer: timer
						     forMode: runLoopMode];
		}

		return;
	}

	pool = objc_autoreleasePoolPush();

	context = [[[OFDNSResolver_AsyncResolveSocketAddressesContext alloc]