tcp

package
v1.5.9 Latest Latest
Warning

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

Go to latest
Published: May 16, 2018 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Handler

type Handler interface {
	ServeTCP(in net.Conn) error
}

Handler responds to a TCP request.

ServeTCP should write responses to the in connection and close it on return.

type HandlerFunc

type HandlerFunc func(in net.Conn) error

func (HandlerFunc) ServeTCP

func (f HandlerFunc) ServeTCP(in net.Conn) error

type Proxy

type Proxy struct {
	// DialTimeout sets the timeout for establishing the outbound
	// connection.
	DialTimeout time.Duration

	// Lookup returns a target host for the given request.
	// The proxy will panic if this value is nil.
	Lookup func(host string) *route.Target

	// Conn counts the number of connections.
	Conn metrics.Counter

	// ConnFail counts the failed upstream connection attempts.
	ConnFail metrics.Counter

	// Noroute counts the failed Lookup() calls.
	Noroute metrics.Counter
}

Proxy implements a generic TCP proxying handler.

func (*Proxy) ServeTCP

func (p *Proxy) ServeTCP(in net.Conn) error

type SNIProxy

type SNIProxy struct {
	// DialTimeout sets the timeout for establishing the outbound
	// connection.
	DialTimeout time.Duration

	// Lookup returns a target host for the given server name.
	// The proxy will panic if this value is nil.
	Lookup func(host string) *route.Target

	// Conn counts the number of connections.
	Conn metrics.Counter

	// ConnFail counts the failed upstream connection attempts.
	ConnFail metrics.Counter

	// Noroute counts the failed Lookup() calls.
	Noroute metrics.Counter
}

SNIProxy implements an SNI aware transparent TCP proxy which captures the TLS client hello, extracts the host name and uses it for finding the upstream server. Then it replays the ClientHello message and copies data transparently allowing to route a TLS connection based on the SNI header without decrypting it.

func (*SNIProxy) ServeTCP

func (p *SNIProxy) ServeTCP(in net.Conn) error

type Server

type Server struct {
	Addr         string
	Handler      Handler
	ReadTimeout  time.Duration
	WriteTimeout time.Duration
	// contains filtered or unexported fields
}

Server implements a generic TCP server.

func (*Server) Close

func (s *Server) Close() error

func (*Server) ListenAndServe

func (s *Server) ListenAndServe() error

func (*Server) ListenAndServeTLS

func (s *Server) ListenAndServeTLS(certFile, keyFile string) error

func (*Server) Serve

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

func (*Server) Shutdown

func (s *Server) Shutdown(ctx context.Context) error

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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