Documentation
¶
Index ¶
- Constants
- Variables
- func ParsePortRanges(spec string) ([]int, error)
- type Budget
- type DescriptorBudget
- type GenericSocket
- func (s *GenericSocket) Addr() string
- func (s *GenericSocket) Close() error
- func (s *GenericSocket) Read(b []byte) (int, error)
- func (s *GenericSocket) RemoteAddr() string
- func (s *GenericSocket) SetReadDeadline(t time.Time) error
- func (s *GenericSocket) SetWriteDeadline(t time.Time) error
- func (s *GenericSocket) Type() SocketType
- func (s *GenericSocket) Write(b []byte) (int, error)
- type ISocketRegistry
- type Limits
- type PathSelector
- func (s *PathSelector) Close() error
- func (s *PathSelector) ForcePath(i int)
- func (s *PathSelector) Initialize(local, remote pan.UDPAddr, paths []*pan.Path)
- func (s *PathSelector) Path() *pan.Path
- func (s *PathSelector) PathDown(pf pan.PathFingerprint, pi pan.PathInterface)
- func (s *PathSelector) Paths() []*pan.Path
- func (s *PathSelector) Refresh(paths []*pan.Path)
- type PortManager
- func (s *PortManager) Enabled() bool
- func (s *PortManager) ListenTCP(control func(network, address string, c syscall.RawConn) error) (*net.TCPListener, int, string, error)
- func (s *PortManager) ListenTCP4(control func(network, address string, c syscall.RawConn) error) (*net.TCPListener, int, string, error)
- func (s *PortManager) ListenUDP(control func(network, address string, c syscall.RawConn) error) (*net.UDPConn, int, string, error)
- func (s *PortManager) ListenUDP4(control func(network, address string, c syscall.RawConn) error) (*net.UDPConn, int, string, error)
- func (s *PortManager) PublicHost() string
- func (s *PortManager) Release(port int)
- type Reservation
- type SCIONConn
- type SCIONConnRegistry
- type Socket
- type SocketRegistry
- func (r *SocketRegistry) Add(s Socket) (int32, error)
- func (r *SocketRegistry) AddReserved(s Socket, reservation *SocketReservation) (int32, error)
- func (r *SocketRegistry) All() []Socket
- func (r *SocketRegistry) Close(handle int32) error
- func (r *SocketRegistry) CloseAll() error
- func (r *SocketRegistry) CloseRemote(match func(remote string) bool) int
- func (r *SocketRegistry) Get(handle int32) (Socket, error)
- func (r *SocketRegistry) Reserve(descriptors int) (*SocketReservation, error)
- type SocketReservation
- type SocketType
Constants ¶
const ( DefaultLiveSockets = 64 DefaultListeners = 3 DefaultSocketAttempts = 4096 DefaultNodeDescriptors = 1024 )
Variables ¶
var ErrQuota = errors.New("guest socket quota exceeded")
var ErrRevoked = fmt.Errorf("destination revoked: %w", net.ErrClosed)
ErrRevoked is what a socket closed because its destination was denied reports. It is a closed socket to the guest, as a lost connection is.
Functions ¶
func ParsePortRanges ¶
ParsePortRanges expands "2022,2025-3005,56000-62000" into a deduped, ordered []int. Each port must satisfy 1 <= p <= 65535 and range start <= end. Empty string yields an empty list with no error.
Types ¶
type Budget ¶ added in v0.3.0
type Budget struct {
// contains filtered or unexported fields
}
Budget belongs to one run. Limits are fixed at construction.
func NewBudget ¶ added in v0.3.0
func NewBudget(limits Limits, node *DescriptorBudget) *Budget
func (*Budget) ReserveListener ¶ added in v0.3.0
func (b *Budget) ReserveListener() (*Reservation, error)
func (*Budget) ReserveSocket ¶ added in v0.3.0
func (b *Budget) ReserveSocket(descriptors int) (*Reservation, error)
type DescriptorBudget ¶ added in v0.3.0
type DescriptorBudget struct {
// contains filtered or unexported fields
}
DescriptorBudget is shared by every run and control session on one node. It counts guest socket reservations, not the process's complete descriptor table. Control transports do not acquire from this budget.
func NewDescriptorBudget ¶ added in v0.3.0
func NewDescriptorBudget(limit int) *DescriptorBudget
type GenericSocket ¶
type GenericSocket struct {
// contains filtered or unexported fields
}
func NewGenericSocket ¶
func NewGenericSocket(conn net.Conn, socketType SocketType, addr string) *GenericSocket
func (*GenericSocket) Addr ¶
func (s *GenericSocket) Addr() string
func (*GenericSocket) Close ¶
func (s *GenericSocket) Close() error
func (*GenericSocket) RemoteAddr ¶
func (s *GenericSocket) RemoteAddr() string
func (*GenericSocket) SetReadDeadline ¶ added in v0.3.0
func (s *GenericSocket) SetReadDeadline(t time.Time) error
func (*GenericSocket) SetWriteDeadline ¶ added in v0.3.0
func (s *GenericSocket) SetWriteDeadline(t time.Time) error
func (*GenericSocket) Type ¶
func (s *GenericSocket) Type() SocketType
type ISocketRegistry ¶
type Limits ¶ added in v0.3.0
Limits bound a run's live connections, listeners and lifetime connection attempts. Failed dial/accept attempts count once admitted; closing a socket returns live capacity but never resets the lifetime budget or its handle.
func DefaultLimits ¶ added in v0.3.0
func DefaultLimits() Limits
type PathSelector ¶
type PathSelector struct {
// contains filtered or unexported fields
}
PathSelector implements pan.Selector and provides the WASM module with control over which SCION path is used for a given connection. Automatic selection fails over to the first remaining path. Explicit pins stay bound to their fingerprint and return no path while that path is absent.
func NewPathSelector ¶
func NewPathSelector() *PathSelector
func (*PathSelector) Close ¶
func (s *PathSelector) Close() error
func (*PathSelector) ForcePath ¶
func (s *PathSelector) ForcePath(i int)
ForcePath pins the selector to the path at index i. An invalid index clears the pin and resumes automatic selection.
func (*PathSelector) Initialize ¶
func (s *PathSelector) Initialize(local, remote pan.UDPAddr, paths []*pan.Path)
func (*PathSelector) Path ¶
func (s *PathSelector) Path() *pan.Path
Path returns the currently selected SCION path.
func (*PathSelector) PathDown ¶
func (s *PathSelector) PathDown(pf pan.PathFingerprint, pi pan.PathInterface)
PathDown removes every path affected by the fingerprint or interface until Refresh supplies it again. A lost pin does not silently select another path.
func (*PathSelector) Paths ¶
func (s *PathSelector) Paths() []*pan.Path
Paths returns a snapshot of the available paths, excluding reported failures.
func (*PathSelector) Refresh ¶
func (s *PathSelector) Refresh(paths []*pan.Path)
Refresh replaces the available paths. A still-present selection survives a reorder; a missing automatic selection falls back to the first path. A pin remains unavailable until its fingerprint reappears or ForcePath changes it.
type PortManager ¶
type PortManager struct {
// contains filtered or unexported fields
}
PortManager hands out listener ports from a pre-configured pool, shared across protocols (TCP and UDP). One unused port is allocated per listening debuglet and released on close; a port allocated to one protocol can never be handed out to the other because both share the same inUse map. It is intentionally dependency-free (plain string args) so it does not introduce import cycles between the config and executor packages.
func NewPortManager ¶
func NewPortManager(publicAddr, portsSpec string) (*PortManager, error)
NewPortManager parses portsSpec and returns a ready-to-use PortManager.
func (*PortManager) Enabled ¶
func (s *PortManager) Enabled() bool
Enabled reports whether listening is configured and available.
func (*PortManager) ListenTCP ¶
func (s *PortManager) ListenTCP(control func(network, address string, c syscall.RawConn) error) (*net.TCPListener, int, string, error)
ListenTCP binds a TCP listener on the first free port in the pool and returns the listener, the bound port, and the public "host:port" address. control, when not nil, runs on the socket before it is bound and listening, so a setting it applies covers the listener's first handshake reply. It returns an error when no free port is available or when control refused the socket; in both cases no port is allocated and no socket is left open. The listener is dual-stack.
func (*PortManager) ListenTCP4 ¶ added in v0.3.0
func (s *PortManager) ListenTCP4(control func(network, address string, c syscall.RawConn) error) (*net.TCPListener, int, string, error)
ListenTCP4 is ListenTCP bound to IPv4 only, for a run that must not accept IPv6 peers: its handshake replies and segments to them would leave untagged.
func (*PortManager) ListenUDP ¶
func (s *PortManager) ListenUDP(control func(network, address string, c syscall.RawConn) error) (*net.UDPConn, int, string, error)
ListenUDP binds a UDP socket on the first free port in the pool and returns the connection, the bound port, and the public "host:port" address. control, when not nil, runs on the socket before it is bound, so a setting it applies covers the first datagram. It returns an error when no free port is available or when control refused the socket; in both cases no port is allocated and no socket is left open. The socket is dual-stack.
func (*PortManager) ListenUDP4 ¶ added in v0.3.0
func (s *PortManager) ListenUDP4(control func(network, address string, c syscall.RawConn) error) (*net.UDPConn, int, string, error)
ListenUDP4 is ListenUDP bound to IPv4 only, for a run that must not exchange datagrams with IPv6 peers.
func (*PortManager) PublicHost ¶ added in v0.3.0
func (s *PortManager) PublicHost() string
PublicHost is the configured public host listeners are advertised under.
func (*PortManager) Release ¶
func (s *PortManager) Release(port int)
Release returns a previously allocated port back to the pool.
type Reservation ¶ added in v0.3.0
type Reservation struct {
// contains filtered or unexported fields
}
Reservation owns capacity from before an external operation starts until its resource has been closed or creation has failed. Release is idempotent.
func (*Reservation) Release ¶ added in v0.3.0
func (r *Reservation) Release()
type SCIONConn ¶
type SCIONConn struct {
Conn *pan.Conn
Selector *PathSelector
}
SCIONConn wraps a SCION/UDP connection and its associated PathSelector. It replaces the former ScionDialWrapper.
type SCIONConnRegistry ¶
type SCIONConnRegistry struct {
// contains filtered or unexported fields
}
SCIONConnRegistry manages lazily-dialled SCION connections keyed by address index. The capacity is fixed at construction time to match the number of addresses provided to the WASM module.
func NewSCIONConnRegistry ¶
func NewSCIONConnRegistry(capacity int) *SCIONConnRegistry
func (*SCIONConnRegistry) CloseAll ¶
func (r *SCIONConnRegistry) CloseAll() error
func (*SCIONConnRegistry) GetOrDial ¶
func (r *SCIONConnRegistry) GetOrDial(ctx context.Context, addr string, sugar *zap.SugaredLogger, pktTagger tagger.TaggerInterface) (*SCIONConn, error)
type Socket ¶
type Socket interface {
io.ReadWriteCloser
// Type returns the transport type of this socket.
Type() SocketType
Addr() string
// RemoteAddr returns the full "host:port" address of the socket's peer.
RemoteAddr() string
}
Socket is the common interface for all stream-oriented socket types exposed to WASM modules.
type SocketRegistry ¶
type SocketRegistry struct {
// contains filtered or unexported fields
}
SocketRegistry manages the lifecycle of all open sockets within a single WASM execution. Handles are stable int32 indices into the registry.
func NewSocketRegistry ¶ added in v0.3.0
func NewSocketRegistry(budget *Budget) *SocketRegistry
NewSocketRegistry gives every handle the same run budget as its listeners.
func (*SocketRegistry) Add ¶
func (r *SocketRegistry) Add(s Socket) (int32, error)
Add consumes s, including when quota or terminal admission rejects it. Host operations reserve before creating a socket and use AddReserved.
func (*SocketRegistry) AddReserved ¶ added in v0.3.0
func (r *SocketRegistry) AddReserved(s Socket, reservation *SocketReservation) (int32, error)
AddReserved consumes the socket and its reservation on every path.
func (*SocketRegistry) All ¶
func (r *SocketRegistry) All() []Socket
func (*SocketRegistry) Close ¶
func (r *SocketRegistry) Close(handle int32) error
func (*SocketRegistry) CloseAll ¶
func (r *SocketRegistry) CloseAll() error
CloseAll permanently stops admission before invoking any external Close. sync.Once also joins concurrent callers, including a held underlying Close.
func (*SocketRegistry) CloseRemote ¶ added in v0.3.0
func (r *SocketRegistry) CloseRemote(match func(remote string) bool) int
CloseRemote closes every open socket whose RemoteAddr matches and returns how many it closed. A blocked read or write on one of them returns, and the handle then reports ErrRevoked. The registry stays open for other sockets. A matching socket another closer already detached is joined, not counted: CloseRemote returns only once every matching socket's close has completed.
func (*SocketRegistry) Reserve ¶ added in v0.3.0
func (r *SocketRegistry) Reserve(descriptors int) (*SocketReservation, error)
type SocketReservation ¶ added in v0.3.0
type SocketReservation struct {
// contains filtered or unexported fields
}
SocketReservation also binds an attempt to its registry. A reservation can publish one socket, and admission after terminal closure still consumes it.
func (*SocketReservation) Release ¶ added in v0.3.0
func (s *SocketReservation) Release()
Release abandons an attempt that did not publish a socket.
type SocketType ¶
type SocketType int
SocketType identifies the transport layer of a Socket.
const ( SocketTypeTCP SocketType = iota SocketTypeTLS SocketTypeICMP4 SocketTypeUDP )