portchecks

package
v0.2.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 13, 2023 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package portchecks provides types and functions used by this application to check access to one or more remote ports.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func UniquePorts

func UniquePorts(ports ...int) []int

UniquePorts accepts one or more ports of potentially duplicated ports and returns a slice of unique ports

Types

type Result

type Result struct {
	Host  string
	Port  int
	Open  bool
	Error error
}

Result is the outcome of a port check.

func CheckPort

func CheckPort(netAddr net.Addr, port int, timeout time.Duration) Result

CheckPort accepts a net.Addr interface type and a timeout. A connection check is performed to determine whether the port is reachable. The result of this check is returned as a Result value for later processing. Any errors which occur as part of this check are recorded as a partial check Result.

type Results

type Results []Result

Results is a collection of port check results. Intended for aggregation before bulk processing of some kind.

func (Results) Hosts

func (rs Results) Hosts() int

Hosts returns the number of unique hosts in the results set.

func (Results) HostsReachable

func (rs Results) HostsReachable() int

HostsReachable returns the number of hosts with at least one open port.

func (Results) Ports

func (rs Results) Ports() int

Ports returns the number of unique ports in the results set.

func (Results) PortsReachable

func (rs Results) PortsReachable() int

PortsReachable returns the number of open ports found.

func (Results) PortsScanned

func (rs Results) PortsScanned() int

PortsScanned returns the total port scan attempts in the results set.

func (Results) PrintSummary

func (rs Results) PrintSummary()

PrintSummary generates a table of all collected port check results

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL