Skip to content

Commit b56abb9

Browse files
committed
Added readyTimeout support in connection settings
Signed-off-by: Seb Julliand <[email protected]>
1 parent ef7b2c1 commit b56abb9

File tree

4 files changed

+13
-7
lines changed

4 files changed

+13
-7
lines changed

src/api/IBMi.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import { IBMiComponent } from "../components/component";
88
import { CopyToImport } from "../components/copyToImport";
99
import { CustomQSh } from '../components/cqsh';
1010
import { ComponentManager } from "../components/manager";
11-
import { CommandData, CommandResult, ConnectionData, IBMiMember, RemoteCommand, SpecialAuthorities, WrapResult } from "../typings";
11+
import { CommandData, CommandResult, ConnectionData, IBMiMember, RemoteCommand, WrapResult } from "../typings";
1212
import { CompileTools } from "./CompileTools";
1313
import { ConnectionConfiguration } from "./Configuration";
1414
import IBMiContent from "./IBMiContent";
@@ -76,7 +76,7 @@ export default class IBMi {
7676
*/
7777
content = new IBMiContent(this);
7878

79-
client: node_ssh.NodeSSH|undefined;
79+
client: node_ssh.NodeSSH | undefined;
8080
currentHost: string = ``;
8181
currentPort: number = 22;
8282
currentUser: string = ``;
@@ -106,7 +106,7 @@ export default class IBMi {
106106
//Maximum admited length for command's argument - any command whose arguments are longer than this won't be executed by the shell
107107
maximumArgsLength = 0;
108108

109-
private disconnectedCallback: (DisconnectCallback)|undefined;
109+
private disconnectedCallback: (DisconnectCallback) | undefined;
110110

111111
/**
112112
* Will only be called once per connection.

src/typings.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ export interface ConnectionData {
8585
password?: string;
8686
privateKeyPath?: string;
8787
keepaliveInterval?: number;
88+
readyTimeout?: number;
8889
}
8990

9091
export interface Server {

src/webviews/login/index.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
import vscode, { l10n, ThemeIcon } from "vscode";
22
import { ConnectionConfiguration, ConnectionManager } from "../../api/Configuration";
33
import { CustomUI, Section } from "../../api/CustomUI";
4-
import IBMi from "../../api/IBMi";
5-
import { safeDisconnect, instance } from "../../instantiate";
64
import { Tools } from "../../api/Tools";
5+
import { instance, safeDisconnect } from "../../instantiate";
76
import { ConnectionData } from '../../typings';
87

98
type NewLoginSettings = ConnectionData & {
@@ -30,6 +29,8 @@ export class Login {
3029
.addInput(`host`, l10n.t(`Host or IP Address`), undefined, { minlength: 1 })
3130
.addInput(`port`, l10n.t(`Port (SSH)`), ``, { default: `22`, minlength: 1, maxlength: 5, regexTest: `^\\d+$` })
3231
.addInput(`username`, l10n.t(`Username`), undefined, { minlength: 1, maxlength: 10 })
32+
.addInput(`readyTimeout`, l10n.t(`Connection Timeout (in milliseconds)`), l10n.t(`How long to wait for the SSH handshake to complete.`), { inputType: "number", min: 1, default: "20000" })
33+
.addHorizontalRule()
3334
.addParagraph(l10n.t(`Only provide either the password or a private key - not both.`))
3435
.addPassword(`password`, l10n.t(`Password`))
3536
.addCheckbox(`savePassword`, l10n.t(`Save Password`))
@@ -55,6 +56,7 @@ export class Login {
5556
page.panel.dispose();
5657

5758
data.port = Number(data.port);
59+
data.readyTimeout = Number(data.readyTimeout);
5860
data.privateKeyPath = data.privateKeyPath?.trim() ? Tools.normalizePath(data.privateKeyPath) : undefined;
5961
if (data.name) {
6062
const existingConnection = ConnectionManager.getByName(data.name);
@@ -96,7 +98,7 @@ export class Login {
9698

9799
if (data.password || data.privateKeyPath) {
98100
try {
99-
const connected = await instance.connect({data, onConnectedOperations: toDoOnConnected});
101+
const connected = await instance.connect({ data, onConnectedOperations: toDoOnConnected });
100102
if (connected.success) {
101103
if (newConnection) {
102104
vscode.window.showInformationMessage(`Connected to ${data.host}! Would you like to configure this connection?`, `Open configuration`).then(async (selectionA) => {
@@ -172,7 +174,7 @@ export class Login {
172174
}
173175

174176
try {
175-
const connected = await instance.connect({data: connectionConfig, onConnectedOperations: toDoOnConnected, reloadServerSettings});
177+
const connected = await instance.connect({ data: connectionConfig, onConnectedOperations: toDoOnConnected, reloadServerSettings });
176178
if (connected.success) {
177179
vscode.window.showInformationMessage(`Connected to ${connectionConfig.host}!`);
178180
} else {

src/webviews/settings/index.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -362,6 +362,8 @@ export class SettingsUI {
362362
.addInput(`host`, vscode.l10n.t(`Host or IP Address`), undefined, { default: stored.host, minlength: 1 })
363363
.addInput(`port`, vscode.l10n.t(`Port (SSH)`), undefined, { default: String(stored.port), minlength: 1, maxlength: 5, regexTest: `^\\d+$` })
364364
.addInput(`username`, vscode.l10n.t(`Username`), undefined, { default: stored.username, minlength: 1 })
365+
.addInput(`readyTimeout`, vscode.l10n.t(`Connection Timeout (in milliseconds)`), vscode.l10n.t(`How long to wait for the SSH handshake to complete.`), { inputType: "number", min: 1, default: stored.readyTimeout ? String(stored.readyTimeout) : "20000" })
366+
.addHorizontalRule()
365367
.addParagraph(vscode.l10n.t(`Only provide either the password or a private key - not both.`))
366368
.addPassword(`password`, `${vscode.l10n.t(`Password`)}${storedPassword ? ` (${vscode.l10n.t(`stored`)})` : ``}`, vscode.l10n.t("Only provide a password if you want to update an existing one or set a new one."))
367369
.addFile(`privateKeyPath`, `${vscode.l10n.t(`Private Key`)}${privateKeyPath ? ` (${vscode.l10n.t(`Private Key`)}: ${privateKeyPath})` : ``}`, privateKeyWarning + vscode.l10n.t("Only provide a private key if you want to update from the existing one or set one.") + '<br />' + vscode.l10n.t("OpenSSH, RFC4716 and PPK formats are supported."))
@@ -410,6 +412,7 @@ export class SettingsUI {
410412

411413
//Fix values before assigning the data
412414
data.port = Number(data.port);
415+
data.readyTimeout = Number(data.readyTimeout);
413416
delete data.password;
414417
delete data.buttons;
415418

0 commit comments

Comments
 (0)