订阅支持添加代理

This commit is contained in:
whyour
2022-11-12 22:45:46 +08:00
parent 8fdd8db51b
commit ff2b4e0b2f
5 changed files with 56 additions and 24 deletions
+15 -6
View File
@@ -38,8 +38,12 @@ export default class SshKeyService {
}
}
private generateSingleSshConfig(alias: string, host: string): string {
return `\nHost ${alias}\n Hostname ${host}\n IdentityFile ${this.sshPath}/${alias}\n StrictHostKeyChecking no`;
private generateSingleSshConfig(
alias: string,
host: string,
proxy?: string,
): string {
return `\nHost ${alias}\n Hostname ${host}\n IdentityFile ${this.sshPath}/${alias}\n StrictHostKeyChecking no\n`;
}
private generateSshConfig(configs: string[]) {
@@ -69,16 +73,21 @@ export default class SshKeyService {
}
}
public addSSHKey(key: string, alias: string, host: string): void {
public addSSHKey(
key: string,
alias: string,
host: string,
proxy?: string,
): void {
this.generatePrivateKeyFile(alias, key);
const config = this.generateSingleSshConfig(alias, host);
const config = this.generateSingleSshConfig(alias, host, proxy);
this.removeSshConfig(alias);
this.generateSshConfig([config]);
}
public removeSSHKey(alias: string, host: string): void {
public removeSSHKey(alias: string, host: string, proxy?: string): void {
this.removePrivateKeyFile(alias);
const config = this.generateSingleSshConfig(alias, host);
const config = this.generateSingleSshConfig(alias, host, proxy);
this.removeSshConfig(config);
}
}