Documentation
¶
Index ¶
Constants ¶
const ( // RangeWithoutNetworkNumber drops the network number (the first address) RangeWithoutNetworkNumber = iota + 1 // RangeWithoutBroadcast drops the broadcast address (the last address) RangeWithoutBroadcast )
Variables ¶
var ( // ErrMixedIPVersion presents an error while trying to compute IPv4 // with IPv6. ErrMixedIPVersion = errors.New("IPv4 and IPv6 can not be computed together") )
Functions ¶
This section is empty.
Types ¶
type Network ¶
type Network struct {
Subnets []*Subnet
}
Network is an IP network which can combine multiple subnets inside.
func NewNetwork ¶
NewNetwork intializes a new network with given subnets.
func (*Network) Range ¶
func (in *Network) Range(opts ...RangeOption) (ips []net.IP)
Range returns all available IP addresses in the network, which also includes the network number (the first) and the broadcast address (the last).
func (*Network) RangeString ¶
func (in *Network) RangeString(opts ...RangeOption) (ips []string)
RangeString returns all available IP addresses as a string array in the network, which also includes the network number (the first) and the broadcast address (the last).
type PortScanner ¶
type PortScanner interface {
Scan(ctx context.Context, hostports ...string) ([]PortStatus, error)
}
PortScanner is the generic interface of port scanner
func NewTCPPortScanner ¶
func NewTCPPortScanner() PortScanner
NewTCPPortScanner returns a new TCPPortScanner as PortScanner.
type PortStatus ¶
type PortStatus struct { // Host represents the host address or its DNS hostname. Host string // The RemoteAddr while scanning on remote host. For TCPPortScanner, its type // should be *net.TCPAddr. Addr net.Addr // Indicates whether the port is open. Opened bool }
PortStatus is the scanning result of a single host.
type Subnet ¶
type Subnet struct {
// contains filtered or unexported fields
}
Subnet is a subset of IP network.
func NewSubnet ¶
NewSubnet initialize a new subnet with given `cidr`, returns encountered error if any.
func (*Subnet) Range ¶
func (in *Subnet) Range(opts ...RangeOption) (ips []net.IP)
Range returns all available IP addresses in the subnet, which also includes the network number (the first) and the broadcast address (the last).
func (*Subnet) RangeString ¶
func (in *Subnet) RangeString(opts ...RangeOption) (ips []string)
RangeString returns all available IP addresses as a string array in the subnet, which also includes the network number (the first) and the broadcast address (the last).
type TCPPortScanner ¶
type TCPPortScanner struct { ScanFn func(ctx context.Context, hostports ...string) ([]PortStatus, error) // contains filtered or unexported fields }
TCPPortScanner is used for
func (*TCPPortScanner) Scan ¶
func (in *TCPPortScanner) Scan(ctx context.Context, hostports ...string) ([]PortStatus, error)
Scan implements the Scan method of PortScanner. To change its default behavior, you can override the ScanFn with your own implementation.