mirror of https://github.com/certd/certd
perf: ssh 增加超时断开连接,默认10分钟超时
parent
4f39cb8dfa
commit
c24a040c19
|
@ -86,6 +86,15 @@ export class SshAccess extends BaseAccess {
|
||||||
})
|
})
|
||||||
socksProxy!: string;
|
socksProxy!: string;
|
||||||
|
|
||||||
|
@AccessInput({
|
||||||
|
title: "超时时间",
|
||||||
|
helper: "执行命令的超时时间,单位秒,默认10分钟",
|
||||||
|
component: {
|
||||||
|
name: "a-input-number",
|
||||||
|
},
|
||||||
|
})
|
||||||
|
timeout: number;
|
||||||
|
|
||||||
@AccessInput({
|
@AccessInput({
|
||||||
title: "是否Windows",
|
title: "是否Windows",
|
||||||
helper: "如果是Windows主机,请勾选此项\n并且需要windows[安装OpenSSH](https://certd.docmirror.cn/guide/use/host/windows.html)",
|
helper: "如果是Windows主机,请勾选此项\n并且需要windows[安装OpenSSH](https://certd.docmirror.cn/guide/use/host/windows.html)",
|
||||||
|
|
|
@ -588,10 +588,15 @@ export class SshClient {
|
||||||
}
|
}
|
||||||
throw e;
|
throw e;
|
||||||
}
|
}
|
||||||
|
let timeoutId = null;
|
||||||
try {
|
try {
|
||||||
|
timeoutId = setTimeout(() => {
|
||||||
|
this.logger.info("执行超时,断开连接");
|
||||||
|
conn.end();
|
||||||
|
}, 1000 * (connectConf.timeout || 600));
|
||||||
return await callable(conn);
|
return await callable(conn);
|
||||||
} finally {
|
} finally {
|
||||||
|
clearTimeout(timeoutId);
|
||||||
conn.end();
|
conn.end();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue