mirror of https://github.com/Fabio286/antares.git
fix: ssh tunnel keep-alive not working properly
This commit is contained in:
parent
3c2e2be40f
commit
debc1da289
|
@ -55,7 +55,7 @@ export default (connections: {[key: string]: antares.Client}) => {
|
||||||
port: conn.sshPort ? conn.sshPort : 22,
|
port: conn.sshPort ? conn.sshPort : 22,
|
||||||
privateKey: conn.sshKey ? fs.readFileSync(conn.sshKey).toString() : null,
|
privateKey: conn.sshKey ? fs.readFileSync(conn.sshKey).toString() : null,
|
||||||
passphrase: conn.sshPassphrase,
|
passphrase: conn.sshPassphrase,
|
||||||
keepaliveInterval: conn.sshKeepAliveInterval ?? conn.sshKeepAliveInterval*1000
|
keepaliveInterval: conn.sshKeepAliveInterval ? conn.sshKeepAliveInterval*1000 : null
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -137,7 +137,7 @@ export default (connections: {[key: string]: antares.Client}) => {
|
||||||
port: conn.sshPort ? conn.sshPort : 22,
|
port: conn.sshPort ? conn.sshPort : 22,
|
||||||
privateKey: conn.sshKey ? fs.readFileSync(conn.sshKey).toString() : null,
|
privateKey: conn.sshKey ? fs.readFileSync(conn.sshKey).toString() : null,
|
||||||
passphrase: conn.sshPassphrase,
|
passphrase: conn.sshPassphrase,
|
||||||
keepaliveInterval: conn.sshKeepAliveInterval ?? conn.sshKeepAliveInterval*1000
|
keepaliveInterval: conn.sshKeepAliveInterval ? conn.sshKeepAliveInterval*1000 : null
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -168,7 +168,10 @@ export class MySQLClient extends BaseClient {
|
||||||
dbConfig.port = tunnel.localPort;
|
dbConfig.port = tunnel.localPort;
|
||||||
}
|
}
|
||||||
catch (err) {
|
catch (err) {
|
||||||
if (this._ssh) this._ssh.close();
|
if (this._ssh) {
|
||||||
|
this._ssh.close();
|
||||||
|
this._ssh.closeTunnel();
|
||||||
|
}
|
||||||
throw err;
|
throw err;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -187,7 +190,10 @@ export class MySQLClient extends BaseClient {
|
||||||
this._connection.end();
|
this._connection.end();
|
||||||
clearInterval(this._keepaliveTimer);
|
clearInterval(this._keepaliveTimer);
|
||||||
this._keepaliveTimer = undefined;
|
this._keepaliveTimer = undefined;
|
||||||
if (this._ssh) this._ssh.close();
|
if (this._ssh) {
|
||||||
|
this._ssh.close();
|
||||||
|
this._ssh.closeTunnel();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async getConnection () {
|
async getConnection () {
|
||||||
|
|
|
@ -180,7 +180,10 @@ export class PostgreSQLClient extends BaseClient {
|
||||||
dbConfig.port = tunnel.localPort;
|
dbConfig.port = tunnel.localPort;
|
||||||
}
|
}
|
||||||
catch (err) {
|
catch (err) {
|
||||||
if (this._ssh) this._ssh.close();
|
if (this._ssh) {
|
||||||
|
this._ssh.close();
|
||||||
|
this._ssh.closeTunnel();
|
||||||
|
}
|
||||||
throw err;
|
throw err;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -236,7 +239,10 @@ export class PostgreSQLClient extends BaseClient {
|
||||||
this._connection.end();
|
this._connection.end();
|
||||||
clearInterval(this._keepaliveTimer);
|
clearInterval(this._keepaliveTimer);
|
||||||
this._keepaliveTimer = undefined;
|
this._keepaliveTimer = undefined;
|
||||||
if (this._ssh) this._ssh.close();
|
if (this._ssh) {
|
||||||
|
this._ssh.close();
|
||||||
|
this._ssh.closeTunnel();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private async keepAlive () {
|
private async keepAlive () {
|
||||||
|
|
Loading…
Reference in New Issue