summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--security.py2
-rwxr-xr-xserver.py16
2 files changed, 17 insertions, 1 deletions
diff --git a/security.py b/security.py
index 0424712..b494542 100644
--- a/security.py
+++ b/security.py
@@ -73,7 +73,7 @@ def ban_ip(ip, until=INT_MAX):
global blacklist
blacklist.append([ip, until])
stdout("%s has been banned until %d." % (ip, until))
- # TODO: kick users when they are banned or klined
+ # TODO: kick users when they are banned or klined?
return
def unban_ip(ip):
diff --git a/server.py b/server.py
index f57f02f..fa3b240 100755
--- a/server.py
+++ b/server.py
@@ -143,6 +143,16 @@ def sendmsg(m, t="raw"):
c.send_message(msg)
return
+# Disconnect function
+def disconnect(ip):
+ global clients
+ totaldc=0
+ for c in clients:
+ if c.address[0] == ip:
+ c.close(status=1000, reason="Remote host closed connection.")
+ totaldc+=1
+ return totaldc
+
###############################################################
# Begin stuff
stdout("Starting at: T-%d" % (now()))
@@ -164,6 +174,9 @@ try:
sendmsg("NOTICE:" + com)
elif cmd in ["ban", "nuke"]:
security.ban_ip(com)
+ totaldc=disconnect(com)
+ stdout("BAN: Disconnected %d clients." % totaldc)
+ del totaldc
elif cmd in ["unban"]:
security.unban_ip(com)
elif cmd in ["permaban", "block", "kline"]:
@@ -172,6 +185,9 @@ try:
f.write(com+"\n")
f.close()
stdout("%s has been K-Lined." % com)
+ totaldc=disconnect(com)
+ stdout("Disconnected %d clients." % totaldc)
+ del totaldc
elif cmd in ["exit", "quit", "close", "term", "end"]:
stdout("Preparing to close server...")
sendmsg("NOTICE:Server is going down for scheduled maintenance. Please close, wait five minutes, and then re-open the app.")