mirror of
https://github.com/YGGverse/hl-php.git
synced 2026-03-31 17:15:39 +00:00
simplify port decoding
This commit is contained in:
parent
167f092a28
commit
34390a0713
1 changed files with 2 additions and 17 deletions
|
|
@ -125,29 +125,14 @@ class Master
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Decode first byte of port
|
|
||||||
if (false === $byte1 = fread($socket, 1))
|
|
||||||
{
|
|
||||||
// Shift port byte
|
|
||||||
fread($socket, 1);
|
|
||||||
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Decode second byte of port
|
|
||||||
if (false === $byte2 = fread($socket, 1))
|
|
||||||
{
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Calculate port value
|
// Calculate port value
|
||||||
$port = ord($byte1) * 256 + ord($byte2);
|
$port = unpack('nport', fread($socket, 2));
|
||||||
|
|
||||||
// Validate IPv6 result
|
// Validate IPv6 result
|
||||||
if (
|
if (
|
||||||
false !== strpos($host, '.') || // filter_var not always works with mixed IPv6
|
false !== strpos($host, '.') || // filter_var not always works with mixed IPv6
|
||||||
false === filter_var($host, FILTER_VALIDATE_IP, FILTER_FLAG_IPV6) ||
|
false === filter_var($host, FILTER_VALIDATE_IP, FILTER_FLAG_IPV6) ||
|
||||||
false === filter_var($port, FILTER_VALIDATE_INT)
|
false === filter_var($port, FILTER_VALIDATE_INT) // @TODO
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue