ObjXMPP  Check-in [960467b47f]

Overview
Comment:Adjust to ObjFW changes
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 960467b47f6f9c36d7e79a79fc38e3efc55d4adcbb3b1d0c1b7a4e85738a1c78
User & Date: js on 2018-11-04 22:07:56
Other Links: manifest | tags
Context
2018-11-04
23:01
Fix SCRAM auth check-in: 73157b0bcd user: js tags: trunk
22:07
Adjust to ObjFW changes check-in: 960467b47f user: js tags: trunk
2018-01-21
22:48
Adjust to ObjFW changes check-in: 3ea23c8afd user: js tags: trunk
Changes

Modified src/XMPPConnection.m from [d487bb0c33] to [224a0258a2].

344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
		if ((candidate = [enumerator nextObject]) != nil) {
			do {
				@try {
					[_socket
					    connectToHost: [candidate target]
						     port: [candidate port]];
					break;
				} @catch (OFAddressTranslationFailedException
				    *e) {
				} @catch (OFConnectionFailedException *e) {
				}
			} while ((candidate = [enumerator nextObject]) != nil);
		} else
			/* No SRV records -> fall back to A / AAAA record */
			[_socket connectToHost: _domainToASCII
					  port: _port];







|
<







344
345
346
347
348
349
350
351

352
353
354
355
356
357
358
		if ((candidate = [enumerator nextObject]) != nil) {
			do {
				@try {
					[_socket
					    connectToHost: [candidate target]
						     port: [candidate port]];
					break;
				} @catch (OFResolveHostFailedException *e) {

				} @catch (OFConnectionFailedException *e) {
				}
			} while ((candidate = [enumerator nextObject]) != nil);
		} else
			/* No SRV records -> fall back to A / AAAA record */
			[_socket connectToHost: _domainToASCII
					  port: _port];

Modified src/XMPPSRVLookup.m from [d3b6deb6f8] to [bed03f8f6f].

34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#include <arpa/inet.h>
#include <netdb.h>
#include <sys/types.h>
#include <openssl/rand.h>

#import "XMPPSRVLookup.h"

#import <ObjFW/OFLocalization.h>

OF_ASSUME_NONNULL_BEGIN

@interface XMPPSRVLookup ()
- (void)XMPP_lookup;
- (void)XMPP_addEntry: (XMPPSRVEntry *)item;
@end







|







34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#include <arpa/inet.h>
#include <netdb.h>
#include <sys/types.h>
#include <openssl/rand.h>

#import "XMPPSRVLookup.h"

#import <ObjFW/OFLocale.h>

OF_ASSUME_NONNULL_BEGIN

@interface XMPPSRVLookup ()
- (void)XMPP_lookup;
- (void)XMPP_addEntry: (XMPPSRVEntry *)item;
@end
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
		if (dn_expand(ns_msg_base(handle), ns_msg_end(handle),
		    (uint8_t *)&rdata[3], buffer, NS_MAXDNAME) < 1)
			@throw [OFInitializationFailedException
			    exceptionWithClass: [self class]];

		_target = [[OFString alloc]
		    initWithCString: buffer
			   encoding: [OFLocalization encoding]];
	} @catch (id e) {
		[self release];
		@throw e;
	}

	return self;
}







|







114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
		if (dn_expand(ns_msg_base(handle), ns_msg_end(handle),
		    (uint8_t *)&rdata[3], buffer, NS_MAXDNAME) < 1)
			@throw [OFInitializationFailedException
			    exceptionWithClass: [self class]];

		_target = [[OFString alloc]
		    initWithCString: buffer
			   encoding: [OFLocale encoding]];
	} @catch (id e) {
		[self release];
		@throw e;
	}

	return self;
}
191
192
193
194
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

	@try {
		int answerLen, resourceRecordCount, i;
		ns_rr resourceRecord;
		ns_msg handle;

		if (res_ninit(&_resState))
			@throw [OFAddressTranslationFailedException
			    exceptionWithHost: _domain];




		answer = [self allocMemoryWithSize: pageSize];
		answerLen = res_nsearch(&_resState, [request
		    cStringWithEncoding: [OFLocalization encoding]],
		    ns_c_in, ns_t_srv, answer, (int)pageSize);

		if ((answerLen == -1) && ((h_errno == HOST_NOT_FOUND) ||
		    (h_errno == NO_DATA)))
			return;

		if (answerLen < 1 || answerLen > pageSize)
			@throw [OFAddressTranslationFailedException
			    exceptionWithHost: _domain];




		if (ns_initparse(answer, answerLen, &handle))
			@throw [OFAddressTranslationFailedException
			    exceptionWithHost: _domain];




		resourceRecordCount = ns_msg_count(handle, ns_s_an);
		for (i = 0; i < resourceRecordCount; i++) {
			if (ns_parserr(&handle, ns_s_an, i, &resourceRecord))
				continue;

			if (ns_rr_type(resourceRecord) != ns_t_srv ||







|
|
>
>
>


|
|







|
|
>
>
>


|
|
>
>
>







191
192
193
194
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

	@try {
		int answerLen, resourceRecordCount, i;
		ns_rr resourceRecord;
		ns_msg handle;

		if (res_ninit(&_resState))
			@throw [OFResolveHostFailedException
			    exceptionWithHost: _domain
				  recordClass: OF_DNS_RESOURCE_RECORD_CLASS_IN
				   recordType: OF_DNS_RESOURCE_RECORD_TYPE_SRV
					error: OF_DNS_RESOLVER_ERROR_UNKNOWN];

		answer = [self allocMemoryWithSize: pageSize];
		answerLen = res_nsearch(&_resState,
		    [request cStringWithEncoding: [OFLocale encoding]],
		    ns_c_in, ns_t_srv, answer, (int)pageSize);

		if ((answerLen == -1) && ((h_errno == HOST_NOT_FOUND) ||
		    (h_errno == NO_DATA)))
			return;

		if (answerLen < 1 || answerLen > pageSize)
			@throw [OFResolveHostFailedException
			    exceptionWithHost: _domain
				  recordClass: OF_DNS_RESOURCE_RECORD_CLASS_IN
				   recordType: OF_DNS_RESOURCE_RECORD_TYPE_SRV
					error: OF_DNS_RESOLVER_ERROR_UNKNOWN];

		if (ns_initparse(answer, answerLen, &handle))
			@throw [OFResolveHostFailedException
			    exceptionWithHost: _domain
				  recordClass: OF_DNS_RESOURCE_RECORD_CLASS_IN
				   recordType: OF_DNS_RESOURCE_RECORD_TYPE_SRV
					error: OF_DNS_RESOLVER_ERROR_UNKNOWN];

		resourceRecordCount = ns_msg_count(handle, ns_s_an);
		for (i = 0; i < resourceRecordCount; i++) {
			if (ns_parserr(&handle, ns_s_an, i, &resourceRecord))
				continue;

			if (ns_rr_type(resourceRecord) != ns_t_srv ||