Skip to content

Commit

Permalink
chore: add 2 helper functions to determine if a network is an IPv4 or…
Browse files Browse the repository at this point in the history
… IPv6 network
  • Loading branch information
bschaatsbergen committed Dec 9, 2023
1 parent c1647fc commit 1252e93
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions pkg/helper/network.go
@@ -0,0 +1,15 @@
package helper

import "net"

// isIPv4Network checks if the given network is an IPv4 network.
// It returns true if the network is an IPv4 network, otherwise false.
func IsIPv4Network(network *net.IPNet) bool {
return network.IP.To4() != nil
}

// isIPv6Network checks if the given network is an IPv6 network.
// It returns true if the network is an IPv6 network, otherwise false.
func IsIPv6Network(network *net.IPNet) bool {
return network.IP.To16() != nil
}

0 comments on commit 1252e93

Please sign in to comment.