networks

package
v1.0.0-beta.0 Latest Latest
Warning

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

Go to latest
Published: Oct 20, 2024 License: Apache-2.0 Imports: 19 Imported by: 1

Documentation

Index

Constants

View Source
const (
	SlirpNICName = "eth0"
	// CIDR is intentionally hardcoded to 192.168.5.0/24, as each of QEMU has its own independent slirp network.
	SlirpNetwork   = "192.168.5.0/24"
	SlirpGateway   = "192.168.5.2"
	SlirpIPAddress = "192.168.5.15"
)
View Source
const (
	ModeUserV2  = "user-v2"
	ModeHost    = "host"
	ModeShared  = "shared"
	ModeBridged = "bridged"
)
View Source
const (
	SocketVMNet = "socket_vmnet"
)

Variables

This section is empty.

Functions

func ConfigFile

func ConfigFile() (string, error)

func IsUsernet added in v0.23.0

func IsUsernet(name string) bool

IsUsernet returns true if the given network name is a usernet network. It return false if the cache cannot be loaded or the network is not defined.

func Sock added in v0.12.0

func Sock(name string) (string, error)

Sock returns a socket_vmnet socket.

func Sudoers

func Sudoers() (string, error)

Types

type Config

type Config struct {
	Paths    Paths              `yaml:"paths"`
	Group    string             `yaml:"group,omitempty"` // default: "everyone"
	Networks map[string]Network `yaml:"networks"`
}

func DefaultConfig

func DefaultConfig() (Config, error)

func LoadConfig added in v1.0.0

func LoadConfig() (Config, error)

LoadConfig returns the network cfg from the _config/networks.yaml file.

func (*Config) Check added in v1.0.0

func (c *Config) Check(name string) error

func (*Config) DaemonPath added in v1.0.0

func (c *Config) DaemonPath(daemon string) (string, error)

DaemonPath returns the daemon path.

func (*Config) IsDaemonInstalled added in v1.0.0

func (c *Config) IsDaemonInstalled(daemon string) (bool, error)

IsDaemonInstalled checks whether the daemon is installed.

func (*Config) LogFile added in v1.0.0

func (c *Config) LogFile(name, daemon, stream string) string

func (*Config) MkdirCmd added in v1.0.0

func (c *Config) MkdirCmd() string

func (*Config) PIDFile added in v1.0.0

func (c *Config) PIDFile(name, daemon string) string

func (*Config) Sock added in v1.0.0

func (c *Config) Sock(name string) string

Sock returns a socket_vmnet socket.

func (*Config) StartCmd added in v1.0.0

func (c *Config) StartCmd(name, daemon string) string

func (*Config) StopCmd added in v1.0.0

func (c *Config) StopCmd(name, daemon string) string

func (*Config) User added in v1.0.0

func (c *Config) User(daemon string) (osutil.User, error)

func (*Config) Usernet added in v1.0.0

func (c *Config) Usernet(name string) (bool, error)

Usernet returns true if the mode of given network is ModeUserV2.

func (*Config) Validate added in v1.0.0

func (c *Config) Validate() error

func (*Config) VerifySudoAccess added in v1.0.0

func (c *Config) VerifySudoAccess(sudoersFile string) error

type Network

type Network struct {
	Mode      string `yaml:"mode"`                // "host", "shared", or "bridged"
	Interface string `yaml:"interface,omitempty"` // only used by "bridged" networks
	Gateway   net.IP `yaml:"gateway,omitempty"`   // only used by "host" and "shared" networks
	DHCPEnd   net.IP `yaml:"dhcpEnd,omitempty"`   // default: same as Gateway, last byte is 254
	NetMask   net.IP `yaml:"netmask,omitempty"`   // default: 255.255.255.0
}

type Paths

type Paths struct {
	SocketVMNet string `yaml:"socketVMNet"`
	VarRun      string `yaml:"varRun"`
	Sudoers     string `yaml:"sudoers,omitempty"`
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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