]> git.ipfire.org Git - people/ms/ipfire-2.x.git/commitdiff
freifunk.cgi: Update configuration writer to newer JSON formats
authorMichael Tremer <michael.tremer@ipfire.org>
Sun, 8 Mar 2015 19:14:18 +0000 (20:14 +0100)
committerMichael Tremer <michael.tremer@ipfire.org>
Mon, 9 Mar 2015 15:39:08 +0000 (16:39 +0100)
html/cgi-bin/freifunk.cgi

index 8c3036280addccfd1610b56cd8f582aedaa90594..489c0dfd1dd56605306e8ae045fbbc209d9fcbcf 100755 (executable)
@@ -268,25 +268,48 @@ sub BuildConfiguration() {
        print FILE "secret \"$settings{'FASTD_SECRET'}\";\n";
        print FILE "secure handshakes yes;\n\n";
 
-       print FILE "# Ciphers\n";
-       my $ciphers = $network->{'ciphers'};
-       foreach my $cipher (@$ciphers) {
-               print FILE "method \"$cipher\";\n";
-       }
-       print FILE "\n";
-
-       print FILE "# Upstream connection\n";
-       print FILE "mtu $network->{'mtu-vpn'};\n";
+       my @ciphers = ();
+       my $mtu = 1500;
 
        my $nodes = $network->{'supernodes'};
        foreach my $node (@$nodes) {
+               # We only support fastd for now
+               if ($node->{'protocol'} ne 'fastd') {
+                       next;
+               }
+
                print FILE "peer \"$node->{'peer'}\" {\n";
                print FILE "\tkey \"$node->{'key'}\";\n";
                print FILE "\tremote \"$node->{'remote'}\" port $node->{'port'};\n";
                print FILE "}\n";
+
+               # XXX This will take the ciphers and put them all
+               # in a huge list and pass them to fastd. The order
+               # is not respected very well and it is not guaranteed
+               # that the best cipher will be first in the list.
+               my $node_ciphers = $node->{'ciphers'};
+               foreach my $cipher (@$node_ciphers) {
+                       unless ($cipher ~~ @ciphers) {
+                               push(@ciphers, $cipher);
+                       }
+               }
+
+               my $node_mtu = $node->{'mtu'} ? $node->{'mtu'} : $node->{'mtu-vpn'};
+               if ($node_mtu) {
+                       $mtu = $node_mtu < $mtu ? $node_mtu : $mtu;
+               }
        }
        print FILE "\n";
 
+       print FILE "# Ciphers\n";
+       foreach my $cipher (@ciphers) {
+               print FILE "method \"$cipher\";\n";
+       }
+       print FILE "\n";
+
+       print FILE "# Upstream connection\n";
+       print FILE "mtu $mtu;\n\n";
+
        print FILE "# Hooks\n";
        foreach my $hook ("pre-up", "up") {
                print FILE "on $hook \"/etc/init.d/fastd on-$hook\";\n";