update ssh.ts
This commit is contained in:
@@ -2,8 +2,8 @@
|
||||
|
||||
// reference: https://git.hatter.ink/rust-scripts/scriptbase/src/branch/main/ssh-rs/src/main.rs
|
||||
|
||||
import {spawn} from "node:child_process";
|
||||
import {parseArgs} from "node:util";
|
||||
import { spawn } from "node:child_process";
|
||||
import { parseArgs } from "node:util";
|
||||
|
||||
import fs from "node:fs";
|
||||
import os from "node:os";
|
||||
@@ -26,7 +26,7 @@ interface SshConfig {
|
||||
default_forward_agent?: boolean;
|
||||
default_proxy?: boolean;
|
||||
default_username?: string;
|
||||
profiles: Map<string, SshProfile>;
|
||||
profiles: Record<string, SshProfile>;
|
||||
}
|
||||
|
||||
interface SshProfile {
|
||||
@@ -100,11 +100,11 @@ function loadSshConfig(): SshConfig {
|
||||
const sshConfigText = fs.readFileSync(configFile, "utf8");
|
||||
return JSON5.parse(sshConfigText);
|
||||
} catch (e) {
|
||||
console.error(`Load config file: ${configFile} failed.`, e);
|
||||
throw `Load config file: ${configFile} failed: ${e}`;
|
||||
}
|
||||
}
|
||||
|
||||
function matchProfile(sshConfig: SshConfig, host: string): SshProfile {
|
||||
function matchProfile(sshConfig: SshConfig, host: string): SshProfile | null {
|
||||
let profiles = [];
|
||||
for (const k in sshConfig.profiles) {
|
||||
const sshProfile = sshConfig.profiles[k];
|
||||
@@ -212,5 +212,5 @@ async function main() {
|
||||
}
|
||||
await main();
|
||||
|
||||
// @SCRIPT-SIGNATURE-V1: yk-r1.ES256.20260125T102036+08:00.MEUCIQCn1lxyOA9IK2wnLoXD
|
||||
// 6OjOe3m+V1ZZIwc461wTqQKmsgIgDdRvAsi2Dxvrk1bKXelGeboeO1J3aRdEB/FMPqsXS8Q=
|
||||
// @SCRIPT-SIGNATURE-V1: yk-r1.ES256.20260126T004612+08:00.MEQCIFxHjeu7+pkPpSWVoCTb
|
||||
// BbzbHhc+dsAG6vqx+i0H8MqLAiAYcK0dcCVECG1je0Q/ZCIYohHCNrvDIOr3kiNj7XWoXg==
|
||||
|
||||
Reference in New Issue
Block a user