jobs

package module
v0.0.0-...-c49762d Latest Latest
Warning

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

Go to latest
Published: Dec 27, 2020 License: GPL-3.0 Imports: 17 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetMACstr

func GetMACstr() ([]string, error)

GetMACstr gets the hardware address of this computer returns the interface associated with the mac (the string), and the mac associated

func HostUp

func HostUp(hostname string, w io.Writer) (online []string, offline []string, err error)

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

func TCPFlood(destIPStr string, totalPacketToSend int)

TCPFlood runs a flood with TCP packets to destination IP for as many packets as given

func Traceroute

func Traceroute(ifaceName string, ipStr string) []net.IP

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

func UDPFlood

func UDPFlood(destIPStr string, totalPacketToSend int)

UDPFlood runs a UDP flood to destination IP for as many packets as given

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 GetIfaces

func GetIfaces(name string) *CustomIface

GetIfaces gets ifaces

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) Init

func (c *CustomIface) Init()

Init sets default initializers

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

Jump to

Keyboard shortcuts

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