feat: add param general.enable-process, it will always find process or uid, default value is false
This commit is contained in:
parent
271be43a9d
commit
14dafb2d5c
3 changed files with 11 additions and 5 deletions
|
@ -266,7 +266,7 @@ func UnmarshalRawConfig(buf []byte) (*RawConfig, error) {
|
||||||
Proxy: []map[string]any{},
|
Proxy: []map[string]any{},
|
||||||
ProxyGroup: []map[string]any{},
|
ProxyGroup: []map[string]any{},
|
||||||
TCPConcurrent: false,
|
TCPConcurrent: false,
|
||||||
EnableProcess: true,
|
EnableProcess: false,
|
||||||
Tun: RawTun{
|
Tun: RawTun{
|
||||||
Enable: false,
|
Enable: false,
|
||||||
Device: "",
|
Device: "",
|
||||||
|
|
|
@ -276,6 +276,7 @@ func updateSniffer(sniffer *config.Sniffer) {
|
||||||
func updateGeneral(general *config.General, force bool) {
|
func updateGeneral(general *config.General, force bool) {
|
||||||
log.SetLevel(general.LogLevel)
|
log.SetLevel(general.LogLevel)
|
||||||
tunnel.SetMode(general.Mode)
|
tunnel.SetMode(general.Mode)
|
||||||
|
tunnel.SetAlwaysFindProcess(general.EnableProcess)
|
||||||
dialer.DisableIPv6 = !general.IPv6
|
dialer.DisableIPv6 = !general.IPv6
|
||||||
if !dialer.DisableIPv6 {
|
if !dialer.DisableIPv6 {
|
||||||
log.Infoln("Use IPv6")
|
log.Infoln("Use IPv6")
|
||||||
|
|
|
@ -38,9 +38,9 @@ var (
|
||||||
mode = Rule
|
mode = Rule
|
||||||
|
|
||||||
// default timeout for UDP session
|
// default timeout for UDP session
|
||||||
udpTimeout = 60 * time.Second
|
udpTimeout = 60 * time.Second
|
||||||
procesCache string
|
|
||||||
failTotal int
|
alwaysFindProcess = false
|
||||||
)
|
)
|
||||||
|
|
||||||
func SetSniffing(b bool) {
|
func SetSniffing(b bool) {
|
||||||
|
@ -122,6 +122,11 @@ func SetMode(m TunnelMode) {
|
||||||
mode = m
|
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
|
// processUDP starts a loop to handle udp packet
|
||||||
func processUDP() {
|
func processUDP() {
|
||||||
queue := udpQueue
|
queue := udpQueue
|
||||||
|
@ -381,7 +386,7 @@ func match(metadata *C.Metadata) (C.Proxy, C.Rule, error) {
|
||||||
resolved = true
|
resolved = true
|
||||||
}
|
}
|
||||||
|
|
||||||
if !foundProcess && rule.ShouldFindProcess() {
|
if !foundProcess && alwaysFindProcess && rule.ShouldFindProcess() {
|
||||||
srcPort, err := strconv.ParseUint(metadata.SrcPort, 10, 16)
|
srcPort, err := strconv.ParseUint(metadata.SrcPort, 10, 16)
|
||||||
if err == nil && P.ShouldFindProcess(metadata) {
|
if err == nil && P.ShouldFindProcess(metadata) {
|
||||||
uid, path, err := P.FindProcessName(metadata.NetWork.String(), metadata.SrcIP, int(srcPort))
|
uid, path, err := P.FindProcessName(metadata.NetWork.String(), metadata.SrcIP, int(srcPort))
|
||||||
|
|
Loading…
Reference in a new issue