gg_net_scan

package
v0.3.4 Latest Latest
Warning

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

Go to latest
Published: Dec 23, 2024 License: BSD-3-Clause Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CalculateSubnetIPs

func CalculateSubnetIPs(cidr string, maxAddresses int) (response []string)

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 Errorf

func Errorf(format string, args ...interface{}) error

Errorf creates an error with the specified formatted message.

func IncIP

func IncIP(ip net.IP)

IncIP increments the given IP address by one. It works with both IPv4 and IPv6 addresses.

func IndexOf

func IndexOf(address string, hosts []string) int

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

func IsLinkLocalAddress(ip net.IP) bool

IsLinkLocalAddress checks if the given IP address falls within link-local address ranges specified by RFCs.

func LinkLocalAddresses

func LinkLocalAddresses(network string) []string

LinkLocalAddresses retrieves a list of link-local IP addresses for the specified network type.

func ValidateNetwork

func ValidateNetwork(network string) bool

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

Jump to

Keyboard shortcuts

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