network

package
v0.0.0-...-144c93b Latest Latest
Warning

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

Go to latest
Published: May 13, 2022 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	Address      string
	LANInterface string
	WANInterface string
}

func NewClient

func NewClient(address, lanInterface, wanInterface string) (*Client, error)

func (*Client) ClearRoutes

func (c *Client) ClearRoutes() error

func (*Client) Close

func (c *Client) Close() error

func (*Client) SetRouteTable

func (c *Client) SetRouteTable(id int) error

type Container

type Container struct {
	Config       *openvpn.Config
	ID           string
	DockerID     string
	Name         string
	RouteTableID int
	IPAddress    string
}

func NewContainer

func NewContainer(id, image, subnet string, cfg *openvpn.Config) (*Container, error)

func NewContainerFromID

func NewContainerFromID(id string) (*Container, error)

func (*Container) Close

func (v *Container) Close() error

type ContainerInspectOutput

type ContainerInspectOutput struct {
	ID    string   `json:"Id"`
	Args  []string `json:"Args"`
	State struct {
		Status     string `json:"Status"`
		Running    bool   `json:"Running"`
		Paused     bool   `json:"Paused"`
		Restarting bool   `json:"Restarting"`
		OOMKilled  bool   `json:"OOMKilled"`
		Dead       bool   `json:"Dead"`
		Pid        int    `json:"Pid"`
		ExitCode   int    `json:"ExitCode"`
		Error      string `json:"Error"`
	} `json:"State"`
	Image  string `json:"Image"`
	Name   string `json:"Name"`
	Config struct {
		Labels map[string]string `json:"Labels"`
	} `json:"Config"`
	NetworkSettings struct {
		Networks map[string]struct {
			Gateway     string `json:"Gateway"`
			IPAddress   string `json:"IPAddress"`
			IPPrefixLen int    `json:"IPPrefixLen"`
			MacAddress  string `json:"MacAddress"`
		} `json:"Networks"`
	} `json:"NetworkSettings"`
}

type DNSRouter

type DNSRouter struct {
	Mark         string
	LocalSubnet  string
	Gateway      string
	RouteTableID int
}

func NewDNSRouter

func NewDNSRouter(ctx context.Context, mark, localSubnet string) (*DNSRouter, error)

TODO: how to prevent multiple creation? It only seems possible to use

iptables -C if the mark value is known, but what if someone else
instantiated us with a different mark?

func (*DNSRouter) Clear

func (r *DNSRouter) Clear() error

func (*DNSRouter) Close

func (r *DNSRouter) Close() error

func (*DNSRouter) Route

func (r *DNSRouter) Route(via string) error

type Network

type Network struct {
	ID        string
	DockerID  string
	Subnet    string
	Gateway   string
	Container *Container
}

func New

func New(id, image, subnet string, cfg *openvpn.Config) (*Network, error)

func NewFromID

func NewFromID(id string) (*Network, error)

func (*Network) Close

func (v *Network) Close() error

type NetworkInspectOutput

type NetworkInspectOutput struct {
	Name string `json:"Name"`
	ID   string `json:"Id"`
	IPAM struct {
		Config []struct {
			Subnet  string `json:"Subnet"`
			Gateway string `json:"Gateway"`
		} `json:"Config"`
	} `json:"IPAM"`
	Labels map[string]string `json:"Labels"`
}

Jump to

Keyboard shortcuts

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