Skip to content

Commit

Permalink
Re-add banlist features
Browse files Browse the repository at this point in the history
This effectively reverts commit b366290.
  • Loading branch information
sfan5 committed May 14, 2017
1 parent 5de6082 commit 705ea6e
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
8 changes: 8 additions & 0 deletions config-example.py
Expand Up @@ -13,6 +13,14 @@
# only announce once every 5 minutes, so this should be more than 300.
PURGE_TIME = 350

# List of banned IP addresses for announce
# e.g. ['2620:101::44']
BANNED_IPS = []

# List of banned servers as IP/port pairs
# e.g. ['1.2.3.4/30000']
BANNED_SERVERS = []

# Creates server entries if a server sends an 'update' and there is no entry yet.
# This should only be used to populate the server list after list.json was deleted.
# This WILL cause problems such as mapgen, mods and privilege information missing from the list
Expand Down
6 changes: 6 additions & 0 deletions server.py
Expand Up @@ -39,6 +39,9 @@ def announce():
if ip.startswith("::ffff:"):
ip = ip[7:]

if ip in app.config["BANNED_IPS"]:
return "Banned (IP).", 403

data = request.values["json"]

if len(data) > 5000:
Expand Down Expand Up @@ -72,6 +75,9 @@ def announce():
server["port"] = int(server["port"])
#### End compatability code ####

if "%s/%d" % (server["ip"], server["port"]) in app.config["BANNED_SERVERS"]:
return "Banned (Server).", 403

old = serverList.get(ip, server["port"])

if action == "delete":
Expand Down

0 comments on commit 705ea6e

Please sign in to comment.