From a0d5071a8d2adda13bd6b21a23707c6948084403 Mon Sep 17 00:00:00 2001 From: brent s Date: Sat, 16 May 2020 01:47:06 -0400 Subject: [PATCH] i'm... going to re-do this. --- utils/he_ipv6/config.py | 39 +++++++++++++++++++++++++++++++++++++-- 1 file changed, 37 insertions(+), 2 deletions(-) diff --git a/utils/he_ipv6/config.py b/utils/he_ipv6/config.py index e634284..185d99f 100644 --- a/utils/he_ipv6/config.py +++ b/utils/he_ipv6/config.py @@ -11,8 +11,43 @@ from lxml import etree from pyroute2 import IPRoute ## from . import tunnel -from . import radvd -from . import utils + + +def create_default_cfg(): + # Create a stripped sample config. + nsmap = {None: 'https://tunnelbroker.net/', + 'xsi': 'http://www.w3.org/2001/XMLSchema-instance'} + attr_qname = etree.QName('http://www.w3.org/2001/XMLSchema-instance', 'schemaLocation') + schema_url = 'http://schema.xml.r00t2.io/projects/he_ipv6.xsd' + schema_loc = '{0} {1}'.format(nsmap[None], schema_url) + xml = etree.Element('heIPv6', + {attr_qname: schema_loc}, + nsmap = nsmap) + xml.append(etree.Comment(('See example.tunnelbroker.xml for an extensively commented sample config.'))) + creds = etree.SubElement(xml, 'creds') + creds.append(etree.Comment(('Your tunnelbroker.net *login*. You can specify multiple credentials via multiple ' + '"cred" items. The "id" attribute is up to you but it must be unique.'))) + cred = etree.SubElement(creds, 'cred') + cred.attrib['id'] = '' + user = etree.SubElement(cred, 'user') + user.text = '' + password = etree.SubElement(cred, 'password') + password.text = '' + tunnels = etree.SubElement(xml, 'tunnels') + tunnels.append(etree.Comment(('You can have define multiple tunnels via multiple "tunnel" items. You should most ' + 'likely only run one at a time.'))) + tunnel = etree.SubElement(tunnels, 'tunnel') + tunnel.append(etree.Comment(('The "id" attribute should match the id number of a tunnel on your tunnelbroker.net ' + 'account. The "creds" attribute references a cred item id attribute.'))) + tunnel.attrib['id'] = '' + tunnel.attrib['creds'] = '' + ukey = etree.SubElement(tunnel, '') + return (etree.tostring(xml, + encoding = 'UTF-8', + xml_declaration = True, + pretty_print = True, + with_tail = True, + with_comments = True)) class Credential(object):