-#! /usr/bin/env python
+#! /usr/bin/env python3
#
# This file is part of secnet.
# See README for full list of copyright holders.
cd ~/secnet/sites-test/
execute ~/secnet/make-secnet-sites.py -u vpnheader groupfiles sites
-This program is part of secnet. It relies on the "ipaddr" library from
-Cendio Systems AB.
+This program is part of secnet.
"""
from __future__ import print_function
+from __future__ import unicode_literals
from builtins import int
import string
import getopt
import re
-import ipaddr
+import ipaddress
# entry 0 is "near the executable", or maybe from PYTHONPATH=.,
# which we don't want to preempt
VERSION="0.1.18"
+from sys import version_info
+if version_info.major == 2: # for python2
+ import codecs
+ sys.stdin = codecs.getreader('utf-8')(sys.stdin)
+ sys.stdout = codecs.getwriter('utf-8')(sys.stdout)
+ import io
+ open=lambda f,m='r': io.open(f,m,encoding='utf-8')
+
# Are we being invoked from userv?
service=0
# If we are, which group does the caller want to modify?
class single_ipaddr (basetype):
"An IP address"
def __init__(self,w):
- self.addr=ipaddr.IPAddress(w[1])
+ self.addr=ipaddress.ip_address(w[1])
def __str__(self):
return '"%s"'%self.addr
def __init__(self,w):
self.set=ipaddrset.IPAddressSet()
for i in w[1:]:
- x=ipaddr.IPNetwork(i,strict=True)
+ x=ipaddress.ip_network(i,strict=True)
self.set.append([x])
def __str__(self):
return ",".join(map((lambda n: '"%s"'%n), self.set.networks()))
allow_properties={}
require_properties={}
def __init__(self,w):
+ self.type=w[0]
self.name=w[1]
self.properties={}
self.children={}
return 0
def delempty(n):
"Delete nodes that have no leafnode children"
- for i in n.children.keys():
+ for i in list(n.children.keys()):
delempty(n.children[i])
if not live(n.children[i]):
del n.children[i]