Skip to content

Commit

Permalink
fix: ipv6 len mismatch
Browse files Browse the repository at this point in the history
  • Loading branch information
oilbeater committed Oct 16, 2020
1 parent 0a9aefd commit dc62d10
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion pkg/util/net.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,11 @@ func Ip2BigInt(ipStr string) *big.Int {
}

func BigInt2Ip(ipInt *big.Int) string {
ip := net.IP(ipInt.Bytes())
buf := make([]byte, 4)
if len(ipInt.Bytes()) > 4 {
buf = make([]byte, 16)
}
ip := net.IP(ipInt.FillBytes(buf))
return ip.String()
}

Expand Down

0 comments on commit dc62d10

Please sign in to comment.