mirror of
https://github.com/google/cdc-file-transfer.git
synced 2026-09-13 01:10:44 +03:00
[PortManager] Prefer ss over netstat on Linux (#91)
ss is a modern alternative to netstat. The flags we use and the way we parse the output are compatible with netstat. Since netstat is no longer installed on some Linux distributions, prefer ss, but fall back to netstat if "which ss" fails. Also tweaks some logging. Fixes #65
This commit is contained in:
@@ -43,10 +43,12 @@ const char* GetNetstatCommand(ArchType arch_type) {
|
||||
}
|
||||
|
||||
if (IsLinuxArchType(arch_type)) {
|
||||
// Prefer ss over netstat. The flags out output are compatible.
|
||||
// --numeric to get numerical addresses.
|
||||
// --listening to get only listening sockets.
|
||||
// --tcp to get only TCP connections.
|
||||
return "netstat --numeric --listening --tcp";
|
||||
return "which ss2 && ss --numeric --listening --tcp || netstat "
|
||||
"--numeric --listening --tcp";
|
||||
}
|
||||
|
||||
assert(!kErrorArchTypeUnhandled);
|
||||
|
||||
Reference in New Issue
Block a user