more tweaking

This commit is contained in:
brent s. 2020-05-10 17:22:29 -04:00
parent 5344a99a6b
commit 0b07050ce4
Signed by: bts
GPG Key ID: 8C004C2F93481F6B
1 changed files with 8 additions and 4 deletions

View File

@ -107,7 +107,9 @@ class TunnelBroker(object):
logger.debug('Set server IP to {0}.'.format(str(self.server)))
self.allocations = [ipaddress.ip_network(ip.strip()) for ip in self.cfg['allocations'].split(',')]
logger.debug('Using address allocations: {0}'.format(', '.join([str(ip) for ip in self.allocations])))
self.addr = ipaddress.ip_network(self.cfg['address'].strip())
_net = ipaddress.ip_network(self.cfg['address'].strip(), strict = False)
self.addr = ipaddress.ip_address(self.cfg['address'].strip().split('/')[0])
self.network = ipaddress.ip_network(self.cfg['address'].strip(), strict = False)
for k in ('user', 'update_key'):
setattr(self, k, self.cfg[k])
# Don't log creds, even in debug.
@ -170,10 +172,12 @@ class TunnelBroker(object):
try:
self.ipr.addr('add',
index = self.iface_idx,
address = str(self.addr.network_address),
mask = self.addr.prefixlen,
address = str(self.addr),
mask = self.network.prefixlen,
family = socket.AF_INET6)
logger.debug('Added address {0} to link {1}.'.format(str(self.addr), self.iface_name))
logger.debug('Added address {0} to link {1} with prefix {2}.'.format(str(self.addr),
self.iface_name,
self.network.prefixlen))
except Exception as e:
logger.error(('Could not add address {0} on link {1}: '
'{2}').format(str(self.addr), self.iface_name, e))