change parse to models.ListenPorts from string

This commit is contained in:
MaineK00n
2020-10-14 14:53:30 +09:00
parent ea820a248e
commit d9337eeb38
4 changed files with 57 additions and 4 deletions

View File

@@ -809,3 +809,11 @@ func (l *base) parseLsOf(stdout string) map[string]string {
}
return portPid
}
func (l *base) parseListenPorts(port string) models.ListenPorts {
sep := strings.LastIndex(port, ":")
if sep == -1 {
return models.ListenPorts{}
}
return models.ListenPorts{Address: port[:sep], Port: port[sep+1:]}
}