tcpproxy

package module
v0.1.3 Latest Latest
Warning

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

Go to latest
Published: Jun 12, 2023 License: MIT Imports: 4 Imported by: 2

README

tcpproxy

golangci-lint

Go TCP proxy. Wrapper arround https://github.com/inetaf/tcpproxy

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Proxy

type Proxy struct {
	Proxy     *tcpproxy.Proxy
	DialProxy *tcpproxy.DialProxy
	// contains filtered or unexported fields
}

Proxy is a TCP proxy. Wrapper around https://inet.af/tcpproxy

func New

func New(listenAddr string, toAddr string) *Proxy

New creates a new proxy instance.

func NewUnusedAddr

func NewUnusedAddr(listenHost string, toAddr string) (*Proxy, error)

NewUnusedAddr creates a new proxy instance on a unused random port.

func (*Proxy) Close

func (p *Proxy) Close() error

Close closes the TCP listener and closes all active connections.

func (*Proxy) CloseConnections

func (p *Proxy) CloseConnections()

CloseConnections closes the currently active connections.

func (*Proxy) HandleConn

func (p *Proxy) HandleConn(conn net.Conn)

HandleConn is used for hooking into inet.af/tcpproxy

func (*Proxy) ListenAddr

func (p *Proxy) ListenAddr() string

ListenAddr returns the listen address.

func (*Proxy) SetOnServerRead added in v0.1.3

func (p *Proxy) SetOnServerRead(onServerRead func(c net.Conn, b []byte) (n int, err error))

SetOnServerRead sets TCP connection Read interceptor. Called when client calls Write.

func (*Proxy) SetOnServerWrite added in v0.1.3

func (p *Proxy) SetOnServerWrite(onServerWrite func(c net.Conn, b []byte) (n int, err error))

SetOnServerWrite sets TCP connection Write interceptor. Called when client calls Read.

func (*Proxy) Start

func (p *Proxy) Start() error

Start starts the proxy.

Jump to

Keyboard shortcuts

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