chore: stylish d2ae94f2 (#1132)

This commit is contained in:
bobo liu 2024-03-24 21:41:05 +08:00 committed by GitHub
parent 5af7f4e847
commit 288899a473
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -41,9 +41,8 @@ func ResolveInterface(name string) (*Interface, error) {
ipNets := make([]netip.Prefix, 0, len(addrs))
for _, addr := range addrs {
var pf netip.Prefix
switch addr.(type) {
switch ipNet := addr.(type) {
case *net.IPNet:
ipNet := addr.(*net.IPNet)
ip, _ := netip.AddrFromSlice(ipNet.IP)
ones, bits := ipNet.Mask.Size()
if bits == 32 {
@ -51,7 +50,6 @@ func ResolveInterface(name string) (*Interface, error) {
}
pf = netip.PrefixFrom(ip, ones)
case *net.IPAddr:
ipNet := addr.(*net.IPAddr)
ip, _ := netip.AddrFromSlice(ipNet.IP)
ip = ip.Unmap()
pf = netip.PrefixFrom(ip, ip.BitLen())