Skip to content

Commit dac9b77

Browse files
committed
Fix a couple of issues in the RC (#1709)
* Provide a domain to the socket * fix auth error * failing to return socket * changelog
1 parent cd8104f commit dac9b77

File tree

3 files changed

+7
-5
lines changed

3 files changed

+7
-5
lines changed

changelog.d/1709.bugfix

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Fix the bridge pooling so it supports TLS.

src/irc/ConnectionInstance.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -428,18 +428,19 @@ export class ConnectionInstance {
428428

429429
// Returns: A promise which resolves to a ConnectionInstance
430430
const retryConnection = async () => {
431-
431+
const domain = server.randomDomain();
432432
const redisConn = opts.useRedisPool && await opts.useRedisPool.createOrGetIrcSocket(ident, {
433433
...connectionOpts,
434434
clientId: ident,
435435
port: connectionOpts.port ?? 6667,
436436
localAddress: connectionOpts.localAddress ?? undefined,
437437
localPort: connectionOpts.localPort ?? undefined,
438438
family: connectionOpts.family ?? undefined,
439+
host: domain,
439440
});
440441

441442
const nodeClient = new Client(
442-
server.randomDomain(), opts.nick, connectionOpts, redisConn?.state, redisConn,
443+
domain, opts.nick, connectionOpts, redisConn?.state, redisConn,
443444
);
444445
const inst = new ConnectionInstance(
445446
nodeClient, server.domain, opts.nick, {

src/pool-service/IrcConnectionPool.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,6 @@ export class IrcConnectionPool {
7474
}
7575

7676
private async createConnectionForOpts(opts: ConnectionCreateArgs): Promise<Socket> {
77-
let socket: Socket;
7877
if (opts.secure) {
7978
let secureOpts: tls.ConnectionOptions = {
8079
...opts,
@@ -89,11 +88,12 @@ export class IrcConnectionPool {
8988
};
9089
}
9190

92-
socket = await new Promise((resolve, reject) => {
91+
return await new Promise((resolve, reject) => {
9392
// Taken from https://github.com/matrix-org/node-irc/blob/0764733af7c324ee24f8c2a3c26fe9d1614be344/src/irc.ts#L1231
9493
const sock = tls.connect(secureOpts, () => {
9594
if (sock.authorized) {
9695
resolve(sock);
96+
return;
9797
}
9898
let valid = false;
9999
const err = sock.authorizationError.toString();
@@ -125,7 +125,7 @@ export class IrcConnectionPool {
125125
});
126126
}
127127
return new Promise((resolve, reject) => {
128-
socket = createConnection(opts, () => resolve(socket)) as Socket;
128+
const socket = createConnection(opts, () => resolve(socket)) as Socket;
129129
socket.once('error', (error) => {
130130
reject(error);
131131
});

0 commit comments

Comments
 (0)