Compare commits

..

No commits in common. "31f5e94ae14cd915444c1df8b4a493dc81b2085e" and "b1a296f05a5cee6633a6ee25139853c91706bc9a" have entirely different histories.

2 changed files with 12 additions and 23 deletions

View File

@ -68,17 +68,15 @@ def load_conf():
def ping(hostname):
cmd = "ping -4 -c1 -w3 %s" % hostname
cmd = "ping -c1 -w3 %s" % hostname
ret = subprocess.run(cmd.split(), stdout=subprocess.PIPE, stderr=subprocess.PIPE)
return 0 if ret.returncode else 1
def get_hosts():
r = sysbus.requete('Devices:get', silent=True)
hosts = { 'A': {}, 'AAAA': {} }
if not r:
return hosts
r = sysbus.requete('Devices:get')
hosts = { 'A': {}, 'AAAA': {} }
for h in r['status']:
ns = {}
for n in h['Names']:
@ -104,11 +102,8 @@ def get_hosts():
def get_wan_addr():
r = sysbus.requete('NMC:getWANStatus', silent=True)
r = sysbus.requete('NMC:getWANStatus')
wan = dict()
if not r or not r.get('data') or not r['data'].get('IPAddress') or not r['data'].get('IPv6Address'):
log('get_wan_addr: {}'.format(r))
return None
wan['ipv4'] = r['data']['IPAddress']
wan['ipv6'] = r['data']['IPv6Address']
if wan['ipv4'] == '0.0.0.0':
@ -278,12 +273,12 @@ def livebox_rule_id(words):
def livebox_delete_port_nat(port, addr):
log('livebox: delete PortNat {} to {}'.format(port, addr))
id = livebox_rule_id([port])
r = sysbus.requete('Firewall:deletePortForwarding', { 'id': id, 'origin': 'webui' }, silent=True)
r = sysbus.requete('Firewall:deletePortForwarding', { 'id': id, 'origin': 'webui' })
def livebox_delete_pinhole(port, addr):
log('livebox: delete pinhole {} to {}'.format(port, addr))
id = livebox_rule_id([port, addr])
r = sysbus.requete('Firewall:deletePinhole', { 'id': id, 'origin': 'webui' }, silent=True)
r = sysbus.requete('Firewall:deletePinhole', { 'id': id, 'origin': 'webui' })
def livebox_add_port_nat(port, addr):
log('livebox: add PortNat {} to {}'.format(port, addr))
@ -297,7 +292,7 @@ def livebox_add_port_nat(port, addr):
'internalPort': port,
'enable': True,
}
r = sysbus.requete('Firewall:setPortForwarding', a, silent=True)
r = sysbus.requete('Firewall:setPortForwarding', a)
def livebox_add_pinhole(port, addr):
log('livebox: add pinhole {} to {}'.format(port, addr))
@ -312,7 +307,7 @@ def livebox_add_pinhole(port, addr):
'ipversion': '6',
'enable': True,
}
r = sysbus.requete('Firewall:setPinhole', a, silent=True)
r = sysbus.requete('Firewall:setPinhole', a)
def livebox_update_fw(zone, update, sync_zone):
for prot, addr, port in update['delete']:
@ -377,19 +372,13 @@ if not ping(wan_hostname):
sys.exit(0)
sysbus.load_conf()
try:
r = sysbus.auth(False)
if not r:
log('Error: cannot authenticate on livebox')
sys.exit(1)
except Exception as e:
log('Error: %s'.format(e))
sys.exit(1)
hosts = get_hosts()
wan = get_wan_addr()
if not wan:
sys.exit(0)
zone = read_zone_list(zone_filename)
sync_zone = False

2
sysbus

@ -1 +1 @@
Subproject commit 87040a0906df80ade21ea863452838a8a574bdbd
Subproject commit 5526cb53641e5620dfe9d688b9a4b90a40076f91