Skip to content

Commit

Permalink
fix: ipv6 len mismatch
Browse files Browse the repository at this point in the history
(cherry picked from commit dc62d10)
  • Loading branch information
oilbeater committed Oct 17, 2020
1 parent bbda6a8 commit 5fbb92b
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 5fbb92b

Please sign in to comment.