config

package
v0.0.0-...-b700294 Latest Latest
Warning

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

Go to latest
Published: Dec 23, 2024 License: GPL-3.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	QdSwr = 32 * 4
	QdSrd = 32 * 4
	QdTwr = 32 * 2
	QdTrd = 2
	QdVsd = 32 * 8
	QdVWr = 32 * 4
)

Functions

func CorrectAddr

func CorrectAddr(listen *string, port int)

func CorrectRoutes

func CorrectRoutes(routes []PrefixRoute, nexthop string)

func GenName

func GenName(prefix string) string

func GetAlias

func GetAlias() string

func LogFile

func LogFile(file string) string

func Reload

func Reload()

func Update

func Update(obj *Switch)

func VarDir

func VarDir(name ...string) string

Types

type ACL

type ACL struct {
	File  string     `json:"-"`
	Name  string     `json:"name"`
	Rules []*ACLRule `json:"rules,omitempty"`
}

func GetAcl

func GetAcl(name string) *ACL

func (*ACL) Correct

func (ru *ACL) Correct(sw *Switch)

func (*ACL) Save

func (ru *ACL) Save()

type ACLRule

type ACLRule struct {
	Name    string `json:"name,omitempty"`
	SrcIp   string `json:"source,omitempty"`
	DstIp   string `json:"destination,omitempty"`
	Proto   string `json:"protocol,omitempty"`
	SrcPort int    `json:"sport,omitempty"`
	DstPort int    `json:"dport,omitempty"`
	Action  string `json:"action,omitempty"`
}

func (*ACLRule) Correct

func (ru *ACLRule) Correct()

type Bridge

type Bridge struct {
	Network  string `json:"-" yaml:"-"`
	Peer     string `json:"peer,omitempty"`
	Name     string `json:"name,omitempty"`
	IPMtu    int    `json:"mtu,omitempty"`
	Address  string `json:"address,omitempty"`
	Provider string `json:"-" yaml:"-"`
	Stp      string `json:"stp,omitempty"`
	Delay    int    `json:"delay,omitempty"`
	Mss      int    `json:"tcpMss,omitempty"`
}

func (*Bridge) Correct

func (br *Bridge) Correct()

type Cert

type Cert struct {
	Dir      string `json:"directory"`
	CrtFile  string `json:"cert"`
	KeyFile  string `json:"key"`
	CaFile   string `json:"rootCa"`
	Insecure bool   `json:"insecure"`
}

func (*Cert) Correct

func (c *Cert) Correct()

func (*Cert) GetCertPool

func (c *Cert) GetCertPool() *x509.CertPool

func (*Cert) GetTlsCfg

func (c *Cert) GetTlsCfg() *tls.Config

type Crypt

type Crypt struct {
	Algo   string `json:"algorithm,omitempty"`
	Secret string `json:"secret,omitempty"`
}

func (*Crypt) Correct

func (c *Crypt) Correct()

func (*Crypt) IsZero

func (c *Crypt) IsZero() bool

type Dhcp

type Dhcp struct {
	Name      string        `json:"name,omitempty"`
	Interface string        `json:"interface,omitempty"`
	Subnet    *Subnet       `json:"subnet,omitempty"`
	Hosts     []HostLease   `json:"hosts,omitempty"`
	Routes    []PrefixRoute `json:"routes,omitempty"`
}

type FindHop

type FindHop struct {
	Name      string      `json:"-"`
	Check     string      `json:"check"`
	Params    PingParams  `json:"params"`
	Mode      string      `json:"mode,omitempty"`
	NextHop   []string    `json:"nexthop"`
	Available []MultiPath `json:"available,omitempty"`
	Vrf       string      `json:"-" yaml:"-"`
}

func (*FindHop) Correct

func (ng *FindHop) Correct()

type FlowRule

