Skip to content

Commit

Permalink
Merge branch 'master' into ssh_agent
Browse files Browse the repository at this point in the history
  • Loading branch information
sedwards2009 committed Jun 15, 2024
2 parents f8da11c + 4b7def7 commit bdf5251
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 3 deletions.
10 changes: 9 additions & 1 deletion extensions/SSHSessionBackend/src/SSHPty.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ export interface PtyOptions {
privateKeyFilenames?: string[];
tryPasswordAuth: boolean;
agentSocketPath?: string;
verboseLogging?: boolean;
}

enum PtyState {
Expand Down Expand Up @@ -157,12 +158,19 @@ export class SSHPty implements Pty {
});

this.#tryAgentAuth = options.agentSocketPath !== undefined;
let debugFunction: ssh2.DebugFunction = undefined;
if (options.verboseLogging) {
debugFunction = (message: string): void => {
this.#onDataEventEmitter.fire(`ssh logging: ${message}\n\r`);
};
}

this.#sshConnection.connect({
debug: debugFunction,
host: options.host,
port: options.port,
username: options.username,
tryKeyboard: true,
tryKeyboard: false,
agent: options.agentSocketPath,
authHandler: (
methodsLeft: ssh2.AuthenticationType[],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ interface SSHSessionConfiguration extends SessionConfiguration {
username?: string;
authenicationMethod?: AuthenticationMethod;
keyFilePath?: string;
verboseLogging?: boolean;
}

class SSHBackend implements SessionBackend {
Expand Down Expand Up @@ -87,6 +88,7 @@ class SSHBackend implements SessionBackend {
privateKeyFilenames,
tryPasswordAuth,
agentSocketPath: this.#createAgentSocketPath(sessionConfig),
verboseLogging: sessionConfig.verboseLogging,
};

return new SSHPty(this._log, options);
Expand Down Expand Up @@ -141,7 +143,10 @@ class SSHBackend implements SessionBackend {
}
}

let log: Logger = null;

export function activate(context: ExtensionContext): any {
log = context.logger;
context.sessions.registerSessionBackend("ssh", new SSHBackend(context.logger));
}

Expand Down
19 changes: 17 additions & 2 deletions extensions/SSHSessionEditor/src/SSHSessionEditorExtension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
*/
import {ExtensionContext, Logger, SessionConfiguration, SessionEditorBase} from "@extraterm/extraterm-extension-api";
import { Direction, FileMode, QFileDialog, QLineEdit, QPushButton, QWidget } from "@nodegui/nodegui";
import { BoxLayout, ComboBox, GridLayout, LineEdit, SpinBox, Widget, PushButton } from "qt-construct";
import { BoxLayout, ComboBox, GridLayout, LineEdit, SpinBox, Widget, PushButton, CheckBox } from "qt-construct";


let log: Logger = null;
Expand All @@ -32,6 +32,7 @@ interface SSHSessionConfiguration extends SessionConfiguration {
username?: string;
authenicationMethod?: AuthenticationMethod;
keyFilePath?: string;
verboseLogging?: boolean;
}

export function activate(context: ExtensionContext): any {
Expand Down Expand Up @@ -144,7 +145,16 @@ class EditorUi {
}
]
})
})
}),

"",
CheckBox({
text: "Verbose logging",
checked: this.#config.verboseLogging ?? false,
onStateChanged: (enabled: number) => {
this.#handleVerboseLoggingChanged(enabled !== 0);
}
}),
]
})
});
Expand Down Expand Up @@ -174,6 +184,11 @@ class EditorUi {
this.#sessionEditorBase.setSessionConfiguration(this.#config);
}

#handleVerboseLoggingChanged(enabled: boolean): void {
this.#config.verboseLogging = enabled;
this.#sessionEditorBase.setSessionConfiguration(this.#config);
}

getWidget(): QWidget {
return this.#widget;
}
Expand Down

0 comments on commit bdf5251

Please sign in to comment.