From 2f8cfa6afa2abd2947b642e54315be120b62c6ef Mon Sep 17 00:00:00 2001 From: Ruakij Date: Sat, 1 Apr 2023 12:10:09 +0200 Subject: [PATCH] Fix conversion between IPv4 -> IPv6 CIDR --- cmd/app/main.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmd/app/main.go b/cmd/app/main.go index 59b89e9..e21a9d6 100644 --- a/cmd/app/main.go +++ b/cmd/app/main.go @@ -144,6 +144,6 @@ func main() { func convertIPv4ToIPv6(ipv6Format *string, ipv4 *net.IPNet) (*string) { CIDR, _ := ipv4.Mask.Size() // Run format - ipv6Str := fmt.Sprintf(*ipv6Format, (*ipv4).IP[0], (*ipv4).IP[1], (*ipv4).IP[2], (*ipv4).IP[4], 128-CIDR) + ipv6Str := fmt.Sprintf(*ipv6Format, (*ipv4).IP[0], (*ipv4).IP[1], (*ipv4).IP[2], (*ipv4).IP[3], net.IPv6len*8-(net.IPv4len*8-CIDR)) return &ipv6Str }