make sure cf.ban_ip doesn't interrupt entire process

This commit is contained in:
Benny
2023-03-20 21:15:30 +01:00
parent 0203fd1a93
commit 05f7d5c8d7

View File

@@ -37,7 +37,10 @@ class ResourceHandler(BaseHandler):
if not referer and os.getenv("GIFT"):
ip = self.get_real_ip()
logging.warning("Good luck to %s!", ip)
cf.ban_new_ip(ip)
try:
cf.ban_new_ip(ip)
except Exception as e:
logging.error("Failed to ban %s: %s", ip, e)
self.set_header("Content-Type", "text/html")
self.set_header("Content-Encoding", "gzip")
with open("templates/gift.gz", "rb") as f: