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