network

package
v0.0.0-...-a4a892e Latest Latest
Warning

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

Go to latest
Published: May 22, 2024 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AllocateNewCidrBlock

func AllocateNewCidrBlock(existingCidrBlocks []string) string

AllocateNewCidrBlock returns an unused cidr block

func SetupNetworkInterfaces

func SetupNetworkInterfaces(network Service, tapDeviceName string, bridgeName string, ipaddress string, netmask string, bridgeipaddress string) error

SetupNetworkInterfaces changes network configuration to support requirements

func TurnOffNetworkInterfaces

func TurnOffNetworkInterfaces(network Service, tapDeviceName string, bridgeName string) error

TurnOffNetworkInterfaces turns network interfaces off if they aren't used

Types

type IprouteNetworkService

type IprouteNetworkService struct {
}

IprouteNetworkService uses iproute commands to change network configuration in OS

func NewIprouteNetworkService

func NewIprouteNetworkService() *IprouteNetworkService

NewIprouteNetworkService returns an instance of IprouteNetworkService

func (*IprouteNetworkService) AddBridge

func (s *IprouteNetworkService) AddBridge(br string) (string, error)

AddBridge creates bridge interface

func (*IprouteNetworkService) AddTap

func (s *IprouteNetworkService) AddTap(tap string) (string, error)

AddTap creates tap interface

func (*IprouteNetworkService) AddTapToBridge

func (s *IprouteNetworkService) AddTapToBridge(br, tap string) (string, error)

AddTapToBridge adds tap interface to bridge network

func (*IprouteNetworkService) CheckBridgeHasInterface

func (s *IprouteNetworkService) CheckBridgeHasInterface(bridgeName string, ifcName string) (bool, error)

CheckBridgeHasInterface checks whether interface is listed in bridge network

func (*IprouteNetworkService) CheckNetworkInterfaceExists

func (s *IprouteNetworkService) CheckNetworkInterfaceExists(name string) (bool, error)

CheckNetworkInterfaceExists checks whether network interface exists

func (*IprouteNetworkService) DeleteNIC

func (s *IprouteNetworkService) DeleteNIC(ifc string) (string, error)

DeleteNIC removes network interface

func (*IprouteNetworkService) FlushIPFromNI

func (s *IprouteNetworkService) FlushIPFromNI(niName string) (string, error)

FlushIPFromNI removes every IP assigned to network interface

func (*IprouteNetworkService) GetBridgeInterfacesNames

func (s *IprouteNetworkService) GetBridgeInterfacesNames(bridgeName string) ([]string, error)

GetBridgeInterfacesNames get list of interfaces names in bridge network

func (*IprouteNetworkService) GetNetworkInterfaceIP

func (s *IprouteNetworkService) GetNetworkInterfaceIP(ifcName string) (string, error)

GetNetworkInterfaceIP get IP from network interface

func (*IprouteNetworkService) IsNIUp

func (s *IprouteNetworkService) IsNIUp(ifcName string) (bool, error)

IsNIUp checks whether network interface is on

func (*IprouteNetworkService) ListBridges

func (s *IprouteNetworkService) ListBridges() (string, error)

ListBridges prints a list of bridge network interfaces

func (*IprouteNetworkService) SetNIIP

func (s *IprouteNetworkService) SetNIIP(ifc string, ip string, netmask string) (string, error)

SetNIIP sets network interface IP

func (*IprouteNetworkService) TurnNIDown

func (s *IprouteNetworkService) TurnNIDown(ifc string) (string, error)

TurnNIDown turns off network interface

func (*IprouteNetworkService) TurnNIUp

func (s *IprouteNetworkService) TurnNIUp(ifc string) (string, error)

TurnNIUp turns on network interface

type Service

type Service interface {
	AddBridge(br string) (string, error)
	ListBridges() (string, error)
	CheckBridgeHasInterface(bridgeName string, ifcName string) (bool, error)
	GetBridgeInterfacesNames(bridgeName string) ([]string, error)
	CheckNetworkInterfaceExists(name string) (bool, error)
	AddTap(tap string) (string, error)
	AddTapToBridge(br, tap string) (string, error)
	SetNIIP(ifc string, ip string, netmask string) (string, error)
	FlushIPFromNI(niName string) (string, error)
	TurnNIUp(ifc string) (string, error)
	TurnNIDown(ifc string) (string, error)
	DeleteNIC(ifc string) (string, error)
	IsNIUp(ifcName string) (bool, error)
	GetNetworkInterfaceIP(ifcName string) (string, error)
}

Service represents a network service able to apply changes to network configuration

Directories

Path Synopsis
Package mocks is a generated GoMock package.
Package mocks is a generated GoMock package.

Jump to

Keyboard shortcuts

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