mirror of
https://github.com/v2fly/v2ray-core.git
synced 2024-11-04 17:27:23 -05:00
fix json parser for IPv6 routing
This commit is contained in:
parent
4e80ed05d9
commit
b3bbd80674
@ -60,9 +60,8 @@ func parseIP(s string) *router.IP {
|
|||||||
mask = s[i+1:]
|
mask = s[i+1:]
|
||||||
}
|
}
|
||||||
ip := v2net.ParseAddress(addr)
|
ip := v2net.ParseAddress(addr)
|
||||||
if !ip.Family().Either(v2net.AddressFamilyIPv4, v2net.AddressFamilyIPv6) {
|
switch ip.Family() {
|
||||||
return nil
|
case v2net.AddressFamilyIPv4:
|
||||||
}
|
|
||||||
bits := uint32(32)
|
bits := uint32(32)
|
||||||
if len(mask) > 0 {
|
if len(mask) > 0 {
|
||||||
bits64, err := strconv.ParseUint(mask, 10, 32)
|
bits64, err := strconv.ParseUint(mask, 10, 32)
|
||||||
@ -79,6 +78,27 @@ func parseIP(s string) *router.IP {
|
|||||||
Ip: []byte(ip.IP()),
|
Ip: []byte(ip.IP()),
|
||||||
UnmatchingBits: 32 - bits,
|
UnmatchingBits: 32 - bits,
|
||||||
}
|
}
|
||||||
|
case v2net.AddressFamilyIPv6:
|
||||||
|
bits := uint32(128)
|
||||||
|
if len(mask) > 0 {
|
||||||
|
bits64, err := strconv.ParseUint(mask, 10, 32)
|
||||||
|
if err != nil {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
bits = uint32(bits64)
|
||||||
|
}
|
||||||
|
if bits > 128 {
|
||||||
|
log.Warning("Router: invalid network mask: ", bits)
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
return &router.IP{
|
||||||
|
Ip: []byte(ip.IP()),
|
||||||
|
UnmatchingBits: 128 - bits,
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
log.Warning("Router: unsupported address: ", s)
|
||||||
|
return nil
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func parseFieldRule(msg json.RawMessage) (*router.RoutingRule, error) {
|
func parseFieldRule(msg json.RawMessage) (*router.RoutingRule, error) {
|
||||||
|
Loading…
Reference in New Issue
Block a user