intra

package
v0.0.0-...-4cf4c4f Latest Latest
Warning

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

Go to latest
Published: Apr 24, 2022 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Listener

type Listener interface {
	UDPListener
	TCPListener
	doh.Listener
}

Listener receives usage statistics when a UDP or TCP socket is closed, or a DNS query is completed.

type TCPHandler

type TCPHandler interface {
	core.TCPConnHandler
	SetDNS(doh.Transport)
	SetAlwaysSplitHTTPS(bool)
	EnableSNIReporter(file io.ReadWriter, suffix, country string) error
}

TCPHandler is a core TCP handler that also supports DOH and splitting control.

func NewTCPHandler

func NewTCPHandler(fakedns net.TCPAddr, dialer *net.Dialer, listener TCPListener) TCPHandler

NewTCPHandler returns a TCP forwarder with Intra-style behavior. Connections to `fakedns` are redirected to DOH. All other traffic is forwarded using `dialer`. `listener` is provided with a summary of each socket when it is closed.

type TCPListener

type TCPListener interface {
	OnTCPSocketClosed(*TCPSocketSummary)
}

TCPListener is notified when a socket closes.

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 is non-nil if retry was possible.  Retry.Split is non-zero if a retry occurred.
	Retry *split.RetryStats
}

TCPSocketSummary provides information about each TCP socket, reported when it is closed.

type Tunnel

type Tunnel interface {
	tunnel.Tunnel
	// Get the DNSTransport (default: nil).
	GetDNS() doh.Transport
	// Set the DNSTransport.  This method must be called before connecting the transport
	// to the TUN device.  The transport can be changed at any time during operation, but
	// must not be nil.
	SetDNS(doh.Transport)
	// When set to true, Intra will pre-emptively split all HTTPS connections.
	SetAlwaysSplitHTTPS(bool)
	// Enable reporting of SNIs that resulted in connection failures, using the
	// Choir library for privacy-preserving error reports.  `file` is the path
	// that Choir should use to store its persistent state, `suffix` is the
	// authoritative domain to which reports will be sent, and `country` is a
	// two-letter ISO country code for the user's current location.
	EnableSNIReporter(file, suffix, country string) error
}

Tunnel represents an Intra session.

func NewTunnel

func NewTunnel(fakedns string, dohdns doh.Transport, tunWriter io.WriteCloser, dialer *net.Dialer, config *net.ListenConfig, listener Listener) (Tunnel, error)

NewTunnel creates a connected Intra session.

`fakedns` is the DNS server (IP and port) that will be used by apps on the TUN device.

This will normally be a reserved or remote IP address, port 53.

`udpdns` and `tcpdns` are the actual location of the DNS server in use.

These will normally be localhost with a high-numbered port.

`dohdns` is the initial DOH transport. `tunWriter` is the downstream VPN tunnel. IntraTunnel.Disconnect() will close `tunWriter`. `dialer` and `config` will be used for all network activity. `listener` will be notified at the completion of every tunneled socket.

type UDPHandler

type UDPHandler interface {
	core.UDPConnHandler
	SetDNS(dns doh.Transport)
}

UDPHandler adds DOH support to the base UDPConnHandler interface.

func NewUDPHandler

func NewUDPHandler(fakedns net.UDPAddr, timeout time.Duration, config *net.ListenConfig, listener UDPListener) UDPHandler

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 DOH. `timeout` controls the effective NAT mapping lifetime. `config` is used to bind new external UDP ports. `listener` receives a summary about each UDP binding when it expires.

type UDPListener

type UDPListener interface {
	OnUDPSocketClosed(*UDPSocketSummary)
}

UDPListener is notified when a non-DNS UDP association is discarded.

type UDPSocketSummary

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

UDPSocketSummary describes a non-DNS UDP association, reported when it is discarded.

Directories

Path Synopsis
doh

Jump to

Keyboard shortcuts

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