fix: 获取网络连接进程参数调整
This commit is contained in:
@@ -8,13 +8,13 @@ type NetConnectData struct {
|
||||
Status string `json:"status"`
|
||||
Laddr net.Addr `json:"localaddr"`
|
||||
Raddr net.Addr `json:"remoteaddr"`
|
||||
PID int32 `json:"PID"`
|
||||
PID int32 `json:"pid"`
|
||||
Name string `json:"name"`
|
||||
}
|
||||
|
||||
// NetConnectQuery 网络连接进程查询
|
||||
type NetConnectQuery struct {
|
||||
Port int32 `json:"port"`
|
||||
ProcessName string `json:"processName"`
|
||||
ProcessID int32 `json:"processID"`
|
||||
Port int32 `json:"port"`
|
||||
Name string `json:"name"`
|
||||
PID int32 `json:"pid"`
|
||||
}
|
||||
|
||||
@@ -29,13 +29,16 @@ func GetNetConnections(requestID string, data any) ([]byte, error) {
|
||||
continue
|
||||
}
|
||||
for _, conn := range connections {
|
||||
if query.ProcessID > 0 && query.ProcessID != conn.Pid {
|
||||
if query.PID > 0 && query.PID != conn.Pid {
|
||||
continue
|
||||
}
|
||||
proc, err := process.NewProcess(conn.Pid)
|
||||
if err == nil {
|
||||
name, _ := proc.Name()
|
||||
if name != "" && query.ProcessName != "" && !strings.Contains(name, query.ProcessName) {
|
||||
name, err := proc.Name()
|
||||
if err != nil {
|
||||
continue
|
||||
}
|
||||
if query.Name != "" && !strings.Contains(name, query.Name) {
|
||||
continue
|
||||
}
|
||||
if query.Port > 0 && query.Port != int32(conn.Laddr.Port) && query.Port != int32(conn.Raddr.Port) {
|
||||
|
||||
Reference in New Issue
Block a user