Documentation ¶
Overview ¶
Package tls provides tls connection utilities.
Index ¶
- func NewService(ln net.Listener, handler Handler, opts ...ServerOption) (tnet.Service, error)
- type ClientOption
- type Conn
- type Handler
- type OnClosed
- type OnOpened
- type ServerOption
- func WithOnClosed(onClosed OnClosed) ServerOption
- func WithOnOpened(onOpened OnOpened) ServerOption
- func WithServerFlushWrite(flushWrite bool) ServerOption
- func WithServerIdleTimeout(idleTimeout time.Duration) ServerOption
- func WithServerTLSConfig(cfg *tls.Config) ServerOption
- func WithTCPKeepAlive(keepAlive time.Duration) ServerOption
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewService ¶
NewService creates a new tls service.
Types ¶
type ClientOption ¶
type ClientOption func(*clientOptions)
ClientOption is the type for a single client option.
func WithClientFlushWrite ¶
func WithClientFlushWrite(flushWrite bool) ClientOption
WithClientFlushWrite sets the flush write flag for client connection.
func WithClientIdleTimeout ¶
func WithClientIdleTimeout(idleTimeout time.Duration) ClientOption
WithClientIdleTimeout sets the idle timeout to close the connection.
func WithClientTLSConfig ¶
func WithClientTLSConfig(cfg *tls.Config) ClientOption
WithClientTLSConfig provides the option to set TLS configuration.
func WithTimeout ¶
func WithTimeout(timeout time.Duration) ClientOption
WithTimeout provides the option to set dial timeout.
type Conn ¶
type Conn interface { net.Conn // SetMetaData sets meta data. Through this method, users can bind some custom data to a connection. SetMetaData(any) // GetMetaData gets meta data. GetMetaData() any // SetIdleTimeout sets connection level idle timeout. SetIdleTimeout(d time.Duration) error // SetFlushWrite sets flush write flag for the connection. SetFlushWrite(flushWrite bool) // SetOnRequest can set or replace the tls.Handler method for a connection. SetOnRequest(handle Handler) error // SetOnClosed sets the additional close process for a connection. SetOnClosed(handle Handler) error // IsActive checks whether the connection is active or not. IsActive() bool }
Conn defines tls connection interface.
type OnClosed ¶
OnClosed fires when the connection is closed. In this method, please do not perform read-write operations, because the connection has been closed. But you can still manipulate the MetaData in the connection.
type ServerOption ¶
type ServerOption func(*serverOptions)
ServerOption is the type for a single server option.
func WithOnClosed ¶
func WithOnClosed(onClosed OnClosed) ServerOption
WithOnClosed registers the OnClosed method that is fired when connection is closed.
func WithOnOpened ¶
func WithOnOpened(onOpened OnOpened) ServerOption
WithOnOpened registers the OnOpened method that is fired when connection is established.
func WithServerFlushWrite ¶
func WithServerFlushWrite(flushWrite bool) ServerOption
WithServerFlushWrite sets the flush write flag for server connection.
func WithServerIdleTimeout ¶
func WithServerIdleTimeout(idleTimeout time.Duration) ServerOption
WithServerIdleTimeout sets the idle timeout to close the connection.
func WithServerTLSConfig ¶
func WithServerTLSConfig(cfg *tls.Config) ServerOption
WithServerTLSConfig provides the option to set TLS configuration.
func WithTCPKeepAlive ¶
func WithTCPKeepAlive(keepAlive time.Duration) ServerOption
WithTCPKeepAlive sets the tcp keep alive interval.
Directories ¶
Path | Synopsis |
---|---|
examples
|
|
echo/client
Package main is the main package.
|
Package main is the main package. |
echo/server
Package main is the main package.
|
Package main is the main package. |