Compare commits
1 Commits
master
...
boost-doma
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ce10e802bc |
@@ -1,4 +1,3 @@
|
|||||||
|
|
||||||
# Enables detailed tracebacks and an interactive Python console on errors.
|
# Enables detailed tracebacks and an interactive Python console on errors.
|
||||||
# Never use in production!
|
# Never use in production!
|
||||||
DEBUG = False
|
DEBUG = False
|
||||||
@@ -8,7 +7,7 @@ HOST = "127.0.0.1"
|
|||||||
# Port for development server to listen on
|
# Port for development server to listen on
|
||||||
PORT = 5000
|
PORT = 5000
|
||||||
|
|
||||||
# Amount of time, is seconds, after which servers are removed from the list
|
# Amount of time, in seconds, after which servers are removed from the list
|
||||||
# if they haven't updated their listings. Note: By default Minetest servers
|
# if they haven't updated their listings. Note: By default Minetest servers
|
||||||
# only announce once every 5 minutes, so this should be more than 300.
|
# only announce once every 5 minutes, so this should be more than 300.
|
||||||
PURGE_TIME = 350
|
PURGE_TIME = 350
|
||||||
@@ -17,12 +16,18 @@ PURGE_TIME = 350
|
|||||||
# e.g. ['2620:101::44']
|
# e.g. ['2620:101::44']
|
||||||
BANNED_IPS = []
|
BANNED_IPS = []
|
||||||
|
|
||||||
# List of banned servers as host/port pairs
|
# List of banned servers as host/port pairs, domains must be lowercase
|
||||||
# e.g. ['1.2.3.4/30000', 'lowercase.hostname', 'lowercase.hostname/30001']
|
# e.g. ['1.2.3.4/30000', 'server.example.net', 'server.example.net/30001']
|
||||||
BANNED_SERVERS = []
|
BANNED_SERVERS = []
|
||||||
|
|
||||||
|
# List of banned domain suffixes, must be lowercase
|
||||||
|
# e.g. ['.example.net', 'server.example.com']
|
||||||
|
BANNED_DOMAINS = []
|
||||||
|
|
||||||
|
# List of domain suffixes that should not get a point bonus (e.g. free domains), must be lowercase
|
||||||
|
IRREPUTABLE_DOMAINS = ['.cf', '.ga', '.gq', '.ml', '.tk']
|
||||||
|
|
||||||
# Creates server entries if a server sends an 'update' and there is no entry yet.
|
# 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 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
|
# This WILL cause problems such as mapgen, mods and privilege information missing from the list
|
||||||
ALLOW_UPDATE_WITHOUT_OLD = False
|
ALLOW_UPDATE_WITHOUT_OLD = False
|
||||||
|
|
||||||
|
|||||||
25
server.py
25
server.py
@@ -1,5 +1,5 @@
|
|||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python3
|
||||||
import os, re, sys, json, time, socket
|
import os, re, sys, json, time, socket, ipaddress
|
||||||
from threading import Thread, RLock
|
from threading import Thread, RLock
|
||||||
from geolite2 import geolite2
|
from geolite2 import geolite2
|
||||||
|
|
||||||
@@ -73,10 +73,15 @@ def announce():
|
|||||||
|
|
||||||
if "%s/%d" % (server["ip"], server["port"]) in app.config["BANNED_SERVERS"]:
|
if "%s/%d" % (server["ip"], server["port"]) in app.config["BANNED_SERVERS"]:
|
||||||
return "Banned (Server).", 403
|
return "Banned (Server).", 403
|
||||||
elif "address" in server and "%s/%d" % (server["address"].lower(), server["port"]) in app.config["BANNED_SERVERS"]:
|
elif "address" in server:
|
||||||
return "Banned (Server).", 403
|
# Normalize address for ban checks
|
||||||
elif "address" in server and server["address"].lower() in app.config["BANNED_SERVERS"]:
|
server["address"] = server["address"].lower().rstrip(".")
|
||||||
return "Banned (Server).", 403
|
if f'{server["address"]}/{server["port"]}' in app.config["BANNED_SERVERS"] or \
|
||||||
|
server["address"] in app.config["BANNED_SERVERS"]:
|
||||||
|
return "Banned (Server).", 403
|
||||||
|
for domain in app.config["BANNED_DOMAINS"]:
|
||||||
|
if server["address"].endswith(domain):
|
||||||
|
return "Banned (Domain).", 403
|
||||||
|
|
||||||
old = serverList.get(ip, server["port"])
|
old = serverList.get(ip, server["port"])
|
||||||
|
|
||||||
@@ -376,6 +381,16 @@ class ServerList:
|
|||||||
if server["clients"] > cap:
|
if server["clients"] > cap:
|
||||||
points -= server["clients"] - cap
|
points -= server["clients"] - cap
|
||||||
|
|
||||||
|
# 8 for servers with a reputable domain name
|
||||||
|
try:
|
||||||
|
ipaddress.ip_address(server["address"])
|
||||||
|
except ValueError:
|
||||||
|
for domain in app.config["IRREPUTABLE_DOMAINS"]:
|
||||||
|
if server["address"].endswith(domain):
|
||||||
|
break
|
||||||
|
else:
|
||||||
|
points += 8
|
||||||
|
|
||||||
# 1 per month of age, limited to 8
|
# 1 per month of age, limited to 8
|
||||||
points += min(8, server["game_time"] / (60*60*24*30))
|
points += min(8, server["game_time"] / (60*60*24*30))
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user