intra

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Aug 7, 2019 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewTCPHandler

func NewTCPHandler(fakedns, truedns net.Addr, listener TCPListener) core.TCPConnHandler

NewTCPHandler returns a TCP forwarder with Intra-style behavior. Currently this class only redirects DNS traffic to a specified server. (This should be rare for TCP.) All other traffic is forwarded unmodified.

func NewUDPHandler

func NewUDPHandler(fakedns, truedns net.Addr, timeout time.Duration, listener UDPListener) core.UDPConnHandler

NewUDPHandler makes a UDP handler with Intra-style DNS redirection: All packets are routed directly to their destination, except packets whose destination is `fakedns`. Those packets are redirected to `truedns`. Similarly, packets arriving from `truedns` have the source address replaced with `fakedns`.

Types

type DuplexConn

type DuplexConn interface {
	io.ReadWriter
	io.ReaderFrom
	CloseWrite() error
	CloseRead() error
}

func DialWithSplitRetry

func DialWithSplitRetry(network string, addr *net.TCPAddr, summary *TCPSocketSummary) (DuplexConn, error)

DialWithSplitRetry returns a TCP connection that transparently retries by splitting the initial upstream segment if the socket closes without receiving a reply. Like net.Conn, it is intended for two-threaded use, with one thread calling Read and CloseRead, and another calling Write, ReadFrom, and CloseWrite.

type RetryStats

type RetryStats struct {
	Bytes   int32 // Number of bytes uploaded before the retry.
	Chunks  int16 // Number of writes before the retry.
	Split   int16 // Number of bytes in the first retried segment.
	Timeout bool  // True if the retry was caused by a timeout.
}

type TCPListener

type TCPListener interface {
	OnTCPSocketClosed(*TCPSocketSummary)
}

type TCPSocketSummary

type TCPSocketSummary struct {
	DownloadBytes int64       // Total bytes downloaded.
	UploadBytes   int64       // Total bytes uploaded.
	Duration      int32       // Duration in seconds.
	ServerPort    int16       // The server port.  All values except 80, 443, and 0 are set to -1.
	Synack        int32       // TCP handshake latency (ms)
	Retry         *RetryStats // Non-nil if a retry occurred.
}

Usage summary for each TCP socket, reported when it is closed.

type UDPListener

type UDPListener interface {
	OnUDPSocketClosed(*UDPSocketSummary)
}

type UDPSocketSummary

type UDPSocketSummary struct {
	UploadBytes   int64 // Amount uploaded (bytes)
	DownloadBytes int64 // Amount downloaded (bytes)
	Duration      int32 // How long the socket was open (seconds)
}

Summary of a non-DNS UDP association, reported when it is discarded.

Jump to

Keyboard shortcuts

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