[Fixed] Fixed clash process name is Clash.Meta
This commit is contained in:
parent
b79eb1cea9
commit
a8dafd434e
3 changed files with 20 additions and 17 deletions
|
@ -28,7 +28,7 @@ func NewInner(conn net.Conn, dst string, host string) *context.ConnContext {
|
||||||
metadata.DNSMode = C.DNSMapping
|
metadata.DNSMode = C.DNSMapping
|
||||||
metadata.Host = host
|
metadata.Host = host
|
||||||
metadata.AddrType = C.AtypDomainName
|
metadata.AddrType = C.AtypDomainName
|
||||||
|
metadata.Process = C.ClashName
|
||||||
if ip, port, err := parseAddr(dst); err == nil {
|
if ip, port, err := parseAddr(dst); err == nil {
|
||||||
metadata.DstPort = port
|
metadata.DstPort = port
|
||||||
if host == "" {
|
if host == "" {
|
||||||
|
|
|
@ -5,4 +5,5 @@ var (
|
||||||
Version = "1.9.0"
|
Version = "1.9.0"
|
||||||
BuildTime = "unknown time"
|
BuildTime = "unknown time"
|
||||||
AutoIptables string
|
AutoIptables string
|
||||||
|
ClashName = "Clash.Meta"
|
||||||
)
|
)
|
||||||
|
|
|
@ -35,26 +35,28 @@ func (ps *Process) Match(metadata *C.Metadata) bool {
|
||||||
}
|
}
|
||||||
|
|
||||||
key := fmt.Sprintf("%s:%s:%s", metadata.NetWork.String(), metadata.SrcIP.String(), metadata.SrcPort)
|
key := fmt.Sprintf("%s:%s:%s", metadata.NetWork.String(), metadata.SrcIP.String(), metadata.SrcPort)
|
||||||
cached, hit := processCache.Get(key)
|
if strings.TrimSpace(metadata.Process) == "" {
|
||||||
if !hit {
|
cached, hit := processCache.Get(key)
|
||||||
srcPort, err := strconv.Atoi(metadata.SrcPort)
|
if !hit {
|
||||||
if err != nil {
|
srcPort, err := strconv.Atoi(metadata.SrcPort)
|
||||||
processCache.Set(key, "")
|
if err != nil {
|
||||||
return false
|
processCache.Set(key, "")
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
name, err := process.FindProcessName(metadata.NetWork.String(), metadata.SrcIP, srcPort)
|
||||||
|
if err != nil {
|
||||||
|
log.Debugln("[Rule] find process name %s error: %s", C.Process.String(), err.Error())
|
||||||
|
}
|
||||||
|
|
||||||
|
processCache.Set(key, name)
|
||||||
|
|
||||||
|
cached = name
|
||||||
}
|
}
|
||||||
|
|
||||||
name, err := process.FindProcessName(metadata.NetWork.String(), metadata.SrcIP, srcPort)
|
metadata.Process = cached.(string)
|
||||||
if err != nil {
|
|
||||||
log.Debugln("[Rule] find process name %s error: %s", C.Process.String(), err.Error())
|
|
||||||
}
|
|
||||||
|
|
||||||
processCache.Set(key, name)
|
|
||||||
|
|
||||||
cached = name
|
|
||||||
}
|
}
|
||||||
|
|
||||||
metadata.Process = cached.(string)
|
|
||||||
|
|
||||||
return strings.EqualFold(metadata.Process, ps.process)
|
return strings.EqualFold(metadata.Process, ps.process)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue