Skip to content

Commit

Permalink
chore: stylish d2ae94f (#1132)
Browse files Browse the repository at this point in the history
  • Loading branch information
fakeboboliu committed Mar 24, 2024
1 parent 5af7f4e commit 288899a
Showing 1 changed file with 1 addition and 3 deletions.
4 changes: 1 addition & 3 deletions component/iface/iface.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,17 +41,15 @@ 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 {
ip = ip.Unmap()
}
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())
Expand Down

0 comments on commit 288899a

Please sign in to comment.