]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Whoops -- ACTUALLY commit those new files too ;)
authorSamual <samual@xonotic.org>
Tue, 13 Dec 2011 10:38:24 +0000 (05:38 -0500)
committerSamual <samual@xonotic.org>
Tue, 13 Dec 2011 10:38:24 +0000 (05:38 -0500)
qcsrc/server/command/ipban.qc [new file with mode: 0644]
qcsrc/server/command/ipban.qh [new file with mode: 0644]

diff --git a/qcsrc/server/command/ipban.qc b/qcsrc/server/command/ipban.qc
new file mode 100644 (file)
index 0000000..45b7f21
--- /dev/null
@@ -0,0 +1,75 @@
+float GameCommand_Ban(string command)
+{
+       float argc;
+       float bantime;
+       entity client;
+       float entno;
+       float masksize;
+       string reason;
+       float reasonarg;
+
+       argc = tokenize_console(command);
+       if(argv(0) == "help")
+       {
+               print("  kickban # n m p reason - kickban player n for m seconds, using mask size p (1 to 4)\n");
+               print("  ban ip m reason - ban an IP or range (incomplete IP, like 1.2.3) for m seconds\n");
+               print("  bans - list all existing bans\n");
+               print("  unban n - delete the entry #n from the bans list\n");
+               return TRUE;
+       }
+       if(argv(0) == "kickban")
+       {
+#define INITARG(c) reasonarg = c
+#define GETARG(v,d) if((argc > reasonarg) && ((v = stof(argv(reasonarg))) != 0)) ++reasonarg; else v = d
+#define RESTARG(v) if(argc > reasonarg) v = substring(command, argv_start_index(reasonarg), strlen(command) - argv_start_index(reasonarg)); else v = ""
+               if(argc >= 3)
+               {
+                       entno = stof(argv(2));
+                       if(entno > maxclients || entno < 1)
+                               return TRUE;
+                       client = edict_num(entno);
+
+                       INITARG(3);
+                       GETARG(bantime, autocvar_g_ban_default_bantime);
+                       GETARG(masksize, autocvar_g_ban_default_masksize);
+                       RESTARG(reason);
+
+                       Ban_KickBanClient(client, bantime, masksize, reason);
+                       return TRUE;
+               }
+       }
+       else if(argv(0) == "ban")
+       {
+               if(argc >= 2)
+               {
+                       string ip;
+                       ip = argv(1);
+
+                       INITARG(2);
+                       GETARG(bantime, autocvar_g_ban_default_bantime);
+                       RESTARG(reason);
+
+                       Ban_Insert(ip, bantime, reason, 1);
+                       return TRUE;
+               }
+#undef INITARG
+#undef GETARG
+#undef RESTARG
+       }
+       else if(argv(0) == "bans")
+       {
+               Ban_View();
+               return TRUE;
+       }
+       else if(argv(0) == "unban")
+       {
+               if(argc >= 2)
+               {
+                       float who;
+                       who = stof(argv(1));
+                       Ban_Delete(who);
+                       return TRUE;
+               }
+       }
+       return FALSE;
+}
\ No newline at end of file
diff --git a/qcsrc/server/command/ipban.qh b/qcsrc/server/command/ipban.qh
new file mode 100644 (file)
index 0000000..58e7b40
--- /dev/null
@@ -0,0 +1,4 @@
+void Ban_KickBanClient(entity client, float bantime, float masksize, string reason);
+float Ban_Insert(string ip, float bantime, string reason, float dosync);
+void Ban_View();
+float Ban_Delete(float i);
\ No newline at end of file