Documentation ¶
Index ¶
- func GetMACstr() ([]string, error)
- func HostUp(hostname string, w io.Writer) (online []string, offline []string, err error)
- func Neighbours(macMap map[string]interface{}, duration time.Duration) (sameLAN map[string]map[string]int, report map[string]map[string]int)
- func TCPFlood(destIPStr string, totalPacketToSend int)
- func Traceroute(ifaceName string, ipStr string) []net.IP
- func UDPFlood(destIPStr string, totalPacketToSend int)
- type CustomIface
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetMACstr ¶
GetMACstr gets the hardware address of this computer returns the interface associated with the mac (the string), and the mac associated
func HostUp ¶
HostUp checks if a given host is online with ICMP echo packets. uses an external library (made for the purpose of this assignment) called ping-go check it out here: https://pkg.go.dev/github.com/bachittle/ping-go pass a regular domain name or CIDR name EX: - jobs.HostUp("google.com") // hostname DNS lookup - jobs.HostUp("192.168.2.1/24") // local CIDR lookup
returns a string of hostnames that are online and offline.
func Neighbours ¶
func Neighbours(macMap map[string]interface{}, duration time.Duration) (sameLAN map[string]map[string]int, report map[string]map[string]int)
Neighbours checks for job seeker neighbours within the same LAN it checks if ip addresses in an ip addr array are floating around the LAN returns job seekers within the same LAN, as well as a report of all the packets for future reference.
macMap and sameLAN structure:
{ "192.168.50.1" : [ "12:34:56:78:9A:BC", "34:56:78:9A:BC:DE" ] }
func TCPFlood ¶
TCPFlood runs a flood with TCP packets to destination IP for as many packets as given
func Traceroute ¶
Traceroute traces the route of a given IP address string, then returns a list of IPs that are the route that was taken to that IP
Types ¶
type CustomIface ¶
type CustomIface struct { PcapName string NetName string HardwareAddr net.HardwareAddr IPAddr net.IP IPNet net.IPNet ResultIPs []net.IP GotType chan uint8 Seq uint16 // an id that all icmp packets will use // contains filtered or unexported fields }
CustomIface is a custom interface type used in this library since pcap and net use different interface types
func (*CustomIface) Close ¶
func (c *CustomIface) Close()
Close closes the handler and the asynchronous goroutine
func (*CustomIface) GetGateway ¶
func (c *CustomIface) GetGateway() (net.IP, net.HardwareAddr, error)
GetGateway gets the gateway IP and MAC.
func (*CustomIface) ICMPReqPacket ¶
func (c *CustomIface) ICMPReqPacket(ipStr string) ([]byte, error)
ICMPReqPacket writes an ICMP packet to an ipv4 string (no CIDR)
func (*CustomIface) StartReading ¶
func (c *CustomIface) StartReading() error
StartReading starts reading ICMP packets and keeps the handle in state if you want to use it. Close it by running Close()
func (*CustomIface) WriteData ¶
func (c *CustomIface) WriteData(buf []byte) error
WriteData writes buffer data on the wire