type FlowRule struct {
	Table    string `json:"table,omitempty"`
	Chain    string `json:"chain,omitempty"`
	Input    string `json:"input,omitempty"`
	Source   string `json:"source,omitempty"`
	ToSource string `json:"toSource,omitempty"`
	Dest     string `json:"destination,omitempty"`
	ToDest   string `json:"toDestination"`
	Output   string `json:"output,omitempty"`
	Comment  string `json:"comment,omitempty"`
	Proto    string `json:"protocol,omitempty"`
	Match    string `json:"match,omitempty"`
	DstPort  string `json:"destPort,omitempty"`
	SrcPort  string `json:"sourcePort,omitempty"`
	CtState  string `json:"ctState,omitempty"`
	Jump     string `json:"jump,omitempty"` // SNAT/RETURN/MASQUERADE
}

type HostLease

type HostLease struct {
	Network  string `json:"network,omitempty"`
	Hostname string `json:"hostname"`
	Address  string `json:"address"`
}

type Http

type Http struct {
	Listen string `json:"listen,omitempty"`
	Public string `json:"public,omitempty"`
}

func (*Http) Correct

func (h *Http) Correct()

func (*Http) GetUrl

func (h *Http) GetUrl() string

type HttpForward

type HttpForward struct {
	Protocol string   `json:"protocol,omitempty" yaml:"protocol,omitempty"`
	Server   string   `json:"server,omitempty"`
	Insecure bool     `json:"insecure,omitempty"`
	Match    []string `json:"match,omitempty"`
	Secret   string   `json:"secret,omitempty"`
}

type HttpProxy

type HttpProxy struct {
	ConfDir  string         `json:"-" yaml:"-"`
	Listen   string         `json:"listen,omitempty"`
	Auth     *Password      `json:"auth,omitempty" yaml:"auth,omitempty"`
	Cert     *Cert          `json:"cert,omitempty" yaml:"cert,omitempty"`
	Password string         `json:"password,omitempty" yaml:"password,omitempty"`
	Forward  *HttpForward   `json:"forward,omitempty" yaml:"forward,omitempty"`
	Backends []*HttpForward `json:"backends,omitempty" yaml:"backend,omitempty"`
}

func (*HttpProxy) AddMatch

func (h *HttpProxy) AddMatch(domain, remote string) int

func (*HttpProxy) Correct

func (h *HttpProxy) Correct()

func (*HttpProxy) DelMatch

func (h *HttpProxy) DelMatch(domain, remote string) int

func (*HttpProxy) FindBackend

func (h *HttpProxy) FindBackend(remote string) *HttpForward

func (*HttpProxy) FindMatch

func (h *HttpProxy) FindMatch(domain string, to *HttpForward) int

type IPSecSpecifies

type IPSecSpecifies struct {
	Name    string         `json:"name"`
	Tunnels []*IPSecTunnel `json:"tunnels"`
}

func (*IPSecSpecifies) AddTunnel

func (s *IPSecSpecifies) AddTunnel(value *IPSecTunnel) bool

func (*IPSecSpecifies) Correct

func (s *IPSecSpecifies) Correct()

func (*IPSecSpecifies) DelTunnel

func (s *IPSecSpecifies) DelTunnel(value *IPSecTunnel) (*IPSecTunnel, bool)

func (*IPSecSpecifies) FindTunnel

func (s *IPSecSpecifies) FindTunnel(value *IPSecTunnel) (*IPSecTunnel, int)

type IPSecTunnel

type IPSecTunnel struct {
	Name      string `json:"-"`
	Left      string `json:"local"`
	LeftId    string `json:"localid,omitempty"`
	LeftPort  int    `json:"localport,omitempty"`
	Right     string `json:"remote"`
	RightId   string `json:"remoteid,omitempty"`
	RightPort int    `json:"remoteport,omitempty"`
	Transport string `json:"protocol"`
	Secret    string `json:"secret"`
	State     string `json:"state"`
}

func (*IPSecTunnel) Correct

func (s *IPSecTunnel) Correct()

func (*IPSecTunnel) Id

func (s *IPSecTunnel) Id() string

type Interface

type Interface struct {
	Name     string `json:"name,omitempty"`
	IPMtu    int    `json:"mtu,omitempty"`
	Address  string `json:"address,omitempty"`
	Bridge   string `json:"bridge,omitempty"`
	Provider string `json:"provider,omitempty"`
	Cost     int    `json:"cost,omitempty"`
}

