From e4cd09d1dc5606db1ce9560239d754559196bb4b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=88=98=E5=98=89=E4=BC=9F?= <8473136@qq.com> Date: Sat, 7 Sep 2024 17:24:51 +0800 Subject: [PATCH] =?UTF-8?q?:sparkles:=20ini=E6=89=B9=E9=87=8F=E7=AB=AF?= =?UTF-8?q?=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- electron/api/frpc.ts | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/electron/api/frpc.ts b/electron/api/frpc.ts index e7dcc43..be3452c 100644 --- a/electron/api/frpc.ts +++ b/electron/api/frpc.ts @@ -33,6 +33,13 @@ const getFrpcVersionWorkerPath = ( }); }; +const isRangePort = (m: Proxy) => { + return ( + (m.localPort.indexOf("-") !== -1 || m.localPort.indexOf(",") !== -1) && + (m.type === "tcp" || m.type === "udp") + ); +}; + /** * 生成toml配置文件 * @param config @@ -40,9 +47,7 @@ const getFrpcVersionWorkerPath = ( */ export const genTomlConfig = (config: FrpConfig, proxys: Proxy[]) => { const proxyToml = proxys.map(m => { - const rangePort = - (m.localPort.indexOf("-") !== -1 || m.localPort.indexOf(",") !== -1) && - (m.type === "tcp" || m.type === "udp"); + const rangePort = isRangePort(m); let toml = ` ${ rangePort @@ -197,8 +202,9 @@ ${proxyToml.join("")} */ export const genIniConfig = (config: FrpConfig, proxys: Proxy[]) => { const proxyIni = proxys.map(m => { + const rangePort = isRangePort(m); let ini = ` -[${m.name}] +[${rangePort ? 'range:' : ''}${m.name}] type = "${m.type}" `; switch (m.type) {