ObjXMPP  Diff

Differences From Artifact [890298a587]:

To Artifact [6251193e54]:


1
2
3
4



5
6

7
8
9
10
11
12
13
1



2
3
4
5

6
7
8
9
10
11
12
13

-
-
-
+
+
+

-
+







/*
 * Copyright (c) 2011, 2012, 2013, 2014, 2015
 *     Jonathan Schleifer <js@webkeks.org>
 * Copyright (c) 2011, Florian Zeitz <florob@babelmonkeys.de>
 * Copyright (c) 2011, 2012, 2013, 2014, 2015, 2016
 *     Jonathan Schleifer <js@heap.zone>
 * Copyright (c) 2011, 2012, 2013, 2014, Florian Zeitz <florob@babelmonkeys.de>
 *
 * https://webkeks.org/git/?p=objxmpp.git
 * https://heap.zone/git/?p=objxmpp.git
 *
 * Permission to use, copy, modify, and/or distribute this software for any
 * purpose with or without fee is hereby granted, provided that the above
 * copyright notice and this permission notice is present in all copies.
 *
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
36
37
38
39
40
41
42




43
44
45
46
47
48
49
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53







+
+
+
+







#include <openssl/rand.h>

#import "XMPPSRVLookup.h"

#import <ObjFW/OFSystemInfo.h>

@implementation XMPPSRVEntry
@synthesize priority = _priority, weight = _weight;
@synthesize accumulatedWeight = _accumulatedWeight, port = _port;
@synthesize target = _target;

+ (instancetype)entryWithPriority: (uint16_t)priority
			   weight: (uint16_t)weight
			     port: (uint16_t)port
			   target: (OFString*)target
{
	return [[[self alloc] initWithPriority: priority
					weight: weight
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168


169
170
171
172
173
174
175
133
134
135
136
137
138
139






























140
141
142
143
144
145
146
147
148
149
150
151







-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-



+
+








- (OFString*)description
{
	return [OFString stringWithFormat:
	    @"<%@ priority: %" PRIu16 @", weight: %" PRIu16 @", target: %@:%"
	    PRIu16 @">", [self class], _priority, _weight, _target, _port];
}

- (uint16_t)priority
{
	return _priority;
}

- (uint16_t)weight
{
	return _weight;
}

- (void)setAccumulatedWeight: (uint32_t)accumulatedWeight
{
	_accumulatedWeight = accumulatedWeight;
}

- (uint32_t)accumulatedWeight
{
	return _accumulatedWeight;
}

- (uint16_t)port
{
	return _port;
}

- (OFString*)target
{
	OF_GETTER(_target, true)
}
@end

@implementation XMPPSRVLookup
@synthesize domain = _domain;

+ (instancetype)lookupWithDomain: (OFString*)domain
{
	return [[[self alloc] initWithDomain: domain] autorelease];
}

- initWithDomain: (OFString*)domain
{
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
168
169
170
171
172
173
174





175
176
177
178
179
180
181







-
-
-
-
-







{
	[_list release];
	[_domain release];

	[super dealloc];
}

- (OFString*)domain;
{
	OF_GETTER(_domain, true)
}

- (void)XMPP_lookup
{
	OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init];
	unsigned char *answer = NULL;
	size_t pageSize = [OFSystemInfo pageSize];
	OFString *request;