server

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Sep 26, 2025 License: MIT Imports: 23 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func SendReply

func SendReply(w io.Writer, rep uint8, bindAddr net.Addr) error

Types

type GPool

type GPool interface {
	Submit(f func()) error
}

type Logger

type Logger interface {
	Errorf(format string, args ...interface{})
}

type Option

type Option func(s *Server)

func WithAssociateHandle

func WithAssociateHandle(h func(ctx context.Context, writer io.Writer, req *handler.Request) error) Option

func WithAssociateMiddleware

func WithAssociateMiddleware(m handler.Middleware) Option

func WithAuthMethods

func WithAuthMethods(authMethods []auth.Authenticator) Option

func WithBindAcceptTimeout

func WithBindAcceptTimeout(d time.Duration) Option

func WithBindHandle

func WithBindHandle(h func(ctx context.Context, writer io.Writer, req *handler.Request) error) Option

func WithBindIP

func WithBindIP(ip net.IP) Option

func WithBindMiddleware

func WithBindMiddleware(m handler.Middleware) Option

func WithBindPeerCheckIPOnly

func WithBindPeerCheckIPOnly(b bool) Option

func WithBufferPool

func WithBufferPool(pool buffer.BufPool) Option

func WithConnectHandle

func WithConnectHandle(h func(ctx context.Context, writer io.Writer, req *handler.Request) error) Option

func WithConnectMiddleware

func WithConnectMiddleware(m handler.Middleware) Option

func WithCredential

func WithCredential(cs auth.CredentialStore) Option

func WithDial

func WithDial(dial func(ctx context.Context, network, addr string) (net.Conn, error)) Option

func WithDialAndRequest

func WithDialAndRequest(dial func(ctx context.Context, network, addr string, req *handler.Request) (net.Conn, error)) Option

func WithDialer

func WithDialer(d net.Dialer) Option

WithDialer sets a custom net.Dialer for outbound connections when a custom dial is not provided.

func WithGPool

func WithGPool(pool GPool) Option

func WithHandshakeTimeout

func WithHandshakeTimeout(d time.Duration) Option

WithHandshakeTimeout sets a deadline for initial negotiation and request parsing. Zero disables the handshake deadline.

func WithLogger

func WithLogger(l Logger) Option

func WithResolver

func WithResolver(res resolver.NameResolver) Option

func WithRewriter

func WithRewriter(rew handler.AddressRewriter) Option

func WithRule

func WithRule(rule rules.RuleSet) Option

func WithTCPKeepAlive

func WithTCPKeepAlive(period time.Duration) Option

WithTCPKeepAlive enables TCP keepalives on accepted connections with the given period. Zero disables keepalives.

func WithUDPAssociateLimits

func WithUDPAssociateLimits(maxPeers int, idleTimeout time.Duration) Option

WithUDPAssociateLimits configures UDP ASSOCIATE peer limits and idle cleanup. If maxPeers <= 0, unlimited peers are allowed. If idleTimeout <= 0, peers are not GC'd by idle.

func WithUseBindIpBaseResolveAsUdpAddr

func WithUseBindIpBaseResolveAsUdpAddr(b bool) Option

type Server

type Server struct {
	// contains filtered or unexported fields
}

func New

func New(opts ...Option) *Server

func (*Server) ListenAndServe

func (sf *Server) ListenAndServe(network, addr string) error

func (*Server) ListenAndServeTLS

func (sf *Server) ListenAndServeTLS(network, addr string, c *tls.Config) error

func (*Server) Proxy

func (sf *Server) Proxy(dst io.Writer, src io.Reader) error

Proxy copies data from src to dst. It prefers optimized io.Copy paths (ReaderFrom/WriterTo) and uses the shared buffer pool for the generic copy case to avoid per-call allocations.

func (*Server) Serve

func (sf *Server) Serve(l net.Listener) error

func (*Server) ServeConn

func (sf *Server) ServeConn(conn net.Conn) error

type Std

type Std struct {
	*log.Logger
}

func NewLogger

func NewLogger(l *log.Logger) *Std

func (Std) Errorf

func (sf Std) Errorf(format string, args ...interface{})

Jump to

Keyboard shortcuts

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