bug fixes
This commit is contained in:
parent
3ecb33fda4
commit
3f5eeca68e
1 changed files with 23 additions and 19 deletions
32
main.py
32
main.py
|
@ -16,9 +16,12 @@ import argparse
|
||||||
import firewall_config
|
import firewall_config
|
||||||
|
|
||||||
import sys
|
import sys
|
||||||
|
import os
|
||||||
|
|
||||||
|
path =(os.path.dirname(os.path.abspath(__file__)))
|
||||||
|
|
||||||
config = ConfigParser()
|
config = ConfigParser()
|
||||||
config.read('config.ini')
|
config.read(path+'/config.ini')
|
||||||
|
|
||||||
api_hostname = config.get('Re2o', 'hostname')
|
api_hostname = config.get('Re2o', 'hostname')
|
||||||
api_password = config.get('Re2o', 'password')
|
api_password = config.get('Re2o', 'password')
|
||||||
|
@ -28,11 +31,6 @@ api_client = Re2oAPIClient(api_hostname, api_username, api_password)
|
||||||
|
|
||||||
client_hostname = socket.gethostname().split('.', 1)[0]
|
client_hostname = socket.gethostname().split('.', 1)[0]
|
||||||
|
|
||||||
for arg in sys.argv:
|
|
||||||
if arg=="--force":
|
|
||||||
table=iptables()
|
|
||||||
table.action="restart"
|
|
||||||
table.do_action()
|
|
||||||
|
|
||||||
class iptables:
|
class iptables:
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
|
@ -625,13 +623,7 @@ class iptables:
|
||||||
"""Retire la mac de la blacklist"""
|
"""Retire la mac de la blacklist"""
|
||||||
self.atomic_del("filter", subtable, """-m mac --mac-source %s -j REJECT""" % mac, mode=mode)
|
self.atomic_del("filter", subtable, """-m mac --mac-source %s -j REJECT""" % mac, mode=mode)
|
||||||
|
|
||||||
|
def run(args):
|
||||||
if __name__ == '__main__':
|
|
||||||
parser = argparse.ArgumentParser()
|
|
||||||
parser.add_argument("-v", "--verbose", help="increase output verbosity", action="store_true")
|
|
||||||
parser.add_argument("-e", "--export", help="export le contenu du parefeu", action="store_true")
|
|
||||||
parser.add_argument("action", help="Mode reconnus : start, stop ou restart")
|
|
||||||
args = parser.parse_args()
|
|
||||||
table = iptables()
|
table = iptables()
|
||||||
if args.verbose:
|
if args.verbose:
|
||||||
table.verbose = True
|
table.verbose = True
|
||||||
|
@ -639,10 +631,22 @@ if __name__ == '__main__':
|
||||||
table.export = args.export
|
table.export = args.export
|
||||||
table.do_action()
|
table.do_action()
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
parser = argparse.ArgumentParser()
|
||||||
|
parser.add_argument("-v", "--verbose", help="increase output verbosity", action="store_true")
|
||||||
|
parser.add_argument("-e", "--export", help="export le contenu du parefeu", action="store_true")
|
||||||
|
parser.add_argument("action", help="Mode reconnus : start, stop ou restart", default="restart")
|
||||||
|
args = parser.parse_args()
|
||||||
|
|
||||||
|
for arg in sys.argv:
|
||||||
|
if arg=="--force":
|
||||||
|
run(args)
|
||||||
|
|
||||||
for service in api_client.list("services/regen/"):
|
for service in api_client.list("services/regen/"):
|
||||||
if service['hostname'] == client_hostname and \
|
if service['hostname'] == client_hostname and \
|
||||||
service['service_name'] == 'firewall' and \
|
service['service_name'] == 'firewall' and \
|
||||||
service['need_regen']:
|
service['need_regen']:
|
||||||
notif_end_adhesion(api_client)
|
run(args)
|
||||||
api_client.patch(service['api_url'], data={'need_regen': False})
|
api_client.patch(service['api_url'], data={'need_regen': False})
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue