mirror of
https://codeberg.org/prof_x_pvt_ltd/captive.whump.shanti-portal
synced 2024-08-14 22:46:42 +00:00
returning out of process to create only one rule each.
This commit is contained in:
parent
630a1f93c5
commit
f5f4106273
1 changed files with 16 additions and 1 deletions
|
@ -23,7 +23,8 @@ def run(arg):
|
||||||
# Setup plugin logging
|
# Setup plugin logging
|
||||||
l = getLogger('plugin_iptables')
|
l = getLogger('plugin_iptables')
|
||||||
l.addHandler(logHandler)
|
l.addHandler(logHandler)
|
||||||
l.setLevel(DEBUG)
|
if config.get('debug', False):
|
||||||
|
l.setLevel(DEBUG)
|
||||||
|
|
||||||
client_ip = environ.get(
|
client_ip = environ.get(
|
||||||
'HTTP_X_FORWARDED_FOR',
|
'HTTP_X_FORWARDED_FOR',
|
||||||
|
@ -63,6 +64,13 @@ def run(arg):
|
||||||
error = BytesIO()
|
error = BytesIO()
|
||||||
try:
|
try:
|
||||||
rc = sudo.iptables(iptables_mac, _out=output, _err=error)
|
rc = sudo.iptables(iptables_mac, _out=output, _err=error)
|
||||||
|
|
||||||
|
if rc.exit_code == 0:
|
||||||
|
l.debug('Created iptables MAC rule successfully')
|
||||||
|
return {
|
||||||
|
'error': error_msg,
|
||||||
|
'failed': False
|
||||||
|
}
|
||||||
except ErrorReturnCode:
|
except ErrorReturnCode:
|
||||||
error.seek(0)
|
error.seek(0)
|
||||||
error_msg = error.read()
|
error_msg = error.read()
|
||||||
|
@ -96,6 +104,13 @@ def run(arg):
|
||||||
error = BytesIO()
|
error = BytesIO()
|
||||||
try:
|
try:
|
||||||
rc = sudo.iptables(iptables_ip, _out=output, _err=error)
|
rc = sudo.iptables(iptables_ip, _out=output, _err=error)
|
||||||
|
|
||||||
|
if rc.exit_code == 0:
|
||||||
|
l.debug('Created iptables IP rule successfully')
|
||||||
|
return {
|
||||||
|
'error': error_msg,
|
||||||
|
'failed': False
|
||||||
|
}
|
||||||
except ErrorReturnCode:
|
except ErrorReturnCode:
|
||||||
error.seek(0)
|
error.seek(0)
|
||||||
error_msg = error.read()
|
error_msg = error.read()
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue