netif

package module
v0.0.0-...-eededdc Latest Latest
Warning

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

Go to latest
Published: Apr 12, 2017 License: BSD-3-Clause Imports: 8 Imported by: 0

README

Netif

This is a simple Golang package for reading, manipulating and writing the /etc/network/interface file in most Debian based distributions.

This package is heavily based on the Python library Debinterface github.com/dggreenbaum/debinterface.

Installation
go get github.com/hilt0n/netif
Basic usage
package main

import (
    "github.com/hilt0n/netif"
)

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BackupPath

func BackupPath(path string) fn.Option

func Path

func Path(path string) fn.Option

Types

type AddrFamily

type AddrFamily int
const (
	INET AddrFamily = 1 + iota
	INET6
)

type AddrSource

type AddrSource int
const (
	DHCP AddrSource = 1 + iota
	STATIC
	LOOPBACK
	MANUAL
)

type InterfaceSet

type InterfaceSet struct {
	InterfacesReader

	InterfacesPath string
	Adapters       []*NetworkAdapter
}

func NewInterfaceSet

func NewInterfaceSet(opts ...fn.Option) *InterfaceSet

func Parse

func Parse(opts ...fn.Option) *InterfaceSet

func (*InterfaceSet) Write

func (is *InterfaceSet) Write(opts ...fn.Option) error

func (*InterfaceSet) WriteToFile

func (is *InterfaceSet) WriteToFile(f *os.File) error

type InterfacesReader

type InterfacesReader struct {
	// contains filtered or unexported fields
}

TODO get rid of interfaceReader

func NewInterfacesReader

func NewInterfacesReader(filePath string) *InterfacesReader

func (*InterfacesReader) ParseInterfaces

func (ir *InterfacesReader) ParseInterfaces() []*NetworkAdapter

type NetworkAdapter

type NetworkAdapter struct {
	Name       string
	Hotplug    bool
	Auto       bool
	Address    net.IP
	Netmask    net.IP
	Network    net.IP
	Broadcast  net.IP
	Gateway    net.IP
	AddrSource AddrSource
	AddrFamily AddrFamily
}

A representation of a network adapter

func (*NetworkAdapter) GetAddrFamilyString

func (a *NetworkAdapter) GetAddrFamilyString() string

func (*NetworkAdapter) GetSourceFamilyString

func (a *NetworkAdapter) GetSourceFamilyString() string

func (*NetworkAdapter) ParseAddressFamily

func (na *NetworkAdapter) ParseAddressFamily(AddressFamily string) (AddrFamily, error)

func (*NetworkAdapter) ParseAddressSource

func (na *NetworkAdapter) ParseAddressSource(AddressSource string) (AddrSource, error)

func (*NetworkAdapter) SetAddress

func (na *NetworkAdapter) SetAddress(address string) error

func (*NetworkAdapter) SetBroadcast

func (na *NetworkAdapter) SetBroadcast(address string) error

func (*NetworkAdapter) SetConfigType

func (na *NetworkAdapter) SetConfigType(configType string) error

func (*NetworkAdapter) SetGateway

func (na *NetworkAdapter) SetGateway(address string) error

func (*NetworkAdapter) SetNetmask

func (na *NetworkAdapter) SetNetmask(address string) error

func (*NetworkAdapter) SetNetwork

func (na *NetworkAdapter) SetNetwork(address string) error

Directories

Path Synopsis
examples
1 command

Jump to

Keyboard shortcuts

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