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(network string) error
- func TeardownNode(network, node 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) CommandWith(name string, env []string, dir 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) RunWith(cmd string, env []string, dir 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) StartWith(cmd string, env []string, dir 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 BaseNodeOption
- type BridgeOption
- type Callback
- type Capture
- type CaptureCallbackFunc
- type CaptureFilterInterfaceFunc
- type CaptureFilterPacketFunc
- type CaptureInterface
- type CaptureOption
- type CapturePacket
- type CaptureStats
- 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) Nodes() []Node
- 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 Option
- type Route
- type Router
- type RouterOption
- type Switch
- type SwitchOption
- type VethOption
Constants ¶
const ( WithQdiscNetem = (1 << iota) WithQdiscTbf = (1 << iota) )
const CGoPCAP = true
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 TeardownNode ¶ added in v1.4.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 EmptyDirs []string // 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) CommandWith ¶ added in v1.5.0
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 BaseNodeOption ¶ added in v1.5.0
type BaseNodeOption interface {
Apply(b *BaseNode)
}
type BridgeOption ¶ added in v0.1.0
type Capture ¶ added in v1.2.0
type Capture struct { // Options CaptureLength int Promiscuous bool Comment string Timeout time.Duration // Filter options FilterInterface CaptureFilterInterfaceFunc FilterPackets CaptureFilterPacketFunc FilterExpression string FilterInstructions []bpf.Instruction // Output options File *os.File Filename string Channel chan CapturePacket Callback CaptureCallbackFunc // contains filtered or unexported fields }
func NewCapture ¶ added in v1.2.0
func NewCapture() *Capture
type CaptureCallbackFunc ¶ added in v1.4.0
type CaptureCallbackFunc func(pkt CapturePacket)
type CaptureFilterInterfaceFunc ¶ added in v1.2.0
type CaptureFilterPacketFunc ¶ added in v1.4.0
type CaptureFilterPacketFunc func(p *CapturePacket) bool
type CaptureInterface ¶ added in v1.4.0
type CaptureOption ¶ added in v1.2.0
type CaptureOption interface {
Apply(n *Capture)
}
type CapturePacket ¶ added in v1.4.0
type CapturePacket struct { gopacket.Packet Interface *CaptureInterface }
func (CapturePacket) Time ¶ added in v1.4.0
func (p CapturePacket) Time() time.Time
type CaptureStats ¶ added in v1.4.0
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 }
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 HostOption interface {
Apply(h *Host)
}
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 InterfaceOption interface {
Apply(n *Interface)
}
type LinkOption ¶
type NAT ¶
type Namespace ¶
func NewNamespace ¶
type Network ¶
type Network struct { Name string 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 host names 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 NetworkOption interface {
Apply(n *Network)
}
type RouterOption ¶ added in v1.5.0
type RouterOption interface {
Apply(r *Router)
}
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
type SwitchOption ¶
type SwitchOption interface {
Apply(sw *Switch)
}
type VethOption ¶
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
Package options contains all the general options for configuring the general objects like hosts, switches, routers and interfaces
|
Package options contains all the general options for configuring the general objects like hosts, switches, routers and interfaces |
capture
Package capture contains the options to configure to packet capturing
|
Package capture contains the options to configure to packet capturing |
filters
Package filters contains the options for configuring NFTables filtering
|
Package filters contains the options for configuring NFTables filtering |
tc
Package tc contains the options for configuring per-interface Traffic Control (TC) queuing disciplines
|
Package tc contains the options for configuring per-interface Traffic Control (TC) queuing disciplines |