Documentation ¶
Overview ¶
package designed to be a user-friendly way to interact with the various network interfaces of one's computer. this will allow the user to grab the IP address of a given interface, grab all the IPs of all interfaces, etc. this can be very useful when performing network-specific tasks that require interaction on a specific interface.
Index ¶
- type IPGrabber
- func (grabber *IPGrabber) AddIP(ipaddr net.IP) (err error)
- func (grabber *IPGrabber) AlreadyFound(ipaddr net.IP) (err error)
- func (grabber *IPGrabber) GetFirstNonLoop() (iface string, err error)
- func (grabber *IPGrabber) GrabIPs() (err error)
- func (grabber *IPGrabber) GrabInterfaceIP(targetiface string) (ipaddr net.IP, err error)
- func (grabber *IPGrabber) GrabInterfaces() (err error)
- func (grabber *IPGrabber) IFacesEmpty() (empty bool)
- func (grabber *IPGrabber) InterfaceExists(ifaceName string) (err error)
- func (grabber *IPGrabber) ListIFaces() (err error)
- func (grabber *IPGrabber) ListIPs() (err error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type IPGrabber ¶
type IPGrabber struct { // slice holding all the discovered network interfaces on // the current system. this excludes the loopback interface. Interfaces []net.Interface // slice holding all the discovered IP addresses for all // the interfaces in the Interfaces slice. Discovered []net.IP }
structure representing the main object that will search for and hold the discovered addresses and interfaces.
func NewGrabber ¶
function designed to create a new IPGrabber, populate both slices and return the pointer to the user. if an error occurs nil and the error will be returned, otherwise the pointer and nil will be returned.
func (*IPGrabber) AddIP ¶
function designed to add an IP address to the list of discovred IP addresses. this first checks if the address was previously discovered/added to the list. if the address is already in the list, it does not add it and returns an error.
func (*IPGrabber) AlreadyFound ¶
function designed to determine if the given IP address is already in the list of discovred addresses. returns error if the address is not in the list, nil if it is in the list.
func (*IPGrabber) GetFirstNonLoop ¶ added in v0.0.18
function designed to return the first non-loopback interface from the Interfaces slice. if there is an error or no non-loopback interface is discovered an error will be returned, otherwise the interface name and nil will be returned.
func (*IPGrabber) GrabIPs ¶
Function designed to acquire all IPv4 network addresses attached to the current machine.
func (*IPGrabber) GrabInterfaceIP ¶
function designed to acquire the IP address of a target interface. this will return the net.IP object and nil if the interface is successfully discovered, otherwise it will return nil and error.
func (*IPGrabber) GrabInterfaces ¶
function designed to populate/repopulate the Interfaces slice of the IPGrabber struct by calling the net.Interfaces function.
func (*IPGrabber) IFacesEmpty ¶
function designed to check whether the interface list is empty. returns true/false based on the length of grabber.Interfaces.
func (*IPGrabber) InterfaceExists ¶
function designed to check wheter an interface with a given name exists in the discovered interfaces.
func (*IPGrabber) ListIFaces ¶
function designed to list out all discovered Interfaces on the current machine. if the interface slice is empty, it will attempt to populate it first.