fixed server query
This commit is contained in:
parent
e6541370b9
commit
a1e5331f4a
7 changed files with 221 additions and 13 deletions
|
|
@ -124,12 +124,11 @@ function gsp_agent_port_listening($remote, $server_port)
|
|||
if ($server_port <= 0 || !method_exists($remote, 'exec')) {
|
||||
return null;
|
||||
}
|
||||
$port_arg = escapeshellarg((string)$server_port);
|
||||
$command = 'p='.$port_arg.'; '
|
||||
. 'if command -v ss >/dev/null 2>&1; then ss -lntu 2>/dev/null; else netstat -an 2>/dev/null; fi '
|
||||
$port_pattern = '[:.]' . $server_port . '([[:space:]]|$)';
|
||||
$command = 'if command -v ss >/dev/null 2>&1; then ss -lntu 2>/dev/null; else netstat -an 2>/dev/null; fi '
|
||||
. '| tr -d "\r" '
|
||||
. '| grep -Eai "(LISTEN|LISTENING|UDP|tcp|udp)" '
|
||||
. '| grep -E "[:.]$p([[:space:]]|$)" >/dev/null '
|
||||
. '| grep -E ' . escapeshellarg($port_pattern) . ' >/dev/null '
|
||||
. '&& echo GSP_PORT_LISTENING || echo GSP_PORT_CLOSED';
|
||||
$output = $remote->exec($command);
|
||||
if (strpos((string)$output, 'GSP_PORT_LISTENING') !== false) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue