network

package
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: Jul 9, 2025 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Connect

func Connect(networkName string, cinfo *container.ContainerInfo) error

func CreateNetwork

func CreateNetwork(driver string, subnet string, name string) error

func InitNetwork

func InitNetwork() error

func ListNetwork

func ListNetwork()

func RemoveNetwork

func RemoveNetwork(netName string) error

Types

type BridgeNetworkDriver

type BridgeNetworkDriver struct{}

func (*BridgeNetworkDriver) Connect

func (b *BridgeNetworkDriver) Connect(network *Network, endpoint *Endpoint) error

func (*BridgeNetworkDriver) Create

func (b *BridgeNetworkDriver) Create(subnet string, name string) (*Network, error)

func (*BridgeNetworkDriver) Delete

func (b *BridgeNetworkDriver) Delete(network Network) error

func (*BridgeNetworkDriver) Disconnect

func (b *BridgeNetworkDriver) Disconnect(network *Network, endpoint *Endpoint) error

func (*BridgeNetworkDriver) Name

func (b *BridgeNetworkDriver) Name() string

type Endpoint

type Endpoint struct {
	ID          string           `json:"id"`
	Device      netlink.Veth     `json:"device"`
	IPAddress   net.IP           `json:"ip"`
	MacAddress  net.HardwareAddr `json:"mac"`
	PortMapping []string         `json:"portMapping"`
	Network     *Network
}

type IPAM

type IPAM struct {
	SubnetAllocatorPath string             // Allocation of document storage locations
	Subnets             *map[string][]byte // key is the network segment, value is an array of allocated bitmaps
}

IPAM store ip address allocate information

func (*IPAM) Allocate

func (i *IPAM) Allocate(subnet *net.IPNet) (net.IP, error)

func (*IPAM) Release

func (i *IPAM) Release(subnet *net.IPNet, ipAddr *net.IP) error

type Network

type Network struct {
	Name    string     `json:"name"`    // network name
	IpRange *net.IPNet `json:"ipRange"` // network segment
	Driver  string     `json:"driver"`  // network driver name
}

func (*Network) MarshalJSON

func (nw *Network) MarshalJSON() ([]byte, error)

MarshalJSON implements json.Marshaler interface

func (*Network) UnmarshalJSON

func (nw *Network) UnmarshalJSON(data []byte) error

UnmarshalJSON implements json.Unmarshaler interface

type NetworkDriver

type NetworkDriver interface {
	Name() string
	Create(subnet string, name string) (*Network, error)
	Delete(network Network) error
	Connect(network *Network, endpoint *Endpoint) error
	Disconnect(network *Network, endpoint *Endpoint) error
}

type NetworkJSON

type NetworkJSON struct {
	Name    string `json:"name"`
	IpRange string `json:"ipRange"` // CIDR string format
	Driver  string `json:"driver"`
}

NetworkJSON is used for JSON serialization of Network

Jump to

Keyboard shortcuts

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