From d3e228bcd62fdd9dcc4590aca44289b3fbbd6de5 Mon Sep 17 00:00:00 2001 From: Mr Chen Date: Sat, 19 Oct 2024 03:01:05 +0800 Subject: [PATCH] Update index.py --- plugins/fail2ban/index.py | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/plugins/fail2ban/index.py b/plugins/fail2ban/index.py index fc1784ba0..bddb4bca9 100755 --- a/plugins/fail2ban/index.py +++ b/plugins/fail2ban/index.py @@ -269,8 +269,26 @@ def initdUinstall(): return 'ok' - - +# 读取配置 +def _read_conf(path, l=None): + conf = mw.readFile(path) + if not conf: + if not l: + conf = {} + else: + conf = [] + mw.writeFile(path, json.dumps(conf)) + return conf + return json.loads(conf) + +def getBlackList(): + _black_list = getServerDir + "/black_list.json" + conf = _read_conf(_black_list, l=1) + if not conf: + return '' + if not conf: + return [] + return "\n".join(conf) if __name__ == "__main__": func = sys.argv[1]