netutil

package
v0.5.1 Latest Latest
Warning

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

Go to latest
Published: Feb 17, 2024 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Download

func Download(url string) ([]byte, error)

Download fetches a file from the internet

func DownloadAndSave

func DownloadAndSave(url, destination string) error

Download fetches a file from the internet

func GenerateIPAddress

func GenerateIPAddress() string

Generate a random IP address

func GetGatewayFromIP

func GetGatewayFromIP(ip string) (string, error)

getGatewayFromIP will return the gateway from the IPv4 addres

Example:
	IP: 192.168.122.100
	GW? 192.168.122.1

func GetIPFromNetworkAddress added in v0.0.2

func GetIPFromNetworkAddress(netAddr string) (string, error)

GetIPFromNetworkAddress returns the IP address from a network address

func RandomMacAddress

func RandomMacAddress() (string, error)

Creates a random Mac Address

func ValidateIPAddress

func ValidateIPAddress(ip string) bool

Checks if an IP address is valid

Types

type Ethernets

type Ethernets struct {
	VirtNet VirtNet `yaml:"virtnet"`
}

type Match

type Match struct {
	MacAddress string `yaml:"macaddress"`
}

Match is used to match the MAC address of the interface

type Nameservers

type Nameservers struct {
	Addresses []string `yaml:"addresses"`
}

Nameservers is used to set the DNS servers

type Network

type Network struct {
	Ethernets Ethernets `yaml:"ethernets"`
	Version   int       `yaml:"version"`
}

func NewNetwork

func NewNetwork() *Network

NewNetwork creates a new network

type VirtNet

type VirtNet struct {
	Name        string      `yaml:"set-name"`
	Addresses   []string    `yaml:"addresses"`
	DHCP4       bool        `yaml:"dhcp4"`
	Gateway4    string      `yaml:"gateway4"`
	Match       Match       `yaml:"match"`
	Nameservers Nameservers `yaml:"nameservers"`
}

Jump to

Keyboard shortcuts

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