1
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2024-12-22 07:14:47 -05:00
denoland-deno/ext
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
..
broadcast_channel chore: forward v1.43.2 release commit to main (#23749) 2024-05-09 00:45:01 +00:00
cache chore: forward v1.43.2 release commit to main (#23749) 2024-05-09 00:45:01 +00:00
canvas chore: forward v1.43.2 release commit to main (#23749) 2024-05-09 00:45:01 +00:00
console chore: forward v1.43.2 release commit to main (#23749) 2024-05-09 00:45:01 +00:00
cron chore: forward v1.43.2 release commit to main (#23749) 2024-05-09 00:45:01 +00:00
crypto chore: forward v1.43.2 release commit to main (#23749) 2024-05-09 00:45:01 +00:00
fetch refactor(ext/tls): Implement required functionality for later SNI support (#23686) 2024-05-09 10:54:47 -06:00
ffi chore: enable clippy::print_stdout and clippy::print_stderr (#23732) 2024-05-08 22:45:06 -04:00
fs chore: forward v1.43.2 release commit to main (#23749) 2024-05-09 00:45:01 +00:00
http chore: enable clippy::print_stdout and clippy::print_stderr (#23732) 2024-05-08 22:45:06 -04:00
io chore: enable clippy::print_stdout and clippy::print_stderr (#23732) 2024-05-08 22:45:06 -04:00
kv refactor(ext/tls): Implement required functionality for later SNI support (#23686) 2024-05-09 10:54:47 -06:00
napi chore: forward v1.43.2 release commit to main (#23749) 2024-05-09 00:45:01 +00:00
net refactor(ext/tls): Implement required functionality for later SNI support (#23686) 2024-05-09 10:54:47 -06:00
node chore: forward v1.43.2 release commit to main (#23749) 2024-05-09 00:45:01 +00:00
tls refactor(ext/tls): Implement required functionality for later SNI support (#23686) 2024-05-09 10:54:47 -06:00
url chore: forward v1.43.2 release commit to main (#23749) 2024-05-09 00:45:01 +00:00
web chore: forward v1.43.2 release commit to main (#23749) 2024-05-09 00:45:01 +00:00
webgpu chore: forward v1.43.2 release commit to main (#23749) 2024-05-09 00:45:01 +00:00
webidl chore: forward v1.43.2 release commit to main (#23749) 2024-05-09 00:45:01 +00:00
websocket refactor(ext/tls): Implement required functionality for later SNI support (#23686) 2024-05-09 10:54:47 -06:00
webstorage chore: forward v1.43.2 release commit to main (#23749) 2024-05-09 00:45:01 +00:00