1
0
mirror of https://github.com/pavel-odintsov/fastnetmon synced 2024-11-24 02:46:36 +01:00

Add stub for firewall queue implementation

This commit is contained in:
Pavel Odintsov 2015-05-15 17:35:02 +03:00
parent a80f0b44f2
commit 0d2440160d
2 changed files with 44 additions and 0 deletions

@ -0,0 +1,36 @@
#!/usr/bin/env python
import os
import sys
import time
from redis import Redis
from rq import Queue
exabgp_log = open("/tmp/exabgp.log", "a")
import firewall_queue
q = Queue(connection=Redis())
while True:
try:
line = sys.stdin.readline().strip()
# print >> sys.stderr, "GOT A LINE"
sys.stdout.flush()
if line == "":
counter += 1
if counter > 100:
break
continue
counter = 0
q.enqueue(firewall_queue.execute_ip_ban, line)
exabgp_log.write(line + "\n")
except KeyboardInterrupt:
pass
except IOError:
# most likely a signal during readline
pass

8
src/firewall_queue.py Normal file

@ -0,0 +1,8 @@
from subprocess import call
def execute_ip_ban(ip):
print "Will ban IP: " + ip + "\n"
call(["iptables", "-A", "INPUT", "-s", ip, "-j", "DROP"])
return True