server

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Sep 25, 2024 License: GPL-3.0 Imports: 26 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewServer

func NewServer() *netemServer

func ProjectClose added in v0.3.0

func ProjectClose(prjId string, progressCh chan TopologyRunCloseProgressT) error

func ProjectGetMany added in v0.3.0

func ProjectGetMany() map[string]*NetemProject

func ProjectGetNodeConfigs added in v0.3.0

func ProjectGetNodeConfigs(prjId string) (*bytes.Buffer, error)

func ProjectIsExist added in v0.3.0

func ProjectIsExist(prjName string) bool

func ProjectIsIdExist added in v0.3.0

func ProjectIsIdExist(prjID string) bool

func ProjectSave added in v0.3.0

func ProjectSave(prjId string, progressCh chan TopologySaveProgressT) (*bytes.Buffer, error)

Types

type BridgeConfig

type BridgeConfig struct {
	Host       string
	Interfaces []string `yaml:",omitempty"`
}

type CloseProgressCode added in v0.3.0

type CloseProgressCode int

type INetemNode

type INetemNode interface {
	GetName() string
	GetShortName() string
	GetType() string
	GetFullType() string
	IsRunning() bool
	Start() error
	Stop() error
	GetNetns() (netns.NsHandle, error)
	GetInterfaceName(ifIndex int) string
	AddInterface(ifName string, ifIndex int, ns netns.NsHandle) error
	LoadConfig(confPath string, timeout int) ([]string, error)
	ExecCommand(cmd []string, in io.ReadCloser, out io.Writer, tty bool, ttyHeight uint, ttyWidth uint, resizeCh chan term.Winsize) error
	GetConsoleCmd(shell bool) ([]string, error)
	Capture(ifIndex int, out io.Writer) error
	CopyFrom(srcPath, destPath string) error
	CopyTo(srcPath, destPath string) error
	ReadConfigFiles(confDir string, timeout int) (map[string][]byte, error)
	Save(dstPath string, timeout int) error
	GetInterfacesState() map[string]link.IfState
	SetInterfaceState(ifIndex int, state link.IfState) error
	Close() error
}

func CreateNode

func CreateNode(prjID string, name string, shortName string, config NodeConfig) (INetemNode, error)

type LinkConfig

type LinkConfig struct {
	Peer1  string
	Peer2  string
	Loss   float64 `yaml:",omitempty"` // percent
	Delay  int     `yaml:",omitempty"` // ms
	Jitter int     `yaml:",omitempty"` // ms
	Rate   int     `yaml:",omitempty"` // kbps
	Buffer float64 `yaml:",omitempty"` // BDP scale factor
}

type NetemBridge

type NetemBridge struct {
	Name          string
	HostInterface string
	Peers         []NetemLinkPeer
	Config        BridgeConfig
}
type NetemLink struct {
	Peer1    NetemLinkPeer
	Peer2    NetemLinkPeer
	Config   LinkConfig
	HasNetem bool
	HasTbf   bool
}

type NetemLinkPeer

type NetemLinkPeer struct {
	Node    INetemNode
	IfIndex int
}

type NetemNode added in v0.3.0

type NetemNode struct {
	Instance        INetemNode
	LaunchAtStartup bool
	Config          NodeConfig
}

type NetemProject

type NetemProject struct {
	Id       string
	Name     string
	Dir      string
	OpenAt   time.Time
	Topology *NetemTopologyManager
}

func ProjectGetOne added in v0.3.0

func ProjectGetOne(prjID string) *NetemProject

func ProjectOpen added in v0.3.0

func ProjectOpen(prjId, name string, data []byte) (*NetemProject, error)

type NetemTopology

type NetemTopology struct {
	Nodes   map[string]NodeConfig   `yaml:",omitempty"`
	Links   []LinkConfig            `yaml:",omitempty"`
	Bridges map[string]BridgeConfig `yaml:",omitempty"`
}

func CheckTopology

func CheckTopology(filepath string) (*NetemTopology, []error)

type NetemTopologyManager

type NetemTopologyManager struct {
	IdGenerator *NodeIdentifierGenerator
	// contains filtered or unexported fields
}

func LoadTopology

func LoadTopology(prjID, prjPath string) (*NetemTopologyManager, error)

func (*NetemTopologyManager) Check

func (t *NetemTopologyManager) Check() error

func (*NetemTopologyManager) Close

func (t *NetemTopologyManager) Close(progressCh chan TopologyRunCloseProgressT) error

func (*NetemTopologyManager) GetAllNodes

func (t *NetemTopologyManager) GetAllNodes() []INetemNode
func (t *NetemTopologyManager) GetLink(peer1V string, peer2V string) (*NetemLink, int, error)

func (*NetemTopologyManager) GetNetFilePath

