so it turns out it returns the same structure, just with a single <tunnels> child. i can probably just use the general HEConf then and wrap it?

This commit is contained in:
brent s. 2020-05-15 01:40:42 -04:00
parent b00351f762
commit cf51e96852
Signed by: bts
GPG Key ID: 8C004C2F93481F6B
2 changed files with 10 additions and 9 deletions

View File

@ -12,7 +12,7 @@ def parseArgs():
args.add_argument('-c', '--config', args.add_argument('-c', '--config',
dest = 'conf_xml', dest = 'conf_xml',
default = '~/.config/he_tunnelbroker.xml', default = '~/.config/he_tunnelbroker.xml',
help = ('The path to the config. See example.tunnelbroker.xml' help = ('The path to the config. See example.tunnelbroker.xml '
'Default: ~/.config/he_tunnelbroker.xml')) 'Default: ~/.config/he_tunnelbroker.xml'))
args.add_argument('-t', '--tunnel-id', args.add_argument('-t', '--tunnel-id',
dest = 'tun_id', dest = 'tun_id',

View File

@ -266,37 +266,38 @@ class HETunnelConfig(HEBaseConfig):
self.my_ip = None # Client IPv4 (not necessary; we locally cache Tunnel.my_ip) self.my_ip = None # Client IPv4 (not necessary; we locally cache Tunnel.my_ip)
self.allocations = {} # keys are 64 and 48 self.allocations = {} # keys are 64 and 48
self.rdns = [] # Also not necessary, but it's in the XML so why not. self.rdns = [] # Also not necessary, but it's in the XML so why not.
self.tun_xml = self.xml.find('tunnel') # Will only return a single <tunnel> for this URL.
self.parse() self.parse()


def _alloc(self): def _alloc(self):
for a in ('64', '48'): for a in ('64', '48'):
_alloc = self.xml.find('routed{0}'.format(a)) _alloc = self.tun_xml.find('routed{0}'.format(a))
if _alloc is not None and _alloc.text.strip() != '': if _alloc is not None and _alloc.text.strip() != '':
self.allocations[int(a)] = tunnel.Allocation(_alloc.text.strip()) self.allocations[int(a)] = tunnel.Allocation(_alloc.text.strip())
return(None) return(None)


def _client(self): def _client(self):
_client = self.xml.find('clientv4').text _client = self.tun_xml.find('clientv4').text
if _client is not None and _client.strip() != '': if _client is not None and _client.strip() != '':
self.client = tunnel.IP4(_client.strip(), 32) self.client = tunnel.IP4(_client.strip(), 32)
return(None) return(None)


def _desc(self): def _desc(self):
_desc = self.xml.find('description').text _desc = self.tun_xml.find('description').text
if _desc is not None and _desc.strip() != '': if _desc is not None and _desc.strip() != '':
self.description = _desc.strip() self.description = _desc.strip()
return(None) return(None)


def _endpoint(self): def _endpoint(self):
self.endpoint = tunnel.IP4(self.xml.find('serverv4').text.strip(), 32) self.endpoint = tunnel.IP4(self.tun_xml.find('serverv4').text.strip(), 32)
return(None) return(None)


def _id(self): def _id(self):
self.id = int(self.xml.attrib['id']) self.id = int(self.tun_xml.attrib['id'])
return(None) return(None)


def _my_ip(self): def _my_ip(self):
_ip = self.xml.find('clientv4').text _ip = self.tun_xml.find('clientv4').text
if _ip is not None and _ip.strip() != '': if _ip is not None and _ip.strip() != '':
self.my_ip = tunnel.IP4(_ip.strip(), 32) self.my_ip = tunnel.IP4(_ip.strip(), 32)
return(None) return(None)
@ -304,14 +305,14 @@ class HETunnelConfig(HEBaseConfig):
def _rdns(self): def _rdns(self):
self.rdns = [] self.rdns = []
for r in range(1, 6): for r in range(1, 6):
_rdns = self.xml.find('rdns{0}'.format(r)) _rdns = self.tun_xml.find('rdns{0}'.format(r))
if _rdns is not None and _rdns.text.strip() != '': if _rdns is not None and _rdns.text.strip() != '':
self.rdns.append(_rdns.text.strip()) self.rdns.append(_rdns.text.strip())
self.rdns = tuple(self.rdns) self.rdns = tuple(self.rdns)
return(None) return(None)


def _server(self): def _server(self):
self.server = tunnel.IP6(self.xml.find('serverv6'), 128) self.server = tunnel.IP6(self.tun_xml.find('serverv6'), 128)
return(None) return(None)


def parse(self): def parse(self):