|
@@ -10,7 +10,7 @@ import pendulum
|
|
currentdir = dirname(abspath(__file__))
|
|
currentdir = dirname(abspath(__file__))
|
|
|
|
|
|
# Target log file
|
|
# Target log file
|
|
-TARGET = join("bbs", join("logs", "enigma-bbs.log"))
|
|
|
|
|
|
+TARGET = join("data", join("data", "hack.log"))
|
|
|
|
|
|
# Setup logging
|
|
# Setup logging
|
|
# DEBUG, INFO, WARN, ERROR, CRITICAL
|
|
# DEBUG, INFO, WARN, ERROR, CRITICAL
|
|
@@ -38,8 +38,8 @@ def load_config():
|
|
if not exists("failUser.cfg"):
|
|
if not exists("failUser.cfg"):
|
|
now = pendulum.now().to_datetime_string()
|
|
now = pendulum.now().to_datetime_string()
|
|
defaults = {
|
|
defaults = {
|
|
- # Target enigma logs
|
|
|
|
- "target": "bbs/logs/enigma-bbs.log",
|
|
|
|
|
|
+ # Target hack logs
|
|
|
|
+ "target": "data/data/hack.log",
|
|
# block_time in hours
|
|
# block_time in hours
|
|
"block_time": 4,
|
|
"block_time": 4,
|
|
# Last unblock
|
|
# Last unblock
|
|
@@ -51,6 +51,7 @@ def load_config():
|
|
"mysql",
|
|
"mysql",
|
|
"apache",
|
|
"apache",
|
|
"nginx",
|
|
"nginx",
|
|
|
|
+ "admin"
|
|
],
|
|
],
|
|
}
|
|
}
|
|
save_config(defaults)
|
|
save_config(defaults)
|
|
@@ -69,6 +70,9 @@ def add_block(ip, time):
|
|
except FileNotFoundError:
|
|
except FileNotFoundError:
|
|
blocks = {}
|
|
blocks = {}
|
|
pass
|
|
pass
|
|
|
|
+ except JSONDecodeError:
|
|
|
|
+ blocks = {}
|
|
|
|
+ pass
|
|
# add ip and time
|
|
# add ip and time
|
|
#log.debug("Added {0} in blocks.json".format(ip))
|
|
#log.debug("Added {0} in blocks.json".format(ip))
|
|
blocks[ip] = time
|
|
blocks[ip] = time
|
|
@@ -83,6 +87,8 @@ def rm_block(ip):
|
|
blocks = loads(f.read())
|
|
blocks = loads(f.read())
|
|
except FileNotFoundError:
|
|
except FileNotFoundError:
|
|
return
|
|
return
|
|
|
|
+ except JSONDecodeError:
|
|
|
|
+ return
|
|
try:
|
|
try:
|
|
if blocks[ip]:
|
|
if blocks[ip]:
|
|
#log.debug("Removed {0} in blocks.json".format(ip))
|
|
#log.debug("Removed {0} in blocks.json".format(ip))
|
|
@@ -91,7 +97,7 @@ def rm_block(ip):
|
|
with open("blocks.json", "w") as f:
|
|
with open("blocks.json", "w") as f:
|
|
f.write(dumps(blocks))
|
|
f.write(dumps(blocks))
|
|
except KeyError:
|
|
except KeyError:
|
|
- log.debug("Unable to unblock '{0}'".format(ip))
|
|
|
|
|
|
+ log.error("Unable to unblock '{0}'".format(ip))
|
|
|
|
|
|
def check_blocks():
|
|
def check_blocks():
|
|
# return a list of ips exceeding block_time in config
|
|
# return a list of ips exceeding block_time in config
|