tproxy

package
v0.3.1 Latest Latest
Warning

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

Go to latest
Published: Aug 20, 2023 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const (
	IPV6_TRANSPARENT     = 75
	IPV6_RECVORIGDSTADDR = 74
)
View Source
const (
	// UDPConnTrackTimeout is the timeout used for UDP connection tracking
	UDPConnTrackTimeout = 90 * time.Second
	// UDPBufSize is the buffer size for the UDP proxy
	UDPBufSize = 65507
)
View Source
const (
	DefaultDialTimeout = 10 * time.Second
)

Variables

This section is empty.

Functions

func DialUDP

func DialUDP(network string, laddr *net.UDPAddr, raddr *net.UDPAddr) (*net.UDPConn, error)

DialUDP connects to the remote address raddr on the network net, which must be "udp", "udp4", or "udp6". If laddr is not nil, it is used as the local address for the connection.

func ReadFromUDP

func ReadFromUDP(conn *net.UDPConn, b []byte) (int, *net.UDPAddr, *net.UDPAddr, error)

ReadFromUDP reads a UDP packet from c, copying the payload into b. It returns the number of bytes copied into b and the return address that was on the packet.

Out-of-band data is also read in so that the original destination address can be identified and parsed.

Types

type Config

type Config struct {
	ListenAddr  netip.AddrPort
	Mapper      Mapper
	DialTimeout time.Duration
	Dialer      Dialer
}

type Dialer

type Dialer interface {
	DialContext(ctx context.Context, network, address string) (net.Conn, error)
}

type EOFSender

type EOFSender interface {
	CloseWrite() error
}

type Mapper

type Mapper interface {
	ReverseLookup(clientKey string, addr netip.Addr) (domainName string, ok bool, err error)
}

type RawConnContainer

type RawConnContainer interface {
	Raw() net.Conn
}

type TCPProxy

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

func NewTCPProxy

func NewTCPProxy(ctx context.Context, cfg *Config) (*TCPProxy, error)

type UDPProxy

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

func NewUDPProxy

func NewUDPProxy(ctx context.Context, cfg *Config) (*UDPProxy, error)

func (*UDPProxy) Close

func (proxy *UDPProxy) Close()

Close stops forwarding the traffic.

Jump to

Keyboard shortcuts

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