add fail2ban scripts

This commit is contained in:
Kovasky Buezo
2024-03-21 14:48:17 -04:00
parent cec0093439
commit cfba8ee2b8
3 changed files with 11 additions and 4 deletions

View File

@ -1,3 +1,3 @@
[Definition]
actionban = /data/action.d/entryPoint.py <ip> add
actionunban = /data/action.d/entryPoint.py <ip>clea del
actionunban = /data/action.d/entryPoint.py <ip> del

View File

@ -1,5 +1,9 @@
#!/usr/bin/python3
"""
Creates a virtual environment, installs dependencies, and then calls modifyBanList.py
"""
import os
import sys
@ -12,8 +16,5 @@ venv_dir = 'env'
if not os.path.exists(venv_dir):
os.system(f"{sys.executable} -m venv {venv_dir}")
activate_script = os.path.join(venv_dir, 'bin', 'activate')
os.system(f"chmod +x {activate_script}")
os.system(f"{os.path.join(venv_dir, 'bin', 'pip')} install --upgrade requests ipaddress")
os.system(f"{os.path.join(venv_dir, 'bin', 'python')} /data/action.d/modifyBanList.py {sys.argv[1]} {sys.argv[2]}")

View File

@ -1,5 +1,10 @@
#!/usr/bin/python3
"""
Called by entryPoint.py, performs the addition or deletion of an item in a Cloudflare custom list.
Support for IPV6 is limited as it blocks the entire /64 subnet.
"""
import sys
import requests
from requests import Response
@ -53,6 +58,7 @@ if __name__ == "__main__":
}
existingIpList = getIPList(apiEndpoint,headers)
print(existingIpList)
response = None
if action == "del":