tproxy

package
v0.0.0-...-ab8fcfb Latest Latest
Warning

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

Go to latest
Published: Apr 10, 2020 License: GPL-3.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

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 ListenTCP

func ListenTCP(network string, laddr *net.TCPAddr) (net.Listener, error)

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

func ListenUDP

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

ListenUDP will construct a new UDP listener socket with the Linux IP_TRANSPARENT option set on the underlying socket

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 Conn

type Conn struct {
	*net.TCPConn
}

Conn describes a connection accepted by the TProxy listener.

It is simply a TCP connection with the ability to dial a connection to the original destination while assuming the IP address of the client

func (*Conn) DialOriginalDestination

func (conn *Conn) DialOriginalDestination(dontAssumeRemote bool) (*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 `dontAssumeRemote` is false, the connection will originate from the IP address and port that the client used when making the connection. 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

type Listener

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

Listener describes a TCP Listener with the Linux IP_TRANSPARENT option defined on the listening socket

func (*Listener) Accept

func (listener *Listener) Accept() (net.Conn, error)

Accept waits for and returns the next connection to the listener.

This command wraps the AcceptTProxy method of the Listener

func (*Listener) AcceptTProxy

func (listener *Listener) AcceptTProxy() (*Conn, error)

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

func (*Listener) Addr

func (listener *Listener) Addr() net.Addr

Addr returns the network address the listener is accepting connections from

func (*Listener) Close

func (listener *Listener) Close() error

Close will close the listener from accepting any more connections. Any blocked connections will unblock and close

Jump to

Keyboard shortcuts

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