func (t *NetemTopologyManager) GetNetFilePath() string

func (*NetemTopologyManager) GetNode

func (t *NetemTopologyManager) GetNode(name string) INetemNode

func (*NetemTopologyManager) IsNodeLaunchAtStartup added in v0.3.0

func (t *NetemTopologyManager) IsNodeLaunchAtStartup(name string) bool

func (*NetemTopologyManager) IsRunning

func (t *NetemTopologyManager) IsRunning() bool

func (*NetemTopologyManager) LinkAdd added in v0.4.0

func (t *NetemTopologyManager) LinkAdd(linkCfg LinkConfig, sync bool) error

func (*NetemTopologyManager) LinkDel added in v0.4.0

func (t *NetemTopologyManager) LinkDel(linkCfg LinkConfig, sync bool) error

func (*NetemTopologyManager) LinkUpdate added in v0.3.0

func (t *NetemTopologyManager) LinkUpdate(linkCfg LinkConfig, sync bool) error

func (*NetemTopologyManager) Load

func (t *NetemTopologyManager) Load() error

func (*NetemTopologyManager) ReadConfigFiles added in v0.2.0

func (t *NetemTopologyManager) ReadConfigFiles(nodeName string) (map[string][]byte, error)

func (*NetemTopologyManager) ReadNetworkFile

func (t *NetemTopologyManager) ReadNetworkFile() ([]byte, error)

func (*NetemTopologyManager) Reload

func (*NetemTopologyManager) Run

func (*NetemTopologyManager) Save

func (t *NetemTopologyManager) Save(progressCh chan TopologySaveProgressT) error

func (*NetemTopologyManager) Start

func (t *NetemTopologyManager) Start(nodeName string) ([]string, error)

func (*NetemTopologyManager) Stop

func (t *NetemTopologyManager) Stop(nodeName string) error

func (*NetemTopologyManager) SynchroniseTopology added in v0.4.0

func (t *NetemTopologyManager) SynchroniseTopology() error

func (*NetemTopologyManager) WriteNetworkFile

func (t *NetemTopologyManager) WriteNetworkFile(data []byte) error

type NodeConfig

type NodeConfig struct {
	Type    string
	IPv6    bool          `yaml:",omitempty" default:"false"`
	Mpls    bool          `yaml:",omitempty" default:"false"`
	Vrfs    []string      `yaml:",omitempty"`
	Vrrps   []VrrpOptions `yaml:",omitempty"`
	Volumes []string      `yaml:",omitempty"`
	Image   string        `yaml:",omitempty"`
	Launch  bool          `default:"true"`
}

func (*NodeConfig) UnmarshalYAML added in v0.3.0

func (n *NodeConfig) UnmarshalYAML(unmarshal func(interface{}) error) error

type NodeIdentifierGenerator added in v0.1.1

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

func (*NodeIdentifierGenerator) Close added in v0.1.1

func (nIdGen *NodeIdentifierGenerator) Close()

func (*NodeIdentifierGenerator) GetId added in v0.1.1

func (nIdGen *NodeIdentifierGenerator) GetId(name string) (string, error)

type NodeNotFoundError

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

func (*NodeNotFoundError) Error

func (e *NodeNotFoundError) Error() string

type ProjectNotFoundError

type ProjectNotFoundError struct {
	Id string
}

func (*ProjectNotFoundError) Error

func (e *ProjectNotFoundError) Error() string

type RunCloseProgressCode added in v0.3.0

type RunCloseProgressCode int
const (
	NODE_COUNT      RunCloseProgressCode = 1
	BRIDGE_COUNT    RunCloseProgressCode = 2
	LINK_COUNT      RunCloseProgressCode = 3
	LOAD_TOPO       RunCloseProgressCode = 4
	START_NODE      RunCloseProgressCode = 5
	SETUP_LINK      RunCloseProgressCode = 6
	START_BRIDGE    RunCloseProgressCode = 7
	LOADCONFIG_NODE RunCloseProgressCode = 8
	CLOSE_NODE      RunCloseProgressCode = 9
	CLOSE_BRIDGE    RunCloseProgressCode = 10
)

type SaveProgressCode added in v0.3.0

type SaveProgressCode int
const (
	NODE_SAVE_COUNT SaveProgressCode = 1
	NODE_SAVE       SaveProgressCode = 2
)

type TopologyRunCloseProgressT added in v0.3.0

type TopologyRunCloseProgressT struct {
	Code  RunCloseProgressCode
	Value int
}

type TopologySaveProgressT added in v0.3.0

type TopologySaveProgressT struct {
	Code  SaveProgressCode
	Value int
}

type VrrpOptions added in v0.1.1

type VrrpOptions struct {
	Interface int
	Group     int
	Address   string
}

Jump to

Keyboard shortcuts

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