X-Git-Url: https://jfr.im/git/irc/evilnet/x3.git/blobdiff_plain/d76ed9a966ee3d955c8ef00ecc02e643c2005e2e..bc06f607a61a8d0c48642bc859998f34346024b8:/src/main.c diff --git a/src/main.c b/src/main.c index c16aafa..6b80504 100644 --- a/src/main.c +++ b/src/main.c @@ -1,9 +1,9 @@ -/* main.c - srvx +/* main.c - X3 * Copyright 2000-2004 srvx Development Team * - * This file is part of srvx. + * This file is part of x3. * - * srvx is free software; you can redistribute it and/or modify + * x3 is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. @@ -18,7 +18,7 @@ * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -#define PID_FILE "srvx.pid" +#define PID_FILE "x3.pid" #include "conf.h" #include "gline.h" @@ -26,6 +26,8 @@ #include "modcmd.h" #include "saxdb.h" #include "sendmail.h" +#include "spamserv.h" +#include "shun.h" #include "timeq.h" #include "chanserv.h" @@ -63,7 +65,7 @@ struct log_type *MAIN_LOG; int quit_services, max_cycles; -char *services_config = "srvx.conf"; +char *services_config = "x3.conf"; char **services_argv; int services_argc; @@ -77,6 +79,7 @@ static const struct message_entry msgtab[] = { { "MSG_ON", "On" }, { "MSG_OFF", "Off" }, { "MSG_NEVER", "Never" }, + { "MSG_BAR", "----------------------------------------" }, { "MSG_SERVICE_IMMUNE", "$b%s$b may not be kicked, killed, banned, or deopped." }, { "MSG_SERVICE_PRIVILEGED", "$b%s$b is a privileged service." }, { "MSG_NOT_A_SERVICE", "$b%s$b is not a service bot." }, @@ -94,10 +97,11 @@ static const struct message_entry msgtab[] = { { "MSG_MODULE_UNKNOWN", "No module has been registered with name $b%s$b." }, { "MSG_INVALID_MODES", "$b%s$b is an invalid set of channel modes." }, { "MSG_INVALID_GLINE", "Invalid G-line '%s'." }, + { "MSG_INVALID_SHUN", "Invalid Shun '%s'." }, { "MSG_INVALID_DURATION", "Invalid time span '%s'." }, { "MSG_NOT_TARGET_NAME", "You must provide the name of a channel or user." }, - { "MSG_NOT_CHANNEL_NAME", "You must provide a valid channel name." }, - { "MSG_INVALID_CHANNEL", "You must provide the name of a channel that exists." }, + { "MSG_NOT_CHANNEL_NAME", "The channel name you specified is not a valid channel name." }, + { "MSG_INVALID_CHANNEL", "The channel name you specified does not exist." }, { "MSG_CHANNEL_ABSENT", "You aren't currently in $b%s$b." }, { "MSG_CHANNEL_USER_ABSENT", "$b%s$b isn't currently in $b%s$b." }, { "MSG_MISSING_PARAMS", "$b%s$b requires more parameters." }, @@ -107,7 +111,7 @@ static const struct message_entry msgtab[] = { { "MSG_STUPID_ACCESS_CHANGE", "Please ask someone $belse$b to demote you." }, { "MSG_NO_SEARCH_ACCESS", "You do not have enough access to search based on $b%s$b." }, { "MSG_INVALID_CRITERIA", "$b%s$b is an invalid search criteria." }, - { "MSG_MATCH_COUNT", "Found $b%u$b matches." }, + { "MSG_MATCH_COUNT", "-----------Found $b%3u$b Matches------------" }, { "MSG_NO_MATCHES", "Nothing matched the criteria of your search." }, { "MSG_TOPIC_UNKNOWN", "No help on that topic." }, { "MSG_INVALID_BINARY", "$b%s$b is an invalid binary value." }, @@ -117,20 +121,20 @@ static const struct message_entry msgtab[] = { { "MSG_DB_WRITE_ERROR", "Error while writing database %s." }, { "MSG_DB_WROTE_DB", "Wrote database %s (in "FMT_TIME_T".%06lu seconds)." }, { "MSG_DB_WROTE_ALL", "Wrote all databases (in "FMT_TIME_T".%06lu seconds)." }, - { "MSG_AND", "and" }, + { "MSG_AND", "," }, { "MSG_0_SECONDS", "0 seconds" }, - { "MSG_YEAR", "year" }, - { "MSG_YEARS", "years" }, - { "MSG_WEEK", "week" }, - { "MSG_WEEKS", "weeks" }, - { "MSG_DAY", "day" }, - { "MSG_DAYS", "days" }, - { "MSG_HOUR", "hour" }, - { "MSG_HOURS", "hours" }, - { "MSG_MINUTE", "minute" }, - { "MSG_MINUTES", "minutes" }, - { "MSG_SECOND", "second" }, - { "MSG_SECONDS", "seconds" }, + { "MSG_YEAR", "y" }, + { "MSG_YEARS", "y" }, + { "MSG_WEEK", "w" }, + { "MSG_WEEKS", "w" }, + { "MSG_DAY", "d" }, + { "MSG_DAYS", "d" }, + { "MSG_HOUR", "h" }, + { "MSG_HOURS", "h" }, + { "MSG_MINUTE", "m" }, + { "MSG_MINUTES", "m" }, + { "MSG_SECOND", "s" }, + { "MSG_SECONDS", "s" }, { NULL, NULL } }; @@ -141,10 +145,9 @@ uplink_insert(const char *key, void *data, UNUSED_ARG(void *extra)) { struct uplinkNode *uplink = malloc(sizeof(struct uplinkNode)); struct record_data *rd = data; + struct addrinfo hints, *ai; int enabled = 1; char *str; - struct sockaddr_in *sin; - unsigned long addr; if(!uplink) { @@ -174,15 +177,17 @@ uplink_insert(const char *key, void *data, UNUSED_ARG(void *extra)) uplink->tries = 0; str = database_get_data(rd->d.object, "bind_address", RECDB_QSTRING); - uplink->bind_addr_len = sizeof(*sin); - if (str && getipbyname(str, &addr)) + memset(&hints, 0, sizeof(hints)); + hints.ai_flags = AI_PASSIVE; + hints.ai_socktype = SOCK_STREAM; + if (!getaddrinfo(str, NULL, &hints, &ai)) { - sin = calloc(1, uplink->bind_addr_len); - sin->sin_family = AF_INET; - sin->sin_addr.s_addr = addr; - uplink->bind_addr = sin; - } - else + uplink->bind_addr_len = ai->ai_addrlen; + uplink->bind_addr = calloc(1, ai->ai_addrlen); + memcpy(uplink->bind_addr, ai->ai_addr, ai->ai_addrlen); + freeaddrinfo(ai); + } + else { uplink->bind_addr = NULL; uplink->bind_addr_len = 0; @@ -517,21 +522,6 @@ conf_globals(void) const char *info; dict_t dict; - info = conf_get_data("services/global/nick", RECDB_QSTRING); - if (info && (info[0] == '.')) - info = NULL; - init_global(info); - - info = conf_get_data("services/nickserv/nick", RECDB_QSTRING); - if (info && (info[0] == '.')) - info = NULL; - init_nickserv(info); - - info = conf_get_data("services/chanserv/nick", RECDB_QSTRING); - if (info && (info[0] == '.')) - info = NULL; - init_chanserv(info); - god_policer_params = policer_params_new(); if ((dict = conf_get_data("policers/commands-god", RECDB_OBJECT))) { dict_foreach(dict, set_policer_param, god_policer_params); @@ -558,6 +548,26 @@ conf_globals(void) if (info && (info[0] == '.')) info = NULL; init_opserv(info); + + info = conf_get_data("services/global/nick", RECDB_QSTRING); + if (info && (info[0] == '.')) + info = NULL; + init_global(info); + + info = conf_get_data("services/nickserv/nick", RECDB_QSTRING); + if (info && (info[0] == '.')) + info = NULL; + init_nickserv(info); + + info = conf_get_data("services/chanserv/nick", RECDB_QSTRING); + if (info && (info[0] == '.')) + info = NULL; + init_chanserv(info); + + info = conf_get_data("services/spamserv/nick", RECDB_QSTRING); + if (info && (info[0] == '.')) + info = NULL; + init_spamserv(info); } #ifdef HAVE_SYS_RESOURCE_H @@ -565,12 +575,13 @@ conf_globals(void) static int set_item_rlimit(const char *name, void *data, void *extra) { - int rsrc, found; + long rsrc; + int found; struct record_data *rd = data; struct rlimit rlim; const char *str; - rsrc = (int)dict_find(extra, name, &found); + rsrc = (long)dict_find(extra, name, &found); if (!found) { log_module(MAIN_LOG, LOG_ERROR, "Invalid rlimit \"%s\" in rlimits section.", name); return 0; @@ -644,7 +655,7 @@ void usage(char *self) { printf("Usage: %s [-c config] [-r log] [-d] [-f] [-v|-h]\n" "-c, --config selects a different configuration file.\n" "-d, --debug enables debug mode.\n" - "-f, --foreground run srvx in the foreground.\n" + "-f, --foreground run X3 in the foreground.\n" "-h, --help prints this usage message.\n" "-k, --check checks the configuration file's syntax.\n" "-r, --replay replay a log file (for debugging)\n" @@ -654,8 +665,9 @@ void usage(char *self) { void version() { printf(" --------------------------------------------------\n" - " - "PACKAGE_STRING" ("CODENAME"), Built: " __DATE__ ", " __TIME__".\n" - " - Copyright (C) 2000 - 2003, srvx Development Team\n" + " - "PACKAGE_STRING", Built: " __DATE__ ", " __TIME__".\n" + " - Copyright (C) 2000 - 2005, srvx Development Team\n" + " - Copyright (C) 2004 - 2005, X3 Development Team\n" " --------------------------------------------------\n"); } @@ -691,6 +703,12 @@ int main(int argc, char *argv[]) FILE *file_out; struct sigaction sv; +#if WITH_MALLOC_BOEHM_GC + GC_find_leak = 1; + GC_set_warn_proc(gc_warn_proc); + GC_enable_incremental(); +#endif + daemon = 1; debug = 0; tools_init(); @@ -813,19 +831,16 @@ int main(int argc, char *argv[]) reg_exit_func(main_shutdown); log_init(); - MAIN_LOG = log_register_type("srvx", "file:main.log"); + MAIN_LOG = log_register_type("x3", "file:main.log"); if (debug) log_debug(); -#if WITH_MALLOC_BOEHM_GC - GC_set_warn_proc(gc_warn_proc); - GC_enable_incremental(); -#endif timeq_init(); init_structs(); init_parse(); modcmd_init(); saxdb_init(); gline_init(); + shun_init(); sendmail_init(); helpfile_init(); conf_globals(); /* initializes the core services */