Exemple #1
0
 def parse_text(text):
     '''
     >>> text = """
     ... [lns default]
     ... local ip = 10.9.0.1
     ... ip range = 10.9.0.30-250
     ... length bit = yes
     ... """ 
     >>> L2TPConfParser.parse_text(text)
     {'remote_ip': [('10.9.0.30', '10.9.0.250')], 'local_ip': ['10.9.0.1']}
     '''
     conf = {}
     for line in text.split('\n'):
         line = line.strip()
         if line.startswith("local ip"):
             conf['local_ip']= parse_ip_line(line.split("=", 1)[1])
         elif line.startswith("ip range"):
             conf['remote_ip']= parse_ip_line(line.split("=", 1)[1])
     return conf
Exemple #2
0
 def parse_text(text):
     '''
     >>> text = """
     ... localip  10.10.0.1
     ... remoteip 10.10.0.100-200
     ... """ 
     >>> PPTPConfParser.parse_text(text)
     {'remote_ip': [('10.10.0.100', '10.10.0.200')], 'local_ip': ['10.10.0.1']}
     >>> text = """
     ... localip 192.168.0.234-238,192.168.0.245
     ... remoteip 192.168.1.234-238,192.168.1.245
     ... """ 
     >>> PPTPConfParser.parse_text(text)
     {'remote_ip': [('192.168.1.234', '192.168.1.238'), '192.168.1.245'], 'local_ip': [('192.168.0.234', '192.168.0.238'), '192.168.0.245']}
     '''
     conf = {}
     for line in text.split('\n'):
         line = line.strip()
         if line.startswith("localip"):
             conf['local_ip']= parse_ip_line(line.split(None, 1)[1])
         elif line.startswith("remoteip"):
             conf['remote_ip']= parse_ip_line(line.split(None, 1)[1])
     return conf