msg

package
v3.0.0-beta.1 Latest Latest
Warning

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

Go to latest
Published: Apr 7, 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

func Initiate

func Initiate(c *net.UnixConn) error

Initiate sends "init" request to the child UNIX socket.

Types

type Reply

type Reply struct {
	Error string
}

Reply may contain FD as OOB

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