feat: add param general.enable-process, it will always find process or uid, default value is false

This commit is contained in:
Skyxim
2022-06-14 23:08:07 +08:00
parent be298cfa16
commit 2e6bdc5636
3 changed files with 11 additions and 5 deletions

View File

@ -38,9 +38,9 @@ var (
mode = Rule
// default timeout for UDP session
udpTimeout = 60 * time.Second
procesCache string
failTotal int
udpTimeout = 60 * time.Second
alwaysFindProcess = false
)
func SetSniffing(b bool) {
@ -122,6 +122,11 @@ func SetMode(m TunnelMode) {
mode = m
}
// SetAlwaysFindProcess set always find process info, may be increase many memory
func SetAlwaysFindProcess(findProcess bool) {
alwaysFindProcess = findProcess
}
// processUDP starts a loop to handle udp packet
func processUDP() {
queue := udpQueue
@ -381,7 +386,7 @@ func match(metadata *C.Metadata) (C.Proxy, C.Rule, error) {
resolved = true
}
if !foundProcess && rule.ShouldFindProcess() {
if !foundProcess && alwaysFindProcess && rule.ShouldFindProcess() {
srcPort, err := strconv.ParseUint(metadata.SrcPort, 10, 16)
if err == nil && P.ShouldFindProcess(metadata) {
uid, path, err := P.FindProcessName(metadata.NetWork.String(), metadata.SrcIP, int(srcPort))