[Web] add manage f2b external option
This commit is contained in:
parent
65cbc478b8
commit
1537fb39c0
@ -258,14 +258,13 @@ def permBan(net, unban=False):
|
|||||||
global f2boptions
|
global f2boptions
|
||||||
global lock
|
global lock
|
||||||
if type(ipaddress.ip_network(net, strict=False)) is ipaddress.IPv4Network:
|
if type(ipaddress.ip_network(net, strict=False)) is ipaddress.IPv4Network:
|
||||||
if int(f2boptions['manage_external']) != 1:
|
|
||||||
with lock:
|
with lock:
|
||||||
chain = iptc.Chain(iptc.Table(iptc.Table.FILTER), 'MAILCOW')
|
chain = iptc.Chain(iptc.Table(iptc.Table.FILTER), 'MAILCOW')
|
||||||
rule = iptc.Rule()
|
rule = iptc.Rule()
|
||||||
rule.src = net
|
rule.src = net
|
||||||
target = iptc.Target(rule, "REJECT")
|
target = iptc.Target(rule, "REJECT")
|
||||||
rule.target = target
|
rule.target = target
|
||||||
if rule not in chain.rules and not unban:
|
if rule not in chain.rules and not unban and int(f2boptions['manage_external']) != 1:
|
||||||
logCrit('Add host/network %s to blacklist' % net)
|
logCrit('Add host/network %s to blacklist' % net)
|
||||||
chain.insert_rule(rule)
|
chain.insert_rule(rule)
|
||||||
r.hset('F2B_PERM_BANS', '%s' % net, int(round(time.time())))
|
r.hset('F2B_PERM_BANS', '%s' % net, int(round(time.time())))
|
||||||
@ -273,21 +272,14 @@ def permBan(net, unban=False):
|
|||||||
logCrit('Remove host/network %s from blacklist' % net)
|
logCrit('Remove host/network %s from blacklist' % net)
|
||||||
chain.delete_rule(rule)
|
chain.delete_rule(rule)
|
||||||
r.hdel('F2B_PERM_BANS', '%s' % net)
|
r.hdel('F2B_PERM_BANS', '%s' % net)
|
||||||
elif not unban:
|
|
||||||
logCrit('Add host/network %s to blacklist' % net)
|
|
||||||
r.hset('F2B_PERM_BANS', '%s' % net, int(round(time.time())))
|
|
||||||
elif unban:
|
|
||||||
logCrit('Remove host/network %s from blacklist' % net)
|
|
||||||
r.hdel('F2B_PERM_BANS', '%s' % net)
|
|
||||||
else:
|
else:
|
||||||
if int(f2boptions['manage_external']) != 1:
|
|
||||||
with lock:
|
with lock:
|
||||||
chain = iptc.Chain(iptc.Table6(iptc.Table6.FILTER), 'MAILCOW')
|
chain = iptc.Chain(iptc.Table6(iptc.Table6.FILTER), 'MAILCOW')
|
||||||
rule = iptc.Rule6()
|
rule = iptc.Rule6()
|
||||||
rule.src = net
|
rule.src = net
|
||||||
target = iptc.Target(rule, "REJECT")
|
target = iptc.Target(rule, "REJECT")
|
||||||
rule.target = target
|
rule.target = target
|
||||||
if rule not in chain.rules and not unban:
|
if rule not in chain.rules and not unban and int(f2boptions['manage_external']) != 1:
|
||||||
logCrit('Add host/network %s to blacklist' % net)
|
logCrit('Add host/network %s to blacklist' % net)
|
||||||
chain.insert_rule(rule)
|
chain.insert_rule(rule)
|
||||||
r.hset('F2B_PERM_BANS', '%s' % net, int(round(time.time())))
|
r.hset('F2B_PERM_BANS', '%s' % net, int(round(time.time())))
|
||||||
@ -295,12 +287,6 @@ def permBan(net, unban=False):
|
|||||||
logCrit('Remove host/network %s from blacklist' % net)
|
logCrit('Remove host/network %s from blacklist' % net)
|
||||||
chain.delete_rule(rule)
|
chain.delete_rule(rule)
|
||||||
r.hdel('F2B_PERM_BANS', '%s' % net)
|
r.hdel('F2B_PERM_BANS', '%s' % net)
|
||||||
elif not unban:
|
|
||||||
logCrit('Add host/network %s to blacklist' % net)
|
|
||||||
r.hset('F2B_PERM_BANS', '%s' % net, int(round(time.time())))
|
|
||||||
elif unban:
|
|
||||||
logCrit('Remove host/network %s from blacklist' % net)
|
|
||||||
r.hdel('F2B_PERM_BANS', '%s' % net)
|
|
||||||
|
|
||||||
def quit(signum, frame):
|
def quit(signum, frame):
|
||||||
global quit_now
|
global quit_now
|
||||||
|
Loading…
Reference in New Issue
Block a user