hostconn

package
v0.2.0-rc.1 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CleanupError

func CleanupError(err error) error

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.

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) Type

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

func (*HostConn) Write

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

type HostConnOpts

type HostConnOpts struct {
	ConnAddr         string
	MaximumBandwidth app.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) (*HostDialer, error)

NewDialer returns a dialer that consults guard for every socket it opens.

func (*HostDialer) Control

func (hd *HostDialer) Control(network, address string, _ 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.

func (*HostDialer) DialContext

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

Jump to

Keyboard shortcuts

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