Documentation ¶
Index ¶
- func CalculateSubnetIPs(cidr string, maxAddresses int) (response []string)
- func Errorf(format string, args ...interface{}) error
- func IncIP(ip net.IP)
- func IndexOf(address string, hosts []string) int
- func IsLinkLocalAddress(ip net.IP) bool
- func LinkLocalAddresses(network string) []string
- func ValidateNetwork(network string) bool
- type NetScanDescriptor
- type NetScanDescriptorItem
- type NetScanHelper
- func (instance *NetScanHelper) List(args ...interface{}) (response *NetScanResponses, err error)
- func (instance *NetScanHelper) ListAll(protocols []string, ports []int) (response *NetScanResponses, err error)
- func (instance *NetScanHelper) ListDeep(args ...interface{}) (response *NetScanResponses, err error)
- func (instance *NetScanHelper) ListTcp(ports ...int) (response *NetScanResponses, err error)
- func (instance *NetScanHelper) ListTcpDeep(ports ...int) (response *NetScanResponses, err error)
- func (instance *NetScanHelper) LookUpFirstFreePort(protocol string, startPort int) int
- type NetScanResponse
- type NetScanResponses
- func (instance *NetScanResponses) Add(protocol string, port int, ip string) *NetScanResponses
- func (instance *NetScanResponses) Append(item *NetScanResponse) *NetScanResponses
- func (instance *NetScanResponses) Filter(protocol string, port int) (response []*NetScanResponse)
- func (instance *NetScanResponses) Get(protocol string, port int, ip string) (response *NetScanResponse)
- func (instance *NetScanResponses) String() string
- type NetworkScanner
- func (instance *NetworkScanner) GetAvoidThisIP() bool
- func (instance *NetworkScanner) GetNetwork() string
- func (instance *NetworkScanner) GetPort() int
- func (instance *NetworkScanner) GetThreads() int
- func (instance *NetworkScanner) GetTimeout() time.Duration
- func (instance *NetworkScanner) ScanIPs() (response []string, err error)
- func (instance *NetworkScanner) SetAvoidThisIP(b bool) *NetworkScanner
- func (instance *NetworkScanner) SetNetwork(network string) *NetworkScanner
- func (instance *NetworkScanner) SetPort(port int) *NetworkScanner
- func (instance *NetworkScanner) SetThreads(threads int) *NetworkScanner
- func (instance *NetworkScanner) SetTimeout(timeout time.Duration) *NetworkScanner
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CalculateSubnetIPs ¶
CalculateSubnetIPs calculates all valid IP addresses in a given subnet defined by the CIDR notation, excluding network and broadcast addresses. Parameters: - cidr: A string representing the CIDR notation of the subnet. - maxAddresses: The maximum number of IP addresses to calculate. Returns a slice of strings, each representing an IP address in the subnet.
func IncIP ¶
IncIP increments the given IP address by one. It works with both IPv4 and IPv6 addresses.
func IndexOf ¶
IndexOf locates the index of a given IP address within a slice of host IPs. Returns the index if found, otherwise returns 0.
func IsLinkLocalAddress ¶
IsLinkLocalAddress checks if the given IP address falls within link-local address ranges specified by RFCs.
func LinkLocalAddresses ¶
LinkLocalAddresses retrieves a list of link-local IP addresses for the specified network type.
func ValidateNetwork ¶
ValidateNetwork checks if the provided network string is one of the valid network types. Returns true if the network is valid, false otherwise.
Types ¶
type NetScanDescriptor ¶
type NetScanDescriptor struct {
// contains filtered or unexported fields
}
func NewNetScanDescriptor ¶
func NewNetScanDescriptor() (instance *NetScanDescriptor)
func (*NetScanDescriptor) Describe ¶
func (instance *NetScanDescriptor) Describe(port int) *NetScanDescriptorItem
type NetScanDescriptorItem ¶
type NetScanDescriptorItem struct { Port []int `json:"port"` Name string `json:"name"` Description string `json:"description"` Protocol []string `json:"protocol"` }
func (*NetScanDescriptorItem) String ¶
func (instance *NetScanDescriptorItem) String() string
type NetScanHelper ¶
type NetScanHelper struct { }
var NetScan *NetScanHelper
func (*NetScanHelper) List ¶ added in v0.2.96
func (instance *NetScanHelper) List(args ...interface{}) (response *NetScanResponses, err error)
func (*NetScanHelper) ListAll ¶
func (instance *NetScanHelper) ListAll(protocols []string, ports []int) (response *NetScanResponses, err error)
func (*NetScanHelper) ListDeep ¶ added in v0.2.96
func (instance *NetScanHelper) ListDeep(args ...interface{}) (response *NetScanResponses, err error)
ListDeep Scan network for passed protocols, ports and repeat n times the cycle waiting a timespan arguments: float32 is used as number of cycles to perform. Default is 3 time.Duration is the wait time. Default is 1 second string are the protocols int are the ports
func (*NetScanHelper) ListTcp ¶
func (instance *NetScanHelper) ListTcp(ports ...int) (response *NetScanResponses, err error)
func (*NetScanHelper) ListTcpDeep ¶
func (instance *NetScanHelper) ListTcpDeep(ports ...int) (response *NetScanResponses, err error)
func (*NetScanHelper) LookUpFirstFreePort ¶ added in v0.2.98
func (instance *NetScanHelper) LookUpFirstFreePort(protocol string, startPort int) int
type NetScanResponse ¶
type NetScanResponse struct { Uid string `json:"uid"` Protocol string `json:"protocol"` Port int `json:"port"` IP string `json:"ip"` }
func NewNetScanResponse ¶
func NewNetScanResponse(protocol string, port int, ip string) *NetScanResponse
func (*NetScanResponse) Describe ¶
func (instance *NetScanResponse) Describe() (response *NetScanDescriptorItem)
func (*NetScanResponse) String ¶
func (instance *NetScanResponse) String() string
type NetScanResponses ¶
type NetScanResponses struct {
Values []*NetScanResponse `json:"values"`
}
func NewNetScanResponses ¶
func NewNetScanResponses() *NetScanResponses
func (*NetScanResponses) Add ¶
func (instance *NetScanResponses) Add(protocol string, port int, ip string) *NetScanResponses
func (*NetScanResponses) Append ¶
func (instance *NetScanResponses) Append(item *NetScanResponse) *NetScanResponses
func (*NetScanResponses) Filter ¶
func (instance *NetScanResponses) Filter(protocol string, port int) (response []*NetScanResponse)
func (*NetScanResponses) Get ¶
func (instance *NetScanResponses) Get(protocol string, port int, ip string) (response *NetScanResponse)
func (*NetScanResponses) String ¶
func (instance *NetScanResponses) String() string
type NetworkScanner ¶
type NetworkScanner struct {
// contains filtered or unexported fields
}
NetworkScanner is a struct that defines the configuration for scanning a network. Fields include network type, port number, number of threads, timeout duration, and an option to avoid scanning its own IP.
func NewNetworkScanner ¶
func NewNetworkScanner() (instance *NetworkScanner)
NewNetworkScanner creates a new instance of NetworkScanner with default settings: network set to "tcp4", port set to 80, 20 threads, 5-second timeout, and avoidThisIP set to false.
func (*NetworkScanner) GetAvoidThisIP ¶
func (instance *NetworkScanner) GetAvoidThisIP() bool
func (*NetworkScanner) GetNetwork ¶
func (instance *NetworkScanner) GetNetwork() string
func (*NetworkScanner) GetPort ¶
func (instance *NetworkScanner) GetPort() int
func (*NetworkScanner) GetThreads ¶
func (instance *NetworkScanner) GetThreads() int
func (*NetworkScanner) GetTimeout ¶
func (instance *NetworkScanner) GetTimeout() time.Duration
func (*NetworkScanner) ScanIPs ¶
func (instance *NetworkScanner) ScanIPs() (response []string, err error)
ScanIPs scans the network for active IP addresses using the specified network, port, timeout, and thread settings. It returns a list of responsive IP addresses, or an error if the configuration is invalid or the scan fails.
func (*NetworkScanner) SetAvoidThisIP ¶
func (instance *NetworkScanner) SetAvoidThisIP(b bool) *NetworkScanner
func (*NetworkScanner) SetNetwork ¶
func (instance *NetworkScanner) SetNetwork(network string) *NetworkScanner
func (*NetworkScanner) SetPort ¶
func (instance *NetworkScanner) SetPort(port int) *NetworkScanner
func (*NetworkScanner) SetThreads ¶
func (instance *NetworkScanner) SetThreads(threads int) *NetworkScanner
func (*NetworkScanner) SetTimeout ¶
func (instance *NetworkScanner) SetTimeout(timeout time.Duration) *NetworkScanner