fix(scan): show listening ip:port of procs (#862)
This commit is contained in:
@@ -787,7 +787,7 @@ func (l *base) parseGrepProcMap(stdout string) (soPaths []string) {
|
||||
}
|
||||
|
||||
func (l *base) lsOfListen() (stdout string, err error) {
|
||||
cmd := `lsof -i -P | grep LISTEN`
|
||||
cmd := `lsof -i -P -n | grep LISTEN`
|
||||
r := l.exec(util.PrependProxyEnv(cmd), sudo)
|
||||
if !r.isSuccess() {
|
||||
return "", xerrors.Errorf("Failed to SSH: %s", r)
|
||||
@@ -804,11 +804,7 @@ func (l *base) parseLsOf(stdout string) map[string]string {
|
||||
continue
|
||||
}
|
||||
pid, ipPort := ss[1], ss[8]
|
||||
sss := strings.Split(ipPort, ":")
|
||||
if len(sss) != 2 {
|
||||
continue
|
||||
}
|
||||
portPid[sss[1]] = pid
|
||||
portPid[ipPort] = pid
|
||||
}
|
||||
return portPid
|
||||
}
|
||||
|
||||
@@ -274,12 +274,12 @@ node 1498 ubuntu 22u IPv6 20133 0t0 TCP *:44801 (LISTEN
|
||||
docker-pr 9135 root 4u IPv6 297133 0t0 TCP *:6379 (LISTEN)`,
|
||||
},
|
||||
wantPortPid: map[string]string{
|
||||
"53": "474",
|
||||
"22": "644",
|
||||
"3128": "959",
|
||||
"35401": "1498",
|
||||
"44801": "1498",
|
||||
"6379": "9135",
|
||||
"localhost:53": "474",
|
||||
"*:22": "644",
|
||||
"*:3128": "959",
|
||||
"*:35401": "1498",
|
||||
"*:44801": "1498",
|
||||
"*:6379": "9135",
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user