jabberd2
2.2.17
Main Page
Data Structures
Files
File List
Globals
s2s
s2s.h
Go to the documentation of this file.
1
/*
2
* jabberd - Jabber Open Source Server
3
* Copyright (c) 2002 Jeremie Miller, Thomas Muldowney,
4
* Ryan Eatmon, Robert Norris
5
*
6
* This program is free software; you can redistribute it and/or modify
7
* it under the terms of the GNU General Public License as published by
8
* the Free Software Foundation; either version 2 of the License, or
9
* (at your option) any later version.
10
*
11
* This program is distributed in the hope that it will be useful,
12
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the
14
* GNU General Public License for more details.
15
*
16
* You should have received a copy of the GNU General Public License
17
* along with this program; if not, write to the Free Software
18
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA02111-1307USA
19
*/
20
21
#ifdef HAVE_CONFIG_H
22
# include <
config.h
>
23
#endif
24
25
#include "
mio/mio.h
"
26
#include "
sx/sx.h
"
27
28
#ifdef HAVE_SIGNAL_H
29
# include <signal.h>
30
#endif
31
#ifdef HAVE_SYS_STAT_H
32
# include <sys/stat.h>
33
#endif
34
35
#include <udns.h>
36
37
/* forward decl */
38
typedef
struct
host_st
*
host_t
;
39
typedef
struct
s2s_st
*
s2s_t
;
40
typedef
struct
pkt_st
*
pkt_t
;
41
typedef
struct
conn_st
*
conn_t
;
42
typedef
struct
dnsquery_st
*
dnsquery_t
;
43
typedef
struct
dnscache_st
*
dnscache_t
;
44
typedef
struct
dnsres_st
*
dnsres_t
;
45
46
struct
host_st
{
48
char
*
realm
;
49
51
char
*
host_pemfile
;
52
54
char
*
host_cachain
;
55
57
int
host_verify_mode
;
58
};
59
60
struct
s2s_st
{
62
char
*
id
;
63
65
char
*
router_ip
;
66
int
router_port
;
67
char
*
router_user
;
68
char
*
router_pass
;
69
char
*
router_pemfile
;
70
int
router_default
;
71
73
mio_t
mio
;
74
76
sx_env_t
sx_env
;
77
sx_plugin_t
sx_ssl
;
78
sx_plugin_t
sx_sasl
;
79
sx_plugin_t
sx_db
;
80
82
sx_t
router
;
83
mio_fd_t
fd
;
84
86
mio_fd_t
server_fd
;
87
89
config_t
config
;
90
92
log_t
log
;
93
95
log_type_t
log_type
;
96
char
*
log_facility
;
97
char
*
log_ident
;
98
100
long
long
int
packet_count
;
101
char
*
packet_stats
;
102
104
int
retry_init
;
105
int
retry_lost
;
106
int
retry_sleep
;
107
int
retry_left
;
108
110
char
*
local_ip
;
111
int
local_port
;
112
114
char
**
origin_ips
;
115
int
origin_nips
;
116
118
char
*
local_secret
;
119
121
char
*
local_pemfile
;
122
124
char
*
local_cachain
;
125
127
int
local_verify_mode
;
128
130
xht
hosts
;
131
133
int
io_max_fds
;
134
136
int
stanza_size_limit
;
137
139
int
compression
;
140
142
char
**
lookup_srv
;
143
int
lookup_nsrv
;
144
146
int
resolve_aaaa
;
147
149
int
dns_min_ttl
;
150
int
dns_max_ttl
;
151
153
int
etc_hosts_ttl
;
154
156
int
check_interval
;
157
int
check_queue
;
158
int
check_invalid
;
159
int
check_keepalive
;
160
int
check_idle
;
161
int
check_dnscache
;
162
int
retry_limit
;
163
164
time_t
last_queue_check
;
165
time_t
last_invalid_check
;
166
167
time_t
next_check
;
168
time_t
next_expiry
;
169
171
int
require_tls
;
172
int
enable_whitelist
;
173
char
**
whitelist_domains
;
174
int
n_whitelist_domains
;
175
177
jqueue_t
dead
;
178
180
jqueue_t
dead_conn
;
181
183
int
started
;
184
186
int
online
;
187
189
xht
outq
;
190
192
int
out_reuse
;
193
195
xht
out_host
;
196
198
xht
out_dest
;
199
201
xht
in
;
202
204
xht
in_accept
;
205
207
int
udns_fd
;
208
mio_fd_t
udns_mio_fd
;
209
211
xht
dnscache
;
212
int
dns_cache_enabled
;
213
215
xht
dns_bad
;
216
int
dns_bad_timeout
;
217
};
218
219
struct
pkt_st
{
220
nad_t
nad
;
221
222
jid_t
from
;
223
jid_t
to
;
224
225
int
db
;
226
227
char
ip
[
INET6_ADDRSTRLEN
+1];
228
int
port
;
229
};
230
231
typedef
enum
{
232
conn_NONE
,
233
conn_INPROGRESS
,
234
conn_VALID
,
235
conn_INVALID
236
}
conn_state_t
;
237
238
struct
conn_st
{
239
s2s_t
s2s
;
240
241
char
*
key
;
242
char
*
dkey
;
243
244
sx_t
s
;
245
mio_fd_t
fd
;
246
247
char
ip
[
INET6_ADDRSTRLEN
+1];
248
int
port
;
249
251
xht
states
;
252
254
xht
states_time
;
255
257
xht
routes
;
258
259
time_t
init_time
;
260
261
int
online
;
262
264
int
verify
;
265
time_t
last_verify
;
266
268
time_t
last_activity
;
269
time_t
last_packet
;
270
271
unsigned
int
packet_count
;
272
};
273
274
#define DNS_MAX_RESULTS 50
275
277
struct
dnsquery_st
{
278
s2s_t
s2s
;
279
281
char
*
name
;
282
284
int
srv_i
;
285
287
xht
hosts
;
288
290
char
*
cur_host
;
291
293
int
cur_port
;
294
296
time_t
cur_expiry
;
297
299
int
cur_prio
;
300
302
int
cur_weight
;
303
305
xht
results
;
306
308
time_t
expiry
;
309
311
struct
dns_query *
query
;
312
};
313
315
struct
dnscache_st
{
317
char
name
[1024];
318
320
xht
results
;
321
323
time_t
expiry
;
324
325
time_t
init_time
;
326
328
int
pending
;
329
dnsquery_t
query
;
330
};
331
333
struct
dnsres_st
{
335
char
*
key
;
336
338
int
prio
;
339
341
int
weight
;
342
344
time_t
expiry
;
345
};
346
347
extern
sig_atomic_t
s2s_lost_router
;
348
349
int
s2s_router_mio_callback
(
mio_t
m,
mio_action_t
a,
mio_fd_t
fd,
void
*data,
void
*arg);
350
int
s2s_router_sx_callback
(
sx_t
s,
sx_event_t
e,
void
*data,
void
*arg);
351
int
s2s_domain_in_whitelist
(s2s_t s2s,
char
*in_domain);
352
353
char
*
s2s_route_key
(
pool_t
p,
char
*local,
char
*remote);
354
int
s2s_route_key_match
(
char
*local,
char
*remote,
char
*rkey,
int
rkeylen);
355
char
*
s2s_db_key
(
pool_t
p,
char
*secret,
char
*remote,
char
*
id
);
356
char
*
dns_make_ipport
(
char
*host,
int
port);
357
358
int
out_packet
(s2s_t s2s, pkt_t pkt);
359
int
out_route
(s2s_t s2s,
char
*route,
int
routelen, conn_t *out,
int
allow_bad);
360
int
dns_select
(s2s_t s2s,
char
*ip,
int
*port, time_t now, dnscache_t dns,
int
allow_bad);
361
void
dns_resolve_domain
(s2s_t s2s, dnscache_t dns);
362
void
out_resolve
(s2s_t s2s,
char
*domain,
xht
results, time_t expiry);
363
void
out_dialback
(s2s_t s2s, pkt_t pkt);
364
int
out_bounce_domain_queues
(s2s_t s2s,
const
char
*domain,
int
err);
365
int
out_bounce_route_queue
(s2s_t s2s,
char
*rkey,
int
rkeylen,
int
err);
366
int
out_bounce_conn_queues
(conn_t out,
int
err);
367
void
out_flush_domain_queues
(s2s_t s2s,
const
char
*domain);
368
void
out_flush_route_queue
(s2s_t s2s,
char
*rkey,
int
rkeylen);
369
370
int
in_mio_callback
(
mio_t
m,
mio_action_t
a,
mio_fd_t
fd,
void
*data,
void
*arg);
371
372
/* sx flag for outgoing dialback streams */
373
#define S2S_DB_HEADER (1<<10)
374
375
/* max length of FQDN for whitelist matching */
376
#define MAX_DOMAIN_LEN 1023
377
378
int
s2s_db_init
(
sx_env_t
env,
sx_plugin_t
p, va_list args);
379
380
/* union for xhash_iter_get to comply with strict-alias rules for gcc3 */
381
union
xhashv
382
{
383
void
**
val
;
384
char
**
char_val
;
385
conn_t *
conn_val
;
386
conn_state_t
*
state_val
;
387
jqueue_t
*
jq_val
;
388
dnscache_t *
dns_val
;
389
dnsres_t *
dnsres_val
;
390
};
391
392
void
out_pkt_free
(pkt_t pkt);
Generated by
1.8.1.1