#include "WHOHandler.h"
#include "HandleInfoHandler.h"
#include "ssl.h"
+#include "ConfigParser.h"
struct socket_list {
struct ClientSocket *data;
} else
return 0;
+ if(get_int_field("Sockets.NoDelay")) {
+ int flag = 1;
+ if(setsockopt(sock, IPPROTO_TCP, TCP_NODELAY, (char *) &flag, sizeof(int)) == -1) {
+ perror("setsockopt() failed");
+ return 0;
+ }
+ }
+
client->sock = sock;
client->flags |= SOCKET_FLAG_CONNECTED | SOCKET_FLAG_RECONNECT;
client->connection_time = time(0);
CMD_BIND(global_cmd_bots);
CMD_BIND(global_cmd_command);
CMD_BIND(global_cmd_commands);
+CMD_BIND(global_cmd_die);
CMD_BIND(global_cmd_emote);
CMD_BIND(global_cmd_god);
CMD_BIND(global_cmd_motd);
CMD_BIND(global_cmd_notice);
CMD_BIND(global_cmd_raw);
CMD_BIND(global_cmd_register);
+CMD_BIND(global_cmd_reload);
+CMD_BIND(global_cmd_restart);
CMD_BIND(global_cmd_reloadlang);
CMD_BIND(global_cmd_say);
CMD_BIND(global_cmd_setaccess);
--- /dev/null
+/* cmd_global_die.c - NeonServ v5.2
+ * Copyright (C) 2011 Philipp Kreil (pk910)
+ *
+ * This program 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 3 of the License, or
+ * (at your option) any later version.
+ *
+ * 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.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include "cmd_global.h"
+
+/*
+* no args
+*/
+
+CMD_BIND(global_cmd_die) {
+ //hard work! :D
+ stop_bot();
+}
--- /dev/null
+/* cmd_global_reload.c - NeonServ v5.2
+ * Copyright (C) 2011 Philipp Kreil (pk910)
+ *
+ * This program 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 3 of the License, or
+ * (at your option) any later version.
+ *
+ * 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.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include "cmd_global.h"
+
+/*
+* argv[0] soft (optional)
+*/
+
+CMD_BIND(global_cmd_reload) {
+ reload_config();
+ reply(client, user, "reloaded.");
+}
--- /dev/null
+/* cmd_global_restart.c - NeonServ v5.2
+ * Copyright (C) 2011 Philipp Kreil (pk910)
+ *
+ * This program 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 3 of the License, or
+ * (at your option) any later version.
+ *
+ * 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.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include "cmd_global.h"
+
+/*
+* argv[0] soft (optional)
+*/
+
+CMD_BIND(global_cmd_restart) {
+ int hard_restart = 1;
+ if(argc > 0 && !stricmp(argv[0], "soft")) hard_restart = 0;
+ restart_bot(hard_restart);
+}
OPER_COMMAND("unbind", global_cmd_unbind, 1, 900, CMDFLAG_REQUIRE_AUTH | CMDFLAG_CHECK_AUTH | CMDFLAG_OPLOG | CMDFLAG_REQUIRED | CMDFLAG_ESCAPE_ARGS);
OPER_COMMAND("setaccess", global_cmd_setaccess, 2, 1000, CMDFLAG_REQUIRE_AUTH | CMDFLAG_CHECK_AUTH | CMDFLAG_OPLOG);
OPER_COMMAND("bots", global_cmd_bots, 0, 1000, CMDFLAG_REQUIRE_AUTH | CMDFLAG_CHECK_AUTH);
+ OPER_COMMAND("reload", global_cmd_reload, 0, 1000, CMDFLAG_REQUIRE_AUTH | CMDFLAG_CHECK_AUTH | CMDFLAG_OPLOG);
+ OPER_COMMAND("restart", global_cmd_restart, 0, 1000, CMDFLAG_REQUIRE_AUTH | CMDFLAG_CHECK_AUTH | CMDFLAG_OPLOG);
+ OPER_COMMAND("die", global_cmd_die, 0, 1000, CMDFLAG_REQUIRE_AUTH | CMDFLAG_CHECK_AUTH | CMDFLAG_OPLOG);
#undef OPER_COMMAND
//NeonServ Commands
#include "ssl.h"
time_t start_time;
-static int running;
+static int running, hard_restart;
static int statistics_requested_lusers = 0;
int statistics_enabled;
TIMEQ_CALLBACK(main_statistics);
return 1;
}
-int main(void) {
+int main(int argc, char *argv[]) {
main:
start_time = time(0);
queue_loop();
}
cleanup();
+ if(hard_restart) {
+ /* Append a NULL to the end of argv[]. */
+ char **restart_argv = (char **)alloca((argc + 1) * sizeof(char *));
+ memcpy(restart_argv, argv, argc * sizeof(char *));
+ restart_argv[argc] = NULL;
+
+ execv(argv[0], restart_argv);
+ }
goto main;
}
return c1 - c2;
}
-void restart_bot(int hard_restart) {
+void restart_bot(int do_hard_restart) {
+ hard_restart = do_hard_restart;
running = 0;
}
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
+#include <netinet/tcp.h>
#include <arpa/inet.h>
#include <netdb.h>
#include <sys/wait.h>
int stricmp (const char *s1, const char *s2);
int stricmplen (const char *s1, const char *s2, int len);
-void restart_bot(int hard_restart);
+void restart_bot(int do_hard_restart);
void stop_bot();
void reload_config();