socket

package
v0.2.0-rc.3 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ParsePortRanges

func ParsePortRanges(spec string) ([]int, error)

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

func (s *GenericSocket) Read(b []byte) (int, error)

func (*GenericSocket) RemoteAddr

func (s *GenericSocket) RemoteAddr() string

func (*GenericSocket) Type

func (s *GenericSocket) Type() SocketType

func (*GenericSocket) Write

func (s *GenericSocket) Write(b []byte) (int, error)

type ISocketRegistry

type ISocketRegistry interface {
	Add(s Socket) (int32, error)
	Close(handle int32) error
	CloseAll() error
	Get(handle int32) (Socket, error)
}

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. It replaces the former DebugletSelector.

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.

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)

func (*PathSelector) Paths

func (s *PathSelector) Paths() []*pan.Path

Paths returns a snapshot of all known paths.

func (*PathSelector) Refresh

func (s *PathSelector) Refresh(paths []*pan.Path)

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() (*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. It returns an error when no free port is available.

func (*PortManager) ListenUDP

func (s *PortManager) ListenUDP() (*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. It returns an error when no free port is available.

func (*PortManager) Release

func (s *PortManager) Release(port int)

Release returns a previously allocated port back to the pool.

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 (*SocketRegistry) Add

func (r *SocketRegistry) Add(s Socket) (int32, error)

Add consumes s, including when terminal admission rejects it.

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

func (r *SocketRegistry) Get(handle int32) (Socket, error)

type SocketType

type SocketType int

SocketType identifies the transport layer of a Socket.

const (
	SocketTypeTCP SocketType = iota
	SocketTypeTLS
	SocketTypeICMP4
	SocketTypeUDP
)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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