tcp

package
v2.9.5+incompatible Latest Latest
Warning

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

Go to latest
Published: Mar 31, 2021 License: MPL-2.0 Imports: 11 Imported by: 9

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsSocketClosed

func IsSocketClosed(err error) bool

IsSocketClosed returns true if err is a result of reading from closed network connection

Types

type ConnState

type ConnState uint
const (
	Active ConnState = iota
	Open
	Closed
)

type Modifier

type Modifier struct {
	ModifyRequest  func(src, dst net.Conn, data []byte) ([]byte, error)
	ModifyResponse func(src, dst net.Conn, data []byte) ([]byte, error)
}

Modifier define rules for tranforming incoming and outcoming TCP messages To filter response set data to empty To close connection, return error

type Proxy

type Proxy struct {
	sync.RWMutex

	DialTLS         func(network, addr string) (net.Conn, error)
	Dial            func(network, addr string) (net.Conn, error)
	TLSConfigTarget *tls.Config

	ReadTimeout  time.Duration
	WriteTimeout time.Duration

	SyncStats func(Stat)
	// Duration in which connection stats will be flushed. Defaults to one second.
	StatsSyncInterval time.Duration
	// contains filtered or unexported fields
}

func (*Proxy) AddDomainHandler

func (p *Proxy) AddDomainHandler(domain, target string, modifier *Modifier)

func (*Proxy) RemoveDomainHandler

func (p *Proxy) RemoveDomainHandler(domain string)

func (*Proxy) Serve

func (p *Proxy) Serve(l net.Listener) error

func (*Proxy) Swap

func (p *Proxy) Swap(new *Proxy)

type Stat

type Stat struct {
	State    ConnState
	BytesIn  int64
	BytesOut int64
}

Stat defines basic statistics about a tcp connection

func (*Stat) Flush

func (s *Stat) Flush() Stat

Jump to

Keyboard shortcuts

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