|
|
@ -14,7 +14,9 @@ |
|
|
#include "log.h" |
|
|
#include "log.h" |
|
|
#include "call.h" |
|
|
#include "call.h" |
|
|
#include "kernel.h" |
|
|
#include "kernel.h" |
|
|
|
|
|
#ifndef NO_REDIS |
|
|
#include "redis.h" |
|
|
#include "redis.h" |
|
|
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -39,9 +41,11 @@ static int timeout; |
|
|
static int silent_timeout; |
|
|
static int silent_timeout; |
|
|
static int port_min; |
|
|
static int port_min; |
|
|
static int port_max; |
|
|
static int port_max; |
|
|
|
|
|
#ifndef NO_REDIS |
|
|
static u_int32_t redis_ip; |
|
|
static u_int32_t redis_ip; |
|
|
static u_int16_t redis_port; |
|
|
static u_int16_t redis_port; |
|
|
static int redis_db = -1; |
|
|
static int redis_db = -1; |
|
|
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -108,7 +112,9 @@ static void options(int *argc, char ***argv) { |
|
|
static char *adv_ips; |
|
|
static char *adv_ips; |
|
|
static char *listenps; |
|
|
static char *listenps; |
|
|
static char *listenudps; |
|
|
static char *listenudps; |
|
|
|
|
|
#ifndef NO_REDIS |
|
|
static char *redisps; |
|
|
static char *redisps; |
|
|
|
|
|
#endif |
|
|
|
|
|
|
|
|
static GOptionEntry e[] = { |
|
|
static GOptionEntry e[] = { |
|
|
{ "table", 't', 0, G_OPTION_ARG_INT, &table, "Kernel table to use", "INT" }, |
|
|
{ "table", 't', 0, G_OPTION_ARG_INT, &table, "Kernel table to use", "INT" }, |
|
|
@ -123,8 +129,10 @@ static void options(int *argc, char ***argv) { |
|
|
{ "foreground", 'f', 0, G_OPTION_ARG_NONE, &foreground, "Don't fork to background", NULL }, |
|
|
{ "foreground", 'f', 0, G_OPTION_ARG_NONE, &foreground, "Don't fork to background", NULL }, |
|
|
{ "port-min", 'm', 0, G_OPTION_ARG_INT, &port_min, "Lowest port to use for RTP", "INT" }, |
|
|
{ "port-min", 'm', 0, G_OPTION_ARG_INT, &port_min, "Lowest port to use for RTP", "INT" }, |
|
|
{ "port-max", 'M', 0, G_OPTION_ARG_INT, &port_max, "Highest port to use for RTP", "INT" }, |
|
|
{ "port-max", 'M', 0, G_OPTION_ARG_INT, &port_max, "Highest port to use for RTP", "INT" }, |
|
|
|
|
|
#ifndef NO_REDIS |
|
|
{ "redis", 'r', 0, G_OPTION_ARG_STRING, &redisps, "Connect to Redis database", "IP:PORT" }, |
|
|
{ "redis", 'r', 0, G_OPTION_ARG_STRING, &redisps, "Connect to Redis database", "IP:PORT" }, |
|
|
{ "redis-db", 'R', 0, G_OPTION_ARG_INT, &redis_db, "Which Redis DB to use", "INT" }, |
|
|
{ "redis-db", 'R', 0, G_OPTION_ARG_INT, &redis_db, "Which Redis DB to use", "INT" }, |
|
|
|
|
|
#endif |
|
|
{ NULL, } |
|
|
{ NULL, } |
|
|
}; |
|
|
}; |
|
|
|
|
|
|
|
|
@ -168,12 +176,14 @@ static void options(int *argc, char ***argv) { |
|
|
if (silent_timeout <= 0) |
|
|
if (silent_timeout <= 0) |
|
|
silent_timeout = 3600; |
|
|
silent_timeout = 3600; |
|
|
|
|
|
|
|
|
|
|
|
#ifndef NO_REDIS |
|
|
if (redisps) { |
|
|
if (redisps) { |
|
|
if (parse_ip_port(&redis_ip, &redis_port, redisps) || !redis_ip) |
|
|
if (parse_ip_port(&redis_ip, &redis_port, redisps) || !redis_ip) |
|
|
die("Invalid IP or port (--redis)\n"); |
|
|
die("Invalid IP or port (--redis)\n"); |
|
|
if (redis_db < 0) |
|
|
if (redis_db < 0) |
|
|
die("Must specify Redis DB number (--redis-db) when using Redis\n"); |
|
|
die("Must specify Redis DB number (--redis-db) when using Redis\n"); |
|
|
} |
|
|
} |
|
|
|
|
|
#endif |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -251,11 +261,13 @@ int main(int argc, char **argv) { |
|
|
die("Failed to open UDP control connection port\n"); |
|
|
die("Failed to open UDP control connection port\n"); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
#ifndef NO_REDIS |
|
|
if (redis_ip) { |
|
|
if (redis_ip) { |
|
|
m->redis = redis_new(redis_ip, redis_port, redis_db); |
|
|
m->redis = redis_new(redis_ip, redis_port, redis_db); |
|
|
if (!m->redis) |
|
|
if (!m->redis) |
|
|
die("Cannot start up without Redis database\n"); |
|
|
die("Cannot start up without Redis database\n"); |
|
|
} |
|
|
} |
|
|
|
|
|
#endif |
|
|
|
|
|
|
|
|
mylog(LOG_INFO, "Startup complete"); |
|
|
mylog(LOG_INFO, "Startup complete"); |
|
|
|
|
|
|
|
|
@ -263,10 +275,12 @@ int main(int argc, char **argv) { |
|
|
daemonize(); |
|
|
daemonize(); |
|
|
wpidfile(); |
|
|
wpidfile(); |
|
|
|
|
|
|
|
|
|
|
|
#ifndef NO_REDIS |
|
|
if (m->redis) { |
|
|
if (m->redis) { |
|
|
if (redis_restore(m)) |
|
|
if (redis_restore(m)) |
|
|
die("Refusing to continue without working Redis database\n"); |
|
|
die("Refusing to continue without working Redis database\n"); |
|
|
} |
|
|
} |
|
|
|
|
|
#endif |
|
|
|
|
|
|
|
|
for (;;) { |
|
|
for (;;) { |
|
|
ret = poller_poll(p, 100); |
|
|
ret = poller_poll(p, 100); |
|
|
|