mirror of
https://github.com/MetaCubeX/mihomo.git
synced 2024-10-01 04:07:54 +00:00
parent
5af7f4e847
commit
288899a473
1 changed files with 1 additions and 3 deletions
|
@ -41,9 +41,8 @@ func ResolveInterface(name string) (*Interface, error) {
|
||||||
ipNets := make([]netip.Prefix, 0, len(addrs))
|
ipNets := make([]netip.Prefix, 0, len(addrs))
|
||||||
for _, addr := range addrs {
|
for _, addr := range addrs {
|
||||||
var pf netip.Prefix
|
var pf netip.Prefix
|
||||||
switch addr.(type) {
|
switch ipNet := addr.(type) {
|
||||||
case *net.IPNet:
|
case *net.IPNet:
|
||||||
ipNet := addr.(*net.IPNet)
|
|
||||||
ip, _ := netip.AddrFromSlice(ipNet.IP)
|
ip, _ := netip.AddrFromSlice(ipNet.IP)
|
||||||
ones, bits := ipNet.Mask.Size()
|
ones, bits := ipNet.Mask.Size()
|
||||||
if bits == 32 {
|
if bits == 32 {
|
||||||
|
@ -51,7 +50,6 @@ func ResolveInterface(name string) (*Interface, error) {
|
||||||
}
|
}
|
||||||
pf = netip.PrefixFrom(ip, ones)
|
pf = netip.PrefixFrom(ip, ones)
|
||||||
case *net.IPAddr:
|
case *net.IPAddr:
|
||||||
ipNet := addr.(*net.IPAddr)
|
|
||||||
ip, _ := netip.AddrFromSlice(ipNet.IP)
|
ip, _ := netip.AddrFromSlice(ipNet.IP)
|
||||||
ip = ip.Unmap()
|
ip = ip.Unmap()
|
||||||
pf = netip.PrefixFrom(ip, ip.BitLen())
|
pf = netip.PrefixFrom(ip, ip.BitLen())
|
||||||
|
|
Loading…
Reference in a new issue