network

package
v0.0.0-...-b967545 Latest Latest
Warning

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

Go to latest
Published: Nov 19, 2017 License: BSD-3-Clause Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const ReceiverSocketPath = "/tmp/fwoz.sock"

Variables

View Source
var PairLock = &sync.Mutex{}
View Source
var ProxyPairs []*ProxyPair

Functions

func FindEmptyRange

func FindEmptyRange() (net.IP, *net.IPNet, error)

func GetProxyPairInfo

func GetProxyPairInfo() []string

func NetAttach

func NetAttach(stn *SandboxNetwork, htn *HostNetwork, childPid int) error

func NetInit

func NetInit(stn *SandboxNetwork, htn *HostNetwork, log *logging.Logger) error

func NetPrint

func NetPrint(log *logging.Logger)

Print status of the network interfaces

func NetReconfigure

func NetReconfigure(stn *SandboxNetwork, htn *HostNetwork, childPid int, log *logging.Logger) error

func NetSetup

func NetSetup() error

Setup the networking inside the child Namely setup the loopback interface and the veth interface if requested

func ProxySetup

func ProxySetup(childPid int, ozSockets []ProxyConfig, log *logging.Logger, ready sync.WaitGroup) error

Types

type Bridges

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

Bridges manages the creation of bridges for sandbox bridged networking

func NewBridges

func NewBridges(log *logging.Logger) *Bridges

func (*Bridges) GetBridge

func (bs *Bridges) GetBridge(name string) (*OzBridge, error)

func (*Bridges) GetBridgeMap

func (bs *Bridges) GetBridgeMap() map[string]*OzBridge

func (*Bridges) Reconfigure

func (bs *Bridges) Reconfigure() error

type HostNetwork

type HostNetwork struct {
	// Bridge interface
	Interface tenus.Bridger
	// Gateway ip (bridge ip)
	Gateway net.IP
	// Gateway ip (bridge ip)
	GatewayNet *net.IPNet
	// Bridge netmask
	Netmask net.IP
	// Broadcast ip
	Broadcast net.IP
	// IP class (ie: /24)
	Class string
	// Minimum longip available ip
	Min uint64
	// Maximum longip available ip
	Max uint64
	// Bridge interface MAC Address
	BridgeMAC string
	// The type of network configuration
	Nettype NetType
	//
	IpBytes []uint

	Name string
	// contains filtered or unexported fields
}

func BridgeInit

func BridgeInit(bridgeMAC string, nmIgnoreFile string, log *logging.Logger) (*HostNetwork, error)

func NewHostNetwork

func NewHostNetwork(name string, log *logging.Logger) *HostNetwork

func (*HostNetwork) BridgeReconfigure

func (htn *HostNetwork) BridgeReconfigure() (*HostNetwork, error)

func (*HostNetwork) Initialize

func (hn *HostNetwork) Initialize() error

type IPRange

type IPRange struct {
	*net.IPNet
	// contains filtered or unexported fields
}

IPRange represents a subnet range from which individual IP addresses can be allocated

func (*IPRange) FirstIP

func (ipr *IPRange) FirstIP() net.IP

func (*IPRange) FreshIP

func (ipr *IPRange) FreshIP() net.IP

type NetType

type NetType string
const (
	TYPE_NONE   NetType = "none"
	TYPE_HOST   NetType = "host"
	TYPE_EMPTY  NetType = "empty"
	TYPE_BRIDGE NetType = "bridge"
)

type OzBridge

type OzBridge struct {
	tenus.Bridger        // Bridge instance
	Name          string // Name of bridge
	// contains filtered or unexported fields
}

OzBridge represents a single bridge used for sandbox bridged networking

func (*OzBridge) GetIP

func (b *OzBridge) GetIP() *net.IP

func (*OzBridge) NewVeth

func (b *OzBridge) NewVeth(id int, peerPid int) (*OzVeth, error)

type OzVeth

type OzVeth struct {
	tenus.Vether // The pair of veth interfaces
	// contains filtered or unexported fields
}

OzVeth is a pair of Veth interfaces

func (*OzVeth) AssignIP

func (v *OzVeth) AssignIP() error

func (*OzVeth) Delete

func (v *OzVeth) Delete() error

func (*OzVeth) GetSandboxIP

func (v *OzVeth) GetSandboxIP() net.IP

func (*OzVeth) GetVethBridge

func (v *OzVeth) GetVethBridge() *OzBridge

func (*OzVeth) RemoveFWRules

func (v *OzVeth) RemoveFWRules() error

func (*OzVeth) SetIP

func (v *OzVeth) SetIP(ip net.IP) error

func (*OzVeth) Setup

func (v *OzVeth) Setup() error

type PConnInfo

type PConnInfo struct {
	Saddr net.IP
	Sport uint16
	Daddr net.IP
	Dport uint16
}

type ProtoType

type ProtoType string
const (
	PROTO_TCP         ProtoType = "tcp"
	PROTO_UDP         ProtoType = "udp"
	PROTO_UNIX        ProtoType = "unix"
	PROTO_TCP_TO_UNIX ProtoType = "tcp2unix"
	PROTO_UNIXGRAM    ProtoType = "unixgram"
	PROTO_UNIXPACKET  ProtoType = "unixpacket"
)

type ProxyConfig

type ProxyConfig struct {
	// One of client, server
	Nettype ProxyType `json:"type"`

	// One of tcp, udp, socket
	Proto ProtoType

	// TCP or UDP port number
	Port int

	// Destination port number
	DPort int
	// Optional: Destination address
	// In client mode: the host side address to connect to
	// In server mode: the sandbox side address to bind to
	// For unix sockets this is an abstract path
	// If left empty, localhost is used
	Destination string
}

Socket list, used to hold ports that should be forwarded

type ProxyPair

type ProxyPair struct {
	In  *PConnInfo
	Out *PConnInfo
	Cnt int
}

type ProxyType

type ProxyType string
const (
	PROXY_CLIENT ProxyType = "client"
	PROXY_SERVER ProxyType = "server"
)

type SandboxNetwork

type SandboxNetwork struct {
	// veth interface is present
	Interface tenus.Linker
	// Name of the veth in the host
	VethHost string
	// Temporary name of the guest' veth in the host
	VethGuest string
	// Guest ip address
	Ip string
	// Gateway ip (bridge ip)
	Gateway net.IP
	// IP class (ie: /24)
	Class string
	// The type of network configuration
	Nettype NetType
	// Host side virtual interface
	Veth tenus.Vether
	//
	IpByte uint
}

func PrepareSandboxNetwork

func PrepareSandboxNetwork(stn *SandboxNetwork, htn *HostNetwork, staticByte uint, log *logging.Logger) (*SandboxNetwork, error)

func (*SandboxNetwork) Cleanup

func (stn *SandboxNetwork) Cleanup(log *logging.Logger)

Jump to

Keyboard shortcuts

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