comm

package
v0.0.0-...-a03a6ab Latest Latest
Warning

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

Go to latest
Published: Mar 28, 2023 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MapAddrSz          int           = 20
	MapRealServerSz    int           = 24
	MapConnKeySz       int           = 40
	MapConnValSz       int           = 56
	TickerTime         time.Duration = 2 * time.Second
	NsCnt              uint64        = 1000000000
	DefaultConnTimeout uint32        = 5
	DefailtApiPort     int           = 8081
)

Variables

This section is empty.

Functions

func AddFilter

func AddFilter(idx, fd int) error
func AttachLink(idx, fd int) error

func ConvertToIP

func ConvertToIP(ipStr string) net.IP

func ConvertToIPStrs

func ConvertToIPStrs(ips []net.IP) []string

func ConvertToIPs

func ConvertToIPs(ipStrs []string) ([]net.IP, error)

func DelFilter

func DelFilter(idx int) error
func DetachLink(idx int) error

func GetUint16

func GetUint16(b []byte) uint16

func GetUint32

func GetUint32(b []byte) uint32

func GetUint64

func GetUint64(b []byte) uint64

func GetUptime

func GetUptime() (uint64, error)

return system up time(s)

func IsLittleEndian

func IsLittleEndian() bool

func JoinIP

func JoinIP(ip, parentIP string) string

func PutBeAddr

func PutBeAddr(b []byte, proto SockProto, ip net.IP, port uint16)

func PutSession

func PutSession(se *Session)

func PutUint16

func PutUint16(b []byte, v uint16)

func PutUint32

func PutUint32(b []byte, v uint32)

func PutUint64

func PutUint64(b []byte, v uint64)

func SplitIP

func SplitIP(ip string) (string, string)

func StrToMac

func StrToMac(macStr string) net.HardwareAddr

Types

type AfType

type AfType = byte

func GetAddrFamily

func GetAddrFamily(ipStr string) (AfType, error)

type BpfMode

type BpfMode = uint32
const (
	NodeInvalid BpfMode = 0
	ModeNat     BpfMode = 0x1
	ModeFNat    BpfMode = 0x2
)

type ConnKey

type ConnKey struct {
	Af      AfType
	Proto   SockProto
	RxSIP   string
	RxSPort uint16
	RxDIP   string
	RxDPort uint16
}

func (*ConnKey) Marshal

func (k *ConnKey) Marshal() ([]byte, error)

func (*ConnKey) Unmarshal

func (k *ConnKey) Unmarshal(b []byte) error

type ConnVal

type ConnVal struct {
	TxSrcIP     string
	TxSrcPort   uint16
	TxDstIP     string
	TxDstPort   uint16
	IfIdx       uint32
	Proto       SockProto
	Ts          uint64
	IsLocal     bool
	IsLocalPort bool
	IsPositive  bool
}

func (*ConnVal) Marshal

func (v *ConnVal) Marshal() ([]byte, error)

func (*ConnVal) Unmarshal

func (v *ConnVal) Unmarshal(b []byte) error

type Service

type Service interface {
	Add(*SrvKey, *SrvVal) error
	Del(*SrvKey) error
	Attach(int) error
	Detach(int) error
	PollSession() []*Session
	PushSession([]*Session)
	Release()
}

type Session

type Session struct {
	CIP     string
	CPort   uint16
	VIP     string
	VPort   uint16
	LIP     string
	LPort   uint16
	RIP     string
	RPort   uint16
	Proto   SockProto
	IsLocal bool
}

func GetSession

func GetSession() *Session

func (*Session) FromAPI

func (s *Session) FromAPI(se *api.Session)

func (*Session) FromConn

func (s *Session) FromConn(k *ConnKey, v *ConnVal)

func (*Session) ToAPI

func (s *Session) ToAPI() *api.Session

func (*Session) ToConn

func (s *Session) ToConn(af AfType, virtualIfIdx, localIfIdx uint32, ts uint64) ([]ConnKey, []ConnVal)

type SockProto

type SockProto byte

func GetBeAddr

func GetBeAddr(b []byte) (net.IP, uint16, SockProto)

func SockProtoValue

func SockProtoValue(v string) (SockProto, error)

func (SockProto) String

func (p SockProto) String() string

func (SockProto) Valid

func (p SockProto) Valid() bool

type SrvKey

type SrvKey struct {
	IP       string
	ParentIP string
	Port     uint16
	Proto    SockProto
}

func (*SrvKey) Marshal

func (k *SrvKey) Marshal() ([]byte, error)

type SrvVal

type SrvVal struct {
	LocalIP       string
	ParentLocalIP string
	Proto         SockProto
	Mode          BpfMode
	Strategy      byte
	RealPort      uint16
	RealServerIPs []string
	VirtualIfIdx  int
	LocalIfIdx    int
	Timeout       uint32
}

func (*SrvVal) Marshal

func (v *SrvVal) Marshal() ([]byte, error)

Jump to

Keyboard shortcuts

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