Documentation
¶
Index ¶
- Constants
- Variables
- func Base64Decode(value string) ([]byte, error)
- func Base64Encode(value []byte) string
- func BasicAuth(username, password string) string
- func Catch(name string)
- func Cmd(format string, v ...any)
- func CreateFile(path string) (*os.File, error)
- func CreateFileEx(path string) (*os.File, error)
- func Debug(format string, v ...any)
- func Error(format string, v ...any)
- func Exec(bin string, args ...string) (string, error)
- func Fatal(format string, v ...any)
- func FileExist(file string) error
- func FunName(i any) string
- func GenEthAddr(n int) []byte
- func GenInt32() int
- func GenLetters(n int) []byte
- func GenString(n int) string
- func GenUint32() uint32
- func GetHostPort(addr string) (string, string)
- func GetIPAddr(addr string) string
- func GetKcpBlock(algo string, key string) kcp.BlockCrypt
- func GetLeaseTime(value string) (time.Time, error)
- func GetLocalByGw(addr string) (net.IP, error)
- func GetLocalTime(layout, value string) (time.Time, error)
- func GetPrefix(value string, index int) string
- func GetPrefixLen(addr string) int
- func GetSuffix(value string, index int) string
- func Go(call func())
- func HasLog(level int) bool
- func HasProcess(pid int) bool
- func IPNetmask(ipAddr string) (string, error)
- func IPNetwork(ipAddr string) (string, error)
- func IfName(name string) string
- func Info(format string, v ...any)
- func IpProto2Str(proto uint8) string
- func IsJson(file string) bool
- func IsYaml(file string) bool
- func Kill(pid int) (*os.Process, error)
- func LoadFile(file string) ([]byte, error)
- func Log(format string, v ...any)
- func LogDate()
- func Marshal(v any, pretty bool) ([]byte, error)
- func MarshalSave(v any, file string, pretty bool) error
- func MarshalYaml(v any) ([]byte, error)
- func Netmask2Len(s string) int
- func NewErr(message string, v ...any) error
- func NoLogDate()
- func OpenRead(path string) (*os.File, error)
- func OpenTrunk(path string) (*os.File, error)
- func OpenWrite(path string) (*os.File, error)
- func ParseAddr(addr string) net.IP
- func ParseCIDR(addr string) (*net.IPNet, error)
- func ParseNet(addr string) (*net.IPNet, error)
- func PreNotify()
- func PrettyBits(b uint64) string
- func PrettyBytes(b uint64) string
- func PrettyTime(t int64) string
- func Print(format string, v ...any)
- func RouteProtocol(code int) string
- func SdNotify()
- func SetLevel(level int)
- func SetLogger(file string, level int)
- func ShowVersion()
- func Stack(format string, v ...any)
- func StateCode(code int) string
- func Sudo(bin string, args ...string) (string, error)
- func ToSegment(id int, sec string) string
- func Uint2S(value uint32) string
- func UnixTime(value int64) string
- func Unmarshal(v any, contents []byte) error
- func UnmarshalLoad(v any, file string) error
- func UnmarshalYaml(v any, contents []byte) error
- func Wait()
- func Warn(format string, v ...any)
- func WritePid(file string)
- func XDPListen(addr string, clients, bufSize int) (net.Listener, error)
- type Arp
- type Auth
- type BlockCrypt
- type CertConfig
- type ClientListener
- type ConnStats
- type ControlMessage
- type Device
- type Ether
- type FrameMessage
- func (m *FrameMessage) Action() string
- func (m *FrameMessage) Append(data []byte)
- func (m *FrameMessage) CmdAndParams() (string, []byte)
- func (m *FrameMessage) Decode() bool
- func (m *FrameMessage) Frame() []byte
- func (m *FrameMessage) IsControl() bool
- func (m *FrameMessage) IsEthernet() bool
- func (m *FrameMessage) Proto() (*FrameProto, error)
- func (m *FrameMessage) SetSize(v int)
- func (m *FrameMessage) Size() int
- func (m *FrameMessage) String() string
- type FrameProto
- type HttpClient
- type Ipv4
- type KcpClient
- type KcpConfig
- type KcpServer
- type LDAPConfig
- type LDAPService
- type Message
- type Messager
- type Neighbor
- type PProf
- type PacketMessagerImpl
- func (s *PacketMessagerImpl) Crypt() *BlockCrypt
- func (s *PacketMessagerImpl) Flush()
- func (s *PacketMessagerImpl) Receive(conn net.Conn, max, min int) (*FrameMessage, error)
- func (s *PacketMessagerImpl) Send(conn net.Conn, frame *FrameMessage) (int, error)
- func (s *PacketMessagerImpl) SetCrypt(block *BlockCrypt)
- type Prefix
- type PrefixPath
- type Promise
- type ReadClient
- type SafeStrInt64
- type SafeStrMap
- func (sm *SafeStrMap) Clear()
- func (sm *SafeStrMap) Del(k string)
- func (sm *SafeStrMap) Full() bool
- func (sm *SafeStrMap) Get(k string) any
- func (sm *SafeStrMap) GetEx(k string) (any, bool)
- func (sm *SafeStrMap) Iter(proc func(k string, v any)) int
- func (sm *SafeStrMap) Len() int
- func (sm *SafeStrMap) Mod(k string, v any) error
- func (sm *SafeStrMap) Set(k string, v any) error
- type SafeStrStr
- func (sm *SafeStrStr) Del(k string)
- func (sm *SafeStrStr) Get(k string) string
- func (sm *SafeStrStr) GetEx(k string) (string, bool)
- func (sm *SafeStrStr) Iter(proc func(k, v string)) int
- func (sm *SafeStrStr) Len() int
- func (sm *SafeStrStr) Reset(k, v string) error
- func (sm *SafeStrStr) Set(k, v string) error
- type SafeVar
- type ServerListener
- type SocketClient
- type SocketClientImpl
- func (s *SocketClientImpl) AliveTime() int64
- func (s *SocketClientImpl) Close()
- func (s *SocketClientImpl) Connect() error
- func (s *SocketClientImpl) Have(state SocketStatus) bool
- func (s *SocketClientImpl) MaxSize() int
- func (s *SocketClientImpl) MinSize() int
- func (s *SocketClientImpl) Out() *SubLogger
- func (s *SocketClientImpl) Private() any
- func (s *SocketClientImpl) Reset(conn net.Conn)
- func (s *SocketClientImpl) Retry() bool
- func (s *SocketClientImpl) SetListener(listener ClientListener)
- func (s *SocketClientImpl) SetMaxSize(value int)
- func (s *SocketClientImpl) SetPrivate(v any)
- func (s *SocketClientImpl) SetStatus(v SocketStatus)
- func (s *SocketClientImpl) SetTimeout(v int64)
- func (s *SocketClientImpl) Statistics() map[string]int64
- func (s *SocketClientImpl) Status() SocketStatus
- func (s *SocketClientImpl) Terminal()
- func (s *SocketClientImpl) UpTime() int64
- type SocketConfig
- type SocketServer
- type SocketServerImpl
- func (t *SocketServerImpl) Accept()
- func (t *SocketServerImpl) Address() string
- func (t *SocketServerImpl) Close()
- func (t *SocketServerImpl) ListClient() <-chan SocketClient
- func (t *SocketServerImpl) Listen() error
- func (t *SocketServerImpl) Loop(call ServerListener)
- func (t *SocketServerImpl) OffClient(client SocketClient)
- func (t *SocketServerImpl) Read(client SocketClient, ReadAt ReadClient)
- func (t *SocketServerImpl) SetTimeout(v int64)
- func (t *SocketServerImpl) Statistics() map[string]int64
- func (t *SocketServerImpl) String() string
- func (t *SocketServerImpl) TotalClient() int
- type SocketStatus
- type StreamMessagerImpl
- func (s *StreamMessagerImpl) Crypt() *BlockCrypt
- func (s *StreamMessagerImpl) Flush()
- func (s *StreamMessagerImpl) Receive(conn net.Conn, max, min int) (*FrameMessage, error)
- func (s *StreamMessagerImpl) Send(conn net.Conn, frame *FrameMessage) (int, error)
- func (s *StreamMessagerImpl) SetCrypt(block *BlockCrypt)
- type StreamSocket
- func (t *StreamSocket) IsOk() bool
- func (t *StreamSocket) Key() string
- func (t *StreamSocket) LocalAddr() string
- func (t *StreamSocket) ReadMsg() (*FrameMessage, error)
- func (t *StreamSocket) RemoteAddr() string
- func (t *StreamSocket) SetKey(key string)
- func (t *StreamSocket) String() string
- func (t *StreamSocket) WriteMsg(frame *FrameMessage) error
- type SubLogger
- func (s *SubLogger) Cmd(format string, v ...any)
- func (s *SubLogger) Debug(format string, v ...any)
- func (s *SubLogger) Error(format string, v ...any)
- func (s *SubLogger) Event(format string, v ...any)
- func (s *SubLogger) Fatal(format string, v ...any)
- func (s *SubLogger) Flow(format string, v ...any)
- func (s *SubLogger) Fmt(format string) string
- func (s *SubLogger) Has(level int) bool
- func (s *SubLogger) Info(format string, v ...any)
- func (l SubLogger) List() <-chan *Message
- func (s *SubLogger) Log(format string, v ...any)
- func (s *SubLogger) Print(format string, v ...any)
- func (s *SubLogger) Printf(format string, v ...any)
- func (l SubLogger) Save(level string, format string, v ...any)
- func (s *SubLogger) Stack(format string, v ...any)
- func (s *SubLogger) Warn(format string, v ...any)
- func (l SubLogger) Write(level int, format string, v ...any)
- type Tcp
- type TcpClient
- type TcpConfig
- type TcpServer
- type Udp
- type UdpClient
- type UdpConfig
- type UdpServer
- type Vlan
- type WaitOne
- type WebClient
- type WebConfig
- type WebServer
- type WsClient
- type XDP
- type XDPConn
- func (c *XDPConn) Close() error
- func (c *XDPConn) LocalAddr() net.Addr
- func (c *XDPConn) Read(b []byte) (n int, err error)
- func (c *XDPConn) RemoteAddr() net.Addr
- func (c *XDPConn) SetDeadline(t time.Time) error
- func (c *XDPConn) SetReadDeadline(t time.Time) error
- func (c *XDPConn) SetWriteDeadline(t time.Time) error
- func (c *XDPConn) String() string
- func (c *XDPConn) Write(b []byte) (n int, err error)
Constants ¶
View Source
const ( PRINT = 01 LOG = 05 STACK = 06 DEBUG = 10 FLOW = 11 CMD = 15 EVENT = 16 INFO = 20 WARN = 30 ERROR = 40 FATAL = 99 )
View Source
const ( MaxFrame = 1600 MaxBuf = 4096 HlMI = 0x02 HlLI = 0x04 HlSize = 0x04 EthDI = 0x06 MaxMsg = 1600 * 8 )
View Source
const ( LoginReq = "logi= " LoginResp = "logi: " NeighborReq = "neig= " NeighborResp = "neig: " IpAddrReq = "ipad= " IpAddrResp = "ipad: " LeftReq = "left= " SignReq = "sign= " PingReq = "ping= " PongResp = "pong: " NegoReq = "nego= " NegoResp = "nego: " )
View Source
const ( RTPROT_BGP = 0xba RTPROT_BIRD = 0xc RTPROT_KERNEL = 0x2 RTPROT_BOOT = 0x3 RTPROT_DHCP = 0x10 RTPROT_ISIS = 0xbb RTPROT_OSPF = 0xbc RTPROT_REDIRECT = 0x1 RTPROT_RIP = 0xbd RTPROT_STATIC = 0x4 RTPROT_UNSPEC = 0x0 RTPROT_ZEBRA = 0xb )
View Source
const ( EthArp = 0x0806 EthIp4 = 0x0800 EthIp6 = 0x86DD EthVlan = 0x8100 )
View Source
const ( EtherLen = 14 VlanLen = 4 TcpLen = 20 Ipv4Len = 20 UdpLen = 8 )
View Source
const ( ArpRequest = 1 ArpReply = 2 )
View Source
const ( ArpHrdNetrom = 0 ArpHrdEther = 1 )
View Source
const ( Ipv4Ver = 0x04 Ipv6Ver = 0x06 )
View Source
const ( IpIcmp = 0x01 IpIgmp = 0x02 IpIpIp = 0x04 IpTcp = 0x06 IpUdp = 0x11 IpEsp = 0x32 IpAh = 0x33 IpOspf = 0x59 IpPim = 0x67 IpVrrp = 0x70 IpIsis = 0x7c )
View Source
const ( TcpUrg = 0x20 TcpAck = 0x10 TcpPsh = 0x08 TcpRst = 0x04 TcpSyn = 0x02 TcpFin = 0x01 )
View Source
const ( ClInit = 0x00 ClConnected = 0x01 ClUnAuth = 0x02 ClAuth = 0x03 ClConnecting = 0x04 ClTerminal = 0x05 ClClosed = 0x06 ClNegotiating = 0x07 ClNegotiated = 0x08 )
View Source
const ( CsSendOkay = "send" CsRecvOkay = "recv" CsSendError = "error" CsDropped = "dropped" )
View Source
const ( SsRecv = "recv" SsDeny = "deny" SsAlive = "alive" SsSend = "send" SsDrop = "dropped" SsAccept = "accept" SsClose = "closed" )
View Source
const LeaseTime = "2006-01-02T15"
View Source
const MacBase = 0x00
View Source
const SimpleTime = "2006-01-02 15:04:05"
Variables ¶
View Source
var ( EthZero = []byte{0x00, 0x00, 0x00, 0x00, 0x00, 0x00} EthAll = []byte{0xff, 0xff, 0xff, 0xff, 0xff, 0xff} )
View Source
var ( Date string Version string Commit string )
View Source
var Gos = gos{}
View Source
var Letters = []byte("0123456789abcdefghijklmnopqrstuvwxyz")
View Source
var Logger = &logger{ Level: INFO, FileName: ".log.error", Errors: list.New(), }
View Source
var MAGIC = []byte{0xff, 0xff}
Functions ¶
func Base64Decode ¶
func Base64Encode ¶
func GenEthAddr ¶
func GenLetters ¶
func GetHostPort ¶
func GetKcpBlock ¶
func GetKcpBlock(algo string, key string) kcp.BlockCrypt
func GetPrefixLen ¶
func HasProcess ¶
func IpProto2Str ¶
func MarshalYaml ¶
func Netmask2Len ¶
func PrettyBits ¶
func PrettyBytes ¶
func PrettyTime ¶
func RouteProtocol ¶
func ShowVersion ¶
func ShowVersion()
func UnmarshalLoad ¶
func UnmarshalYaml ¶
Types ¶
type Arp ¶
type Arp struct {
HrdCode uint16 // format hardware address
ProCode uint16 // format protocol address
HrdLen uint8 // length of hardware address
ProLen uint8 // length of protocol address
OpCode uint16 // ARP Op(command)
SHwAddr []byte // sender hardware address.
SIpAddr []byte // sender IP address.
THwAddr []byte // target hardware address.
TIpAddr []byte // target IP address.
Len int
}
func NewArpFromFrame ¶
type BlockCrypt ¶
type BlockCrypt struct {
kcp.BlockCrypt
// contains filtered or unexported fields
}
func CopyBlockCrypt ¶
func CopyBlockCrypt(crypt *BlockCrypt) *BlockCrypt
func NewBlockCrypt ¶
func NewBlockCrypt(algo string, key string) *BlockCrypt
func (*BlockCrypt) Update ¶
func (b *BlockCrypt) Update(key string)
type ClientListener ¶
type ClientListener struct {
OnClose func(client SocketClient) error
OnConnected func(client SocketClient) error
OnStatus func(client SocketClient, old, new SocketStatus)
}
type ConnStats ¶
func ListConnStats ¶
func ListConnStats() ConnStats
type ControlMessage ¶
type ControlMessage struct {
// contains filtered or unexported fields
}
func NewControlMessage ¶
func NewControlMessage(action, opr string, body []byte) *ControlMessage
operator: request is '= ', and response is ': ' action: login, network etc. body: json string.
func (*ControlMessage) Encode ¶
func (c *ControlMessage) Encode() *FrameMessage
type Device ¶
type Device struct {
Name string
Send uint64
Recv uint64
Drop uint64
Mac string
State string
Mtu int
Type string
}
func ListPhyLinks ¶
func ListPhyLinks() []Device
type Ether ¶
func NewEtherArp ¶
func NewEtherArp() (e *Ether)
func NewEtherFromFrame ¶
func NewEtherIP4 ¶
func NewEtherIP4() (e *Ether)
type FrameMessage ¶
type FrameMessage struct {
// contains filtered or unexported fields
}
func NewControlFrame ¶
func NewControlFrame(action string, body []byte) *FrameMessage
func NewFrameMessage ¶
func NewFrameMessage(maxSize int) *FrameMessage
func NewFrameMessageFromBytes ¶
func NewFrameMessageFromBytes(buffer []byte) *FrameMessage
func (*FrameMessage) Action ¶
func (m *FrameMessage) Action() string
func (*FrameMessage) Append ¶
func (m *FrameMessage) Append(data []byte)
func (*FrameMessage) CmdAndParams ¶
func (m *FrameMessage) CmdAndParams() (string, []byte)
func (*FrameMessage) Decode ¶
func (m *FrameMessage) Decode() bool
func (*FrameMessage) Frame ¶
func (m *FrameMessage) Frame() []byte
func (*FrameMessage) IsControl ¶
func (m *FrameMessage) IsControl() bool
func (*FrameMessage) IsEthernet ¶
func (m *FrameMessage) IsEthernet() bool
func (*FrameMessage) Proto ¶
func (m *FrameMessage) Proto() (*FrameProto, error)
func (*FrameMessage) SetSize ¶
func (m *FrameMessage) SetSize(v int)
func (*FrameMessage) Size ¶
func (m *FrameMessage) Size() int
func (*FrameMessage) String ¶
func (m *FrameMessage) String() string
type FrameProto ¶
type FrameProto struct {
// public
Eth *Ether
Vlan *Vlan
Arp *Arp
Ip4 *Ipv4
Udp *Udp
Tcp *Tcp
Err error
Frame []byte
}
func (*FrameProto) Decode ¶
func (i *FrameProto) Decode() error
type HttpClient ¶
type HttpClient struct {
Method string
Url string
Payload io.Reader
Auth Auth
TlsConfig *tls.Config
Client *http.Client
Timeout time.Duration
}
func (*HttpClient) Close ¶
func (cl *HttpClient) Close()
type Ipv4 ¶
type Ipv4 struct {
Version uint8 //4bite v4: 0100, v6: 0110
HeaderLen uint8 //4bit 15*4
ToS uint8 //Type of Service
TotalLen uint16
Identifier uint16
Flag uint16 //3bit Z|DF|MF
Offset uint16 //13bit Fragment offset
ToL uint8 //Time of Live
Protocol uint8
HeaderChecksum uint16 //Header Checksum
Source []byte
Destination []byte
Options uint32 //Reserved
Len int
}
func NewIpv4FromFrame ¶
type KcpClient ¶
type KcpClient struct {
*SocketClientImpl
// contains filtered or unexported fields
}
func NewKcpClient ¶
func (*KcpClient) SetStatus ¶
func (c *KcpClient) SetStatus(v SocketStatus)
type KcpConfig ¶
type KcpConfig struct {
Block *BlockCrypt
WinSize int // default 1024
DataShards int // default 10
ParityShards int // default 3
Timeout time.Duration // ns
RdQus int // per frames
WrQus int // per frames
}
func NewKcpConfig ¶
func NewKcpConfig() *KcpConfig
type KcpServer ¶
type KcpServer struct {
*SocketServerImpl
// contains filtered or unexported fields
}
func NewKcpServer ¶
type LDAPConfig ¶
type LDAPService ¶
type LDAPService struct {
Conn *ldap.Conn
Cfg LDAPConfig
Error string
}
func NewLDAPService ¶
func NewLDAPService(cfg LDAPConfig) (*LDAPService, error)
func (*LDAPService) State ¶
func (l *LDAPService) State() string
type Messager ¶
type Messager interface {
Crypt() *BlockCrypt
SetCrypt(*BlockCrypt)
Send(conn net.Conn, frame *FrameMessage) (int, error)
Receive(conn net.Conn, max, min int) (*FrameMessage, error)
Flush()
}
type Neighbor ¶
func ListNeighbrs ¶
type PacketMessagerImpl ¶
type PacketMessagerImpl struct {
// contains filtered or unexported fields
}
func (*PacketMessagerImpl) Crypt ¶
func (s *PacketMessagerImpl) Crypt() *BlockCrypt
func (*PacketMessagerImpl) Flush ¶
func (s *PacketMessagerImpl) Flush()
func (*PacketMessagerImpl) Receive ¶
func (s *PacketMessagerImpl) Receive(conn net.Conn, max, min int) (*FrameMessage, error)
func (*PacketMessagerImpl) Send ¶
func (s *PacketMessagerImpl) Send(conn net.Conn, frame *FrameMessage) (int, error)
func (*PacketMessagerImpl) SetCrypt ¶
func (s *PacketMessagerImpl) SetCrypt(block *BlockCrypt)
type Prefix ¶
type Prefix struct {
Link string
Dst string
Src string
Gw string
Protocol string
Priority int
Table int
MultiPath []PrefixPath
}
func ListRoutes ¶
type PrefixPath ¶
type Promise ¶
type Promise struct {
Count int
MaxTry int
First time.Duration // the delay time.
MinInt time.Duration // the normal time.
MaxInt time.Duration // the max delay time.
}
func NewPromise ¶
func NewPromise() *Promise
func NewPromiseAlways ¶
func NewPromiseAlways() *Promise
type ReadClient ¶
type ReadClient func(client SocketClient, f *FrameMessage) error
type SafeStrInt64 ¶
type SafeStrInt64 struct {
// contains filtered or unexported fields
}
func NewSafeStrInt64 ¶
func NewSafeStrInt64() *SafeStrInt64
func (*SafeStrInt64) Add ¶
func (s *SafeStrInt64) Add(k string, v int64)
func (*SafeStrInt64) Copy ¶
func (s *SafeStrInt64) Copy(dst map[string]int64)
func (*SafeStrInt64) Data ¶
func (s *SafeStrInt64) Data() map[string]int64
func (*SafeStrInt64) Get ¶
func (s *SafeStrInt64) Get(k string) int64
func (*SafeStrInt64) Set ¶
func (s *SafeStrInt64) Set(k string, v int64)
type SafeStrMap ¶
type SafeStrMap struct {
// contains filtered or unexported fields
}
func NewSafeStrMap ¶
func NewSafeStrMap(size int) *SafeStrMap
func (*SafeStrMap) Clear ¶
func (sm *SafeStrMap) Clear()
func (*SafeStrMap) Del ¶
func (sm *SafeStrMap) Del(k string)
func (*SafeStrMap) Full ¶
func (sm *SafeStrMap) Full() bool
func (*SafeStrMap) Get ¶
func (sm *SafeStrMap) Get(k string) any
func (*SafeStrMap) Len ¶
func (sm *SafeStrMap) Len() int
type SafeStrStr ¶
type SafeStrStr struct {
// contains filtered or unexported fields
}
func NewSafeStrStr ¶
func NewSafeStrStr(size int) *SafeStrStr
func (*SafeStrStr) Del ¶
func (sm *SafeStrStr) Del(k string)
func (*SafeStrStr) Get ¶
func (sm *SafeStrStr) Get(k string) string
func (*SafeStrStr) Iter ¶
func (sm *SafeStrStr) Iter(proc func(k, v string)) int
func (*SafeStrStr) Len ¶
func (sm *SafeStrStr) Len() int
func (*SafeStrStr) Reset ¶
func (sm *SafeStrStr) Reset(k, v string) error
func (*SafeStrStr) Set ¶
func (sm *SafeStrStr) Set(k, v string) error
type SafeVar ¶
type SafeVar struct {
// contains filtered or unexported fields
}
func NewSafeVar ¶
func NewSafeVar() *SafeVar
func (*SafeVar) GetWithFunc ¶
type ServerListener ¶
type ServerListener struct {
OnClient func(client SocketClient) error
OnClose func(client SocketClient) error
ReadAt func(client SocketClient, f *FrameMessage) error
}
type SocketClient ¶
type SocketClient interface {
LocalAddr() string
RemoteAddr() string
Connect() error
Close()
WriteMsg(frame *FrameMessage) error
ReadMsg() (*FrameMessage, error)
UpTime() int64
AliveTime() int64
String() string
Terminal()
Private() any
SetPrivate(v any)
Status() SocketStatus
SetStatus(v SocketStatus)
MaxSize() int
SetMaxSize(value int)
MinSize() int
IsOk() bool
Have(status SocketStatus) bool
Statistics() map[string]int64
SetListener(listener ClientListener)
SetTimeout(v int64)
Out() *SubLogger
SetKey(key string)
Key() string
}
type SocketClientImpl ¶
type SocketClientImpl struct {
*StreamSocket
// contains filtered or unexported fields
}
func NewSocketClient ¶
func NewSocketClient(cfg SocketConfig, message Messager) *SocketClientImpl
func (*SocketClientImpl) AliveTime ¶
func (s *SocketClientImpl) AliveTime() int64
func (*SocketClientImpl) Have ¶
func (s *SocketClientImpl) Have(state SocketStatus) bool
func (*SocketClientImpl) MaxSize ¶
func (s *SocketClientImpl) MaxSize() int
func (*SocketClientImpl) MinSize ¶
func (s *SocketClientImpl) MinSize() int
func (*SocketClientImpl) Out ¶
func (s *SocketClientImpl) Out() *SubLogger
func (*SocketClientImpl) Private ¶
func (s *SocketClientImpl) Private() any
func (*SocketClientImpl) Reset ¶
func (s *SocketClientImpl) Reset(conn net.Conn)
func (*SocketClientImpl) Retry ¶
func (s *SocketClientImpl) Retry() bool
func (*SocketClientImpl) SetListener ¶
func (s *SocketClientImpl) SetListener(listener ClientListener)
func (*SocketClientImpl) SetMaxSize ¶
func (s *SocketClientImpl) SetMaxSize(value int)
func (*SocketClientImpl) SetPrivate ¶
func (s *SocketClientImpl) SetPrivate(v any)
func (*SocketClientImpl) SetStatus ¶
func (s *SocketClientImpl) SetStatus(v SocketStatus)
MUST IMPLEMENT
func (*SocketClientImpl) SetTimeout ¶
func (s *SocketClientImpl) SetTimeout(v int64)
func (*SocketClientImpl) Statistics ¶
func (s *SocketClientImpl) Statistics() map[string]int64
func (*SocketClientImpl) Status ¶
func (s *SocketClientImpl) Status() SocketStatus
func (*SocketClientImpl) UpTime ¶
func (s *SocketClientImpl) UpTime() int64
type SocketConfig ¶
type SocketConfig struct {
Address string
Block *BlockCrypt
}
type SocketServer ¶
type SocketServer interface {
Listen() (err error)
Close()
Accept()
ListClient() <-chan SocketClient
OffClient(client SocketClient)
TotalClient() int
Loop(call ServerListener)
Read(client SocketClient, ReadAt ReadClient)
String() string
Address() string
Statistics() map[string]int64
SetTimeout(v int64)
}
type SocketServerImpl ¶
type SocketServerImpl struct {
WrQus int // per frames.
// contains filtered or unexported fields
}
TODO keepalive to release zombie connections.
func NewSocketServer ¶
func NewSocketServer(listen string) *SocketServerImpl
func (*SocketServerImpl) Address ¶
func (t *SocketServerImpl) Address() string
func (*SocketServerImpl) ListClient ¶
func (t *SocketServerImpl) ListClient() <-chan SocketClient
func (*SocketServerImpl) Loop ¶
func (t *SocketServerImpl) Loop(call ServerListener)
func (*SocketServerImpl) OffClient ¶
func (t *SocketServerImpl) OffClient(client SocketClient)
func (*SocketServerImpl) Read ¶
func (t *SocketServerImpl) Read(client SocketClient, ReadAt ReadClient)
func (*SocketServerImpl) SetTimeout ¶
func (t *SocketServerImpl) SetTimeout(v int64)
func (*SocketServerImpl) Statistics ¶
func (t *SocketServerImpl) Statistics() map[string]int64
func (*SocketServerImpl) String ¶
func (t *SocketServerImpl) String() string
func (*SocketServerImpl) TotalClient ¶
func (t *SocketServerImpl) TotalClient() int
type SocketStatus ¶
type SocketStatus uint8
func (SocketStatus) String ¶
func (s SocketStatus) String() string
type StreamMessagerImpl ¶
type StreamMessagerImpl struct {
// contains filtered or unexported fields
}
func (*StreamMessagerImpl) Crypt ¶
func (s *StreamMessagerImpl) Crypt() *BlockCrypt
func (*StreamMessagerImpl) Flush ¶
func (s *StreamMessagerImpl) Flush()
func (*StreamMessagerImpl) Receive ¶
func (s *StreamMessagerImpl) Receive(conn net.Conn, max, min int) (*FrameMessage, error)
430Mib
func (*StreamMessagerImpl) Send ¶
func (s *StreamMessagerImpl) Send(conn net.Conn, frame *FrameMessage) (int, error)
func (*StreamMessagerImpl) SetCrypt ¶
func (s *StreamMessagerImpl) SetCrypt(block *BlockCrypt)
type StreamSocket ¶
type StreamSocket struct {
Block *BlockCrypt
// contains filtered or unexported fields
}
func (*StreamSocket) IsOk ¶
func (t *StreamSocket) IsOk() bool
func (*StreamSocket) Key ¶
func (t *StreamSocket) Key() string
func (*StreamSocket) LocalAddr ¶
func (t *StreamSocket) LocalAddr() string
func (*StreamSocket) ReadMsg ¶
func (t *StreamSocket) ReadMsg() (*FrameMessage, error)
func (*StreamSocket) RemoteAddr ¶
func (t *StreamSocket) RemoteAddr() string
func (*StreamSocket) SetKey ¶
func (t *StreamSocket) SetKey(key string)
func (*StreamSocket) String ¶
func (t *StreamSocket) String() string
func (*StreamSocket) WriteMsg ¶
func (t *StreamSocket) WriteMsg(frame *FrameMessage) error
type SubLogger ¶
type SubLogger struct {
Prefix string
// contains filtered or unexported fields
}
func NewSubLogger ¶
type Tcp ¶
type Tcp struct {
Source uint16
Destination uint16
Sequence uint32
Acknowledgment uint32
DataOffset uint8
ControlBits uint8
Window uint16
Checksum uint16
UrgentPointer uint16
Options []byte
Padding []byte
Len int
Payload []byte
}
func NewTcpFromFrame ¶
type TcpClient ¶
type TcpClient struct {
*SocketClientImpl
// contains filtered or unexported fields
}
func NewTcpClient ¶
func (*TcpClient) SetStatus ¶
func (t *TcpClient) SetStatus(v SocketStatus)
type TcpServer ¶
type TcpServer struct {
*SocketServerImpl
// contains filtered or unexported fields
}
func NewTcpServer ¶
type Udp ¶
type Udp struct {
Source uint16
Destination uint16
Length uint16
Checksum uint16
Len int
Payload []byte
}
func NewUdpFromFrame ¶
type UdpClient ¶
type UdpClient struct {
*SocketClientImpl
// contains filtered or unexported fields
}
func NewUdpClient ¶
func (*UdpClient) SetStatus ¶
func (c *UdpClient) SetStatus(v SocketStatus)
type UdpServer ¶
type UdpServer struct {
*SocketServerImpl
// contains filtered or unexported fields
}
func NewUdpServer ¶
type Vlan ¶
func NewVlanFromFrame ¶
type WebClient ¶
type WebClient struct {
*SocketClientImpl
RdBuf int // per frames
WrBuf int // per frames
// contains filtered or unexported fields
}
func NewWebClient ¶
func (*WebClient) SetStatus ¶
func (t *WebClient) SetStatus(v SocketStatus)
type WebConfig ¶
type WebConfig struct {
Cert *CertConfig
Block *BlockCrypt
Timeout time.Duration // ns
RdQus int // per frames
WrQus int // per frames
}
type WebServer ¶
type WebServer struct {
*SocketServerImpl
// contains filtered or unexported fields
}
func NewWebServer ¶
type WsClient ¶
func (*WsClient) Initialize ¶
func (w *WsClient) Initialize()
type XDP ¶
type XDP struct {
// contains filtered or unexported fields
}
type XDPConn ¶
type XDPConn struct {
// contains filtered or unexported fields
}
func (*XDPConn) RemoteAddr ¶
Click to show internal directories.
Click to hide internal directories.