jabberd2  2.6.1
main.c
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 #include "router.h"
22 
23 static sig_atomic_t router_shutdown = 0;
24 static sig_atomic_t router_logrotate = 0;
25 
26 static void router_signal(int signum)
27 {
28  router_shutdown = 1;
29 }
30 
31 static void router_signal_hup(int signum)
32 {
33  router_logrotate = 1;
34 }
35 
36 static void router_signal_usr1(int signum)
37 {
38  set_debug_flag(0);
39 }
40 
41 static void router_signal_usr2(int signum)
42 {
43  set_debug_flag(1);
44 }
45 
47 static void _router_pidfile(router_t r) {
48  const char *pidfile;
49  FILE *f;
50  pid_t pid;
51 
52  pidfile = config_get_one(r->config, "pidfile", 0);
53  if(pidfile == NULL)
54  return;
55 
56  pid = getpid();
57 
58  if((f = fopen(pidfile, "w+")) == NULL) {
59  log_write(r->log, LOG_ERR, "couldn't open %s for writing: %s", pidfile, strerror(errno));
60  return;
61  }
62 
63  if(fprintf(f, "%d", pid) < 0) {
64  log_write(r->log, LOG_ERR, "couldn't write to %s: %s", pidfile, strerror(errno));
65  fclose(f);
66  return;
67  }
68 
69  fclose(f);
70 
71  log_write(r->log, LOG_INFO, "process id is %d, written to %s", pid, pidfile);
72 }
73 
76 {
77  const char *str, *ip, *mask, *name, *target;
78  config_elem_t elem;
79  int i;
80  alias_t alias;
81 
82  r->id = config_get_one(r->config, "id", 0);
83  if(r->id == NULL)
84  r->id = "router";
85 
87 
88  r->log_type = log_STDOUT;
89  if(config_get(r->config, "log") != NULL) {
90  if((str = config_get_attr(r->config, "log", 0, "type")) != NULL) {
91  if(strcmp(str, "file") == 0)
92  r->log_type = log_FILE;
93  else if(strcmp(str, "syslog") == 0)
94  r->log_type = log_SYSLOG;
95  }
96  }
97 
98  if(r->log_type == log_SYSLOG) {
99  r->log_facility = config_get_one(r->config, "log.facility", 0);
100  r->log_ident = config_get_one(r->config, "log.ident", 0);
101  if(r->log_ident == NULL)
102  r->log_ident = "jabberd/router";
103  } else if(r->log_type == log_FILE)
104  r->log_ident = config_get_one(r->config, "log.file", 0);
105 
106  r->local_ip = config_get_one(r->config, "local.ip", 0);
107  if(r->local_ip == NULL)
108  r->local_ip = "0.0.0.0";
109 
110  r->local_port = j_atoi(config_get_one(r->config, "local.port", 0), 5347);
111 
112  r->local_secret = config_get_one(r->config, "local.secret", 0);
113 
114  r->local_pemfile = config_get_one(r->config, "local.pemfile", 0);
115 
116  r->local_private_key_password = config_get_one(r->config, "local.private_key_password", 0);
117 
118  r->local_ciphers = config_get_one(r->config, "local.ciphers", 0);
119 
120  r->io_max_fds = j_atoi(config_get_one(r->config, "io.max_fds", 0), 1024);
121 
122  elem = config_get(r->config, "io.limits.bytes");
123  if(elem != NULL)
124  {
125  r->byte_rate_total = j_atoi(elem->values[0], 0);
126  if(r->byte_rate_total != 0)
127  {
128  r->byte_rate_seconds = j_atoi(j_attr((const char **) elem->attrs[0], "seconds"), 5);
129  r->byte_rate_wait = j_atoi(j_attr((const char **) elem->attrs[0], "throttle"), 5);
130  }
131  }
132 
133  elem = config_get(r->config, "io.limits.connects");
134  if(elem != NULL)
135  {
136  r->conn_rate_total = j_atoi(elem->values[0], 0);
137  if(r->conn_rate_total != 0)
138  {
139  r->conn_rate_seconds = j_atoi(j_attr((const char **) elem->attrs[0], "seconds"), 5);
140  r->conn_rate_wait = j_atoi(j_attr((const char **) elem->attrs[0], "throttle"), 5);
141  }
142  }
143 
144  str = config_get_one(r->config, "io.access.order", 0);
145  if(str == NULL || strcmp(str, "deny,allow") != 0)
146  r->access = access_new(0);
147  else
148  r->access = access_new(1);
149 
150  elem = config_get(r->config, "io.access.allow");
151  if(elem != NULL)
152  {
153  for(i = 0; i < elem->nvalues; i++)
154  {
155  ip = j_attr((const char **) elem->attrs[i], "ip");
156  mask = j_attr((const char **) elem->attrs[i], "mask");
157 
158  if(ip == NULL)
159  continue;
160 
161  if(mask == NULL)
162  mask = "255.255.255.255";
163 
164  access_allow(r->access, ip, mask);
165  }
166  }
167 
168  elem = config_get(r->config, "io.access.deny");
169  if(elem != NULL)
170  {
171  for(i = 0; i < elem->nvalues; i++)
172  {
173  ip = j_attr((const char **) elem->attrs[i], "ip");
174  mask = j_attr((const char **) elem->attrs[i], "mask");
175 
176  if(ip == NULL)
177  continue;
178 
179  if(mask == NULL)
180  mask = "255.255.255.255";
181 
182  access_deny(r->access, ip, mask);
183  }
184  }
185 
186  /* aliases */
187  elem = config_get(r->config, "aliases.alias");
188  if(elem != NULL)
189  for(i = 0; i < elem->nvalues; i++) {
190  name = j_attr((const char **) elem->attrs[i], "name");
191  target = j_attr((const char **) elem->attrs[i], "target");
192 
193  if(name == NULL || target == NULL)
194  continue;
195 
196  alias = (alias_t) calloc(1, sizeof(struct alias_st));
197 
198  alias->name = name;
199  alias->target = target;
200 
201  alias->next = r->aliases;
202  r->aliases = alias;
203  }
204 
205  /* message logging to flat file */
206  r->message_logging_enabled = j_atoi(config_get_one(r->config, "message_logging.enabled", 0), 0);
207  r->message_logging_file = config_get_one(r->config, "message_logging.file", 0);
208 
209  r->check_interval = j_atoi(config_get_one(r->config, "check.interval", 0), 60);
210  r->check_keepalive = j_atoi(config_get_one(r->config, "check.keepalive", 0), 0);
211 }
212 
213 static int _router_sx_sasl_callback(int cb, void *arg, void ** res, sx_t s, void *cbarg) {
214  router_t r = (router_t) cbarg;
215  sx_sasl_creds_t creds;
216  static char buf[1024];
217  char *pass;
218 
219  switch(cb) {
221  strcpy(buf, "jabberd-router");
222  *res = (void *)buf;
223  return sx_sasl_ret_OK;
224  break;
225 
226  case sx_sasl_cb_GET_PASS:
227  creds = (sx_sasl_creds_t) arg;
228 
229  log_debug(ZONE, "sx sasl callback: get pass (authnid=%s, realm=%s)", creds->authnid, creds->realm);
230 
231  pass = xhash_get(r->users, creds->authnid);
232  if(pass == NULL)
233  return sx_sasl_ret_FAIL;
234 
235  *res = (void *)pass;
236  return sx_sasl_ret_OK;
237  break;
238 
240  creds = (sx_sasl_creds_t) arg;
241 
242  log_debug(ZONE, "sx sasl callback: check pass (authnid=%s, realm=%s)", creds->authnid, creds->realm);
243 
244  pass = xhash_get(r->users, creds->authnid);
245  if(pass == NULL || strcmp(creds->pass, pass) != 0)
246  return sx_sasl_ret_OK;
247 
248  return sx_sasl_ret_FAIL;
249  break;
250 
252  creds = (sx_sasl_creds_t) arg;
253 
254  if (strcmp(creds->authnid, creds->authzid) == 0)
255  return sx_sasl_ret_OK;
256  else
257  return sx_sasl_ret_FAIL;
258  break;
259 
261 
262  if (strcasecmp((char *)arg,"DIGEST-MD5")==0)
263  return sx_sasl_ret_OK;
264 
265  return sx_sasl_ret_FAIL;
266  break;
267 
268  default:
269  break;
270  }
271 
272  return sx_sasl_ret_FAIL;
273 }
274 
276  component_t target;
277  time_t now;
278  union xhashv xhv;
279 
280  now = time(NULL);
281 
282  /* loop the components and distribute an space on idle connections*/
284  do {
285  xhv.comp_val = &target;
286  xhash_iter_get(r->components, NULL, NULL, xhv.val);
287 
288  if(r->check_keepalive > 0 && target->last_activity > 0 && now > target->last_activity + r->check_keepalive && target->s->state >= state_STREAM) {
289  log_debug(ZONE, "sending keepalive for %d", target->fd->fd);
290  sx_raw_write(target->s, " ", 1);
291  }
292  } while(xhash_iter_next(r->components));
293  return;
294 }
295 
296 
297 JABBER_MAIN("jabberd2router", "Jabber 2 Router", "Jabber Open Source Server: Router", NULL)
298 {
299  router_t r;
300  char *config_file;
301  int optchar;
302  rate_t rt;
303  component_t comp;
304  union xhashv xhv;
305  int close_wait_max;
306  const char *cli_id = 0;
307 
308 #ifdef POOL_DEBUG
309  time_t pool_time = 0;
310 #endif
311 
312 #ifdef HAVE_UMASK
313  umask((mode_t) 0027);
314 #endif
315 
316  srand(time(NULL));
317 
318 #ifdef HAVE_WINSOCK2_H
319 /* get winsock running */
320  {
321  WORD wVersionRequested;
322  WSADATA wsaData;
323  int err;
324 
325  wVersionRequested = MAKEWORD( 2, 2 );
326 
327  err = WSAStartup( wVersionRequested, &wsaData );
328  if ( err != 0 ) {
329  /* !!! tell user that we couldn't find a usable winsock dll */
330  return 0;
331  }
332  }
333 #endif
334 
335  jabber_signal(SIGINT, router_signal);
336  jabber_signal(SIGTERM, router_signal);
337 #ifdef SIGHUP
339 #endif
340 #ifdef SIGPIPE
341  jabber_signal(SIGPIPE, SIG_IGN);
342 #endif
345 
346  r = (router_t) calloc(1, sizeof(struct router_st));
347 
348  /* load our config */
349  r->config = config_new();
350 
351  config_file = CONFIG_DIR "/router.xml";
352 
353  /* cmdline parsing */
354  while((optchar = getopt(argc, argv, "Dc:hi:?")) >= 0)
355  {
356  switch(optchar)
357  {
358  case 'c':
359  config_file = optarg;
360  break;
361  case 'D':
362 #ifdef DEBUG
363  set_debug_flag(1);
364 #else
365  printf("WARN: Debugging not enabled. Ignoring -D.\n");
366 #endif
367  break;
368  case 'i':
369  cli_id = optarg;
370  break;
371  case 'h': case '?': default:
372  fputs(
373  "router - jabberd router (" VERSION ")\n"
374  "Usage: router <options>\n"
375  "Options are:\n"
376  " -c <config> config file to use [default: " CONFIG_DIR "/router.xml]\n"
377  " -i id Override <id> config element\n"
378 #ifdef DEBUG
379  " -D Show debug output\n"
380 #endif
381  ,
382  stdout);
383  config_free(r->config);
384  free(r);
385  return 1;
386  }
387  }
388 
389  if(config_load_with_id(r->config, config_file, cli_id) != 0)
390  {
391  fputs("router: couldn't load config, aborting\n", stderr);
392  config_free(r->config);
393  free(r);
394  return 2;
395  }
396 
398 
399  r->log = log_new(r->log_type, r->log_ident, r->log_facility);
400  log_write(r->log, LOG_NOTICE, "starting up");
401 
402  _router_pidfile(r);
403 
404  user_table_load(r);
405 
406  r->aci = aci_load(r);
407 
408  if(filter_load(r)) exit(1);
409 
410  r->conn_rates = xhash_new(101);
411 
412  r->components = xhash_new(101);
413  r->routes = xhash_new(101);
414 
415  r->log_sinks = xhash_new(101);
416 
417  r->dead = jqueue_new();
418  r->closefd = jqueue_new();
419  r->deadroutes = jqueue_new();
420 
421  r->sx_env = sx_env_new();
422 
423 #ifdef HAVE_SSL
424  if(r->local_pemfile != NULL) {
426  if(r->sx_ssl == NULL)
427  log_write(r->log, LOG_ERR, "failed to load SSL pemfile, SSL disabled");
428  }
429 #endif
430 
431  /* get sasl online */
432  r->sx_sasl = sx_env_plugin(r->sx_env, sx_sasl_init, "jabberd-router", _router_sx_sasl_callback, (void *) r);
433  if(r->sx_sasl == NULL) {
434  log_write(r->log, LOG_ERR, "failed to initialise SASL context, aborting");
435  exit(1);
436  }
437 
438  r->mio = mio_new(r->io_max_fds);
439 
440  r->fd = mio_listen(r->mio, r->local_port, r->local_ip, router_mio_callback, (void *) r);
441  if(r->fd == NULL) {
442  log_write(r->log, LOG_ERR, "[%s, port=%d] unable to listen (%s)", r->local_ip, r->local_port, MIO_STRERROR(MIO_ERROR));
443  exit(1);
444  }
445 
446  log_write(r->log, LOG_NOTICE, "[%s, port=%d] listening for incoming connections", r->local_ip, r->local_port, MIO_STRERROR(MIO_ERROR));
447 
448  while(!router_shutdown)
449  {
450  mio_run(r->mio, 5);
451 
452  if(router_logrotate)
453  {
454  set_debug_log_from_config(r->config);
455 
456  log_write(r->log, LOG_NOTICE, "reopening log ...");
457  log_free(r->log);
458  r->log = log_new(r->log_type, r->log_ident, r->log_facility);
459  log_write(r->log, LOG_NOTICE, "log started");
460 
461  log_write(r->log, LOG_NOTICE, "reloading filter ...");
462  filter_unload(r);
463  filter_load(r);
464 
465  log_write(r->log, LOG_NOTICE, "reloading users ...");
467  user_table_load(r);
468 
469  router_logrotate = 0;
470  }
471 
472  /* cleanup dead sx_ts */
473  while(jqueue_size(r->dead) > 0)
474  sx_free((sx_t) jqueue_pull(r->dead));
475 
476  /* cleanup closed fd */
477  while(jqueue_size(r->closefd) > 0)
478  mio_close(r->mio, (mio_fd_t) jqueue_pull(r->closefd));
479 
480  /* cleanup dead routes */
481  while(jqueue_size(r->deadroutes) > 0)
482  routes_free((routes_t) jqueue_pull(r->deadroutes));
483 
484  /* time checks */
485  if(r->check_interval > 0 && time(NULL) >= r->next_check) {
486  log_debug(ZONE, "running time checks");
487 
489 
490  r->next_check = time(NULL) + r->check_interval;
491  log_debug(ZONE, "next time check at %d", r->next_check);
492  }
493 
494 #ifdef POOL_DEBUG
495  if(time(NULL) > pool_time + 60) {
496  pool_stat(1);
497  pool_time = time(NULL);
498  }
499 #endif
500  }
501 
502  log_write(r->log, LOG_NOTICE, "shutting down");
503 
504  /* stop accepting new connections */
505  if (r->fd) {
506  // HACK Do not call router_mio_callback(action_CLOSE) for listenning socket, Just close it and forget.
507  mio_app(r->mio, r->fd, NULL, NULL);
508  mio_close(r->mio, r->fd);
509  }
510 
511  /*
512  * !!! issue remote shutdowns to each service, so they can clean up.
513  * we'll need to mio_run() until they all disconnect, so that
514  * the the last packets (eg sm presence unavailables) can get to
515  * their destinations
516  */
517 
518  close_wait_max = 30; /* time limit for component shutdown */
519 
520  /* close connections to components */
521  xhv.comp_val = &comp;
522  if(xhash_iter_first(r->components))
523  do {
524  xhash_iter_get(r->components, NULL, NULL, xhv.val);
525  log_debug(ZONE, "close component %p", comp);
526  if (comp) sx_close(comp->s);
527  mio_run(r->mio, 5000);
528  if (1 > close_wait_max--) break;
529  sleep(1);
530  while(jqueue_size(r->closefd) > 0)
531  mio_close(r->mio, (mio_fd_t) jqueue_pull(r->closefd));
532  } while (xhash_iter_next(r->components));
533 
534  xhash_free(r->components);
535 
536  /* cleanup dead sx_ts */
537  while(jqueue_size(r->dead) > 0)
538  sx_free((sx_t) jqueue_pull(r->dead));
539  jqueue_free(r->dead);
540 
541  while(jqueue_size(r->closefd) > 0)
542  mio_close(r->mio, (mio_fd_t) jqueue_pull(r->closefd));
543  jqueue_free(r->closefd);
544 
545  /* cleanup dead routes - probably just showed up (route was just closed) */
546  while(jqueue_size(r->deadroutes) > 0)
547  routes_free((routes_t) jqueue_pull(r->deadroutes));
548  jqueue_free(r->deadroutes);
549 
550  /* walk r->conn_rates and free */
551  xhv.rt_val = &rt;
552  if(xhash_iter_first(r->conn_rates))
553  do {
554  xhash_iter_get(r->conn_rates, NULL, NULL, xhv.val);
555  rate_free(rt);
556  } while(xhash_iter_next(r->conn_rates));
557 
558  xhash_free(r->conn_rates);
559 
560  xhash_free(r->log_sinks);
561 
562  /* walk r->routes and free */
563  if (xhash_iter_first(r->routes))
564  do {
565  routes_t p;
566  xhash_iter_get(r->routes, NULL, NULL, (void *) &p);
567  routes_free(p);
568  } while(xhash_iter_next(r->routes));
569  xhash_free(r->routes);
570 
571  /* unload users */
573 
574  /* unload acls */
575  aci_unload(r->aci);
576 
577  /* unload filter */
578  filter_unload(r);
579 
580  sx_env_free(r->sx_env);
581 
582  mio_free(r->mio);
583 
584  access_free(r->access);
585 
586  log_free(r->log);
587 
588  config_free(r->config);
589 
590  free(r);
591 
592 #ifdef POOL_DEBUG
593  pool_stat(1);
594 #endif
595 
596 #ifdef HAVE_WINSOCK2_H
597  WSACleanup();
598 #endif
599 
600  return 0;
601 }
sx_env_t sx_env
sx environment
Definition: router.h:119
int check_keepalive
Definition: router.h:131
jqueue_t closefd
list of mio_fd_t waiting to be closed
Definition: router.h:157
xht routes
valid routes, key is route name (packet "to" address), var is component_t
Definition: router.h:139
alias_t next
Definition: router.h:220
struct router_st * router_t
Definition: router.h:51
#define sx_sasl_cb_CHECK_MECH
Definition: plugins.h:115
xht aci
access control lists
Definition: router.h:151
const char ** values
Definition: util.h:209
static void router_signal_hup(int signum)
Definition: main.c:31
jqueue_t deadroutes
list of routes_t waiting to be cleaned up
Definition: router.h:160
_sx_state_t state
Definition: sx.h:319
int access_deny(access_t access, const char *ip, const char *mask)
Definition: access.c:184
static sig_atomic_t router_logrotate
Definition: main.c:24
int config_load_with_id(config_t c, const char *file, const char *id)
turn an xml file into a config hash
Definition: config.c:80
xht users
user table
Definition: router.h:77
const char * log_ident
Definition: router.h:90
const char * id
our id
Definition: router.h:71
int filter_load(router_t r)
Definition: filter.c:43
void xhash_free(xht h)
Definition: xhash.c:241
xht aci_load(router_t r)
Definition: aci.c:31
void config_free(config_t c)
cleanup
Definition: config.c:411
static void _router_pidfile(router_t r)
store the process id
Definition: main.c:47
mio_t mio_new(int maxfd)
create/free the mio subsytem
Definition: mio.c:38
access_t access_new(int order)
Definition: access.c:26
#define sx_sasl_ret_FAIL
Definition: plugins.h:119
#define mio_run(m, timeout)
give some cpu time to mio to check it&#39;s sockets, 0 is non-blocking
Definition: mio.h:164
int jqueue_size(jqueue_t q)
Definition: jqueue.c:126
void log_write(log_t log, int level, const char *msgfmt,...)
Definition: log.c:104
void routes_free(routes_t routes)
Definition: router.c:153
config_t config_new(void)
new config structure
Definition: config.c:25
#define MIO_STRERROR(e)
Definition: mio.h:170
#define mio_free(m)
Definition: mio.h:137
static char * config_file
Definition: main.c:34
static void router_signal_usr1(int signum)
Definition: main.c:36
const char * local_private_key_password
Definition: router.h:97
access_t access
access controls
Definition: router.h:104
void sx_raw_write(sx_t s, const char *buf, int len)
app version
Definition: io.c:483
int j_atoi(const char *a, int def)
Definition: str.c:87
rate_t * rt_val
Definition: router.h:247
int message_logging_enabled
simple message logging
Definition: router.h:163
int local_port
Definition: router.h:94
void log_free(log_t log)
Definition: log.c:174
int xhash_iter_next(xht h)
Definition: xhash.c:320
sx_env_t sx_env_new(void)
Definition: env.c:23
const char * authnid
Definition: plugins.h:126
void rate_free(rate_t rt)
Definition: rate.c:36
#define sx_sasl_ret_OK
Definition: plugins.h:118
char * config_get_attr(config_t c, const char *key, int num, const char *attr)
get an attr for this value
Definition: config.c:315
void jqueue_free(jqueue_t q)
Definition: jqueue.c:38
time_t last_activity
timestamps for idle timeouts
Definition: router.h:198
void access_free(access_t access)
Definition: access.c:35
a single component
Definition: router.h:168
Definition: log.h:42
#define MIO_ERROR
all MIO related routines should use those for error reporting
Definition: mio.h:168
#define sx_sasl_cb_CHECK_AUTHZID
Definition: plugins.h:113
sx_plugin_t sx_env_plugin(sx_env_t env, sx_plugin_init_t init,...)
load a plugin into the environment
Definition: env.c:48
holds the state for a single stream
Definition: sx.h:253
int conn_rate_wait
Definition: router.h:109
void ** val
Definition: c2s.h:404
void set_debug_log_from_config(config_t c)
Definition: log.c:267
const char * local_pemfile
Definition: router.h:96
const char * target
Definition: router.h:218
sx_plugin_t sx_sasl
Definition: router.h:121
component_t * comp_val
Definition: router.h:246
int byte_rate_seconds
Definition: router.h:115
void pool_stat(int full)
Definition: pool.c:285
xht conn_rates
Definition: router.h:111
log_t log
logging
Definition: router.h:85
const char * local_ciphers
Definition: router.h:98
struct sx_sasl_creds_st * sx_sasl_creds_t
static void router_signal(int signum)
Definition: main.c:26
#define mio_listen(m, port, sourceip, app, arg)
for creating a new listen socket in this mio (returns new fd or <0)
Definition: mio.h:140
static void router_signal_usr2(int signum)
Definition: main.c:41
jqueue_t dead
list of sx_t waiting to be cleaned up
Definition: router.h:154
alias_t aliases
configured aliases
Definition: router.h:148
int xhash_iter_get(xht h, const char **key, int *keylen, void **val)
Definition: xhash.c:374
void sx_free(sx_t s)
Definition: sx.c:70
void sx_close(sx_t s)
Definition: io.c:512
JABBER_MAIN("jabberd2c2s", "Jabber 2 C2S", "Jabber Open Source Server: Client to Server", "jabberd2router\)
Definition: main.c:657
const char * authzid
Definition: plugins.h:128
int byte_rate_total
default byte rates (karma)
Definition: router.h:114
mio_fd_t fd
file descriptor
Definition: router.h:172
#define log_debug(...)
Definition: log.h:65
jsighandler_t * jabber_signal(int signo, jsighandler_t *func)
Definition: jsignal.c:33
int conn_rate_seconds
Definition: router.h:108
const char * realm
Definition: plugins.h:127
void filter_unload(router_t r)
filter manager
Definition: filter.c:25
int router_mio_callback(mio_t m, mio_action_t a, mio_fd_t fd, void *data, void *arg)
Definition: router.c:1028
JABBERD2_API int sx_sasl_init(sx_env_t env, sx_plugin_t p, va_list args)
init function
Definition: sasl.c:881
config_elem_t config_get(config_t c, const char *key)
get the config element for this key
Definition: config.c:272
#define sx_sasl_cb_GET_REALM
Definition: plugins.h:110
#define mio_app(m, fd, app, arg)
re-set the app handler
Definition: mio.h:152
void * jqueue_pull(jqueue_t q)
Definition: jqueue.c:96
int xhash_iter_first(xht h)
iteration
Definition: xhash.c:311
static int _router_sx_sasl_callback(int cb, void *arg, void **res, sx_t s, void *cbarg)
Definition: main.c:213
int fd
Definition: mio.h:102
const char * log_facility
Definition: router.h:89
jqueue_t jqueue_new(void)
Definition: jqueue.c:25
xht log_sinks
log sinks, key is route name, var is component_t
Definition: router.h:145
int check_interval
time checks
Definition: router.h:130
void user_table_unload(router_t r)
Definition: user.c:113
void set_debug_flag(int v)
Definition: log.c:264
int sx_ssl_init(sx_env_t env, sx_plugin_t p, va_list args)
args: name, pemfile, cachain, mode
Definition: ssl.c:905
int access_allow(access_t access, const char *ip, const char *mask)
Definition: access.c:164
const char *** attrs
Definition: util.h:211
const char * name
Definition: router.h:217
static void _router_time_checks(router_t r)
Definition: main.c:275
Definition: mio.h:100
Definition: log.h:43
static void _router_config_expand(router_t r)
pull values out of the config file
Definition: main.c:75
Definition: util.h:258
Definition: log.h:44
void * xhash_get(xht h, const char *key)
Definition: xhash.c:184
#define mio_close(m, fd)
request that mio close this fd
Definition: mio.h:155
char * j_attr(const char **atts, const char *attr)
Definition: str.c:95
log_t log_new(log_type_t type, const char *ident, const char *facility)
Definition: log.c:69
int user_table_load(router_t r)
user table manager
Definition: user.c:25
#define ZONE
Definition: mio_impl.h:76
session packet handling
Definition: c2s.h:402
int byte_rate_wait
Definition: router.h:116
const char * config_get_one(config_t c, const char *key, int num)
get config value n for this key
Definition: config.c:278
xht xhash_new(int prime)
Definition: xhash.c:96
log_type_t log_type
log data
Definition: router.h:88
const char * pass
Definition: plugins.h:129
sx_t s
our stream
Definition: router.h:182
int conn_rate_total
connection rates
Definition: router.h:107
config_t config
config
Definition: router.h:74
void sx_env_free(sx_env_t env)
Definition: env.c:31
a single element
Definition: util.h:207
const char * local_secret
Definition: router.h:95
sx_plugin_t sx_ssl
Definition: router.h:120
int io_max_fds
max file descriptors
Definition: router.h:101
xht components
attached components, key is &#39;ip:port&#39;, var is component_t
Definition: router.h:136
struct alias_st * alias_t
Definition: router.h:54
#define sx_sasl_cb_CHECK_PASS
Definition: plugins.h:112
int nvalues
Definition: util.h:210
const char * local_ip
how we listen for stuff
Definition: router.h:93
const char * message_logging_file
Definition: router.h:164
#define sx_sasl_cb_GET_PASS
Definition: plugins.h:111
static sig_atomic_t router_shutdown
Definition: main.c:23
void aci_unload(xht aci)
unload aci table
Definition: aci.c:114