Documentation
¶
Overview ¶
Package wasm contains the WASM host function implementations that are imported by WASM modules at runtime. Each host function follows the wazero calling convention: (ctx context.Context, mod Memory, params []uint64) → []uint64.
Go function names use camelCase with a "host" prefix. The WASM-visible import key strings (used during host module registration) are left unchanged so that existing WASM modules do not need recompilation.
Index ¶
- Constants
- func ExtractMem[T PrimitiveType](mod api.Module, source, num uint32) ([]T, error)
- func ExtractStr(mod api.Module, source, num uint32) (string, error)
- func HostAcceptTCP(env *WasmEnv) func(ctx context.Context) int32
- func HostAnswerSCIONUDPPacket(env *WasmEnv, addresses []string) ...
- func HostClose(env *WasmEnv) func(ctx context.Context, sockID int32)
- func HostConnect(env *WasmEnv, socketType socket.SocketType) func(ctx context.Context, mod api.Module, addrp, addrLen uint32) int32
- func HostDrain(env *WasmEnv) func(ctx context.Context, sockID int32)
- func HostGetRemoteAddr(env *WasmEnv) ...
- func HostGetTCPAddr(env *WasmEnv) func(ctx context.Context, mod api.Module, bufPtr, bufLen uint32) int32
- func HostGetUDPAddr(env *WasmEnv) func(ctx context.Context, mod api.Module, bufPtr, bufLen uint32) int32
- func HostIOAcceptTCP(env *WasmEnv) func(context.Context, int64) uint64
- func HostIOClose(env *WasmEnv) func(context.Context, int32) uint64
- func HostIODeadline(env *WasmEnv) func(context.Context, int32, uint32, int64) uint64
- func HostIODial(env *WasmEnv) func(context.Context, api.Module, uint32, uint32, uint32, int64) uint64
- func HostIORead(env *WasmEnv) func(context.Context, api.Module, int32, uint32, uint32) uint64
- func HostIOWrite(env *WasmEnv) func(context.Context, api.Module, int32, uint32, uint32) uint64
- func HostReceiveData(env *WasmEnv) ...
- func HostReceiveSCIONServerUDPPacket(env *WasmEnv) ...
- func HostReceiveUDPFrom(env *WasmEnv) func(ctx context.Context, mod api.Module, ...) int32
- func HostSCIONAvailablePaths(env *WasmEnv) func(ctx context.Context, mod api.Module, addrp, addrLen uint32) int32
- func HostSCIONGetInterfaceDetails(env *WasmEnv) ...
- func HostSCIONPathLength(env *WasmEnv) ...
- func HostSCIONSelectPath(env *WasmEnv) ...
- func HostSendData(env *WasmEnv) func(ctx context.Context, mod api.Module, sockID int32, bufp, bufLen uint32)
- func HostSendSCIONUDPPacket(env *WasmEnv) ...
- func Register(builder wazero.HostModuleBuilder, module string, functions []Function, ...) wazero.HostModuleBuilder
- func RegisterIO(builder wazero.HostModuleBuilder, env *WasmEnv) wazero.HostModuleBuilder
- type DatagramTagger
- type Drainable
- type ExperimentControl
- type Function
- type Memory
- type PrimitiveType
- type WasmEnv
- func (e *WasmEnv) Close() error
- func (e *WasmEnv) InstallSCION(conn pan.ListenConn, reservation *socket.Reservation) error
- func (e *WasmEnv) InstallTCP(lis *net.TCPListener, port int, addr string, reservation *socket.Reservation) error
- func (e *WasmEnv) InstallUDP(conn *net.UDPConn, port int, addr string, reservation *socket.Reservation) error
- func (e *WasmEnv) RecordCleanupError(err error)
- func (e *WasmEnv) SCIONAddr() string
- func (e *WasmEnv) TCPListenerEndpoint() string
Constants ¶
const ExperimentModule = "debuglet_experiment_v1"
ExperimentModule is the optional readiness ABI; the base env ABI is unchanged.
const (
MAX_SLICE_LENGTH = 8192
)
Variables ¶
This section is empty.
Functions ¶
func ExtractMem ¶
func ExtractMem[T PrimitiveType](mod api.Module, source, num uint32) ([]T, error)
func HostAcceptTCP ¶
HostAcceptTCP accepts one incoming TCP connection on the job's listener and registers it in the SocketRegistry. An accepted peer is admitted by the same policy as an outbound destination and accounted against the same limits: a peer the policy refuses is closed without ever being handed to the guest, and the next connection is accepted in its place. Returns the socket handle as I32. WASM key: "accept_tcp"
func HostConnect ¶
func HostGetRemoteAddr ¶
func HostGetTCPAddr ¶
func HostGetUDPAddr ¶
func HostIOAcceptTCP ¶ added in v0.3.0
HostIOAcceptTCP bounds one accept without applying its timeout to the returned connection. Refused peers share the same deadline.
func HostIOClose ¶ added in v0.3.0
func HostIODeadline ¶ added in v0.3.0
func HostIODial ¶ added in v0.3.0
func HostIORead ¶ added in v0.3.0
func HostIOWrite ¶ added in v0.3.0
func HostReceiveData ¶
func HostReceiveUDPFrom ¶
func HostSCIONAvailablePaths ¶
func HostSCIONPathLength ¶
func HostSCIONSelectPath ¶
func HostSendData ¶
func HostSendSCIONUDPPacket ¶
func Register ¶ added in v0.3.0
func Register(builder wazero.HostModuleBuilder, module string, functions []Function, proxy func(context.Context, api.Module, int, []uint64)) wazero.HostModuleBuilder
Register installs the fixed imports. A nil proxy calls the local host; otherwise the worker calls its parent through the supplied bounded bridge.
func RegisterIO ¶ added in v0.3.0
func RegisterIO(builder wazero.HostModuleBuilder, env *WasmEnv) wazero.HostModuleBuilder
RegisterIO adds recoverable sockets without changing the legacy env module.
Types ¶
type DatagramTagger ¶
DatagramTagger is the pure-Go tagger, which tags UDP and ICMP by sending them itself; the eBPF tagger tags every socket in the kernel instead.
type ExperimentControl ¶ added in v0.3.0
ExperimentControl is the run-bound capability supplied by the executor. The guest can publish metadata but cannot select a run, account or session.
type Function ¶ added in v0.3.0
type Function struct {
Module, Name string
Params, Results []api.ValueType
// contains filtered or unexported fields
}
Function describes one fixed guest import. The supervisor and the local runtime use the same table and implementation; only memory access differs.
type Memory ¶ added in v0.3.0
type Memory interface {
Read(uint32, uint32) ([]byte, bool)
Write(uint32, []byte) bool
WriteUint32Le(uint32, uint32) bool
}
Memory is the bounded memory surface used by network host calls. Read callers must write received data explicitly; a returned slice need not alias the guest.
type PrimitiveType ¶
type WasmEnv ¶
type WasmEnv struct {
Experiment ExperimentControl
DebugletID uuid.UUID
Policy scheduler.Policy
// Net is the network policy every transport is checked against. It is the
// operator's rules and this run's declared destinations together; without
// it no transport is available.
Net *netpolicy.Policy
Limiter *app.Limiter
PacketCount ratelimit.PacketCount
// Accountant covers the traffic no connection wrapper does: listener
// datagrams and SCION packets.
Accountant *ratelimit.Accountant
LastReceived net.Addr
Logger *zap.SugaredLogger
TlsCfg *tls.Config
Tagger tagger.TaggerInterface
// Listeners
PortManager *socket.PortManager
// TCP
TcpServer *net.TCPListener
TcpServerPort int
TcpServerAddr string
// UDP
UdpServer *net.UDPConn
UdpServerPort int
UdpServerAddr string
ScionServer pan.ListenConn
Budget *socket.Budget
Registry *socket.SocketRegistry
ScionConn *socket.SCIONConnRegistry
// contains filtered or unexported fields
}
func (*WasmEnv) InstallSCION ¶
func (e *WasmEnv) InstallSCION(conn pan.ListenConn, reservation *socket.Reservation) error
func (*WasmEnv) InstallTCP ¶
func (e *WasmEnv) InstallTCP(lis *net.TCPListener, port int, addr string, reservation *socket.Reservation) error
Listener publication competes with terminal closure. References remain immutable after successful publication; late resources are consumed/closed. A listener arrives already marked: the PortManager marks it in its listen control hook, before the socket is bound and listening, so no handshake reply or datagram leaves it unattributed.
func (*WasmEnv) InstallUDP ¶
func (*WasmEnv) RecordCleanupError ¶
RecordCleanupError records a resource-release failure independently of the operation's selected execution/cancellation outcome. Nil is a no-op.
func (*WasmEnv) TCPListenerEndpoint ¶ added in v0.3.0
TCPListenerEndpoint returns only an installed listener's advertised endpoint. It becomes unavailable as soon as terminal resource closure begins.