msg

package
v3.2.0 Latest Latest
Warning

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

Go to latest
Published: Sep 19, 2026 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	RequestTypeInit    = "init"
	RequestTypeConnect = "connect"
)

Variables

This section is empty.

Functions

func ConnectToChild

func ConnectToChild(c *net.UnixConn, spec port.Spec, sourceAddr net.Addr) (int, error)

ConnectToChild connects to the child UNIX socket, and obtains TCP or UDP socket FD that corresponds to the port spec. sourceAddr is the real client address (e.g., from net.Conn.RemoteAddr()) for IP_TRANSPARENT support. Pass nil to skip source IP preservation.

func ConnectToChildWithRetry

func ConnectToChildWithRetry(socketPath string, spec port.Spec, retries int, sourceAddr net.Addr) (int, error)

ConnectToChildWithRetry retries ConnectToChild every (i*5) milliseconds.

func ConnectToChildWithSocketPath

func ConnectToChildWithSocketPath(socketPath string, spec port.Spec, sourceAddr net.Addr) (int, error)

ConnectToChildWithSocketPath wraps ConnectToChild

Types

type Reply

type Reply struct {
	Error string
	// SourceIPTransparentBackend is set in the reply to an "init" request:
	// the firewall backend ("nft" or "iptables") that was actually set up
	// for --source-ip-transparent, resolved eagerly at init time. Empty if
	// --source-ip-transparent is disabled, or if no backend could be set up.
	SourceIPTransparentBackend string `json:",omitempty"`
}

Reply may contain FD as OOB

func Initiate

func Initiate(c *net.UnixConn) (*Reply, error)

Initiate sends "init" request to the child UNIX socket, and returns the child's reply (which reports the resolved source-IP-transparent backend, if any).

type Request

type Request struct {
	Type          string // "init" or "connect"
	Proto         string // "tcp", "tcp4", "tcp6", "udp", "udp4", "udp6"
	IP            string
	Port          int
	ParentIP      string
	HostGatewayIP string
	SourceIP      string `json:",omitempty"` // real client IP for IP_TRANSPARENT
	SourcePort    int    `json:",omitempty"` // real client port for IP_TRANSPARENT
}

Request and Response are encoded as JSON with uint32le length header.

Jump to

Keyboard shortcuts

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