mirror of
https://github.com/MetaCubeX/ClashMetaForAndroid.git
synced 2024-11-25 23:06:09 +03:00
Improve: Try tcp6&udp6 files first when search UID for connection (#1514)
This commit is contained in:
parent
a0cdb8acbe
commit
d753ca7225
@ -26,7 +26,7 @@ func QuerySocketUidFromProcFs(source, _ net.Addr) int {
|
||||
|
||||
network := source.Network()
|
||||
|
||||
if strings.HasSuffix(network, "4") {
|
||||
if strings.HasSuffix(network, "4") || strings.HasSuffix(network, "6") {
|
||||
network = network[:len(network)-1]
|
||||
}
|
||||
|
||||
@ -46,16 +46,24 @@ func QuerySocketUidFromProcFs(source, _ net.Addr) int {
|
||||
return -1
|
||||
}
|
||||
|
||||
if strings.HasSuffix(source.Network(), "6") {
|
||||
sIP = sIP.To16()
|
||||
} else {
|
||||
sIP = sIP.To4()
|
||||
}
|
||||
|
||||
sIP = sIP.To16()
|
||||
if sIP == nil {
|
||||
return -1
|
||||
}
|
||||
|
||||
uid := doQuery(path+"6", sIP, sPort)
|
||||
if uid == -1 {
|
||||
sIP = sIP.To4()
|
||||
if sIP == nil {
|
||||
return -1
|
||||
}
|
||||
uid = doQuery(path, sIP, sPort)
|
||||
}
|
||||
|
||||
return uid
|
||||
}
|
||||
|
||||
func doQuery(path string, sIP net.IP, sPort int) int {
|
||||
file, err := os.Open(path)
|
||||
if err != nil {
|
||||
return -1
|
||||
|
Loading…
Reference in New Issue
Block a user