hostconn

package
v0.3.0 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func MarkSocket

func MarkSocket(raw syscall.RawConn, marker Marker) error

MarkSocket applies marker to the socket behind raw.

Types

type Guard

type Guard interface {
	CheckSocket(network, address string) error
}

Guard is the network policy decision a dialer applies to the address the operating system is about to connect to. It is the last gate in front of connect: returning an error from it means no packet is sent.

type HostConn

type HostConn struct {
	// contains filtered or unexported fields
}

func NewConnection

func NewConnection(ctx context.Context, pc ratelimit.PacketCount, id uuid.UUID, conn net.Conn, opts HostConnOpts) (_ *HostConn, err error)

NewConnection consumes conn. On failure it closes the attached wrapper (if available), otherwise the original connection. On success HostConn owns it. A failed close is attached with cleanup.Join, so cleanup.Released separates connection release failure from attach/limit failure without exposing a new guest ABI or conflating execution and cleanup.

func (*HostConn) Addr

func (h *HostConn) Addr() string

func (*HostConn) Close

func (h *HostConn) Close() error

func (*HostConn) Drain

func (h *HostConn) Drain(ctx context.Context)

func (*HostConn) Read

func (h *HostConn) Read(b []byte) (int, error)

func (*HostConn) RemoteAddr

func (h *HostConn) RemoteAddr() string

func (*HostConn) SetReadDeadline added in v0.3.0

func (h *HostConn) SetReadDeadline(t time.Time) error

func (*HostConn) SetWriteDeadline added in v0.3.0

func (h *HostConn) SetWriteDeadline(t time.Time) error

func (*HostConn) Type

func (h *HostConn) Type() socket.SocketType

func (*HostConn) Write

func (h *HostConn) Write(b []byte) (int, error)

type HostConnOpts

type HostConnOpts struct {
	Egress           *netpolicy.Egress
	ConnAddr         string
	MaximumBandwidth bitrate.Bitrate
	SocketType       socket.SocketType
}

type HostDialer

type HostDialer struct {
	// contains filtered or unexported fields
}

HostDialer dials a guest's connection under a Guard. It holds no policy of its own: everything it refuses, it refuses because the guard did.

func NewDialer

func NewDialer(guard Guard, marker Marker) (*HostDialer, error)

NewDialer returns a dialer that consults guard for every socket it opens and marks every admitted socket with marker before it is connected. A nil marker, including a nil tagger converted to a Marker, means no marking.

func (*HostDialer) Control

func (hd *HostDialer) Control(network, address string, raw syscall.RawConn) error

Control is the net.Dialer control hook. The operating system calls it with the resolved address after the socket exists and before it is connected, so a refusal here is a destination that was never contacted, and a mark set here covers the socket's first packet. A socket that cannot be marked is not connected.

func (*HostDialer) DialContext

func (hd *HostDialer) DialContext(ctx context.Context, network, address string) (net.Conn, error)

type Marker

type Marker interface {
	SetSocketMark(fd int) error
}

Marker puts a socket under a run's packet attribution.

Jump to

Keyboard shortcuts

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