[Fixed] Fixed clash process name is Clash.Meta

This commit is contained in:
gVisor bot 2022-02-04 17:36:34 +08:00
parent b79eb1cea9
commit a8dafd434e
3 changed files with 20 additions and 17 deletions

View file

@ -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 == "" {

View file

@ -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"
) )

View file

@ -35,6 +35,7 @@ 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)
if strings.TrimSpace(metadata.Process) == "" {
cached, hit := processCache.Get(key) cached, hit := processCache.Get(key)
if !hit { if !hit {
srcPort, err := strconv.Atoi(metadata.SrcPort) srcPort, err := strconv.Atoi(metadata.SrcPort)
@ -54,6 +55,7 @@ func (ps *Process) Match(metadata *C.Metadata) bool {
} }
metadata.Process = cached.(string) metadata.Process = cached.(string)
}
return strings.EqualFold(metadata.Process, ps.process) return strings.EqualFold(metadata.Process, ps.process)
} }