netscan

package
v0.0.1-dev.14 Latest Latest
Warning

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

Go to latest
Published: Jun 23, 2022 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	NetworkUDP = "udp"
	NetworkTCP = "tcp"
)

Variables

This section is empty.

Functions

func AutoDiscover

func AutoDiscover(ctx context.Context, proto ProtocolSpecificDiscovery, params Params) []sdkModel.DiscoveredDevice

AutoDiscover probes all addresses in the configured network to attempt to discover any possible devices for a specific protocol

Types

type Params

type Params struct {
	// Subnets is a slice of CIDR formatted subnets to scan
	Subnets []string
	// ScanPorts is a slice of ports to scan for on each host. The first port is done synchronously
	// to test if the host is reachable, and any ports after that are done async.
	ScanPorts []string
	// AsyncLimit is the maximum amount of hosts to probe simultaneously. This does not include
	// any async scanning for multiple ports on the same host.
	AsyncLimit int
	// NetworkProtocol is the type of probe to make: tcp, udp, etc.
	NetworkProtocol string
	// Timeout is the maximum amount of time to wait when connecting to a host before giving up.
	Timeout time.Duration
	// Logger is a generic logging client for this code to log messages to.
	Logger logger.LoggingClient
}

Params is the input configuration for a Discovery Net Scan

type ProbeResult

type ProbeResult struct {
	// Host is the IP address that was probed
	Host string
	// Port is the port that was probed
	Port string
	// Data is the generic response details captured by the ProtocolSpecificDiscovery code
	// to be used to further process the result.
	Data interface{}
}

ProbeResult holds the pre-processed information about a discovered device

type ProtocolSpecificDiscovery

type ProtocolSpecificDiscovery interface {
	// ProbeFilter takes in a host and a slice of ports to be scanned. It should return a slice
	// of ports to actually scan, or a nil/empty slice if the host is to not be scanned at all.
	// Can be used to filter out known devices from being probed again if required.
	ProbeFilter(host string, ports []string) []string

	// OnConnectionDialed handles the protocol specific verification if there is actually
	// a valid device or devices at the other end of the connection.
	OnConnectionDialed(host string, port string, conn net.Conn, params Params) ([]ProbeResult, error)

	// ConvertProbeResult takes a raw ProbeResult and transforms it into a
	// processed DiscoveredDevice struct.
	ConvertProbeResult(probeResult ProbeResult, params Params) (sdkModel.DiscoveredDevice, error)
}

Jump to

Keyboard shortcuts

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