Last active
August 29, 2015 13:56
Revisions
-
jplitza revised this gist
Feb 23, 2014 . No changes.There are no files selected for viewing
-
jplitza created this gist
Feb 23, 2014 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,52 @@ <?php require("write_key.inc.php"); ?> <!DOCTYPE html> <html lang="de"> <head> <meta charset="utf-8" /> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <link href="//netdna.bootstrapcdn.com/bootstrap/3.0.3/css/bootstrap.min.css" rel="stylesheet"> <title>Mesh-VPN-Schlüssel eintragen</title> <style type="text/css"> .jumbotron h1:first-child { margin-top: 0; } body { padding-top: 20px; } </style> </head> <body class="container"> <div class="jumbotron"> <?php if ( empty($_GET['key']) || empty($_GET['name']) || !write_key($_GET['name'], $_GET['key'], $_GET['mac'])) { ?> <p class="lead text-danger">Entschuldigung, beim Eintragen deines Mesh-VPN-Schlüssels ist leider etwas schief gelaufen!</p> <p>Bitte gehe <a href="javascript:history.back()">eine Seite zurück</a> und sende den dort angezeigten Schlüssel zusammen mit der MAC-Adresse, die unten auf deinem Gerät steht, an <a href="mailto:[email protected]">[email protected]</a>. Danke!</p> <?php } else { ?> <p class="lead text-success">Vielen Dank, dein Mesh-VPN-Schlüssel wurde erfolgreich eingetragen.</p> <p>Dein Router kann sich jetzt mit unseren Servern verbinden und ist somit auch verbunden, wenn gerade kein anderer Freifunk-Router in der Nähe ist.</p> <p>Willkommen beim <a href="http://bremen.freifunk.net/">Freifunk Bremen</a>!</p> <?php } ?> </div> </body> </html> This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,25 @@ <?php define('PEERS_PATH', '/etc/fastd/ffhb/peers'); function write_key($name, $key, $mac = NULL) { if (!preg_match('/^[0-9a-f]{64}$/', $key)) { return false; } if (!$mac) $mac = $name; $fd = fopen(PEERS_PATH . "/" . $mac . ".conf", "w"); if ($fd) { fwrite($fd, "#name \"" . $name . "\";\n"); fwrite($fd, "key \"" . $key . "\";\n"); fwrite($fd, "float yes;\n"); fclose($fd); // reload config exec("sudo /usr/local/bin/reload-fastd.sh ffhb"); } else { return false; } return true; }