Documentation
¶
Index ¶
- Constants
- func DialWithOptionsReturnConn(ctx context.Context, network, laddr, raddr string, block cipher.BlockCipher) (net.Conn, error)
- type TCPSession
- type TCPSessionListener
- func (l *TCPSessionListener) Accept() (net.Conn, error)
- func (l *TCPSessionListener) Addr() net.Addr
- func (l *TCPSessionListener) Close() error
- func (l *TCPSessionListener) SetSuppressFirstNError(n int)
- func (l *TCPSessionListener) Start()
- func (l *TCPSessionListener) WrapConn(conn net.Conn) net.Conn
Constants ¶
const ( // MaxPayloadSize is the maximum size of a single TCP payload // before encryption. It may include a padding inside. MaxPayloadSize = 1024 * 16 // PayloadOverhead is the overhead of decrypted payload. // This overhead contains 2 bytes of useful payload length and 2 bytes of // useful + padding payload length. PayloadOverhead = 4 )
Variables ¶
This section is empty.
Functions ¶
func DialWithOptionsReturnConn ¶
func DialWithOptionsReturnConn(ctx context.Context, network, laddr, raddr string, block cipher.BlockCipher) (net.Conn, error)
DialWithOptionsReturnConn calls DialWithOptions and returns a generic net.Conn.
Types ¶
type TCPSession ¶
type TCPSession struct { net.Conn // the network connection associated to the TCPSession // contains filtered or unexported fields }
TCPSession defines a TCP session.
func DialWithOptions ¶
func DialWithOptions(ctx context.Context, network, laddr, raddr string, block cipher.BlockCipher) (*TCPSession, error)
DialWithOptions connects to the remote address "raddr" on the network "tcp" with packet encryption. If "laddr" is empty, an automatic address is used. "block" is the block encryption algorithm to encrypt packets.
func (*TCPSession) Close ¶
func (s *TCPSession) Close() error
Close overrides the Close() method in the net.Conn interface.
func (*TCPSession) Read ¶
func (s *TCPSession) Read(b []byte) (n int, err error)
Read overrides the Read() method in the net.Conn interface.
func (*TCPSession) SetSuppressFirstNError ¶
func (s *TCPSession) SetSuppressFirstNError(n int)
SetSuppressFirstNError suppress the first N I/O error before return the error to caller.
type TCPSessionListener ¶
func ListenWithOptions ¶
ListenWithOptions creates a new TCPSession listener.
func (*TCPSessionListener) Accept ¶
func (l *TCPSessionListener) Accept() (net.Conn, error)
Accept implements the Accept() method in the net.Listener interface.
func (*TCPSessionListener) Addr ¶
func (l *TCPSessionListener) Addr() net.Addr
Addr returns the listener's network address.
func (*TCPSessionListener) Close ¶
func (l *TCPSessionListener) Close() error
Close closes the session manager.
func (*TCPSessionListener) SetSuppressFirstNError ¶
func (l *TCPSessionListener) SetSuppressFirstNError(n int)
SetSuppressFirstNError suppress the first N I/O error in subsequent created TCP connections before return the error to caller.
func (*TCPSessionListener) Start ¶
func (l *TCPSessionListener) Start()
Start starts to accept incoming TCP connections.