func (*Interface) Correct

func (i *Interface) Correct()

type LDAP

type LDAP struct {
	Server    string `json:"server"`
	BindDN    string `json:"bindDN"`
	BindPass  string `json:"bindPass"`
	BaseDN    string `json:"baseDN"`
	Attribute string `json:"attribute"`
	Filter    string `json:"filter"`
	Tls       bool   `json:"tLS"`
}

type Linker

type Linker interface {
	Start() error
	Stop() error
}

type Log

type Log struct {
	File    string `json:"file,omitempty"`
	Verbose int    `json:"level,omitempty"`
}

func (*Log) Correct

func (l *Log) Correct()

type MultiPath

type MultiPath struct {
	NextHop string `json:"nexthop"`
	Weight  int    `json:"weight"`
}

func (*MultiPath) CompareEqual

func (mp *MultiPath) CompareEqual(b MultiPath) bool

type Network

type Network struct {
	ConfDir   string              `json:"-"`
	File      string              `json:"-"`
	Alias     string              `json:"-"`
	Name      string              `json:"name"`
	Provider  string              `json:"provider,omitempty"`
	Bridge    *Bridge             `json:"bridge,omitempty"`
	Subnet    *Subnet             `json:"subnet,omitempty"`
	OpenVPN   *OpenVPN            `json:"openvpn,omitempty"`
	Links     []Point             `json:"links,omitempty"`
	Hosts     []HostLease         `json:"hosts,omitempty"`
	Routes    []PrefixRoute       `json:"routes,omitempty"`
	Acl       string              `json:"acl,omitempty"`
	Specifies interface{}         `json:"specifies,omitempty"`
	Dhcp      string              `json:"dhcp,omitempty"`
	Outputs   []*Output           `json:"outputs,omitempty"`
	ZTrust    string              `json:"ztrust,omitempty"`
	Qos       string              `json:"qos,omitempty"`
	Snat      string              `json:"snat,omitempty"`
	Namespace string              `json:"namespace,omitempty"`
	FindHop   map[string]*FindHop `json:"findhop,omitempty"`
}

func GetNetwork

func GetNetwork(name string) *Network

func (*Network) AddFindHop

func (n *Network) AddFindHop(value *FindHop) bool

func (*Network) AddOutput

func (n *Network) AddOutput(value *Output) bool

func (*Network) AddRoute

func (n *Network) AddRoute(value PrefixRoute) bool

func (*Network) Correct

func (n *Network) Correct(sw *Switch)

func (*Network) DelFindHop

func (n *Network) DelFindHop(value *FindHop) (*FindHop, bool)

func (*Network) DelOutput

func (n *Network) DelOutput(value *Output) (*Output, bool)

func (*Network) DelRoute

func (n *Network) DelRoute(value PrefixRoute) (PrefixRoute, bool)

func (*Network) Dir

func (n *Network) Dir(elem ...string) string

func (*Network) FindFindHop

func (n *Network) FindFindHop(value *FindHop) *FindHop

func (*Network) FindOutput

func (n *Network) FindOutput(value *Output) (*Output, int)

func (*Network) FindRoute

func (n *Network) FindRoute(value PrefixRoute) (PrefixRoute, int)

func (*Network) ListRoute

func (n *Network) ListRoute(call func(value PrefixRoute))

func (*Network) LoadFindHop

func (n *Network) LoadFindHop()
func (n *Network) LoadLink()

func (*Network) LoadOutput

func (n *Network) LoadOutput()

func (*Network) LoadRoute

func (n *Network) LoadRoute()

func (*Network) NewSpecifies

func (n *Network) NewSpecifies() interface{}

func (*Network) Reload

func (n *Network) Reload()

func (*Network) Save

func (n *Network) Save()

func (*Network) SaveFindHop

func (n *Network) SaveFindHop()
func (n *Network) SaveLink()

func (*Network) SaveOutput

func (n *Network) SaveOutput()

func (*Network) SaveRoute

func (n *Network) SaveRoute()

