netutil

package
v0.2.8 Latest Latest
Warning

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

Go to latest
Published: May 10, 2023 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(net string) string

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"`
}

type Nameservers

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

type Network

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

func NewNetwork

func NewNetwork() *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