summaryrefslogtreecommitdiff
path: root/roles/install_fastd/templates
diff options
context:
space:
mode:
authorNiklas Yann Wettengel <niyawe@niyawe.de>2017-07-03 09:46:42 +0200
committerNiklas Yann Wettengel <niyawe@niyawe.de>2017-07-03 09:46:42 +0200
commitd82f8524972086862f64750f325ba067ea993d86 (patch)
treeaa7634db168da40d108e43c7c30fbce299bdc7ab /roles/install_fastd/templates
parent90a8a597eaa3a008eac946460b5c621eafa8ec62 (diff)
fastd working
Diffstat (limited to 'roles/install_fastd/templates')
-rw-r--r--roles/install_fastd/templates/fastd-api.php.j245
-rw-r--r--roles/install_fastd/templates/fastd.conf.j212
-rw-r--r--roles/install_fastd/templates/fastd_up.sh.j214
3 files changed, 57 insertions, 14 deletions
diff --git a/roles/install_fastd/templates/fastd-api.php.j2 b/roles/install_fastd/templates/fastd-api.php.j2
new file mode 100644
index 0000000..7b1fc17
--- /dev/null
+++ b/roles/install_fastd/templates/fastd-api.php.j2
@@ -0,0 +1,45 @@
+#!/usr/bin/php -f
+<?php
+//$url = 'http://register.freifunk-myk.de/srvapi.php';
+$url = 'https://www.freifunk-myk.de/node/keys';
+$out = '/etc/fastd/ff{{ item.name }}/peers/';
+
+if(!is_dir($out)) die('Output Dir missing');
+if(!is_writable($out)) die('Output Dir perms');
+
+if( ($data = file_get_contents($url)) === FALSE ) die('Error getting keys');
+$data = unserialize($data);
+
+$active=array();
+
+foreach($data as $router) {
+ $router['MAC'] = trim($router['MAC']);
+ $router['PublicKey'] = trim($router['PublicKey']);
+ if(!preg_match('/^[A-F0-9]{2}:[A-F0-9]{2}:[A-F0-9]{2}:[A-F0-9]{2}:[A-F0-9]{2}:[A-F0-9]{2}$/', $router['MAC'])) {
+ //trigger_error('Router mit falscher MAC?!', E_USER_WARNING);
+ }elseif(!preg_match('/^[A-F0-9]{64}$/', $router['PublicKey'])) {
+ //trigger_error('Router mit falschem Key?!'.$router['MAC'], E_USER_WARNING);
+ }else{
+ $filename='client_'.str_replace(':', '-', $router['MAC']);
+ $fp=fopen($out.$filename, 'w');
+ fwrite($fp, 'key "'.$router['PublicKey'].'";'."\n");
+ fclose($fp);
+ $active[] = $filename;
+ }
+}
+
+//Check if we fscked up
+if(count($active) < 10) die('Less than 10 nodes? Database broken?');
+
+$dh = opendir($out);
+while(($file = readdir($dh)) !== false) {
+ if($file != '.' && $file != '..') {
+ if(!in_array($file, $active) && (strpos($file, 'client_') !== false)) {
+ unlink($out.$file);
+ }
+ }
+}
+
+exec('killall -SIGHUP fastd');
+
+?>
diff --git a/roles/install_fastd/templates/fastd.conf.j2 b/roles/install_fastd/templates/fastd.conf.j2
index 9d8a42b..1ec818d 100644
--- a/roles/install_fastd/templates/fastd.conf.j2
+++ b/roles/install_fastd/templates/fastd.conf.j2
@@ -1,18 +1,16 @@
log to syslog level info;
-interface "ffmyk-mesh-vpn";
+interface "vpn{{ item.name }}";
method "salsa2012+gmac";
method "salsa2012+umac";
secure handshakes yes;
-bind any:10000;
+bind any:{{ item.fastd_port1 }};
hide ip addresses yes;
hide mac addresses yes;
mtu 1280;
peer group "clients" {
include peers from "peers";
- peer limit {{ fastd_peer_limit }};
}
-include peers from "backbone";
-secret "{{ fastd_secret }}";
-on up "/etc/fastd/ffmyk/bin/up.sh $INTERFACE";
-status socket "/run/ffmyk.socket";
+secret "{{ item.fastd_secret }}";
+on up "/etc/fastd/ff{{ item.name }}/bin/up.sh $INTERFACE";
+status socket "/run/ff{{ item.name }}1.socket";
diff --git a/roles/install_fastd/templates/fastd_up.sh.j2 b/roles/install_fastd/templates/fastd_up.sh.j2
index 87b71ce..6ab39b0 100644
--- a/roles/install_fastd/templates/fastd_up.sh.j2
+++ b/roles/install_fastd/templates/fastd_up.sh.j2
@@ -1,11 +1,11 @@
#!/bin/bash
-ip link set address {{ fastd_mesh_mac }} dev $1
+ip link set address {{ item.fastd_mesh_mac }} dev $1
ip link set up dev $1
-batctl -m bat0 if add $1
-batctl -m bat0 gw server 1000000/1000000
-batctl -m bat0 it 10000
-batctl -m bat0 mm 1
-echo 128 > /sys/class/net/bat0/mesh/hop_penalty
-netctl start bat0
+batctl -m bat{{ item.name }} if add $1
+batctl -m bat{{ item.name }} gw server 1000000/1000000
+batctl -m bat{{ item.name }} it 10000
+batctl -m bat{{ item.name }} mm 1
+echo 64 > /sys/class/net/bat0/mesh/hop_penalty
+netctl start bat{{ item.name }}
systemctl restart dhcpd4.service
systemctl restart named.service