Commit c8fbe0d6 authored by Ruzal Gimazov's avatar Ruzal Gimazov Committed by Ruzal Gimazov

Bug fixed

parent bd01bbdb
[Definition]
[INCLUDES]
before = iptables-common.conf
[Definition]
# Notes.: create list blacklist at the start of Fail2Ban
# Value: CMD (eterban-switcher.py)
actionstart = ipset --create blacklist iphash
<iptables> -t nat -I PREROUTING -p tcp -m tcp --dport 80 -m set --match-set blacklist src -j REDIRECT --to-ports 4564
actionflush = ipset flush blacklist
actionstop = <iptables> -t nat -D PREROUTING -p tcp -m tcp --dport 80 -m set --match-set blacklist src -j REDIRECT --to-ports 4564
<actionflush>
ipset destroy blacklist
actionban = ipset -A blacklist <ip>
actionunban = ipset -D blacklist <ip>
......@@ -2,7 +2,7 @@
Description= Start eterban_switcher.py
[Service]
ExecStart=/etc/eterban/eterban_switcher.py
ExecStart=/usr/share/eterban/eterban_switcher.py
[Install]
WantedBy=multi-user.target
\ No newline at end of file
......@@ -6,14 +6,20 @@ f = open ('/etc/eterban/eterban.conf','r')
line = f.readline()
f.close()
if line[:10] == "host_redis":
i = 10
while (line[i] == " "):
i+=1
i+=1
while (line[i] == " "):
i+=1
if line[-1] == '\n':
host_redis = line[-16:-1]
host_redis = line[i:-1]
else:
host_redis = line[-15:]
host_redis = line[i:]
del(line)
del(f)
subprocess.call ('ipset create blacklist hash:ip', stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell = True)
#subprocess.call ('ipset create blacklist hash:ip', stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell = True)
r = redis.Redis(host=host_redis)
p = r.pubsub()
......
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