aboutsummaryrefslogtreecommitdiffstats
path: root/conf.c
diff options
context:
space:
mode:
Diffstat (limited to 'conf.c')
-rw-r--r--conf.c54
1 files changed, 47 insertions, 7 deletions
diff --git a/conf.c b/conf.c
index 15055ca3..dd99d741 100644
--- a/conf.c
+++ b/conf.c
@@ -31,6 +31,7 @@
#include "conf.h"
#include "ini.h"
#include "url.h"
+#include "ipc.h"
#include "protocols/proxy.h"
@@ -45,19 +46,26 @@ conf_t *conf_load( int argc, char *argv[] )
conf = g_new0( conf_t, 1 );
+#ifdef IPV6
+ conf->iface = "::";
+#else
conf->iface = "0.0.0.0";
+#endif
conf->port = 6667;
conf->nofork = 0;
conf->verbose = 0;
conf->primary_storage = "text";
conf->runmode = RUNMODE_INETD;
conf->authmode = AUTHMODE_OPEN;
- conf->password = NULL;
+ conf->auth_pass = NULL;
+ conf->oper_pass = NULL;
conf->configdir = g_strdup( CONFIG );
conf->plugindir = g_strdup( PLUGINDIR );
+ conf->pidfile = g_strdup( "/var/run/bitlbee.pid" );
conf->motdfile = g_strdup( ETCDIR "/motd.txt" );
conf->ping_interval = 180;
conf->ping_timeout = 300;
+ proxytype = 0;
i = conf_loadini( conf, CONF_FILE );
if( i == 0 )
@@ -70,7 +78,8 @@ conf_t *conf_load( int argc, char *argv[] )
fprintf( stderr, "Warning: Unable to read configuration file `%s'.\n", CONF_FILE );
}
- while( ( opt = getopt( argc, argv, "i:p:nvIDc:d:h" ) ) >= 0 )
+ while( argc > 0 && ( opt = getopt( argc, argv, "i:p:P:nvIDFc:d:hR:" ) ) >= 0 )
+ /* ^^^^ Just to make sure we skip this step from the REHASH handler. */
{
if( opt == 'i' )
{
@@ -85,14 +94,21 @@ conf_t *conf_load( int argc, char *argv[] )
}
conf->port = i;
}
+ else if( opt == 'p' )
+ {
+ g_free( conf->pidfile );
+ conf->pidfile = g_strdup( optarg );
+ }
else if( opt == 'n' )
- conf->nofork=1;
+ conf->nofork = 1;
else if( opt == 'v' )
- conf->verbose=1;
+ conf->verbose = 1;
else if( opt == 'I' )
- conf->runmode=RUNMODE_INETD;
+ conf->runmode = RUNMODE_INETD;
else if( opt == 'D' )
- conf->runmode=RUNMODE_DAEMON;
+ conf->runmode = RUNMODE_DAEMON;
+ else if( opt == 'F' )
+ conf->runmode = RUNMODE_FORKDAEMON;
else if( opt == 'c' )
{
if( strcmp( CONF_FILE, optarg ) != 0 )
@@ -100,6 +116,10 @@ conf_t *conf_load( int argc, char *argv[] )
g_free( CONF_FILE );
CONF_FILE = g_strdup( optarg );
g_free( conf );
+ /* Re-evaluate arguments. Don't use this option twice,
+ you'll end up in an infinite loop! Hope this trick
+ works with all libcs BTW.. */
+ optind = 1;
return( conf_load( argc, argv ) );
}
}
@@ -117,6 +137,7 @@ conf_t *conf_load( int argc, char *argv[] )
"\n"
" -I Classic/InetD mode. (Default)\n"
" -D Daemon mode. (Still EXPERIMENTAL!)\n"
+ " -F Forking daemon. (one process per client)\n"
" -i Specify the interface (by IP address) to listen on.\n"
" (Default: 0.0.0.0 (any interface))\n"
" -p Port number to listen on. (Default: 6667)\n"
@@ -127,6 +148,14 @@ conf_t *conf_load( int argc, char *argv[] )
" -h Show this help page.\n" );
return( NULL );
}
+ else if( opt == 'R' )
+ {
+ /* We can't load the statefile yet (and should make very sure we do this
+ only once), so set the filename here and load the state information
+ when initializing ForkDaemon. (This option only makes sense in that
+ mode anyway!) */
+ ipc_master_set_statefile( optarg );
+ }
}
if( conf->configdir[strlen(conf->configdir)-1] != '/' )
@@ -156,9 +185,16 @@ static int conf_loadini( conf_t *conf, char *file )
{
if( g_strcasecmp( ini->value, "daemon" ) == 0 )
conf->runmode = RUNMODE_DAEMON;
+ else if( g_strcasecmp( ini->value, "forkdaemon" ) == 0 )
+ conf->runmode = RUNMODE_FORKDAEMON;
else
conf->runmode = RUNMODE_INETD;
}
+ else if( g_strcasecmp( ini->key, "pidfile" ) == 0 )
+ {
+ g_free( conf->pidfile );
+ conf->pidfile = g_strdup( ini->value );
+ }
else if( g_strcasecmp( ini->key, "daemoninterface" ) == 0 )
{
conf->iface = g_strdup( ini->value );
@@ -183,7 +219,11 @@ static int conf_loadini( conf_t *conf, char *file )
}
else if( g_strcasecmp( ini->key, "authpassword" ) == 0 )
{
- conf->password = g_strdup( ini->value );
+ conf->auth_pass = g_strdup( ini->value );
+ }
+ else if( g_strcasecmp( ini->key, "operpassword" ) == 0 )
+ {
+ conf->oper_pass = g_strdup( ini->value );
}
else if( g_strcasecmp( ini->key, "hostname" ) == 0 )
{