ini批量端口

This commit is contained in:
刘嘉伟 2024-09-07 17:24:51 +08:00
parent 60fbc354d0
commit e4cd09d1dc

View File

@ -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配置文件 * toml配置文件
* @param config * @param config
@ -40,9 +47,7 @@ const getFrpcVersionWorkerPath = (
*/ */
export const genTomlConfig = (config: FrpConfig, proxys: Proxy[]) => { export const genTomlConfig = (config: FrpConfig, proxys: Proxy[]) => {
const proxyToml = proxys.map(m => { const proxyToml = proxys.map(m => {
const rangePort = const rangePort = isRangePort(m);
(m.localPort.indexOf("-") !== -1 || m.localPort.indexOf(",") !== -1) &&
(m.type === "tcp" || m.type === "udp");
let toml = ` let toml = `
${ ${
rangePort rangePort
@ -197,8 +202,9 @@ ${proxyToml.join("")}
*/ */
export const genIniConfig = (config: FrpConfig, proxys: Proxy[]) => { export const genIniConfig = (config: FrpConfig, proxys: Proxy[]) => {
const proxyIni = proxys.map(m => { const proxyIni = proxys.map(m => {
const rangePort = isRangePort(m);
let ini = ` let ini = `
[${m.name}] [${rangePort ? 'range:' : ''}${m.name}]
type = "${m.type}" type = "${m.type}"
`; `;
switch (m.type) { switch (m.type) {