]> jfr.im git - irc/evilnet/x3.git/blobdiff - src/main.c
svsnick and 1 param auth
[irc/evilnet/x3.git] / src / main.c
index 5ed477cc5d6c3999f5e1239ba82533bc767d109a..920ef58148d330a0b574df316aaf00761765f280 100644 (file)
@@ -1,11 +1,11 @@
-/* main.c - srvx
+/* main.c - X3
  * Copyright 2000-2004 srvx Development Team
  *
  * This file is part of x3.
  *
  * Copyright 2000-2004 srvx Development Team
  *
  * 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
  * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
+ * the Free Software Foundation; either version 3 of the License, or
  * (at your option) any later version.
  *
  * This program is distributed in the hope that it will be useful,
  * (at your option) any later version.
  *
  * This program is distributed in the hope that it will be useful,
@@ -26,6 +26,7 @@
 #include "modcmd.h"
 #include "saxdb.h"
 #include "sendmail.h"
 #include "modcmd.h"
 #include "saxdb.h"
 #include "sendmail.h"
+#include "spamserv.h"
 #include "shun.h"
 #include "timeq.h"
 
 #include "shun.h"
 #include "timeq.h"
 
@@ -144,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 uplinkNode *uplink = malloc(sizeof(struct uplinkNode));
     struct record_data *rd = data;
+    struct addrinfo hints, *ai;
     int enabled = 1;
     char *str;
     int enabled = 1;
     char *str;
-    struct sockaddr_in *sin;
-    unsigned long addr;
 
     if(!uplink)
     {
 
     if(!uplink)
     {
@@ -177,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->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;
     {
        uplink->bind_addr = NULL;
        uplink->bind_addr_len = 0;
@@ -520,21 +522,6 @@ conf_globals(void)
     const char *info;
     dict_t dict;
 
     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);
     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);
@@ -561,6 +548,26 @@ conf_globals(void)
     if (info && (info[0] == '.'))
         info = NULL;
     init_opserv(info);
     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
 }
 
 #ifdef HAVE_SYS_RESOURCE_H
@@ -568,12 +575,13 @@ conf_globals(void)
 static int
 set_item_rlimit(const char *name, void *data, void *extra)
 {
 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;
 
     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;
     if (!found) {
         log_module(MAIN_LOG, LOG_ERROR, "Invalid rlimit \"%s\" in rlimits section.", name);
         return 0;
@@ -667,7 +675,7 @@ void license() {
     printf("\n"
            "This program is free software; you can redistribute it and/or modify\n"
            "it under the terms of the GNU General Public License as published by\n"
     printf("\n"
            "This program is free software; you can redistribute it and/or modify\n"
            "it under the terms of the GNU General Public License as published by\n"
-           "the Free Software Foundation; either version 2 of the License, or\n"
+           "the Free Software Foundation; either version 3 of the License, or\n"
            "(at your option) any later version.\n"
            "\n"
            "This program is distributed in the hope that it will be useful,\n"
            "(at your option) any later version.\n"
            "\n"
            "This program is distributed in the hope that it will be useful,\n"