Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 21 additions & 4 deletions ext/node/polyfills/_tls_wrap.js
Original file line number Diff line number Diff line change
Expand Up @@ -402,13 +402,26 @@ export class ServerImpl extends EventEmitter {
}
}

listen(port, callback) {
listen(opt, callback) {
let hostname, port;
if (typeof opt == "object") {
port = opt.port;
hostname = opt.hostname ?? "0.0.0.0";
} else {
// TODO(kt3k): The default host should be "localhost"
hostname = this.options.host ?? "0.0.0.0";
port = opt;
}
const key = this.options.key?.toString();
const cert = this.options.cert?.toString();
// TODO(kt3k): The default host should be "localhost"
const hostname = this.options.host ?? "0.0.0.0";

this.listener = Deno.listenTls({ port, hostname, cert, key });
this.listener = Deno.listenTls({
port,
hostname,
cert,
key,
alpnProtocols: this.options.ALPNProtocols,
});

callback?.call(this);
this.#listen(this.listener);
Expand All @@ -429,6 +442,8 @@ export class ServerImpl extends EventEmitter {
// TODO(@satyarohith): set TLSSocket.alpnProtocol when we use TLSSocket class.
const handle = new TCP(TCPConstants.SOCKET, await listener.accept());
const socket = new net.Socket({ handle });
socket.encrypted = true;
socket.alpnProtocol = "h2";
this.emit("secureConnection", socket);
} catch (e) {
if (e instanceof Deno.errors.BadResource) {
Expand Down Expand Up @@ -457,6 +472,8 @@ export class ServerImpl extends EventEmitter {
address: addr.hostname,
};
}

setTimeout() {}
}

Server.prototype = ServerImpl.prototype;
Expand Down
2 changes: 2 additions & 0 deletions ext/node/polyfills/internal/stream_base_commons.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ export const kMaybeDestroy = Symbol("kMaybeDestroy");
export const kUpdateTimer = Symbol("kUpdateTimer");
export const kAfterAsyncWrite = Symbol("kAfterAsyncWrite");
export const kHandle = Symbol("kHandle");
export const kBoundSession = Symbol("kBoundSession");
export const kSession = Symbol("kSession");
export const kBuffer = Symbol("kBuffer");
export const kBufferGen = Symbol("kBufferGen");
Expand Down Expand Up @@ -365,6 +366,7 @@ export function setStreamTimeout(
if (this[kSession]) {
this[kSession][kUpdateTimer]();
}
if (this[kBoundSession]) this[kBoundSession][kUpdateTimer]();

if (callback !== undefined) {
validateFunction(callback, "callback");
Expand Down
Loading