Documentation ¶
Index ¶
- func NewTCPHandler(fakedns, truedns net.Addr, listener TCPListener) core.TCPConnHandler
- func NewUDPHandler(fakedns, truedns net.Addr, timeout time.Duration, listener UDPListener) core.UDPConnHandler
- type DuplexConn
- type RetryStats
- type TCPListener
- type TCPSocketSummary
- type UDPListener
- type UDPSocketSummary
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 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.