type OpenVPN

type OpenVPN struct {
	Network   string           `json:"network"`
	Url       string           `json:"url,omitempty"`
	Directory string           `json:"directory,omitempty"`
	Listen    string           `json:"listen"`
	Protocol  string           `json:"protocol,omitempty"`
	Subnet    string           `json:"subnet"`
	Device    string           `json:"device"`
	Version   int              `json:"version,omitempty"`
	Auth      string           `json:"auth,omitempty"` // xauth or cert.
	DhPem     string           `json:"dhPem,omitempty"`
	RootCa    string           `json:"rootCa,omitempty"`
	ServerCrt string           `json:"cert,omitempty"`
	ServerKey string           `json:"key,omitempty"`
	TlsAuth   string           `json:"tlsAuth,omitempty"`
	Cipher    string           `json:"cipher,omitempty"`
	Routes    []string         `json:"-"`
	Renego    int              `json:"renego,omitempty"`
	Script    string           `json:"-"`
	Push      []string         `json:"push,omitempty"`
	Clients   []*OpenVPNClient `json:"clients,omitempty"`
}

func DefaultOpenVPN

func DefaultOpenVPN() *OpenVPN

func (*OpenVPN) AddRedirectDef1

func (o *OpenVPN) AddRedirectDef1() bool

func (*OpenVPN) AuthBin

func (o *OpenVPN) AuthBin(obj *OpenVPN) string

func (*OpenVPN) Correct

func (o *OpenVPN) Correct(sw *Switch)

func (*OpenVPN) DelRedirectDef1

func (o *OpenVPN) DelRedirectDef1() bool

func (*OpenVPN) Merge

func (o *OpenVPN) Merge(obj *OpenVPN)

type OpenVPNClient

type OpenVPNClient struct {
	Name    string `json:"name"`
	Address string `json:"address"`
	Netmask string `json:"netmask"`
}

type Output

type Output struct {
	Segment  int    `json:"segment"`
	Protocol string `json:"protocol,omitempty"` // gre, vxlan, tcp/tls/wss etc.
	Remote   string `json:"remote"`
	DstPort  int    `json:"dstport,omitempty"`
	Link     string `json:"link,omitempty"` // link name
	Secret   string `json:"secret,omitempty"`
	Crypt    string `json:"crypt,omitempty"`
	Linker   Linker `json:"-"`
}

func (*Output) GenName

func (o *Output) GenName()

func (*Output) Id

func (o *Output) Id() string

type Password

type Password struct {
	Network  string `json:"network,omitempty"`
	Username string `json:"username"`
	Password string `json:"password"`
}

type Perf

type Perf struct {
	Point    int `json:"point"`
	Neighbor int `json:"neighbor"`
	OnLine   int `json:"online"`
	Link     int `json:"link"`
	User     int `json:"user"`
	Esp      int `json:"esp"`
	State    int `json:"state"`
	Policy   int `json:"policy"`
	VxLAN    int `json:"vxlan"`
}

func (*Perf) Correct

func (p *Perf) Correct()

type PingParams

type PingParams struct {
	Count    int `json:"count"`
	Loss     int `json:"loss,omitempty"`
	Rtt      int `json:"rtt,omitempty"`
	Interval int `json:"interval,omitempty"`
}

func (*PingParams) Correct

func (pp *PingParams) Correct()

type Point

type Point struct {
	File        string    `json:"file,omitempty"`
	Alias       string    `json:"alias,omitempty"`
	Connection  string    `json:"connection"`
	Timeout     int       `json:"timeout,omitempty"`
	Username    string    `json:"username,omitempty"`
	Network     string    `json:"network,omitempty"`
	Password    string    `json:"password,omitempty"`
	Protocol    string    `json:"protocol,omitempty"`
	Interface   Interface `json:"interface,omitempty"`
	Log         Log       `json:"log,omitempty"`
	Http        *Http     `json:"http,omitempty"`
	Crypt       *Crypt    `json:"crypt,omitempty"`
	PProf       string    `json:"pprof,omitempty"`
	RequestAddr bool      `json:"requestAddr"`
	ByPass      bool      `json:"bypass,omitempty"`
	SaveFile    string    `json:"-"`
	Queue       *Queue    `json:"queue,omitempty"`
	Terminal    string    `json:"-"`
	Cert        *Cert     `json:"cert,omitempty"`
	StatusFile  string    `json:"status,omitempty"`
	PidFile     string    `json:"pid,omitempty"`
}

