debinterfaces

package
v0.0.0-...-298751d Latest Latest
Warning

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

Go to latest
Published: Apr 19, 2024 License: AGPL-3.0 Imports: 15 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FormatDefinition

func FormatDefinition(definition []string, count int) string

FormatDefinition formats the complete stanza, indenting any options with count leading spaces.

func FormatStanzas

func FormatStanzas(stanzas []Stanza, count int) string

FormatStanzas returns a string representing all stanzas definitions, recursively expanding stanzas found in both source and source-directory definitions.

Types

type ActivationParams

type ActivationParams struct {
	Clock clock.Clock
	// map deviceName -> bridgeName
	Devices          map[string]string
	DryRun           bool
	Filename         string
	ReconfigureDelay int
	Timeout          time.Duration
}

ActivationParams contains options to use when bridging interfaces

type ActivationResult

type ActivationResult struct {
	Stdout []byte
	Stderr []byte
	Code   int
}

ActivationResult captures the result of actively bridging the interfaces using ifup/ifdown.

func BridgeAndActivate

func BridgeAndActivate(params ActivationParams) (*ActivationResult, error)

BridgeAndActivate will parse a debian-styled interfaces(5) file, change the stanza definitions of the requested devices to be bridged, then reconfigure the network using the ifupdown package for the new bridges.

type AllowStanza

type AllowStanza struct {
	DeviceNames []string
	// contains filtered or unexported fields
}

AllowStanza are lines beginning with the word 'allow-*'.

func (AllowStanza) Definition

func (s AllowStanza) Definition() []string

Definition returns all the lines that define the stanza. The individual lines are trimmed of leading and trailing whitespace.

func (AllowStanza) Location

func (s AllowStanza) Location() Location

Location returns the filename and line number of the first line of the definition, if any.

type AutoStanza

type AutoStanza struct {
	DeviceNames []string
	// contains filtered or unexported fields
}

AutoStanza are lines beginning with the word "auto".

func (AutoStanza) Definition

func (s AutoStanza) Definition() []string

Definition returns all the lines that define the stanza. The individual lines are trimmed of leading and trailing whitespace.

func (AutoStanza) Location

func (s AutoStanza) Location() Location

Location returns the filename and line number of the first line of the definition, if any.

type IfaceStanza

type IfaceStanza struct {
	DeviceName          string
	HasBondMasterOption bool
	HasBondOptions      bool
	IsAlias             bool
	IsBridged           bool
	IsVLAN              bool
	Options             []string
	// contains filtered or unexported fields
}

IfaceStanza are lines beginning with 'iface'.

func (IfaceStanza) Definition

func (s IfaceStanza) Definition() []string

Definition returns all the lines that define the stanza. The individual lines are trimmed of leading and trailing whitespace.

func (IfaceStanza) Location

func (s IfaceStanza) Location() Location

Location returns the filename and line number of the first line of the definition, if any.

type Location

type Location struct {
	Filename string
	LineNum  int
}

Location represents source file and line number information

type MappingStanza

type MappingStanza struct {
	DeviceNames []string
	Options     []string
	// contains filtered or unexported fields
}

MappingStanza are lines beginning with the word "mapping".

func (MappingStanza) Definition

func (s MappingStanza) Definition() []string

Definition returns all the lines that define the stanza. The individual lines are trimmed of leading and trailing whitespace.

func (MappingStanza) Location

func (s MappingStanza) Location() Location

Location returns the filename and line number of the first line of the definition, if any.

type NoAutoDownStanza

type NoAutoDownStanza struct {
	DeviceNames []string
	// contains filtered or unexported fields
}

NoAutoDownStanza are lines beginning with "no-auto-down".

func (NoAutoDownStanza) Definition

func (s NoAutoDownStanza) Definition() []string

Definition returns all the lines that define the stanza. The individual lines are trimmed of leading and trailing whitespace.

func (NoAutoDownStanza) Location

func (s NoAutoDownStanza) Location() Location

Location returns the filename and line number of the first line of the definition, if any.

type NoScriptsStanza

type NoScriptsStanza struct {
	DeviceNames []string
	// contains filtered or unexported fields
}

NoScriptsStanza are lines beginning with "no-scripts".

func (NoScriptsStanza) Definition

func (s NoScriptsStanza) Definition() []string

Definition returns all the lines that define the stanza. The individual lines are trimmed of leading and trailing whitespace.

func (NoScriptsStanza) Location

func (s NoScriptsStanza) Location() Location

Location returns the filename and line number of the first line of the definition, if any.

type ParseError

type ParseError struct {
	Filename string
	Line     string
	LineNum  int
	Message  string
}

ParseError represents an error when parsing a line of a Debian-style interfaces definition. This only covers top-level definitions.

func (*ParseError) Error

func (p *ParseError) Error() string

Error returns the parsing error.

type SourceDirectoryStanza

type SourceDirectoryStanza struct {
	Path    string
	Sources []string
	Stanzas []Stanza
	// contains filtered or unexported fields
}

SourceDirectoryStanza are lines beginning with "source-directory".

func (SourceDirectoryStanza) Definition

func (s SourceDirectoryStanza) Definition() []string

Definition returns all the lines that define the stanza. The individual lines are trimmed of leading and trailing whitespace.

func (SourceDirectoryStanza) Location

func (s SourceDirectoryStanza) Location() Location

Location returns the filename and line number of the first line of the definition, if any.

type SourceStanza

type SourceStanza struct {
	Path    string
	Sources []string
	Stanzas []Stanza
	// contains filtered or unexported fields
}

SourceStanza are lines beginning with "source".

func (SourceStanza) Definition

func (s SourceStanza) Definition() []string

Definition returns all the lines that define the stanza. The individual lines are trimmed of leading and trailing whitespace.

func (SourceStanza) Location

func (s SourceStanza) Location() Location

Location returns the filename and line number of the first line of the definition, if any.

type Stanza

type Stanza interface {
	// A definition is the top-level stanza, together with any
	// options.
	Definition() []string

	// The file and linenumber, if any, where the stanza was
	// declared.
	Location() Location
}

Stanza represents a network definition as described by interfaces(8).

func Bridge

func Bridge(stanzas []Stanza, devices map[string]string) []Stanza

Bridge turns existing devices into bridged devices.

func FlattenStanzas

func FlattenStanzas(stanzas []Stanza) []Stanza

FlattenStanzas flattens all stanzas, and recursively for all 'source' and 'source-directory' stanzas, returning a single slice.

func Parse

func Parse(filename string) ([]Stanza, error)

Parse parses the definitions of a single Debian style network interfaces(5) file and returns the corresponding set of stanza definitions.

type WordExpander

type WordExpander interface {
	// Expand pattern into a slice of words, or an error if the
	// underlying implementation failed.
	Expand(pattern string) ([]string, error)
}

WordExpander performs word expansion like a posix-shell.

Jump to

Keyboard shortcuts

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