bug fixes #23
@ -428,7 +428,11 @@ class LookingGlass
|
||||
*/
|
||||
private static function getLatencyFromSs(string $ip): array
|
||||
{
|
||||
$lines = shell_exec('/usr/sbin/ss -Hti state established');
|
||||
if (file_exists('/usr/sbin/ss')) {
|
||||
$lines = shell_exec('/usr/sbin/ss -Hti state established'); // RHEL Directory for ss
|
||||
} elseif (file_exists('/usr/bin/ss')) {
|
||||
$lines = shell_exec('/usr/bin/ss -Hti state established'); // Debian Directory for ss
|
||||
}
|
||||
$ss = [];
|
||||
|
||||
$i = 0;
|
||||
$j = 0;
|
||||
@ -446,12 +450,13 @@ class LookingGlass
|
||||
foreach ($ss as $socket) {
|
||||
$socket = preg_replace('!\s+!', ' ', $socket);
|
||||
$explodedsocket = explode(' ', $socket);
|
||||
preg_match('/\d+\.\d+\.\d+\.\d+/', $explodedsocket[2], $temp);
|
||||
preg_match('/\d+\.\d+\.\d+\.\d+|\[[:a-fA-F0-9]+\]/', $explodedsocket[2], $temp);
|
||||
if (!isset($temp[0])) {
|
||||
continue;
|
||||
}
|
||||
$sock['local'] = $temp[0];
|
||||
preg_match('/\d+\.\d+\.\d+\.\d+/', $explodedsocket[3], $temp);
|
||||
preg_match('/\d+\.\d+\.\d+\.\d+|\[[:a-fA-F0-9]+\]/', $explodedsocket[3], $temp);
|
||||
if (preg_match('/^\[(.*)\]$/', $temp[0], $matches)) { $temp[0] = $matches[1]; }
|
||||
$sock['remote'] = $temp[0];
|
||||
preg_match('/segs_out:(\d+)/', $socket, $temp);
|
||||
$sock['segs_out'] = $temp[1];
|
||||
|
@ -77,7 +77,7 @@ if (LG_BLOCK_CUSTOM) {
|
||||
$templateData['custom_html'] = ob_get_clean();
|
||||
}
|
||||
|
||||
if (LG_CHECK_LATENCY && filter_var(LookingGlass::detectIpAddress(), FILTER_VALIDATE_IP, FILTER_FLAG_IPV4)) {
|
||||
if (LG_CHECK_LATENCY) {
|
||||
![]() You can keep the
You can keep the `filter_var()` and just add the `FILTER_FLAG_IPV6` to it.
```suggestion
if (LG_CHECK_LATENCY && filter_var(LookingGlass::detectIpAddress(), FILTER_VALIDATE_IP, FILTER_FLAG_IPV4 | FILTER_FLAG_IPV6)) {
```
![]() The filter_var can be removed, validation is done in The filter_var can be removed, validation is done in `detectIpAddress()`. We added the filter to make sure it only works on v4 back then.
|
||||
$templateData['latency'] = LookingGlass::getLatency();
|
||||
}
|
||||
|
||||
@ -167,7 +167,7 @@ $templateData['csrfToken'] = $_SESSION[LookingGlass::SESSION_CSRF] = bin2hex(ran
|
||||
<label class="mb-2 text-muted">Your IP</label>
|
||||
<div class="input-group">
|
||||
<input type="text" class="form-control" value="<?php echo $templateData['user_ip'] ?>" onfocus="this.select()" readonly="">
|
||||
<?php if (LG_CHECK_LATENCY && filter_var(LookingGlass::detectIpAddress(), FILTER_VALIDATE_IP, FILTER_FLAG_IPV4)): ?><label class="input-group-text" title="Latency between this looking glass and your connection." style="cursor: help;"><small><?php echo $templateData['latency'] ?> MS</small></label><?php endif ?>
|
||||
<?php if (LG_CHECK_LATENCY): ?><label class="input-group-text" title="Latency between this looking glass and your connection." style="cursor: help;"><small><?php echo $templateData['latency'] ?> MS</small></label><?php endif ?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
Loading…
x
Reference in New Issue
Block a user
This change makes it working for magnitude of OSs (including alpine)
Also adding
n
option to remove the parsed ports in the output.