mirror of
https://github.com/whyour/qinglong.git
synced 2026-07-01 04:40:38 +08:00
订阅支持添加代理
This commit is contained in:
+15
-6
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user