utils

package
v0.0.0-...-1848e1e Latest Latest
Warning

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

Go to latest
Published: Nov 27, 2023 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AreIPsInSameSubnet

func AreIPsInSameSubnet(ip1, ip2 net.IP) bool

AreIPsInSameSubnet Given two IPs, checks if they belong to the same subnet

func GeneratePool

func GeneratePool(pool, mask string) ([]net.IP, error)

GeneratePool Given a network pool and a mask it will generate all the IPs in the subnet and return the array of the available IPs.

func GetARPLayer

func GetARPLayer(packet gopacket.Packet) *layers.ARP

GetARPLayer retrieves the ARP layer of a packet in format gopacket.Packet

func GetDefaultGatewayIP

func GetDefaultGatewayIP() (net.IP, error)

GetDefaultGatewayInterface Retrives the IP of the default gateway

func GetDefaultGatewayInterface

func GetDefaultGatewayInterface() (*net.Interface, error)

GetDefaultGatewayInterface retrieves the interface that has connection to the default gateway.

func GetInterfaceByIP

func GetInterfaceByIP(ip net.IP) (*net.Interface, error)

GetInterfaceByIP Given a certain IP, it retrieves the interface with the given IP assigned.

func GetRouteInterface

func GetRouteInterface(dstIP net.IP) (string, error)

GetRouteInterface returns the name of the interface that has a routing to the given IP address.

func GetSTPLayer

func GetSTPLayer(packet gopacket.Packet) *layers.STP

GetSTPLayer retrieves the STP layer of a packet in format gopacket.Packet

func IPbyInt

func IPbyInt(interfaceName string) string

IPbyInt given an interface, it checks the OS information and retrieves the IP address assigned to that interface It only supports Unix OS.

func MacByInt

func MacByInt(ifaceName string) string

MacByInt given an interface name, it checks the OS information and retrieves the MAC address of that interface. Not that it only supports Unix OS.

func ParseIPGen

func ParseIPGen(cidr ...string) string

ParseIPGen this function, given an empty argument it generates a random IP. If the argument provided is for e.g. "10.0.0.0" it will generate a random IP in that subnet. Note that the default mask is 255.255.255.0

func ParseMACGen

func ParseMACGen(cidr ...string) string

ParseMACGen Generates a Random Mac address

func RandomPort

func RandomPort() string

RandomPort Generates a random port until 65535.

Types

This section is empty.

Jump to

Keyboard shortcuts

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