Documentation
¶
Index ¶
- Constants
- Variables
- func AddrAdd(name, addr string, opts ...string) ([]byte, error)
- func AddrDel(name, addr string) ([]byte, error)
- func AddrShow(name string) []string
- func GenTable() int
- func GetName(name string) string
- func GetPair(name string) (string, string)
- func IPTableInit()
- func LinkAdd(name string, opts ...string) ([]byte, error)
- func LinkDel(name string, opts ...string) ([]byte, error)
- func LinkDown(name string) ([]byte, error)
- func LinkSet(name string, opts ...string) ([]byte, error)
- func LinkUp(name string) ([]byte, error)
- func LookupIP(name string) string
- func RouteAdd(name, prefix, nexthop string, opts ...string) ([]byte, error)
- func RouteDel(name, prefix, nexthop string, opts ...string) ([]byte, error)
- func RouteShow(name string) []string
- func WaterNew(c TapConfig) (*water.Interface, error)
- type BrCtl
- type BrPort
- type Bridger
- type DeviceStats
- type FireWallChain
- func (ch *FireWallChain) AddRule(rule IPRule)
- func (ch *FireWallChain) AddRuleX(rule IPRule) error
- func (ch *FireWallChain) Cancel()
- func (ch *FireWallChain) Chain() IPChain
- func (ch *FireWallChain) DelRuleX(rule IPRule) error
- func (ch *FireWallChain) Flush()
- func (ch *FireWallChain) Install()
- func (ch *FireWallChain) Jump() IPRule
- func (ch *FireWallChain) Prepare()
- type FireWallFilter
- type FireWallGlobal
- func (f *FireWallGlobal) AddChain(chain IPChain)
- func (f *FireWallGlobal) AddRule(rule IPRule)
- func (f *FireWallGlobal) CancelRule(rule IPRule) error
- func (f *FireWallGlobal) Initialize()
- func (f *FireWallGlobal) InstallRule(rule IPRule) error
- func (f *FireWallGlobal) Refresh()
- func (f *FireWallGlobal) Start()
- func (f *FireWallGlobal) Stop()
- type FireWallMangle
- type FireWallNAT
- type FireWallNATPre
- type FireWallRaw
- type FireWallTable
- type Framer
- type IPChain
- type IPChains
- type IPRule
- type IPRules
- type IPSet
- type KernelTap
- func (t *KernelTap) Close() error
- func (t *KernelTap) Down()
- func (t *KernelTap) Has(v uint) bool
- func (t *KernelTap) IsTun() bool
- func (t *KernelTap) Master() Bridger
- func (t *KernelTap) Mtu() int
- func (t *KernelTap) Name() string
- func (t *KernelTap) Read(p []byte) (int, error)
- func (t *KernelTap) Recv(p []byte) (int, error)
- func (t *KernelTap) Send(p []byte) (int, error)
- func (t *KernelTap) SetMaster(dev Bridger) error
- func (t *KernelTap) Stats() DeviceStats
- func (t *KernelTap) String() string
- func (t *KernelTap) Tenant() string
- func (t *KernelTap) Type() string
- func (t *KernelTap) Up()
- func (t *KernelTap) Write(p []byte) (int, error)
- type LinuxBridge
- func (b *LinuxBridge) AddSlave(name string) error
- func (b *LinuxBridge) CallIptables(value int) error
- func (b *LinuxBridge) Close() error
- func (b *LinuxBridge) DelSlave(name string) error
- func (b *LinuxBridge) Delay(value int) error
- func (b *LinuxBridge) Kernel() string
- func (b *LinuxBridge) L3Name() string
- func (b *LinuxBridge) ListMac() <-chan *MacFdb
- func (b *LinuxBridge) ListSlave() <-chan Taper
- func (b *LinuxBridge) Mtu() int
- func (b *LinuxBridge) Name() string
- func (b *LinuxBridge) Open(addr string)
- func (b *LinuxBridge) Plugin(addr *nl.Addr) error
- func (b *LinuxBridge) SetMtu(mtu int) error
- func (b *LinuxBridge) Stats() DeviceStats
- func (b *LinuxBridge) Stp(enable bool) error
- func (b *LinuxBridge) String() string
- func (b *LinuxBridge) Type() string
- func (b *LinuxBridge) Unplugin() error
- type MacFdb
- type TapConfig
- type Taper
- type VRF
- type VRFs
Constants ¶
View Source
const ( ProviderVir = "virtual" ProviderKer = "kernel" ProviderLin = "linux" )
View Source
const ( OLCInput = "XTT_in" OLCForward = "XTT_for" OLCOutput = "XTT_out" OLCPre = "XTT_pre" OLCPost = "XTT_pos" )
View Source
const ( TNat = "nat" TRaw = "raw" TMangle = "mangle" TFilter = "filter" CInput = "INPUT" CForward = "FORWARD" COutput = "OUTPUT" CPost = "POSTROUTING" CPre = "PREROUTING" CMasq = "MASQUERADE" CMark = "MARK" CCT = "CT" CNoTrk = "NOTRACK" CSnat = "SNAT" CTcpMss = "TCPMSS" )
View Source
const ( UsClose = uint(0x02) UsUp = uint(0x04) TUN = 0x01 TAP = 0x02 )
Variables ¶
View Source
var Bridges = &bridger{}
View Source
var Taps = &tapers{}
Functions ¶
func IPTableInit ¶
func IPTableInit()
Types ¶
type BrCtl ¶
func (*BrCtl) CallIptables ¶
type Bridger ¶
type Bridger interface {
Type() string
Name() string
Open(addr string)
Close() error
AddSlave(name string) error
DelSlave(name string) error
ListSlave() <-chan Taper
Mtu() int
Stp(enable bool) error
Delay(value int) error
Kernel() string // name in kernel.
ListMac() <-chan *MacFdb
String() string
Stats() DeviceStats
CallIptables(value int) error
L3Name() string
SetMtu(mtu int) error
}
func NewBridger ¶
type DeviceStats ¶
type DeviceStats struct {
Send uint64 `json:"send"`
Recv uint64 `json:"recv"`
Drop uint64 `json:"drop"`
Mac string `json:"mac"`
Address uint64 `json:"address"`
Mtu int `json:"mtu"`
}
func GetDevStats ¶
func GetDevStats(name string) DeviceStats
type FireWallChain ¶
type FireWallChain struct {
// contains filtered or unexported fields
}
func NewFireWallChain ¶
func NewFireWallChain(name, table, parent string) *FireWallChain
func (*FireWallChain) AddRule ¶
func (ch *FireWallChain) AddRule(rule IPRule)
func (*FireWallChain) AddRuleX ¶
func (ch *FireWallChain) AddRuleX(rule IPRule) error
func (*FireWallChain) Cancel ¶
func (ch *FireWallChain) Cancel()
func (*FireWallChain) Chain ¶
func (ch *FireWallChain) Chain() IPChain
func (*FireWallChain) DelRuleX ¶
func (ch *FireWallChain) DelRuleX(rule IPRule) error
func (*FireWallChain) Flush ¶
func (ch *FireWallChain) Flush()
func (*FireWallChain) Install ¶
func (ch *FireWallChain) Install()
func (*FireWallChain) Jump ¶
func (ch *FireWallChain) Jump() IPRule
func (*FireWallChain) Prepare ¶
func (ch *FireWallChain) Prepare()
type FireWallFilter ¶
type FireWallFilter struct {
In *FireWallChain
Out *FireWallChain
For *FireWallChain
// contains filtered or unexported fields
}
func NewFireWallFilter ¶
func NewFireWallFilter(name string) *FireWallFilter
func (*FireWallFilter) Cancel ¶
func (f *FireWallFilter) Cancel()
func (*FireWallFilter) Install ¶
func (f *FireWallFilter) Install()
type FireWallGlobal ¶
type FireWallGlobal struct {
// contains filtered or unexported fields
}
func NewFireWallGlobal ¶
func NewFireWallGlobal(flows []config.FlowRule) *FireWallGlobal
func (*FireWallGlobal) AddChain ¶
func (f *FireWallGlobal) AddChain(chain IPChain)
func (*FireWallGlobal) AddRule ¶
func (f *FireWallGlobal) AddRule(rule IPRule)
func (*FireWallGlobal) CancelRule ¶
func (f *FireWallGlobal) CancelRule(rule IPRule) error
func (*FireWallGlobal) Initialize ¶
func (f *FireWallGlobal) Initialize()
func (*FireWallGlobal) InstallRule ¶
func (f *FireWallGlobal) InstallRule(rule IPRule) error
func (*FireWallGlobal) Refresh ¶
func (f *FireWallGlobal) Refresh()
func (*FireWallGlobal) Start ¶
func (f *FireWallGlobal) Start()
func (*FireWallGlobal) Stop ¶
func (f *FireWallGlobal) Stop()
type FireWallMangle ¶
type FireWallMangle struct {
Pre *FireWallChain
In *FireWallChain
For *FireWallChain
Out *FireWallChain
Post *FireWallChain
// contains filtered or unexported fields
}
func NewFireWallMangle ¶
func NewFireWallMangle(name string) *FireWallMangle
func (*FireWallMangle) Cancel ¶
func (m *FireWallMangle) Cancel()
func (*FireWallMangle) Install ¶
func (m *FireWallMangle) Install()
type FireWallNAT ¶
type FireWallNAT struct {
Pre *FireWallChain
In *FireWallChain
Out *FireWallChain
Post *FireWallChain
// contains filtered or unexported fields
}
func NewFireWallNAT ¶
func NewFireWallNAT(name string) *FireWallNAT
func (*FireWallNAT) Cancel ¶
func (n *FireWallNAT) Cancel()
func (*FireWallNAT) Install ¶
func (n *FireWallNAT) Install()
type FireWallNATPre ¶
type FireWallNATPre struct {
*FireWallChain
}
func (*FireWallNATPre) Chain ¶
func (ch *FireWallNATPre) Chain() IPChain
type FireWallRaw ¶
type FireWallRaw struct {
Pre *FireWallChain
Out *FireWallChain
// contains filtered or unexported fields
}
func NewFireWallRaw ¶
func NewFireWallRaw(name string) *FireWallRaw
func (*FireWallRaw) Cancel ¶
func (r *FireWallRaw) Cancel()
func (*FireWallRaw) Install ¶
func (r *FireWallRaw) Install()
type FireWallTable ¶
type FireWallTable struct {
Filter *FireWallFilter
Nat *FireWallNAT
Mangle *FireWallMangle
Raw *FireWallRaw
}
func NewFireWallTable ¶
func NewFireWallTable(name string) *FireWallTable
func (*FireWallTable) Start ¶
func (t *FireWallTable) Start()
func (*FireWallTable) Stop ¶
func (t *FireWallTable) Stop()
type IPRule ¶
type IPRule struct {
Table string
Chain string
Source string
SrcSet string
ToSource string
NoSource string
NoSrcSet string
Dest string
DestSet string
ToDest string
NoDest string
NoDestSet string
Proto string
DstPort string
SrcPort string
Input string
Output string
Comment string
Jump string
Limit string
LimitBurst string
SetMss int
Mark uint32
SetMark uint32
Zone uint32
Order string
Match string
CtState string
TcpFlag []string
}
type KernelTap ¶
type KernelTap struct {
// contains filtered or unexported fields
}
func (*KernelTap) Stats ¶
func (t *KernelTap) Stats() DeviceStats
type LinuxBridge ¶
type LinuxBridge struct {
// contains filtered or unexported fields
}
func NewLinuxBridge ¶
func NewLinuxBridge(name string, mtu int) *LinuxBridge
func (*LinuxBridge) AddSlave ¶
func (b *LinuxBridge) AddSlave(name string) error
func (*LinuxBridge) CallIptables ¶
func (b *LinuxBridge) CallIptables(value int) error
func (*LinuxBridge) Close ¶
func (b *LinuxBridge) Close() error
func (*LinuxBridge) DelSlave ¶
func (b *LinuxBridge) DelSlave(name string) error
func (*LinuxBridge) Delay ¶
func (b *LinuxBridge) Delay(value int) error
func (*LinuxBridge) Kernel ¶
func (b *LinuxBridge) Kernel() string
func (*LinuxBridge) L3Name ¶
func (b *LinuxBridge) L3Name() string
func (*LinuxBridge) ListMac ¶
func (b *LinuxBridge) ListMac() <-chan *MacFdb
func (*LinuxBridge) ListSlave ¶
func (b *LinuxBridge) ListSlave() <-chan Taper
func (*LinuxBridge) Mtu ¶
func (b *LinuxBridge) Mtu() int
func (*LinuxBridge) Name ¶
func (b *LinuxBridge) Name() string
func (*LinuxBridge) Open ¶
func (b *LinuxBridge) Open(addr string)
func (*LinuxBridge) SetMtu ¶
func (b *LinuxBridge) SetMtu(mtu int) error
func (*LinuxBridge) Stats ¶
func (b *LinuxBridge) Stats() DeviceStats
func (*LinuxBridge) Stp ¶
func (b *LinuxBridge) Stp(enable bool) error
func (*LinuxBridge) String ¶
func (b *LinuxBridge) String() string
func (*LinuxBridge) Type ¶
func (b *LinuxBridge) Type() string
func (*LinuxBridge) Unplugin ¶
func (b *LinuxBridge) Unplugin() error
type Taper ¶
type Taper interface {
Type() string
IsTun() bool
Name() string
Read([]byte) (int, error) // read data from kernel to user space
Write([]byte) (int, error) // write data from user space to kernel
Send([]byte) (int, error) // send data from virtual bridge to kernel
Recv([]byte) (int, error) // recv data from kernel to virtual bridge
Close() error
Master() Bridger
SetMaster(dev Bridger) error
Up()
Down()
Tenant() string
Mtu() int
String() string
Has(v uint) bool
Stats() DeviceStats
}
Click to show internal directories.
Click to hide internal directories.