forked from mirror/MCSM-Daemon
Feat: add auto download frp.exe
This commit is contained in:
parent
b166a3b180
commit
2c848665f2
@ -52,12 +52,17 @@ export default class OpenFrpTask implements ILifeCycleTask {
|
||||
if (!openFrpToken || !openFrpTunnelId) return;
|
||||
|
||||
if (!fs.existsSync(OpenFrpTask.FRP_EXE_PATH)) {
|
||||
const tmpTask = setInterval(() => {
|
||||
instance.println("FRP", $t("frp.installing"));
|
||||
}, 1000);
|
||||
try {
|
||||
await downloadFileToLocalFile(OpenFrpTask.FRP_DOWNLOAD_ADDR + OpenFrpTask.FRP_EXE_NAME, OpenFrpTask.FRP_EXE_PATH);
|
||||
} catch (error) {
|
||||
logger.error($t("frp.downloadErr"), error);
|
||||
fs.remove(OpenFrpTask.FRP_EXE_PATH, () => {});
|
||||
return;
|
||||
} finally {
|
||||
clearInterval(tmpTask);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -220,6 +220,7 @@
|
||||
"hiperError": "网络映射进程已存在,不可重复启动!"
|
||||
},
|
||||
"frp": {
|
||||
"downloadErr": "下载 FRP 应用程序失败,无法正常启动 FRP 内网映射程序。"
|
||||
"downloadErr": "下载 FRP 应用程序失败,无法正常启动 FRP 内网映射程序。",
|
||||
"installing": "正在同时下载并安装 FRP 内网映射程序,稍后我们将自动启动映射功能"
|
||||
}
|
||||
}
|
||||
|
@ -10,6 +10,7 @@ export function downloadFileToLocalFile(url: string, localFilePath: string): Pro
|
||||
logger.info(`Download File: ${url} --> ${path.normalize(localFilePath)}`);
|
||||
return new Promise(async (resolve, reject) => {
|
||||
try {
|
||||
if (fs.existsSync(localFilePath)) fs.removeSync(localFilePath);
|
||||
const writeStream = fs.createWriteStream(path.normalize(localFilePath));
|
||||
const response = await axios<Readable>({
|
||||
url,
|
||||
|
Loading…
Reference in New Issue
Block a user