Documentation
¶
Index ¶
- Constants
- Variables
- func SetTLSEngine(engine TLSEngine)
- type ATLSConn
- func NewATLSConnClient(ctx context.Context, fd int, cfg *tls.Config) (*ATLSConn, error)
- func NewATLSConnServer(ctx context.Context, fd int, cfg *tls.Config) (*ATLSConn, error)
- func NewPendingTLSServerConn(fd int, cfg *tls.Config, local, remote net.Addr) (*ATLSConn, error)
- func NewTLSConnClient(ctx context.Context, fd int, cfg *tls.Config) (*ATLSConn, error)
- func NewTLSConnServer(ctx context.Context, fd int, cfg *tls.Config) (*ATLSConn, error)
- func (c *ATLSConn) AcceptLoopID() int
- func (c *ATLSConn) BufferedPlaintextLen() int
- func (c *ATLSConn) Close() error
- func (c *ATLSConn) CompleteServerHandshake() error
- func (c *ATLSConn) ConnectionState() tls.ConnectionState
- func (c *ATLSConn) Destroy()
- func (c *ATLSConn) FlushN(maxBytes int) (int, error)
- func (c *ATLSConn) GetLocalAddr() string
- func (c *ATLSConn) GetRemoteAddr() string
- func (c *ATLSConn) GetType() int
- func (c *ATLSConn) HandshakeAt() time.Time
- func (c *ATLSConn) IsKTLS() bool
- func (c *ATLSConn) IsKTLSRX() bool
- func (c *ATLSConn) LocalAddr() net.Addr
- func (c *ATLSConn) OnData(in *[]byte) (out []byte, close bool)
- func (c *ATLSConn) Open()
- func (c *ATLSConn) ParsePacket(in *[]byte) (length, expect int)
- func (c *ATLSConn) PendingWrite() int
- func (c *ATLSConn) Read(b []byte) (int, error)
- func (c *ATLSConn) RemoteAddr() net.Addr
- func (c *ATLSConn) SetAcceptLoopID(loopID int)
- func (c *ATLSConn) SetCloseCB(cb CloseCb)
- func (c *ATLSConn) SetDeadline(t time.Time) error
- func (c *ATLSConn) SetLocal(addr net.Addr)
- func (c *ATLSConn) SetOpenCB(cb OpenCb)
- func (c *ATLSConn) SetReadDeadline(t time.Time) error
- func (c *ATLSConn) SetRemote(addr net.Addr)
- func (c *ATLSConn) SetWriteDeadline(t time.Time) error
- func (c *ATLSConn) Write(b []byte) (int, error)
- type AppConn
- type Base
- func (c *Base) AcceptAddr() string
- func (c *Base) AddCmd(cmd int, data []byte) error
- func (c *Base) Context() interface{}
- func (c *Base) EnqueueWrite(buf []byte, size int)
- func (c *Base) Fd() int
- func (c *Base) GetLastRecv() int64
- func (c *Base) GetListenerEndpoint() interface{}
- func (c *Base) GetPktHandler() IPktHandler
- func (c *Base) GetRecv(reset bool) int32
- func (c *Base) GetSend(reset bool) int32
- func (c *Base) ID() uint64
- func (c *Base) IsClient() bool
- func (c *Base) LoopID() int
- func (c *Base) PendingWrite() int
- func (c *Base) Recvbuf() *ringbuffer.RingBuffer
- func (c *Base) SetAcceptAddr(addr string)
- func (c *Base) SetContext(itf interface{})
- func (c *Base) SetFd(fd int)
- func (c *Base) SetID(id uint64)
- func (c *Base) SetLastRecv(ts int64)
- func (c *Base) SetListenerEndpoint(ep interface{})
- func (c *Base) SetLoopID(loopID int)
- func (c *Base) SetPktHandler(h IPktHandler)
- func (c *Base) SetReceiver(recv ICmdRecv)
- func (c *Base) SetRecvbuf(buf *ringbuffer.RingBuffer)
- func (c *Base) UpdatePktHandler(h IPktHandler)
- type CloseCb
- type Conn
- func (c *Conn) Close() error
- func (c *Conn) Destroy()
- func (c *Conn) FlushN(maxBytes int) (int, error)
- func (c *Conn) GetLocalAddr() string
- func (c *Conn) GetRemoteAddr() string
- func (c *Conn) GetType() int
- func (c *Conn) LocalAddr() net.Addr
- func (c *Conn) OnData(in *[]byte) (out []byte, close bool)
- func (c *Conn) Open()
- func (c *Conn) ParsePacket(in *[]byte) (length, expect int)
- func (c *Conn) Read(b []byte) (int, error)
- func (c *Conn) RemoteAddr() net.Addr
- func (c *Conn) SetCloseCB(cb CloseCb)
- func (c *Conn) SetDeadline(t time.Time) error
- func (c *Conn) SetLocal(addr net.Addr)
- func (c *Conn) SetOpenCB(cb OpenCb)
- func (c *Conn) SetReadDeadline(t time.Time) error
- func (c *Conn) SetRemote(addr net.Addr)
- func (c *Conn) SetWriteDeadline(t time.Time) error
- func (c *Conn) Write(b []byte) (int, error)
- type EngineConn
- type ICmdRecv
- type IPktHandler
- type ITimerWatcher
- type OpenCb
- type ProtoConn
- type TLSEngine
Constants ¶
const ( TYPE_CONN = iota TYPE_CONN_OPENSSL TYPE_CONN_TLS )
const ( CMD_NOP = iota CMD_DATA CMD_CLOSE )
Variables ¶
var KTLSClientPostHandshakeReadMaxBytes = 64 * 1024
KTLSClientPostHandshakeReadMaxBytes caps buffered app data during ticket drain.
var KTLSClientPostHandshakeTimeout = 10 * time.Millisecond
KTLSClientPostHandshakeTimeout is the max time to wait for TLS1.3 tickets.
var KTLSDisableSessionTickets = false
KTLSDisableSessionTickets disables TLS session tickets when kTLS is enabled.
var KTLSEnableRX = false
KTLSEnableRX controls whether kTLS RX is enabled.
var KTLSForceTLS13AESGCM = true
KTLSForceTLS13AESGCM restricts TLS1.3 cipher suites to AES-GCM.
var KTLSPreferTLS12IfNoAESGCM = true
KTLSPreferTLS12IfNoAESGCM forces TLS1.2 when client doesn't advertise TLS1.3 AES-GCM.
var TlsHandshakeTimeout = 1 * time.Second
Functions ¶
func SetTLSEngine ¶
func SetTLSEngine(engine TLSEngine)
Types ¶
type ATLSConn ¶
ATLSConn is a non-blocking async TLS connection integrated with the event loop. The TLS handshake is completed before the connection is added to the loop.
func NewATLSConnClient ¶
func NewATLSConnServer ¶
func NewPendingTLSServerConn ¶
func NewTLSConnClient ¶
func NewTLSConnServer ¶
func (*ATLSConn) AcceptLoopID ¶
func (*ATLSConn) BufferedPlaintextLen ¶
func (*ATLSConn) CompleteServerHandshake ¶
func (*ATLSConn) ConnectionState ¶
func (c *ATLSConn) ConnectionState() tls.ConnectionState
func (*ATLSConn) GetLocalAddr ¶
func (*ATLSConn) GetRemoteAddr ¶
func (*ATLSConn) HandshakeAt ¶
func (*ATLSConn) ParsePacket ¶
func (*ATLSConn) PendingWrite ¶
func (*ATLSConn) RemoteAddr ¶
func (*ATLSConn) SetAcceptLoopID ¶
func (*ATLSConn) SetCloseCB ¶
type AppConn ¶
type AppConn interface {
ID() uint64
Context() interface{}
SetContext(interface{})
Close() error
AddCmd(cmd int, data []byte) error
LocalAddr() net.Addr
RemoteAddr() net.Addr
GetLocalAddr() string
GetRemoteAddr() string
IsClient() bool
}
AppConn is the application-facing connection surface. Keep this interface narrow for handlers/business code.
type Base ¶
type Base struct {
Client bool
// contains filtered or unexported fields
}
Conn ...
func (*Base) AcceptAddr ¶
func (*Base) EnqueueWrite ¶
EnqueueWrite enqueues a buffer for writev flush.
func (*Base) GetLastRecv ¶
func (*Base) GetListenerEndpoint ¶
func (c *Base) GetListenerEndpoint() interface{}
func (*Base) GetPktHandler ¶
func (c *Base) GetPktHandler() IPktHandler
func (*Base) PendingWrite ¶
PendingWrite returns total pending bytes in the write queue.
func (*Base) Recvbuf ¶
func (c *Base) Recvbuf() *ringbuffer.RingBuffer
func (*Base) SetAcceptAddr ¶
func (*Base) SetContext ¶
func (c *Base) SetContext(itf interface{})
func (*Base) SetLastRecv ¶
func (*Base) SetListenerEndpoint ¶
func (c *Base) SetListenerEndpoint(ep interface{})
func (*Base) SetPktHandler ¶
func (c *Base) SetPktHandler(h IPktHandler)
func (*Base) SetReceiver ¶
func (*Base) SetRecvbuf ¶
func (c *Base) SetRecvbuf(buf *ringbuffer.RingBuffer)
func (*Base) UpdatePktHandler ¶
func (c *Base) UpdatePktHandler(h IPktHandler)
type Conn ¶
type Conn struct {
Base
// contains filtered or unexported fields
}
Conn ...
func (*Conn) GetLocalAddr ¶
func (*Conn) GetRemoteAddr ¶
func (*Conn) ParsePacket ¶
func (*Conn) RemoteAddr ¶
func (*Conn) SetCloseCB ¶
type EngineConn ¶
type EngineConn interface {
ProtoConn
Fd() int
LoopID() int
Recvbuf() *ringbuffer.RingBuffer
GetType() int
FlushN(maxBytes int) (int, error)
PendingWrite() int
SetID(id uint64)
SetLoopID(loopID int)
SetReceiver(recv ICmdRecv)
Destroy()
SetAcceptAddr(string)
Open()
Read(b []byte) (int, error)
Write(b []byte) (int, error)
AcceptAddr() string
SetDeadline(t time.Time) error
SetReadDeadline(t time.Time) error
SetWriteDeadline(t time.Time) error
SetRemote(addr net.Addr)
SetLocal(addr net.Addr)
ParsePacket(in *[]byte) (length, expect int)
OnData(in *[]byte) (out []byte, close bool)
EnqueueWrite(buf []byte, size int)
GetSend(reset bool) int32
GetRecv(reset bool) int32
SetLastRecv(ts int64)
GetLastRecv() int64
SetListenerEndpoint(interface{})
GetListenerEndpoint() interface{}
}
EngineConn is the full engine/internal connection surface. It should only be consumed by eventloop/engine internals.
type IPktHandler ¶
type IPktHandler interface {
// ParsePacket returns:
// - length > 0: a complete packet of "length" bytes is available at (*in)[:length]
// - length == 0: need more data (partial packet)
// - length < 0: fatal parse error (connection will be closed)
// expect is a hint of the expected total packet size (or -1 if unknown).
ParsePacket(c ProtoConn, in *[]byte) (length, expect int)
OnData(c ProtoConn, in *[]byte) (out []byte, close bool)
Stat(bool)
}
type ITimerWatcher ¶
type ProtoConn ¶
type ProtoConn interface {
AppConn
SetPktHandler(h IPktHandler)
UpdatePktHandler(h IPktHandler)
GetPktHandler() IPktHandler
}
ProtoConn is the protocol-facing connection surface. It extends AppConn with packet-handler routing APIs.
type TLSEngine ¶
type TLSEngine int
func GetTLSEngine ¶
func GetTLSEngine() TLSEngine
func ResolveTLSEngine ¶
ResolveTLSEngine selects the effective TLS engine. requested values: "atls" (default) and "ktls".