Documentation
¶
Overview ¶
Package driver is the client side of the relay's data plane: what an engine uses to give its containers a network through the relay. One Session is one connection (one browser, or one native engine); each container attached to the class network is an Endpoint with Listen, Dial, ListenPacket and Resolve, returning ordinary net.Conn, net.Listener and net.PacketConn values that the engine maps the WasmEdge socket calls onto.
Errors carry the errno a socket call should return: a refused connect wraps syscall.ECONNREFUSED, a reset syscall.ECONNRESET, an unknown address syscall.EHOSTUNREACH, a port in use syscall.EADDRINUSE.
Index ¶
- func HelloVersion(ctx context.Context, t Transport, version uint32) error
- func SendRaw(e *Endpoint, srcPort uint16, to netip.AddrPort, payload []byte) error
- type Endpoint
- func (e *Endpoint) Addr() netip.Addr
- func (e *Endpoint) Detach() error
- func (e *Endpoint) Dial(ctx context.Context, network string, addr netip.AddrPort) (net.Conn, error)
- func (e *Endpoint) Listen(ctx context.Context, network string, port uint16) (*Listener, error)
- func (e *Endpoint) ListenPacket(ctx context.Context, network string, port uint16) (*PacketConn, error)
- func (e *Endpoint) Port() *v1.Port
- func (e *Endpoint) Resolve(ctx context.Context, name string) ([]netip.Addr, error)
- type Error
- type Listener
- type PacketConn
- func (pc *PacketConn) Close() error
- func (pc *PacketConn) LocalAddr() net.Addr
- func (pc *PacketConn) ReadFrom(p []byte) (int, net.Addr, error)
- func (pc *PacketConn) SetDeadline(t time.Time) error
- func (pc *PacketConn) SetReadDeadline(t time.Time) error
- func (pc *PacketConn) SetWriteDeadline(t time.Time) error
- func (pc *PacketConn) WriteTo(p []byte, addr net.Addr) (int, error)
- type Session
- func (s *Session) Attach(ctx context.Context, container string) (*Endpoint, error)
- func (s *Session) Close() error
- func (s *Session) Done() <-chan struct{}
- func (s *Session) Err() error
- func (s *Session) GoAway() *v1.Result
- func (s *Session) Reauth(token string) error
- func (s *Session) Welcome() *v1.Welcome
- type Transport
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func HelloVersion ¶
HelloVersion opens a session announcing another protocol version and returns the relay's refusal.
Types ¶
type Endpoint ¶
type Endpoint struct {
// contains filtered or unexported fields
}
Endpoint is one container's place on the class network.
func ForgeEndpoint ¶
ForgeEndpoint is an endpoint of s that names port p, whoever owns it.
func (*Endpoint) Dial ¶
Dial connects to addr ("tcp") or returns a connected datagram socket ("udp").
func (*Endpoint) ListenPacket ¶
func (e *Endpoint) ListenPacket(ctx context.Context, network string, port uint16) (*PacketConn, error)
ListenPacket binds a UDP port (0 picks an ephemeral one).
type Listener ¶
type Listener struct {
// contains filtered or unexported fields
}
Listener accepts streams on one port. It implements net.Listener.
type PacketConn ¶
type PacketConn struct {
// contains filtered or unexported fields
}
PacketConn is a bound UDP socket. It implements net.PacketConn.
func (*PacketConn) LocalAddr ¶
func (pc *PacketConn) LocalAddr() net.Addr
func (*PacketConn) SetDeadline ¶
func (pc *PacketConn) SetDeadline(t time.Time) error
func (*PacketConn) SetReadDeadline ¶
func (pc *PacketConn) SetReadDeadline(t time.Time) error
func (*PacketConn) SetWriteDeadline ¶
func (pc *PacketConn) SetWriteDeadline(t time.Time) error
type Session ¶
type Session struct {
// contains filtered or unexported fields
}
Session is one data connection to the relay.
func Dial ¶
Dial starts a session over t (already authenticated by its transport: the WebSocket carries the session token in its handshake).
func DialWebSocket ¶
DialWebSocket opens a session at url (wss://relay.example/v1/data) with a session token. The token travels as a WebSocket subprotocol, so it is checked before the upgrade and never appears in a URL. hc may be nil (in a browser, js/wasm, the browser's WebSocket is used and hc is ignored).
func (*Session) Attach ¶
Attach gives a container an address on the class network (the same one it had, if it was attached before).
func (*Session) Done ¶
func (s *Session) Done() <-chan struct{}
Done is closed when the session ends; Err then says why.