diff options
Diffstat (limited to 'server.py')
-rwxr-xr-x | server.py | 16 |
1 files changed, 16 insertions, 0 deletions
@@ -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.") |