Documentation ¶
Index ¶
- func CloseConn(conn *net.TCPConn)
- func DialIPWithPortAndGetReply(ip net.IP, port uint16) (string, error)
- func DialTCPAddrAndGetReply(address *net.TCPAddr) (string, error)
- func GenRandomAddressIPv4(port uint16) *net.TCPAddr
- func GenRandomAddressIPv6(port uint16) *net.TCPAddr
- func ReplyWith(msg string) func(conn *net.TCPConn)
- func ReplyWithOriginalDstIPv4(conn *net.TCPConn)
- func ReplyWithOriginalDstIPv6(conn *net.TCPConn)
- func UnsafeStartTCPServer(ns *netns.NetNS, address string, callbacks ...func(conn *net.TCPConn)) (<-chan struct{}, <-chan error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GenRandomAddressIPv4 ¶
GenRandomAddressIPv4 will generate random *net.TCPAddr (IPv4) with provided port
func GenRandomAddressIPv6 ¶
GenRandomAddressIPv6 will generate random *net.TCPAddr (IPv6) with provided port
func ReplyWith ¶
ReplyWith will return a function which will send to provided *net.TCPConn the message (string) from closure which was provided as a parameter to ReplyWith function
func ReplyWithOriginalDstIPv4 ¶
ReplyWithOriginalDstIPv4 will try to extract original destination from the IPv4 socket of the provided *net.TCPConn and send it back as a []byte, if the extraction will fail, the *net.TCPConn will receive error message as []byte instead
func ReplyWithOriginalDstIPv6 ¶
ReplyWithOriginalDstIPv6 will try to extract original destination from the IPv6 socket of the provided *net.TCPConn and send it back as a []byte, if the extraction will fail, the *net.TCPConn will receive error message as []byte instead
func UnsafeStartTCPServer ¶
func UnsafeStartTCPServer( ns *netns.NetNS, address string, callbacks ...func(conn *net.TCPConn), ) (<-chan struct{}, <-chan error)
UnsafeStartTCPServer will start TCP server in provided *netns.NesNS. Every initialized tcp connection will be processed via provided callback functions. It was named UnsafeStartTCPServer instead of StartTCPServer because you have to be very cautious and remember to not spawn new goroutines inside provided callbacks (more info in warning below)
WARNING!:
Don't spawn new goroutines inside callback functions as the goroutine inside UnsafeStartTCPServer function have exclusive access to the current network namespace, and you should assume, that any new goroutine will be placed in a different namespace
Types ¶
This section is empty.