Documentation ¶
Index ¶
- Constants
- Variables
- func CheckCaps() error
- func Exec(network, node string, args []string) error
- func GenerateNetworkName() string
- func GetRandomName() string
- func Identify() (string, string, error)
- func NetworkNames() []string
- func NodeNames(network string) []string
- func TeardownAllNetworks() error
- func TeardownNetwork(name string) error
- func TestConnectivity(hosts ...*Host) error
- type BaseNode
- func (n *BaseNode) AddDefaultRoute(gw net.IP) error
- func (n *BaseNode) AddInterface(i *Interface)
- func (n *BaseNode) AddRoute(r *nl.Route) error
- func (n *BaseNode) Close() error
- func (n *BaseNode) Command(name string, args ...string) *exec.Cmd
- func (n *BaseNode) ConfigureInterface(i *Interface) error
- func (n *BaseNode) EnableForwarding() error
- func (n *BaseNode) Interface(name string) *Interface
- func (n *BaseNode) LinkAddAddress(name string, addr net.IPNet) error
- func (n *BaseNode) Name() string
- func (n *BaseNode) NetNSHandle() netns.NsHandle
- func (n *BaseNode) NetlinkHandle() *nl.Handle
- func (n *BaseNode) Network() *Network
- func (n *BaseNode) NftConn() *nft.Conn
- func (n *BaseNode) Run(cmd string, args ...any) ([]byte, *exec.Cmd, error)
- func (n *BaseNode) RunGo(script string, args ...any) ([]byte, *exec.Cmd, error)
- func (n *BaseNode) Start(cmd string, args ...any) (io.Reader, io.Reader, *exec.Cmd, error)
- func (n *BaseNode) StartGo(script string, args ...any) (io.Reader, io.Reader, *exec.Cmd, error)
- func (n *BaseNode) String() string
- func (n *BaseNode) Teardown() error
- func (n *BaseNode) WriteProcFS(path, value string) error
- type BridgeOption
- type Callback
- type Capture
- type CaptureFilterInterfaceFunc
- type CaptureOption
- type DeviceGroup
- type Filter
- type FilterHook
- type FilterRule
- type Host
- func (h *Host) Apply(i *Interface)
- func (h *Host) ConfigureInterface(i *Interface) error
- func (h *Host) ConfigureLinks() error
- func (h *Host) LookupAddress(n string) *net.IPAddr
- func (h *Host) Ping(o *Host) (*ping.Statistics, error)
- func (h *Host) PingWithNetwork(o *Host, net string) (*ping.Statistics, error)
- func (h *Host) PingWithOptions(o *Host, net string, count int, timeout time.Duration, intv time.Duration, ...) (*ping.Statistics, error)
- func (h *Host) Traceroute(o *Host, opts ...any) error
- type HostOption
- type Interface
- type InterfaceOption
- type LinkOption
- type NAT
- type NATOption
- type Namespace
- type Network
- func (n *Network) AddHost(name string, opts ...Option) (*Host, error)
- func (n *Network) AddHostNAT(name string, opts ...Option) (*NAT, error)
- func (n *Network) AddLink(l, r *Interface, opts ...Option) error
- func (n *Network) AddNAT(name string, opts ...Option) (*NAT, error)
- func (n *Network) AddNode(name string, opts ...Option) (*BaseNode, error)
- func (n *Network) AddRouter(name string, opts ...Option) (*Router, error)
- func (n *Network) AddSwitch(name string, opts ...Option) (*Switch, error)
- func (n *Network) Close() error
- func (n *Network) GenerateConfigFiles() error
- func (n *Network) GenerateHostsFile() error
- func (n *Network) GenerateIProute2Files() error
- func (n *Network) Hosts() []*Host
- func (n *Network) Register(m Node)
- func (n *Network) Routers() []*Router
- func (n *Network) String() string
- func (n *Network) Switches() []*Switch
- func (n *Network) Teardown() error
- type NetworkOption
- type Node
- type NodeOption
- type Option
- type Options
- type Route
- type Router
- type Switch
- type SwitchOption
- type VethOption
Constants ¶
const ( WithQdiscNetem = (1 << iota) WithQdiscTbf = (1 << iota) )
Variables ¶
var ( DefaultIPv4Mask = net.IPNet{ IP: net.IPv4zero, Mask: net.CIDRMask(0, net.IPv4len*8), } DefaultIPv6Mask = net.IPNet{ IP: net.IPv6zero, Mask: net.CIDRMask(0, net.IPv6len*8), } )
var (
IPv4loopback = net.IPv4(127, 0, 0, 1)
)
var (
Names = []string{}/* 120 elements not displayed */
)
Functions ¶
func CheckCaps ¶
func CheckCaps() error
CheckCaps checks if the current process has the required privileges to run Gont
func GenerateNetworkName ¶
func GenerateNetworkName() string
func GetRandomName ¶
func GetRandomName() string
func Identify ¶
Identify returns the network and node name if the current process is running in a network netspace created by Gont
func NetworkNames ¶ added in v0.2.0
func NetworkNames() []string
func TeardownAllNetworks ¶ added in v0.1.0
func TeardownAllNetworks() error
func TeardownNetwork ¶ added in v0.1.0
func TestConnectivity ¶
TestConnectivity performs ICMP ping tests between all pairs of nodes in the network
Types ¶
type BaseNode ¶
type BaseNode struct { *Namespace BasePath string Interfaces []*Interface // Options ConfiguredInterfaces []*Interface ExistingNamespace string ExistingDockerContainer string LogToDebug bool // contains filtered or unexported fields }
func (*BaseNode) AddDefaultRoute ¶ added in v0.2.0
AddDefaultRoute adds a default route for this node by providing a default gateway.
func (*BaseNode) AddInterface ¶ added in v0.2.0
AddInterface adds an interface to the list of configured interfaces
func (*BaseNode) ConfigureInterface ¶ added in v0.2.0
func (*BaseNode) EnableForwarding ¶
EnableForwarding enables forwarding for both IPv4 and IPv6 protocols in the kernel for all interfaces
func (*BaseNode) LinkAddAddress ¶ added in v0.1.0
LinkAddAddress adds a network layer address to a link identified by its name.
func (*BaseNode) NetNSHandle ¶ added in v0.2.0
func (*BaseNode) NetlinkHandle ¶ added in v0.2.0
func (*BaseNode) WriteProcFS ¶
WriteProcFS write a value to a path within the ProcFS by entering the namespace of this node.
type BridgeOption ¶ added in v0.1.0
type Capture ¶ added in v1.2.0
type Capture struct { CaptureLength int Promisc bool Filter CaptureFilterInterfaceFunc BPFilter string Comment string File *os.File Filename string // contains filtered or unexported fields }
func NewCapture ¶ added in v1.2.0
func NewCapture() *Capture
type CaptureFilterInterfaceFunc ¶ added in v1.2.0
type CaptureOption ¶ added in v1.2.0
type CaptureOption interface {
Apply(c *Capture)
}
type DeviceGroup ¶
type DeviceGroup int
const ( DeviceGroupDefault DeviceGroup = 0 DeviceGroupSouthBound DeviceGroup = 1000 + iota DeviceGroupNorthBound )
type Filter ¶ added in v0.3.0
type FilterHook ¶ added in v0.3.0
type FilterHook int
const ( FilterInput FilterHook = iota FilterOutput FilterForward )
type FilterRule ¶ added in v0.3.0
type FilterRule struct { Exprs []expr.Any Hook FilterHook }
func (FilterRule) Apply ¶ added in v0.3.0
func (fr FilterRule) Apply(h *Host)
type Host ¶
type Host struct { *BaseNode Filter *Filter // Options FilterRules []*FilterRule Routes []*nl.Route Forwarding bool }
func (*Host) ConfigureInterface ¶
func (*Host) ConfigureLinks ¶ added in v0.2.0
ConfigureLinks adds links to other nodes which have been configured by functional options
func (*Host) PingWithNetwork ¶ added in v0.1.0
func (*Host) PingWithOptions ¶ added in v0.1.0
type HostOption ¶
type Interface ¶
type Interface struct { Name string Node Node Link nl.Link Flags int // Options Netem nl.NetemQdiscAttrs Tbf nl.Tbf EnableDAD bool LinkAttrs nl.LinkAttrs Addresses []net.IPNet Captures []*Capture }
func (Interface) IsLoopback ¶ added in v0.2.0
type InterfaceOption ¶
type LinkOption ¶
type NAT ¶
type NAT struct { *Router // contains filtered or unexported fields }
func (*NAT) ConfigureInterface ¶ added in v0.2.0
type Namespace ¶
func NewNamespace ¶
type Network ¶
type Network struct { Name string Nodes map[string]Node NodesLock sync.RWMutex HostNode *Host BasePath string // Options Persistent bool NSPrefix string Captures []*Capture // contains filtered or unexported fields }
func (*Network) AddHostNAT ¶
func (*Network) GenerateConfigFiles ¶ added in v0.2.0
func (*Network) GenerateHostsFile ¶ added in v0.2.0
GenerateHostsFile writes the addresses and hostnames of all nodes into a file located at /run/gont/<network>/files/etc/hosts
Processes started via BaseNode.Run or BaseNode.Start, will see this file bind mounted at /etc/hosts
func (*Network) GenerateIProute2Files ¶ added in v0.2.0
type NetworkOption ¶
type NodeOption ¶
type Switch ¶
type Switch struct {
*BaseNode
}
Switch is an abstraction for a Linux virtual bridge
func (*Switch) ConfigureInterface ¶ added in v0.2.0
ConfigureInterface attaches an existing interface to a bridge interface