From 7838c1f3d3118a674294db09d9c70d909238ed32 Mon Sep 17 00:00:00 2001 From: Roy Razon Date: Mon, 12 Feb 2024 18:33:31 +0200 Subject: [PATCH] tunnel server: add ALPN --- tunnel-server/src/tls-server.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tunnel-server/src/tls-server.ts b/tunnel-server/src/tls-server.ts index 84d621ab..10076216 100644 --- a/tunnel-server/src/tls-server.ts +++ b/tunnel-server/src/tls-server.ts @@ -13,12 +13,12 @@ export const createTlsServer = ({ log, httpServer, sshServer, tlsConfig, sshHost log.info('SSH hostnames: %j', sshHostnames) const sshHostnamesSet = new Set(sshHostnames) - return tls.createServer(tlsConfig) + return tls.createServer({ ...tlsConfig, ALPNProtocols: ['http/1.1', 'ssh'] }) .on('error', err => { log.error(err) }) .on('secureConnection', socket => { const { servername } = (socket as { servername?: string }) log.debug('TLS connection: %j', servername) - if (servername && sshHostnamesSet.has(servername)) { + if ((servername && sshHostnamesSet.has(servername)) || socket.alpnProtocol === 'ssh') { sshServer.injectSocket(socket) } else { httpServer.emit('connection', socket)