mirror of
https://github.com/SagerNet/sing-box.git
synced 2024-11-25 18:11:28 +00:00
Fix match 4in6 address in ip_cidr
This commit is contained in:
parent
7aa97a332e
commit
ef7f2d82c0
|
@ -59,13 +59,13 @@ func NewIPCIDRItem(isSource bool, prefixStrings []string) (*IPCIDRItem, error) {
|
|||
|
||||
func (r *IPCIDRItem) Match(metadata *adapter.InboundContext) bool {
|
||||
if r.isSource {
|
||||
return r.ipSet.Contains(metadata.Source.Addr)
|
||||
return r.match(metadata.Source.Addr)
|
||||
} else {
|
||||
if metadata.Destination.IsIP() {
|
||||
return r.ipSet.Contains(metadata.Destination.Addr)
|
||||
return r.match(metadata.Destination.Addr)
|
||||
} else {
|
||||
for _, address := range metadata.DestinationAddresses {
|
||||
if r.ipSet.Contains(address) {
|
||||
if r.match(address) {
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
@ -74,6 +74,14 @@ func (r *IPCIDRItem) Match(metadata *adapter.InboundContext) bool {
|
|||
return false
|
||||
}
|
||||
|
||||
func (r *IPCIDRItem) match(address netip.Addr) bool {
|
||||
if address.Is4In6() {
|
||||
return r.ipSet.Contains(netip.AddrFrom4(address.As4()))
|
||||
} else {
|
||||
return r.ipSet.Contains(address)
|
||||
}
|
||||
}
|
||||
|
||||
func (r *IPCIDRItem) String() string {
|
||||
return r.description
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue