update ssh.ts
This commit is contained in:
@@ -202,12 +202,12 @@
|
|||||||
},
|
},
|
||||||
"ssh.ts": {
|
"ssh.ts": {
|
||||||
"script_name": "ssh.ts",
|
"script_name": "ssh.ts",
|
||||||
"script_length": 6806,
|
"script_length": 6813,
|
||||||
"script_sha256": "1d0e457f1247ba1524a6e11d99bbc79e26d94783bbaf51de0aa9e38f0b3d3985",
|
"script_sha256": "d65f2335b82fc5f5376f1df34057d9feae12fe5f74dbfb572ce18f9a089b3a3a",
|
||||||
"script_full_url": "https://git.hatter.ink/hatter/ts-scripts/raw/branch/main/single-scripts/ssh.ts",
|
"script_full_url": "https://git.hatter.ink/hatter/ts-scripts/raw/branch/main/single-scripts/ssh.ts",
|
||||||
"single_script_file": true,
|
"single_script_file": true,
|
||||||
"publish_time": 1768111677531,
|
"publish_time": 1768111677531,
|
||||||
"update_time": 1769318306584
|
"update_time": 1769359601445
|
||||||
},
|
},
|
||||||
"wget.ts": {
|
"wget.ts": {
|
||||||
"script_name": "wget.ts",
|
"script_name": "wget.ts",
|
||||||
|
|||||||
@@ -2,8 +2,8 @@
|
|||||||
|
|
||||||
// reference: https://git.hatter.ink/rust-scripts/scriptbase/src/branch/main/ssh-rs/src/main.rs
|
// reference: https://git.hatter.ink/rust-scripts/scriptbase/src/branch/main/ssh-rs/src/main.rs
|
||||||
|
|
||||||
import {spawn} from "node:child_process";
|
import { spawn } from "node:child_process";
|
||||||
import {parseArgs} from "node:util";
|
import { parseArgs } from "node:util";
|
||||||
|
|
||||||
import fs from "node:fs";
|
import fs from "node:fs";
|
||||||
import os from "node:os";
|
import os from "node:os";
|
||||||
@@ -26,7 +26,7 @@ interface SshConfig {
|
|||||||
default_forward_agent?: boolean;
|
default_forward_agent?: boolean;
|
||||||
default_proxy?: boolean;
|
default_proxy?: boolean;
|
||||||
default_username?: string;
|
default_username?: string;
|
||||||
profiles: Map<string, SshProfile>;
|
profiles: Record<string, SshProfile>;
|
||||||
}
|
}
|
||||||
|
|
||||||
interface SshProfile {
|
interface SshProfile {
|
||||||
@@ -100,11 +100,11 @@ function loadSshConfig(): SshConfig {
|
|||||||
const sshConfigText = fs.readFileSync(configFile, "utf8");
|
const sshConfigText = fs.readFileSync(configFile, "utf8");
|
||||||
return JSON5.parse(sshConfigText);
|
return JSON5.parse(sshConfigText);
|
||||||
} catch (e) {
|
} 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 = [];
|
let profiles = [];
|
||||||
for (const k in sshConfig.profiles) {
|
for (const k in sshConfig.profiles) {
|
||||||
const sshProfile = sshConfig.profiles[k];
|
const sshProfile = sshConfig.profiles[k];
|
||||||
@@ -212,5 +212,5 @@ async function main() {
|
|||||||
}
|
}
|
||||||
await main();
|
await main();
|
||||||
|
|
||||||
// @SCRIPT-SIGNATURE-V1: yk-r1.ES256.20260125T102036+08:00.MEUCIQCn1lxyOA9IK2wnLoXD
|
// @SCRIPT-SIGNATURE-V1: yk-r1.ES256.20260126T004612+08:00.MEQCIFxHjeu7+pkPpSWVoCTb
|
||||||
// 6OjOe3m+V1ZZIwc461wTqQKmsgIgDdRvAsi2Dxvrk1bKXelGeboeO1J3aRdEB/FMPqsXS8Q=
|
// BbzbHhc+dsAG6vqx+i0H8MqLAiAYcK0dcCVECG1je0Q/ZCIYohHCNrvDIOr3kiNj7XWoXg==
|
||||||
|
|||||||
Reference in New Issue
Block a user