Documentation
¶
Index ¶
- Variables
- type AddressConfig
- type AddressVersion
- type Hooks
- type Interfaces
- type MultiParser
- type NetworkInterface
- func (iface *NetworkInterface) Read(p []byte) (int, error)
- func (iface *NetworkInterface) String() string
- func (iface *NetworkInterface) Validate() error
- func (iface *NetworkInterface) WithAddress(address string) *NetworkInterface
- func (iface *NetworkInterface) WithAddressConfig(config AddressConfig) *NetworkInterface
- func (iface *NetworkInterface) WithAddressVersion(version AddressVersion) *NetworkInterface
- func (iface *NetworkInterface) WithBroadcast(broadcast string) *NetworkInterface
- func (iface *NetworkInterface) WithConfigMethod(config AddressConfig) *NetworkInterface
- func (iface *NetworkInterface) WithDHCP() *NetworkInterface
- func (iface *NetworkInterface) WithDNS(dnsServers []string) *NetworkInterface
- func (iface *NetworkInterface) WithDNSSearch(dnsSearch []string) *NetworkInterface
- func (iface *NetworkInterface) WithGateway(gateway string) *NetworkInterface
- func (iface *NetworkInterface) WithLoopback() *NetworkInterface
- func (iface *NetworkInterface) WithMACAddress(macAddress string) *NetworkInterface
- func (iface *NetworkInterface) WithManual() *NetworkInterface
- func (iface *NetworkInterface) WithNetmask(mask, bits int) *NetworkInterface
- func (iface *NetworkInterface) WithStatic() *NetworkInterface
- func (iface *NetworkInterface) WithVersion(version AddressVersion) *NetworkInterface
- func (iface *NetworkInterface) Write(p []byte) (int, error)
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ErrInvalidAddress = errors.New("invalid address") ErrInvalidMask = errors.New("invalid mask") ErrInvalidBroadcast = errors.New("invalid broadcast") ErrInvalidGateway = errors.New("invalid gateway") ErrInvalidAddressVersion = errors.New("invalid address version") ErrAddressSetWhenDHCP = errors.New("address set when DHCP enabled") ErrAddressNotSetStatic = errors.New("address not set with static config") ErrMaskNotSetStatic = errors.New("mask not set with static config") ErrAdressNotLoopback = errors.New("address must be loopback when config is loopback") ErrInterfaceHasErrors = errors.New("interface has errors") ErrUnallocatedInterface = errors.New("unallocated interface") ErrInvalidIfaceData = errors.New("invalid interface data provided") ErrMultipleInterfaces = errors.New("multiple interfaces in data provided") )
Functions ¶
This section is empty.
Types ¶
type AddressConfig ¶
type AddressConfig uint8
const ( AddressConfigUnset AddressConfig = iota AddressConfigLoopback AddressConfigDHCP AddressConfigStatic AddressConfigManual )
func (AddressConfig) String ¶
func (ac AddressConfig) String() string
type AddressVersion ¶
type AddressVersion uint8
const ( AddressVersionNil AddressVersion = iota AddressVersion4 AddressVersion6 )
func (AddressVersion) String ¶
func (at AddressVersion) String() string
type Hooks ¶
type Hooks struct { // PreUp of the interface PreUp []string `json:"pre_up,omitempty"` // PostUp of the interface PostUp []string `json:"post_up,omitempty"` // PreDown of the interface PreDown []string `json:"pre_down,omitempty"` // PostDown of the interface PostDown []string `json:"post_down,omitempty"` }
type Interfaces ¶
type Interfaces map[string]*NetworkInterface
func (Interfaces) String ¶
func (i Interfaces) String() string
func (Interfaces) UnmarshalJSON ¶
func (i Interfaces) UnmarshalJSON(data []byte) error
type MultiParser ¶
type MultiParser struct { Interfaces map[string]*NetworkInterface Errs []error // contains filtered or unexported fields }
func NewMultiParser ¶
func NewMultiParser() *MultiParser
func (*MultiParser) Parse ¶
func (p *MultiParser) Parse() (Interfaces, error)
type NetworkInterface ¶
type NetworkInterface struct { // Name of the interface. Name string `json:"name"` // Hotplug determines if hot plugging is allowed. Hotplug bool `json:"hotplug,omitempty"` // Auto determines if the interface is automatically brought up. Auto bool `json:"auto,omitempty"` // Address determines the static IP address of the interface. Address net.IP `json:"address,omitempty"` // Netmask determines the netmask of the interface. Netmask net.IPMask `json:"netmask,omitempty"` Broadcast net.IP `json:"broadcast,omitempty"` Gateway net.IP `json:"gateway,omitempty"` Config AddressConfig `json:"config,omitempty"` Version AddressVersion `json:"version,omitempty"` // DNSServers of the interface. DNSServers []net.IP `json:"dns_servers,omitempty"` // DNSSearch of the interface. DNSSearch []string `json:"dns_search,omitempty"` // MACAddress of the interface. MACAddress net.HardwareAddr `json:"mac_address,omitempty"` // Hooks contains the pre/post up/down hooks. Hooks Hooks `json:"hooks,omitempty"` *sync.RWMutex // contains filtered or unexported fields }
NetworkInterface follows the format of ifupdown /etc/network/interfaces
func NewNetworkInterface ¶
func NewNetworkInterface(name string) *NetworkInterface
func (*NetworkInterface) String ¶
func (iface *NetworkInterface) String() string
func (*NetworkInterface) Validate ¶
func (iface *NetworkInterface) Validate() error
func (*NetworkInterface) WithAddress ¶
func (iface *NetworkInterface) WithAddress(address string) *NetworkInterface
func (*NetworkInterface) WithAddressConfig ¶
func (iface *NetworkInterface) WithAddressConfig(config AddressConfig) *NetworkInterface
func (*NetworkInterface) WithAddressVersion ¶
func (iface *NetworkInterface) WithAddressVersion(version AddressVersion) *NetworkInterface
func (*NetworkInterface) WithBroadcast ¶
func (iface *NetworkInterface) WithBroadcast(broadcast string) *NetworkInterface
func (*NetworkInterface) WithConfigMethod ¶
func (iface *NetworkInterface) WithConfigMethod(config AddressConfig) *NetworkInterface
func (*NetworkInterface) WithDHCP ¶
func (iface *NetworkInterface) WithDHCP() *NetworkInterface
func (*NetworkInterface) WithDNS ¶
func (iface *NetworkInterface) WithDNS(dnsServers []string) *NetworkInterface
func (*NetworkInterface) WithDNSSearch ¶
func (iface *NetworkInterface) WithDNSSearch(dnsSearch []string) *NetworkInterface
func (*NetworkInterface) WithGateway ¶
func (iface *NetworkInterface) WithGateway(gateway string) *NetworkInterface
func (*NetworkInterface) WithLoopback ¶
func (iface *NetworkInterface) WithLoopback() *NetworkInterface
func (*NetworkInterface) WithMACAddress ¶
func (iface *NetworkInterface) WithMACAddress(macAddress string) *NetworkInterface
func (*NetworkInterface) WithManual ¶
func (iface *NetworkInterface) WithManual() *NetworkInterface
func (*NetworkInterface) WithNetmask ¶
func (iface *NetworkInterface) WithNetmask(mask, bits int) *NetworkInterface
func (*NetworkInterface) WithStatic ¶
func (iface *NetworkInterface) WithStatic() *NetworkInterface
func (*NetworkInterface) WithVersion ¶
func (iface *NetworkInterface) WithVersion(version AddressVersion) *NetworkInterface
Click to show internal directories.
Click to hide internal directories.