network

package
v0.60.1 Latest Latest
Warning

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

Go to latest
Published: Dec 18, 2024 License: MIT Imports: 4 Imported by: 1

Documentation

Overview

Package network regroups collecting information about the network interfaces

Index

Constants

This section is empty.

Variables

View Source
var ErrAddressNotFound = errors.New("address not found")

ErrAddressNotFound means no such address could be found

Functions

This section is empty.

Types

type Info added in v0.48.0

type Info struct {
	// Interfaces is the list of interfaces which are up
	Interfaces []Interface `json:"interfaces"`
	// MacAddress is a mac address of the host
	MacAddress string `json:"macaddress"`
	// IPAddress is an IPv4 address of the host
	IPAddress string `json:"ipaddress"`
	// IPAddressV6 is an IPv6 address of the host
	IPAddressV6 utils.Value[string] `json:"ipaddressv6"`
}

Info holds network metadata about the host

func CollectInfo added in v0.48.0

func CollectInfo() (*Info, error)

CollectInfo collects the network information.

func (*Info) AsJSON added in v0.48.0

func (netInfo *Info) AsJSON() (interface{}, []string, error)

AsJSON returns an interface which can be marshalled to a JSON and contains the value of non-errored fields.

type Interface added in v0.48.0

type Interface struct {
	// Name is the name of the interface
	Name string `json:"name"`
	// IPv4Network is the ipv4 address for the host
	IPv4Network utils.Value[string] `json:"ipv4-network"`
	// IPv6Network is the ipv6 address for the host
	IPv6Network utils.Value[string] `json:"ipv6-network"`
	// MacAddress is the mac address for the host
	MacAddress utils.Value[string] `json:"macaddress"`
	// IPv4 is the list of IPv4 addresses for the interface
	IPv4 []string `json:"ipv4"`
	// IPv4 is the list of IPv6 addresses for the interface
	IPv6 []string `json:"ipv6"`
}

Interface holds information about a specific interface

Jump to

Keyboard shortcuts

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