Commit 72ffa764 authored by Vitaly Lipatov's avatar Vitaly Lipatov

gateway: reload whitelist on HUP

parent b58b9465
...@@ -89,6 +89,11 @@ if [ "$command" = "clear" ] ; then ...@@ -89,6 +89,11 @@ if [ "$command" = "clear" ] ; then
exit exit
fi fi
if [ "$command" = "reload-whitelist" ] ; then
systemctl kill --signal=HUP eterban.service
exit
fi
if [ "$command" = "info" ] ; then if [ "$command" = "info" ] ; then
/usr/share/eterban/autoban_cli.py info $1 /usr/share/eterban/autoban_cli.py info $1
exit exit
...@@ -121,6 +126,7 @@ Commands: ...@@ -121,6 +126,7 @@ Commands:
unban <ip> - unban IP unban <ip> - unban IP
ban <ip> - ban IP ban <ip> - ban IP
clear --force - remove all IPs from ban clear --force - remove all IPs from ban
reload-whitelist - reload whitelist.txt without restarting eterban
Auto-unban commands: Auto-unban commands:
info <ip> - show ban info and history for IP info <ip> - show ban info and history for IP
......
...@@ -329,6 +329,15 @@ def log_redis_error(message): ...@@ -329,6 +329,15 @@ def log_redis_error(message):
log.flush() log.flush()
def reload_whitelist(signum, frame):
"""Reload the configured whitelist without changing firewall topology."""
try:
loaded = load_whitelist()
log_redis_error("Whitelist reloaded: " + str(loaded) + " entries")
except (OSError, subprocess.SubprocessError) as error:
log_redis_error("Unable to reload whitelist: " + str(error))
def configure_autoban_logging(): def configure_autoban_logging():
autoban_log = logging.getLogger('autoban_manager') autoban_log = logging.getLogger('autoban_manager')
autoban_log.setLevel(logging.ERROR) autoban_log.setLevel(logging.ERROR)
...@@ -339,6 +348,7 @@ def configure_autoban_logging(): ...@@ -339,6 +348,7 @@ def configure_autoban_logging():
configure_autoban_logging() configure_autoban_logging()
signal.signal(signal.SIGHUP, reload_whitelist)
conntrack_queue = queue.Queue(maxsize=1024) conntrack_queue = queue.Queue(maxsize=1024)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment