• v2.18.0 51f08bc3da

    v2.18.0
    All checks were successful
    release / build-and-release (push) Successful in 21s
    Stable

    littleisland released this 2026-11-07 05:07:17 +00:00 | 77 commits to main since this release

    NOE v2.18.0

    This release adds raw TLS streams and UDP datagram sockets to noe:sockets.
    Both reuse the existing native resource ownership and execution/Worker cleanup.
    No dependency changes are required. HTTPS/WSS listeners remain available
    through noe:http, as introduced in v2.17.0.

    Raw TLS streams

    Use network: "tls" with connect and listen. Connections retain the
    existing readable, writable, close, and asynchronous-disposal interface.
    Connect and accept return only after their TLS handshake succeeds.

    import {readFile} from "noe:fs";
    import {connect, listen} from "noe:sockets";
    
    const cert = await readFile("server-cert.pem", "utf8");
    const key = await readFile("server-key.pem", "utf8");
    await using listener = await listen({
      network: "tls", host: "127.0.0.1", port: 0, cert, key,
    });
    const accepting = listener.accept();
    await using client = await connect({
      ...listener.address, ca: cert,
    });
    await using server = await accepting;
    // Exchange bytes through client/server readable and writable Web Streams.
    

    Start accept before awaiting a loopback client so the server can complete its
    handshake. The example identity must include IP:127.0.0.1 in its certificate
    subject alternative names. See the
    complete TLS round-trip example.

    Clients verify the certificate chain and hostname using system roots by
    default. Optional ca PEM replaces roots for that connection; serverName
    selects the verification name. Optional client cert/key enables a client
    identity. Listeners require a matching PEM pair or Go host configuration.
    Invalid or conflicting settings reject before dial/bind without exposing PEM
    material. Values contain PEM text, not implicit file paths; explicit file reads
    remain under the selected noe:fs capability and its Root/Cwd/ReadOnly policy.

    writer.close() sends TLS close_notify and leaves reads available. Reader
    cancellation stops local delivery without waiting behind TLS protocol-alert
    writes; the connection retains that native work until full close. Writer abort
    and full close interrupt transport operations without waiting for a graceful
    alert. Listener close cancels pending handshakes and undelivered results;
    connections already returned retain independent ownership.

    Go TLS configuration and compatibility

    Keep selecting Modules.RawSockets: true. New
    Modules.RawSocketsTLS *stdlib.SocketTLSOptions configures Client and Server
    *tls.Config values plus HandshakeTimeout, without granting sockets by itself.
    A non-nil direction configuration is authoritative; corresponding inline
    JavaScript TLS fields cannot override it. Raw TLS preserves host ALPN choices.
    HTTP/Fetch/WebSocket trust and capabilities remain independent.

    profile.Modules = stdlib.Modules{
        RawSockets: true,
        RawSocketsTLS: &stdlib.SocketTLSOptions{
            Client: &tls.Config{RootCAs: roots},
            Server: &tls.Config{Certificates: []tls.Certificate{certificate}},
        },
    }
    

    This fragment uses crypto/tls and previously loaded roots/certificate material.
    Configuration copies are cloned for profiles, runtimes, Workers, and listeners.
    Referenced keys, pools, caches, and callbacks retain Go's immutable-in-use
    ownership. The handshake timer defaults to ten seconds; positive values
    override it, and a negative value disables it. Owner cancellation stays active.

    Go source compatibility: the additional Modules field requires external
    unkeyed struct literals to move to named fields. Existing keyed selections and
    the public /v2 module path remain supported. See the
    raw TLS contract.

    UDP datagrams

    New bind creates an owned UDP socket with explicit packet operations. Stream
    connect/listen return types remain unchanged.

    import {bind} from "noe:sockets";
    
    await using receiver = await bind({network: "udp", host: "127.0.0.1", port: 0});
    await using sender = await bind({network: "udp", host: "127.0.0.1", port: 0});
    const receiving = receiver.receive();
    await sender.send(new Uint8Array([0, 128, 255]), receiver.address);
    const {data, remoteAddress} = await receiving;
    console.log([...data], remoteAddress);
    

    One send/receive handles one packet, including an empty datagram. Send snapshots
    Uint8Array bytes before asynchronous work and returns the local OS byte count.
    Receive returns fresh bytes and the sender's {network: "udp", host, port}.
    Host resolution supports IPv4/IPv6. OS routing/size failures reject. A 65,536-byte
    receive buffer accommodates ordinary UDP; read errors and full buffers reject
    instead of exposing a possible partial payload. UDP adds no delivery, order,
    duplicate suppression, or retry guarantee.

    Bind/send/receive accept operation-scoped AbortSignal and preserve its exact
    reason. Canceling one operation does not disturb another. Bind signal ownership
    ends at return; cancellation cannot withdraw a packet already accepted by the
    OS and may discard an already received packet. close() returns one shared
    Promise, cancels pending operations, and releases native I/O. Async
    disposal and runtime/Worker teardown use the same ownership model.

    UDP uses the existing RawSockets grant, with no new Go option or implicit
    FS/HTTP/WebSocket capability. See the
    UDP round-trip example
    and UDP contract.

    Verification and distribution

    Implementation verification covers trust/hostname/mTLS, host configuration
    snapshots, scoped cancellation/deadline reset, queued result ownership,
    blocked I/O, Worker/runtime cleanup, UDP packet boundaries/addresses, IPv6,
    types, CLI examples, and standalone public Go consumers. Affected race checks,
    vet, and bounded reviews pass. Consumers build with CGO disabled for all six
    release targets. Release preparation reuses unchanged implementation evidence.

    Generated dist/ is now ignored by Git, so earlier CI build outputs no longer
    mark later binaries' VCS metadata dirty. CI builds six distribution binaries,
    creates SHA256SUMS, and publishes the immutable tag without repeating local
    source suites. Native execution is Linux amd64; other targets receive
    build/checksum verification. Go 1.27.2, go-quickjs v0.32.0, go-intl v0.8.0,
    and disabled JIT remain selected.

    Release requests include verified local installation at both executable paths.
    Running-service restarts and noebot changes remain separate. See the
    release checkpoints for publication and installation
    evidence.

    Downloads