1
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2024-12-22 15:24:46 -05:00
denoland-deno/ext/websocket
Matt Mastracci 684377c92c
refactor(ext/tls): Implement required functionality for later SNI support (#23686)
Precursor to #23236 

This implements the SNI features, but uses private symbols to avoid
exposing the functionality at this time. Note that to properly test this
feature, we need to add a way for `connectTls` to specify a hostname.
This is something that should be pushed into that API at a later time as
well.

```ts
Deno.test(
  { permissions: { net: true, read: true } },
  async function listenResolver() {
    let sniRequests = [];
    const listener = Deno.listenTls({
      hostname: "localhost",
      port: 0,
      [resolverSymbol]: (sni: string) => {
        sniRequests.push(sni);
        return {
          cert,
          key,
        };
      },
    });

    {
      const conn = await Deno.connectTls({
        hostname: "localhost",
        [serverNameSymbol]: "server-1",
        port: listener.addr.port,
      });
      const [_handshake, serverConn] = await Promise.all([
        conn.handshake(),
        listener.accept(),
      ]);
      conn.close();
      serverConn.close();
    }

    {
      const conn = await Deno.connectTls({
        hostname: "localhost",
        [serverNameSymbol]: "server-2",
        port: listener.addr.port,
      });
      const [_handshake, serverConn] = await Promise.all([
        conn.handshake(),
        listener.accept(),
      ]);
      conn.close();
      serverConn.close();
    }

    assertEquals(sniRequests, ["server-1", "server-2"]);
    listener.close();
  },
);
```

---------

Signed-off-by: Matt Mastracci <matthew@mastracci.com>
2024-05-09 10:54:47 -06:00
..
autobahn fix: upgrade deno_ast related crates (#23187) 2024-04-11 23:00:17 +00:00
01_websocket.js fix(ext/websocket): do not continue reading if socket rid closes (#21849) 2024-03-09 09:36:17 +05:30
02_websocketstream.js chore: update WPT (#23111) 2024-04-08 20:46:53 +02:00
Cargo.toml chore: forward v1.43.2 release commit to main (#23749) 2024-05-09 00:45:01 +00:00
lib.deno_websocket.d.ts docs: update categories to match new planned sitemap (#23677) 2024-05-05 18:56:55 -07:00
lib.rs refactor(ext/tls): Implement required functionality for later SNI support (#23686) 2024-05-09 10:54:47 -06:00
README.md Rename extensions/ directory to ext/ (#11643) 2021-08-11 12:27:05 +02:00
stream.rs chore: update copyright to 2024 (#21753) 2024-01-01 19:58:21 +00:00

deno_websocket

This op crate implements the websocket functions of Deno.

Spec: https://html.spec.whatwg.org/multipage/web-sockets.html