@@@ testing
[secnet] / make-secnet-sites
index 371c82e..e63a2c2 100755 (executable)
@@ -70,7 +70,21 @@ VERSION="0.1.18"
 
 class basetype:
        "Common protocol for configuration types."
-       pass
+       def add(self,obj,w):
+               complain("%s %s already has property %s defined"%
+                       (obj.type,obj.name,w[0]))
+
+class conflist:
+       "A list of some kind of configuration type."
+       def __init__(self,subtype,w):
+               self.subtype=subtype
+               self.list=[subtype(w)]
+       def add(self,obj,w):
+               self.list.append(self.subtype(w))
+       def __str__(self):
+               return ', '.join(map(str, self.list))
+def listof(subtype):
+       return lambda w: conflist(subtype, w)
 
 class single_ipaddr (basetype):
        "An IP address"
@@ -89,13 +103,16 @@ class networks (basetype):
        def __str__(self):
                return ",".join(map((lambda n: '"%s"'%n), self.set.networks()))
 
-class dhgroup (basetype):
+class trad_dhgroup (basetype):
        "A Diffie-Hellman group"
        def __init__(self,w):
                self.mod=w[1]
                self.gen=w[2]
        def __str__(self):
                return 'diffie-hellman("%s","%s")'%(self.mod,self.gen)
+def dhgroup(w):
+       if w[1] in ('x25519', 'x448'): return w[1]
+       else: return trad_dhgroup(w)
 
 class hash (basetype):
        "A choice of hash function"
@@ -154,7 +171,7 @@ class rsakey (basetype):
 # Possible properties of configuration nodes
 keywords={
  'contact':(email,"Contact address"),
- 'dh':(dhgroup,"Diffie-Hellman group"),
+ 'dh':(listof(dhgroup),"Diffie-Hellman group"),
  'hash':(hash,"Hash function"),
  'key-lifetime':(num,"Maximum key lifetime (ms)"),
  'setup-timeout':(num,"Key setup timeout (ms)"),
@@ -328,8 +345,7 @@ prefix=''
 def set_property(obj,w):
        "Set a property on a configuration node"
        if obj.properties.has_key(w[0]):
-               complain("%s %s already has property %s defined"%
-                       (obj.type,obj.name,w[0]))
+               obj.properties[w[0]].add(obj,w)
        else:
                obj.properties[w[0]]=keywords[w[0]][0](w)