-
-
Save rotanid/697ec181262400e7b012 to your computer and use it in GitHub Desktop.
This file contains 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 characters
<?php | |
if (!isset($_REQUEST['macadd'])) { | |
?> | |
<!DOCTYPE html> | |
<html> | |
<body> | |
<p>Suche nach der IPv6-Adresse eines Freifunk-Routers im Netz von Freifunk München anhand dessen MAC-Adresse</p> | |
<form method="POST"> | |
<input type="text" name="macadd" value="MAC-Adresse" /> | |
<input type="submit" value="IPv6 Adresse suchen" /> | |
</form> | |
</body> | |
</html> | |
<?php | |
} else { | |
$arrContextOptions=array( | |
"ssl"=>array( | |
"verify_peer"=>false, | |
"verify_peer_name"=>false, | |
), | |
); | |
$macadd = trim($_REQUEST['macadd']); | |
$macaddpure = str_replace(':', '', $macadd); | |
$json = file_get_contents('https://ffmuc.net/data/nodes.json', false, stream_context_create($arrContextOptions)); | |
$json = json_decode($json, true); | |
$nodes = $json['nodes']; | |
foreach ($nodes as $nodekey => $nodeval) { | |
if ($nodekey == $macaddpure) { | |
foreach ($nodeval['nodeinfo']['network']['addresses'] as $addr) { | |
if (substr($addr, 0, 5) != "fe80:" && substr($addr, 0, 5) != "fdef:") { | |
echo $addr; | |
break; | |
} | |
} | |
} | |
} | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment