Merge branch 'HostServ' of ssh://git.pk910.de:16110/srvx into HostServ
[srvx.git] / src / mod-qserver.c
index 678846d851ca8ad31280a4c10e8c8fe9a9990dc4..cc91924490b03b735e831d9085717cce70af82db 100644 (file)
@@ -1,16 +1,21 @@
 /* Direct Query Server module for srvx 1.x
  * Copyright 2006 Michael Poole <mdpoole@troilus.org>
  *
- * This is PROPRIETARY, UNPUBLISHED code.
+ * This file is part of srvx.
  *
- * This file is not part of srvx. The only logical reason for you to have
- * this file is to be working for GameSurge.
+ * srvx 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.
  *
- * If this is not the case, you should delete this copy and inform
- * Michael Poole <mdpoole@troilus.org> where you acquired it.
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
  *
- * The copyright notice above is not evidence that this code is, has been,
- * or ever will be publicly licensed.
+ * You should have received a copy of the GNU General Public License
+ * along with srvx; if not, write to the Free Software Foundation,
+ * Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA.
  */
 
 #include "conf.h"
@@ -84,7 +89,7 @@ qserver_readable(struct io_fd *fd)
         tmpline[--len] = '\0';
     argc = split_line(tmpline, false, ArrayLength(argv), argv);
     if (argc < 3) {
-        ioset_printf(fd, "MISSING_ARGS");
+        ioset_printf(fd, "MISSING_ARGS\n");
         return;
     }
     if (!strcmp(argv[1], "PASS")
@@ -129,7 +134,6 @@ qserver_accept(UNUSED_ARG(struct io_fd *listener), struct io_fd *fd)
 
     client = calloc(1, sizeof(*client));
     fd->data = client;
-    fd->wants_reads = 1;
     fd->line_reads = 1;
     fd->readable_cb = qserver_readable;
     fd->destroy_cb = qserver_destroy_fd;
@@ -156,7 +160,7 @@ qserver_accept(UNUSED_ARG(struct io_fd *listener), struct io_fd *fd)
         if (getnameinfo((struct sockaddr*)&ss, sa_len, host, sizeof(host), NULL, 0, 0) != 0)
             safestrncpy(host, ip, sizeof(host));
     }
-    client->user = AddLocalUser(nick, nick+1, host, "qserver dummy user", "*+i");
+    client->user = AddLocalUser(nick, nick+1, host, "qserver dummy user", "*+oi");
     irc_pton(&client->user->ip, NULL, ip);
     dict_insert(qserver_dict, client->user->nick, client);
 
@@ -179,7 +183,9 @@ qserver_conf_read(void)
     node = conf_get_data("modules/qserver", RECDB_OBJECT);
     if (!node)
         return;
-    str1 = database_get_data(node, "address", RECDB_QSTRING);
+    str1 = database_get_data(node, "bind_address", RECDB_QSTRING);
+    if (!str1)
+        str1 = database_get_data(node, "address", RECDB_QSTRING);
     str2 = database_get_data(node, "port", RECDB_QSTRING);
     if (!str2)
         return;
@@ -201,6 +207,7 @@ qserver_cleanup(void)
 {
     unsigned int ii;
 
+    ioset_close(qserver_listener, 1);
     for (ii = 0; ii < qserver_nbots; ++ii)
         if (qserver_clients[ii])
             DelUser(qserver_clients[ii]->user, NULL, 0, "module finalizing");