diff --git a/component/iface/iface.go b/component/iface/iface.go index 92e0ccf3a..d88d211e2 100644 --- a/component/iface/iface.go +++ b/component/iface/iface.go @@ -84,7 +84,14 @@ func getCache() (*ifaceCache, error) { continue // interface down } for _, prefix := range ipNets { - cache.ifTable.Insert(prefix, ifaceObj) + if _, ok := cache.ifTable.Get(prefix); ok { + // maybe two interfaces have the same prefix but different address, + // so we add a special /32(ipv4) or /128(ipv6) item to let ResolveInterfaceByAddr + // could find the correct interface + cache.ifTable.Insert(netip.PrefixFrom(prefix.Addr(), prefix.Addr().BitLen()), ifaceObj) + } else { + cache.ifTable.Insert(prefix, ifaceObj) + } } } diff --git a/go.mod b/go.mod index cffcde9e3..cf9ce2c79 100644 --- a/go.mod +++ b/go.mod @@ -25,7 +25,7 @@ require ( github.com/metacubex/gopacket v1.1.20-0.20230608035415-7e2f98a3e759 github.com/metacubex/quic-go v0.52.1-0.20250522021943-aef454b9e639 github.com/metacubex/randv2 v0.2.0 - github.com/metacubex/sing v0.5.3-0.20250504031621-1f99e54c15b7 + github.com/metacubex/sing v0.5.3 github.com/metacubex/sing-mux v0.3.2 github.com/metacubex/sing-quic v0.0.0-20250523120938-f1a248e5ec7f github.com/metacubex/sing-shadowsocks v0.2.9 diff --git a/go.sum b/go.sum index cd8787eeb..6b0c9373b 100644 --- a/go.sum +++ b/go.sum @@ -116,8 +116,8 @@ github.com/metacubex/quic-go v0.52.1-0.20250522021943-aef454b9e639/go.mod h1:Kc6 github.com/metacubex/randv2 v0.2.0 h1:uP38uBvV2SxYfLj53kuvAjbND4RUDfFJjwr4UigMiLs= github.com/metacubex/randv2 v0.2.0/go.mod h1:kFi2SzrQ5WuneuoLLCMkABtiBu6VRrMrWFqSPyj2cxY= github.com/metacubex/sing v0.5.2/go.mod h1:ypf0mjwlZm0sKdQSY+yQvmsbWa0hNPtkeqyRMGgoN+w= -github.com/metacubex/sing v0.5.3-0.20250504031621-1f99e54c15b7 h1:m4nSxvw46JEgxMzzmnXams+ebwabcry4Ydep/zNiesQ= -github.com/metacubex/sing v0.5.3-0.20250504031621-1f99e54c15b7/go.mod h1:ypf0mjwlZm0sKdQSY+yQvmsbWa0hNPtkeqyRMGgoN+w= +github.com/metacubex/sing v0.5.3 h1:QWdN16WFKMk06x4nzkc8SvZ7y2x+TLQrpkPoHs+WSVM= +github.com/metacubex/sing v0.5.3/go.mod h1:ypf0mjwlZm0sKdQSY+yQvmsbWa0hNPtkeqyRMGgoN+w= github.com/metacubex/sing-mux v0.3.2 h1:nJv52pyRivHcaZJKk2JgxpaVvj1GAXG81scSa9N7ncw= github.com/metacubex/sing-mux v0.3.2/go.mod h1:3rt1soewn0O6j89GCLmwAQFsq257u0jf2zQSPhTL3Bw= github.com/metacubex/sing-quic v0.0.0-20250523120938-f1a248e5ec7f h1:mP3vIm+9hRFI0C0Vl3pE0NESF/L85FDbuB0tGgUii6I=