Documentation ¶
Overview ¶
Package netutils provides helper functions for network related operations such as port scanning or subnet slicing.
Index ¶
- Variables
- func CIDRHosts(cidr string) ([]string, int, error)
- func ExpandIPAddress(s string) ([]string, error)
- func GetCerts(server string, port int, timeout time.Duration, logger zerolog.Logger) ([]*x509.Certificate, error)
- func IsCIDR(s string) bool
- type IPv4AddressOctetsIndex
- type PortCheckResult
- type PortCheckResults
- type PortCheckResultsIndex
Constants ¶
This section is empty.
Variables ¶
var ErrUnrecognizedHostOrIPValue error = errors.New("unrecognized FQDN, single IP Address or range")
ErrUnrecognizedHostOrIPValue indicates that a given string value is unrecognized as a valid FQDN, single IP Address or range (partial or CIDR). This is usually not a temporary error condition.
Functions ¶
func CIDRHosts ¶
CIDRHosts converts a CIDR network pattern into a slice of hosts within that network, the total count of hosts and an error if any occurred.
https://stackoverflow.com/questions/60540465/go-how-to-list-all-ips-in-a-network https://play.golang.org/p/fe-F2k6prlA https://gist.github.com/kotakanbe/d3059af990252ba89a82
func ExpandIPAddress ¶
ExpandIPAddress accepts a string value representing either an individual IP Address, a CIDR IP range or a partial (dash-separated) range (e.g., 192.168.2.10-15). IP Address ranges and expands to scan for certificates.
func GetCerts ¶
func GetCerts(server string, port int, timeout time.Duration, logger zerolog.Logger) ([]*x509.Certificate, error)
GetCerts retrieves and returns the certificate chain from the specified host & port or an error if one occurs. Enforced certificate verification is intentionally disabled in order to successfully retrieve and examine all certificates in the certificate chain.
Types ¶
type IPv4AddressOctetsIndex ¶
IPv4AddressOctetsIndex is a map of IPv4 octets to values within those octets associated with partial ranges. This type is used to help implement support for octet range addressing.
func (IPv4AddressOctetsIndex) IndexSize ¶
func (idx IPv4AddressOctetsIndex) IndexSize() int
IndexSize returns the number of entries in the index.
type PortCheckResult ¶
PortCheckResult indicates whether a TCP port is open and what error (if any) occurred checking the port.
func CheckPort ¶
func CheckPort(host string, port int, timeout time.Duration) PortCheckResult
CheckPort checks whether a specified TCP port is open. Any errors encountered are returned along with the port status.
func (PortCheckResult) Summary ¶
func (rs PortCheckResult) Summary() string
Summary generates a one-line summary of port check result.
type PortCheckResults ¶
type PortCheckResults []PortCheckResult
PortCheckResults is a collection of PortCheckResult intended for bulk operations such as filtering or generating summaries.
func (PortCheckResults) HasOpenPort ¶
func (rs PortCheckResults) HasOpenPort() bool
HasOpenPort indicates whether at least one specified port was found to be open for a scanned host.
func (PortCheckResults) Host ¶
func (rs PortCheckResults) Host() string
Host returns the (single) host associated with port check results.
func (PortCheckResults) Summary ¶
func (rs PortCheckResults) Summary() string
Summary generates a one-line summary of port check results.
type PortCheckResultsIndex ¶
type PortCheckResultsIndex map[string]PortCheckResults
PortCheckResultsIndex maps the results slice from scan attempts against a specified list of ports to an IP Address associated with scanned ports.