Fix conversion between IPv4 -> IPv6 CIDR

dev
Ruakij 2 years ago
parent fb2a57288e
commit 2f8cfa6afa

@ -144,6 +144,6 @@ func main() {
func convertIPv4ToIPv6(ipv6Format *string, ipv4 *net.IPNet) (*string) { func convertIPv4ToIPv6(ipv6Format *string, ipv4 *net.IPNet) (*string) {
CIDR, _ := ipv4.Mask.Size() CIDR, _ := ipv4.Mask.Size()
// Run format // 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 return &ipv6Str
} }

Loading…
Cancel
Save