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