fix: problems caused when uid is 0

This commit is contained in:
adlyq
2022-04-28 11:51:40 +08:00
parent 96a32f5038
commit 47568051bf
2 changed files with 8 additions and 8 deletions

View File

@ -83,7 +83,7 @@ type Metadata struct {
AddrType int `json:"-"`
Host string `json:"host"`
DNSMode DNSMode `json:"dnsMode"`
Uid int32 `json:"uid"`
Uid *int32 `json:"uid"`
Process string `json:"process"`
ProcessPath string `json:"processPath"`
}
@ -101,10 +101,10 @@ func (m *Metadata) SourceDetail() string {
return fmt.Sprintf("[%s]", ClashName)
}
if m.Process != "" && m.Uid != 0 {
return fmt.Sprintf("%s(%s, uid=%d)", m.SourceAddress(), m.Process, m.Uid)
} else if m.Uid != 0 {
return fmt.Sprintf("%s(%d)", m.SourceAddress(), m.Uid)
if m.Process != "" && m.Uid != nil {
return fmt.Sprintf("%s(%s, uid=%d)", m.SourceAddress(), m.Process, *m.Uid)
} else if m.Uid != nil {
return fmt.Sprintf("%s(%d)", m.SourceAddress(), *m.Uid)
} else if m.Process != "" {
return fmt.Sprintf("%s(%s)", m.SourceAddress(), m.Process)
} else {