tproxy

package
v0.0.0-...-9c75cda Latest Latest
Warning

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

Go to latest
Published: Sep 8, 2024 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	SO_ORIGINAL_DST      = 80
	IP6T_SO_ORIGINAL_DST = 80
)

Variables

This section is empty.

Functions

func AcceptTProxy

func AcceptTProxy(l *net.TCPListener) (*net.TCPConn, error)

AcceptTProxy will accept a TCP connection and wrap it to a TProxy connection to provide TProxy functionality

func DialOriginalDestination

func DialOriginalDestination(remote, local *net.TCPAddr) (*net.TCPConn, error)

DialOriginalDestination will open a TCP connection to the original destination that the client was trying to connect to before being intercepted.

When local is nil, the connection will originate from local, which can be the IP address and port that the client used when making the connection with TProxy. Otherwise, when true, the connection will originate from an IP address and port assigned by the Linux kernel that is owned by the operating system

remoteSocketAddress in TProxy case is the localAddr of the tproxy - original destination. localSocketAddress in TProxy is the local IP - to preserve port

func GetREDIRECTOriginalDst

func GetREDIRECTOriginalDst(clientConn *net.TCPConn) (rawaddr *net.TCPAddr, err error)

Should be used only for REDIRECT capture.

func IptablesCapture

func IptablesCapture(ctx context.Context, addr string, ug func(nc net.Conn, dest, la *net.TCPAddr)) (*net.TCPListener, error)

func ListenTProxy

func ListenTProxy(ctx context.Context, network string, laddr *net.TCPAddr) (*net.TCPListener, error)

ListenTProxy will construct a new TCP listener socket with the Linux IP_TRANSPARENT option set on the underlying socket

Types

This section is empty.

Jump to

Keyboard shortcuts

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