chiark / gitweb /
test: Generate configs from pieces
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Thu, 10 Oct 2019 16:52:25 +0000 (17:52 +0100)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Sat, 12 Oct 2019 22:29:26 +0000 (23:29 +0100)
The resulting files are semantically equivalent to
test-example/{in,out}side.conf.

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
.gitignore
test/invoke

index bf9a085..b124db0 100644 (file)
@@ -35,3 +35,5 @@ test-example/*.key
 test-example/sites.conf
 test-example/bogus-setup-request
 build-stamp
+
+test/*.conf
index 4795075..24e8fca 100755 (executable)
@@ -2,9 +2,68 @@
 
 package require Tclx
 
+set netlink(inside) {
+    local-address "172.18.232.9";
+    secnet-address "172.18.232.10";
+    remote-networks "172.18.232.0/28";
+}
+set netlink(outside) {
+    local-address "172.18.232.1";
+    secnet-address "172.18.232.2";
+    remote-networks "172.18.232.0/28";
+}
+
+set ports(inside) {16913 16910}
+set ports(outside) 16900
+
+set extra(inside) {
+    local-mobile True;
+    mtu-target 1260;
+}
+set extra(outside) {}
+
+proc mkconf {which} {
+    global netlink
+    global ports
+    global extra
+    set cfg "
+       netlink tun {
+           name \"netlink-tun\";
+       $netlink($which)
+           mtu 1400;
+           buffer sysbuffer(2048);
+           interface \"secnet-test-[string range $which 0 0]\";
+        };
+        comm
+"
+    set delim {}
+    foreach port $ports($which) {
+       append cfg "$delim
+           udp {
+                port $port;
+               buffer sysbuffer(4096);
+           }
+       "
+        set delim ,
+    }
+    append cfg ";
+       local-name \"test-example/$which/$which\";
+       local-key rsa-private(\"test-example/$which.key\");
+"
+    append cfg $extra($which)
+    append cfg "
+       include test-example/common.conf
+    "
+    return $cfg
+}
+
 proc spawn-secnet {which} {
     upvar #0 pids($which) pid
-    set argl [list ./secnet -dvnc test-example/$which.conf]
+    set cf test/$which.conf
+    set ch [open $cf w]
+    puts $ch [mkconf $which]
+    close $ch
+    set argl [list ./secnet -dvnc $cf]
     set pid [fork]
     if {!$pid} {
        execl really $argl