func NewPoint

func NewPoint() *Point

func (*Point) Correct

func (ap *Point) Correct()

func (*Point) Id

func (ap *Point) Id() string

func (*Point) Initialize

func (ap *Point) Initialize()

func (*Point) Load

func (ap *Point) Load() error

func (*Point) Parse

func (ap *Point) Parse()

type PrefixRoute

type PrefixRoute struct {
	File      string      `json:"-"`
	Network   string      `json:"network,omitempty"`
	Prefix    string      `json:"prefix"`
	NextHop   string      `json:"nexthop"`
	MultiPath []MultiPath `json:"multipath,omitempty"`
	Metric    int         `json:"metric"`
	FindHop   string      `json:"findhop,omitempty"`
}

func (*PrefixRoute) CorrectRoute

func (r *PrefixRoute) CorrectRoute(nexthop string)

func (*PrefixRoute) String

func (r *PrefixRoute) String() string

type Proxy

type Proxy struct {
	Conf    string         `json:"-" yaml:"-"`
	ConfDir string         `json:"-" yaml:"-"`
	Log     Log            `json:"log"`
	Socks   []*SocksProxy  `json:"socks,omitempty" yaml:"socks,omitempty"`
	Http    []*HttpProxy   `json:"http,omitempty" yaml:"http,omitempty"`
	Tcp     []*TcpProxy    `json:"tcp,omitempty" yaml:"tcp,omitempty"`
	Shadow  []*ShadowProxy `json:"shadow,omitempty" yaml:"shadow,omitempty"`
	PProf   string         `json:"pprof,omitempty" yaml:"pprof,omitempty"`
}

func NewProxy

func NewProxy() *Proxy

func (*Proxy) Correct

func (p *Proxy) Correct()

func (*Proxy) Initialize

func (p *Proxy) Initialize()

func (*Proxy) Load

func (p *Proxy) Load() error

func (*Proxy) Parse

func (p *Proxy) Parse()

func (*Proxy) Save

func (h *Proxy) Save()

type Qos

type Qos struct {
	File   string               `json:"-"`
	Name   string               `json:"name"`
	Config map[string]*QosLimit `json:"qos,omitempty"`
}

func GetQos

func GetQos(name string) *Qos

func (*Qos) Correct

func (q *Qos) Correct(sw *Switch)

func (*Qos) Save

func (q *Qos) Save()

type QosLimit

type QosLimit struct {
	InSpeed float64 `json:"inSpeed,omitempty"`
}

func (*QosLimit) Correct

func (ql *QosLimit) Correct()

type Queue

type Queue struct {
	SockWr int `json:"sockWr"` // per frames about 1572(1514+4+20+20+14)bytes
	SockRd int `json:"sockRd"` // per frames
	TapWr  int `json:"tapWr"`  // per frames about 1572((1514+4+20+20+14))bytes
	TapRd  int `json:"tapRd"`  // per frames
	VirSnd int `json:"virSnd"`
	VirWrt int `json:"virWrt"`
}

func (*Queue) Correct

func (q *Queue) Correct()

type RouterSpecifies

type RouterSpecifies struct {
	Mss      int      `json:"tcpMss,omitempty"`
	Name     string   `json:"name,omitempty"`
	Link     string   `json:"link,omitempty"`
	Subnets  []Subnet `json:"subnets,omitempty"`
	Loopback string   `json:"loopback,omitempty"`
}

func (*RouterSpecifies) Correct

func (n *RouterSpecifies) Correct()

type ShadowProxy

