Skip to content

Commit

Permalink
add ipv6 support
Browse files Browse the repository at this point in the history
  • Loading branch information
BadApple9 committed Nov 30, 2020
1 parent 6d90999 commit 7e3fb7b
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
16 changes: 12 additions & 4 deletions backend/report.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,24 @@
require_once "./SleekDB/SleekDB.php";
require_once "./config.php";

function maskLastSegment($ip) {
$ipaddr = inet_pton($ip);
if (strlen($ipaddr) == 4) {
$ipaddr[3] = chr(0);
} else {
$ipaddr[14] = chr(0);
$ipaddr[15] = chr(0);
}
return rtrim(inet_ntop($ipaddr),"0")."*";
}

$store = \SleekDB\SleekDB::store('speedlogs', './',[
'auto_cache' => false,
'timeout' => 120
]);

$ip = filter_var($_POST['ip'], FILTER_SANITIZE_STRING);
$ipMask = preg_replace('/((?:\d{1,3}\.){3})\d{1,3}/','$1*', $ip);

$reportData = [
"ip" => $ipMask,
"ip" => maskLastSegment(filter_var($_POST['ip'], FILTER_SANITIZE_STRING)),
"isp" => filter_var($_POST['isp'], FILTER_SANITIZE_STRING),
"addr" => filter_var($_POST['addr'], FILTER_SANITIZE_STRING),
"dspeed" => (double) filter_var($_POST['dspeed'], FILTER_SANITIZE_STRING),
Expand Down
2 changes: 1 addition & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ <h1>Speedtest-X</h1>
</div>
<div class="testGroup">
<div class="testArea">
<div class="testName">Ping</div>
<div class="testName">延迟</div>
<div id="pingText" class="meterText"></div>
<div class="unit">ms</div>
</div>
Expand Down

0 comments on commit 7e3fb7b

Please sign in to comment.