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

@ -266,37 +266,38 @@ class HETunnelConfig(HEBaseConfig):
self.my_ip = None # Client IPv4 (not necessary; we locally cache Tunnel.my_ip)
self.allocations = {} # keys are 64 and 48
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()

def _alloc(self):
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() != '':
self.allocations[int(a)] = tunnel.Allocation(_alloc.text.strip())
return(None)

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

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

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)

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

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() != '':
self.my_ip = tunnel.IP4(_ip.strip(), 32)
return(None)
@ -304,14 +305,14 @@ class HETunnelConfig(HEBaseConfig):
def _rdns(self):
self.rdns = []
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() != '':
self.rdns.append(_rdns.text.strip())
self.rdns = tuple(self.rdns)
return(None)

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

def parse(self):