type ShadowProxy struct {
	Server     string `json:"server,omitempty"`
	Key        string `json:"key,omitempty"`
	Cipher     string `json:"cipher,omitempty"`
	Password   string `json:"password,omitempty"`
	Plugin     string `json:"plugin,omitempty"`
	PluginOpts string `json:"pluginOpts,omitempty"`
	Protocol   string `json:"protocol,omitempty"`
}

type SocksProxy

type SocksProxy struct {
	Listen string    `json:"listen,omitempty"`
	Auth   *Password `json:"auth,omitempty"`
}

type Subnet

type Subnet struct {
	Network string `json:"network,omitempty"`
	Start   string `json:"startAt,omitempty"`
	End     string `json:"endAt,omitempty"`
	Netmask string `json:"netmask,omitempty"`
	CIDR    string `json:"cidr,omitempty"`
}

type Switch

type Switch struct {
	File      string              `json:"-"`
	Alias     string              `json:"alias"`
	Perf      Perf                `json:"limit,omitempty"`
	Protocol  string              `json:"protocol"` // tcp, tls, udp, kcp, ws and wss.
	Listen    string              `json:"listen"`
	Timeout   int                 `json:"timeout"`
	Http      *Http               `json:"http,omitempty"`
	Log       Log                 `json:"log"`
	Cert      *Cert               `json:"cert,omitempty"`
	Crypt     *Crypt              `json:"crypt,omitempty"`
	Network   map[string]*Network `json:"network,omitempty"`
	Acl       map[string]*ACL     `json:"acl,omitempty"`
	Qos       map[string]*Qos     `json:"qos,omitempty"`
	FireWall  []FlowRule          `json:"firewall,omitempty"`
	Queue     Queue               `json:"queue"`
	PassFile  string              `json:"password"`
	Ldap      *LDAP               `json:"ldap,omitempty"`
	AddrPool  string              `json:"pool,omitempty"`
	ConfDir   string              `json:"-"`
	TokenFile string              `json:"-"`
}

func Get

func Get() *Switch

func NewSwitch

func NewSwitch() *Switch

func (*Switch) AddNetwork

func (s *Switch) AddNetwork(data []byte) (*Network, error)

func (*Switch) Correct

func (s *Switch) Correct()

func (*Switch) CorrectNetwork

func (s *Switch) CorrectNetwork(obj *Network)

func (*Switch) CorrectNetworks

func (s *Switch) CorrectNetworks()

func (*Switch) Dir

func (s *Switch) Dir(elem ...string) string

func (*Switch) FormatNetworks

func (s *Switch) FormatNetworks()

func (*Switch) GetACL

func (s *Switch) GetACL(name string) *ACL

func (*Switch) GetNetwork

func (s *Switch) GetNetwork(name string) *Network

func (*Switch) GetQos

func (s *Switch) GetQos(name string) *Qos

func (*Switch) Initialize

func (s *Switch) Initialize()

func (*Switch) Load

func (s *Switch) Load() error

func (*Switch) LoadAcl

func (s *Switch) LoadAcl()

func (*Switch) LoadExt

func (s *Switch) LoadExt()

func (*Switch) LoadNetworkJson

func (s *Switch) LoadNetworkJson(data []byte) (*Network, error)

func (*Switch) LoadNetworks

func (s *Switch) LoadNetworks()

func (*Switch) LoadQos

func (s *Switch) LoadQos()

func (*Switch) Parse

func (s *Switch) Parse()

func (*Switch) Reload

func (s *Switch) Reload()

func (*Switch) Save

func (s *Switch) Save()

func (*Switch) SaveAcl

func (s *Switch) SaveAcl()

func (*Switch) SaveNetwork

func (s *Switch) SaveNetwork()

func (*Switch) SaveQos

func (s *Switch) SaveQos()

type TcpProxy

type TcpProxy struct {
	Listen string   `json:"listen,omitempty"`
	Target []string `json:"target,omitempty"`
}

type VxLANSpecifies

type VxLANSpecifies struct {
	Name   string `json:"name,omitempty"`
	Vni    uint32 `json:"vni"`
	Fabric string `json:"fabric"`
}

func (*VxLANSpecifies) Correct

func (c *VxLANSpecifies) Correct()

Jump to

Keyboard shortcuts

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