Compare commits

..
22 Commits
Author SHA1 Message Date
heixiansen 8f2c800380 增加quic代理配置,config.json增加quic配置,默认使用2.3.2内核,增加窗口可拖动的大小用于应对用户调整字体大小缩放的问题 #14 2025-06-23 12:20:29 +08:00
heixiansen 8b2ce406d8 如果是内核是预发布版本,不再提示更新 2025-06-20 16:11:43 +08:00
heixiansen 10dde939cb Merge branch 'main' into dev_1.4.7 2025-06-16 11:44:52 +08:00
heixiansen 84460409ed 对于三层tun而言,winipbroadcast没有作用,先禁用 #15 2025-06-16 11:44:26 +08:00
heixiansen 60faa01769 监听窗口缩放比例,默认按照缩放计算并设置一次窗口大小 2025-06-16 11:44:26 +08:00
heixiansen 26f3f6fb36 托盘菜单也增加重新联机选项 2025-06-16 11:44:26 +08:00
heixiansen 494087820a 增加重新联机的按钮 2025-06-16 11:44:26 +08:00
heixiansen 87f4d98518 对于三层tun而言,winipbroadcast没有作用,先禁用 #15 2025-06-16 11:43:54 +08:00
黑先森andGitHub 30a2c3430b Merge pull request #16 from lurenjia1213/main
允许在使用电池时自启动
2025-06-16 11:42:55 +08:00
lurenjia1213 aab8175ce3 允许在使用电池时自启动 2025-06-15 21:49:46 +08:00
heixiansen 136ce06c33 监听窗口缩放比例,默认按照缩放计算并设置一次窗口大小 2025-06-09 15:49:43 +08:00
heixiansen bdeda8bebd 托盘菜单也增加重新联机选项 2025-06-06 18:13:11 +08:00
heixiansen 3ee09f7d60 增加重新联机的按钮 2025-06-06 18:09:08 +08:00
heixiansen 7853d3b2f5 适配命令行参数用法,修复部分参数不生效的问题 2025-06-06 17:25:39 +08:00
heixiansen aacf47b6f5 自建服务器 增加私有模式配置 2025-06-06 16:40:26 +08:00
heixiansen d9b01fc754 默认使用2.3.1内核,高级选项增加 私有模式配置, 成员列表排序优化, 启动软件时,左上角出现遮盖图标进行去除修复 2025-06-06 16:34:19 +08:00
heixiansen 844fba8462 修复左上角会出现小图标窗口的问题 2025-06-04 18:11:24 +08:00
heixiansen 6bfe3860a8 增加端口转发说明 2025-05-26 20:37:22 +08:00
heixiansen a0b4071c49 增加 端口转发配置 2025-05-26 20:34:02 +08:00
heixiansen 8e9bb114d6 高级选项增加魔法DNS( 2.3.0内核以上) 优化成员列表延迟排序,1.4.5发布 2025-05-26 17:20:56 +08:00
heixiansen fb8e127198 修复主界面保存config.json失败的问题,优化开机自启(默认调整为不登录也自动启动)优化窗口数据同步问题 升级开发包 升级内核至少2.3.0 2025-05-26 16:00:50 +08:00
黑先森 3cd19ae42a 更新element-plus和nuxt3包体,删除增强工具-自定义防火墙策略按钮,修复一键关闭防火墙无效的bug 2025-05-10 16:18:06 +08:00
23 changed files with 4300 additions and 1683 deletions
+18 -1
View File
@@ -2,7 +2,21 @@ import { BaseDirectory, writeTextFile } from "@tauri-apps/plugin-fs";
import useMainStore from "@/stores/index";
import { ElMessage } from "element-plus";
import { uniq, intersection, isNil } from "lodash-es";
export const updateConfigJson = async (configJsonSeverUrl: Array<string> | string | null | undefined) => {
import { bounce } from "~/utils";
const b = bounce(600);
export type ConfigServerUrlType = Array<string> | string | null | undefined | null;
export const updateConfigJsonBounce = (configJsonSeverUrl?: ConfigServerUrlType) => {
b(async () => {
const mainStore = useMainStore();
if (mainStore.createConfigInEasytier) {
await updateConfigJson(configJsonSeverUrl);
}
});
};
export const updateConfigJson = async (configJsonSeverUrl?: ConfigServerUrlType) => {
const mainStore = useMainStore();
const path = import.meta.env.VITE_CONFIG_FILE_NAME;
if (isNil(configJsonSeverUrl)) {
@@ -20,6 +34,9 @@ export const updateConfigJson = async (configJsonSeverUrl: Array<string> | strin
enableCustomListener,
customListenerData,
bindDeviceEnable,
acceptDNS,
enablePortForward,
portForwardData,
...otherConfig
} = mainStore.config;
let writeServerUrl: Array<string> | string = serverUrl;
+3
View File
@@ -20,5 +20,8 @@ export const getServerArgs = () => {
if (!whiteList && mainStore.serverConfig.enableWhiteList) {
args.push("--relay-network-whitelist");
}
if (mainStore.serverConfig.privateMode) {
args.push("--private-mode", "true");
}
return args;
};
+15 -4
View File
@@ -22,7 +22,7 @@ async function toggleVisibility() {
}
}
export async function useTray(init: boolean = false, beforExit: Function, handleConnection: Function) {
export async function useTray(init: boolean = false, beforExit: Function, handleConnection: Function, handleReconnect: Function) {
let tray;
try {
tray = await TrayIcon.getById(DEFAULT_TRAY_NAME);
@@ -31,7 +31,7 @@ export async function useTray(init: boolean = false, beforExit: Function, handle
tooltip: `EasyTierGame\n${pkg.version}`,
title: `EasyTierGame\n${pkg.version}`,
id: DEFAULT_TRAY_NAME,
menu: await Menu.new({ id: "main", items: await generateMenuItem(beforExit, handleConnection) }),
menu: await Menu.new({ id: "main", items: await generateMenuItem(beforExit, handleConnection, handleReconnect) }),
action: async e => {
toggleVisibility();
}
@@ -45,16 +45,17 @@ export async function useTray(init: boolean = false, beforExit: Function, handle
if (init) {
tray.setTooltip(`EasyTierGame\n${pkg.version}`);
tray.setShowMenuOnLeftClick(false);
tray.setMenu(await Menu.new({ id: "main", items: await generateMenuItem(beforExit, handleConnection) }));
tray.setMenu(await Menu.new({ id: "main", items: await generateMenuItem(beforExit, handleConnection, handleReconnect) }));
}
return tray;
}
export async function generateMenuItem(beforExit: Function, handleConnection: Function) {
export async function generateMenuItem(beforExit: Function, handleConnection: Function, handleReconnect: Function) {
return [
await MenuItemShow("显示 / 隐藏"),
await MenuItemExchangeConnection("联机 / 断开", handleConnection),
await MenuItemReconnect("重新联机", handleReconnect),
await MenuItemTheme(),
await PredefinedMenuItem.new({ item: "Separator" }),
await MenuItemPublicPeers(),
@@ -63,6 +64,16 @@ export async function generateMenuItem(beforExit: Function, handleConnection: Fu
];
}
export async function MenuItemReconnect(text: string, handleReconnect: Function) {
return await MenuItem.new({
id: "reconnect",
text,
action: async () => {
await handleReconnect();
}
});
}
export async function MenuItemExit(text: string, beforExit: Function) {
return await MenuItem.new({
id: "quit",
+23 -18
View File
@@ -1,17 +1,14 @@
import { type UnlistenFn } from "@tauri-apps/api/event";
import { getCurrentWindow, PhysicalPosition, type WindowOptions, Window, currentMonitor } from "@tauri-apps/api/window";
import { getCurrentWindow, PhysicalPosition, type WindowOptions, Window, currentMonitor, PhysicalSize } from "@tauri-apps/api/window";
import { WebviewWindow } from "@tauri-apps/api/webviewWindow";
import type { WebviewLabel, WebviewOptions } from "@tauri-apps/api/webview";
import useMainStore from "@/stores/index";
import { onBeforeUnmount } from "vue";
import { updateConfigJsonBounce, type ConfigServerUrlType } from "./configJson";
const _listenersMaps: { [key: string]: [UnlistenFn | null] } = {};
const dealCloseListener = async (
dialog: WebviewWindow,
label: string,
beforeCloseFunc?: () => void | null
) => {
const dealCloseListener = async (dialog: WebviewWindow, label: string, beforeCloseFunc?: () => void | null) => {
const unlistenFnList: [UnlistenFn | null] = _listenersMaps[label] || [null];
let [unListenlogClose] = unlistenFnList;
@@ -20,7 +17,7 @@ const dealCloseListener = async (
unListenlogClose = await dialog.onCloseRequested(async () => {
beforeCloseFunc && (await beforeCloseFunc());
unListenlogClose && (await unListenlogClose());
console.log("close")
console.log("close");
});
};
export default async (
@@ -44,20 +41,24 @@ export default async (
};
const appWindow = getCurrentWindow();
if (appWindow) {
const appSize = await appWindow.outerSize();
const factor = await appWindow.scaleFactor();
const appPosition = await appWindow.outerPosition();
const logicalPosition = new PhysicalPosition(appPosition.x + appSize.width, appPosition.y).toLogical(factor);
defaultOpts.parent = appWindow;
// console.error(logicalPosition);
defaultOpts.x = logicalPosition.x;
defaultOpts.y = logicalPosition.y;
if (defaultOpts.x == 0 && defaultOpts.y == 0) {
const logicalAppSize = {
width: 340,
height: 305
}
const factor = await appWindow.scaleFactor();
const appPosition = await appWindow.outerPosition();
const logicalPosition = new PhysicalPosition(appPosition.x + Math.ceil((logicalAppSize.width + 5) * factor), appPosition.y).toLogical(factor);
defaultOpts.x = logicalPosition.x;
defaultOpts.y = logicalPosition.y;
}
}
dialog = new WebviewWindow(label, { ...defaultOpts, ...options });
await dealCloseListener(dialog, label, beforeCloseFunc);
afterCreatedFunc && (await afterCreatedFunc(dialog, appWindow));
await dialog.show();
afterCreatedFunc && (await afterCreatedFunc(dialog, appWindow));
} else {
const visible = await dialog.isVisible();
if (visible) {
@@ -65,20 +66,23 @@ export default async (
} else {
const appWindow = getCurrentWindow();
await dealCloseListener(dialog, label, beforeCloseFunc);
afterCreatedFunc && (await afterCreatedFunc(dialog, appWindow));
await dialog.show();
afterCreatedFunc && (await afterCreatedFunc(dialog, appWindow));
}
}
};
export const dataSubscribe = async (cb?: (...args: any) => any) => {
if (!cb) return;
export const dataSubscribe = async (cb?: any, getconfigServerUrl?: () => ConfigServerUrlType) => {
const mainStore = useMainStore();
const abort = new AbortController();
window.addEventListener(
"storage",
async () => {
// console.log("触发", {dhcp:mainStore.config.dhcp, c: mainStore.createConfigInEasytier})
mainStore.$hydrate();
const configServerUrl = getconfigServerUrl && getconfigServerUrl instanceof Function ? getconfigServerUrl() : null;
updateConfigJsonBounce(configServerUrl);
if (cb && cb instanceof Function) {
await cb();
}
@@ -88,6 +92,7 @@ export const dataSubscribe = async (cb?: (...args: any) => any) => {
}
);
onBeforeUnmount(() => {
console.log("取消监听");
abort?.abort();
});
};
+11 -11
View File
@@ -3,7 +3,7 @@
"private": true,
"author": "leizi97",
"description": "A simple network initiator based on Easytier",
"version": "1.4.4",
"version": "1.4.7",
"scripts": {
"dev": "nuxt dev --dotenv env/.env.dev --host 0.0.0.0",
"build": "nuxt generate --dotenv env/.env.prod",
@@ -12,30 +12,30 @@
},
"devDependencies": {
"@element-plus/icons-vue": "^2.3.1",
"@element-plus/nuxt": "^1.1.1",
"@element-plus/nuxt": "1.1.3",
"@nuxtjs/tailwindcss": "6.13.2",
"@pinia/nuxt": "0.11.0",
"@pinia/nuxt": "0.11.1",
"@tauri-apps/api": "2.5.0",
"@tauri-apps/cli": "2.5.0",
"@tauri-apps/plugin-cli": "^2.2.0",
"@tauri-apps/plugin-clipboard-manager": "2.2.2",
"@tauri-apps/plugin-dialog": "2.2.1",
"@tauri-apps/plugin-fs": "2.2.1",
"@tauri-apps/plugin-log": "2.3.1",
"@tauri-apps/plugin-dialog": "2.2.2",
"@tauri-apps/plugin-fs": "2.3.0",
"@tauri-apps/plugin-log": "2.4.0",
"@tauri-apps/plugin-shell": "2.2.1",
"@tauri-apps/plugin-window-state": "2.2.2",
"@types/lodash-es": "^4.17.12",
"@vitejs/plugin-vue-jsx": "4.1.2",
"@vueuse/core": "12.7.0",
"archiver": "^7.0.1",
"element-plus": "2.9.7",
"element-plus": "2.10.2",
"less": "4.2.1",
"lodash-es": "^4.17.21",
"nuxt": "3.16.2",
"pinia": "3.0.2",
"pinia-plugin-persistedstate": "^4.2.0",
"nuxt": "3.17.5",
"pinia": "3.0.3",
"pinia-plugin-persistedstate": "4.3.0",
"postcss": "^8.4.38",
"prettier": "3.5.2",
"prettier-plugin-tailwindcss": "0.6.11"
"prettier-plugin-tailwindcss": "0.6.13"
}
}
+127 -50
View File
@@ -44,21 +44,59 @@
</ElTooltip>
</div>
<div class="flex flex-nowrap items-center gap-[5px]">
<ElCheckbox v-model="mainStore.config.enableKcpProxy">启用KCP代理</ElCheckbox>
<ElTooltip content="将TCP流量转为KCP流量,降低传输延迟,提升传输速度">
<ElCheckbox
@change="handleKcpProxyChange"
v-model="mainStore.config.enableKcpProxy"
>
启用KCP代理
</ElCheckbox>
<ElTooltip content="(不可与QUIC代理同时开启)将TCP流量转为KCP流量,降低传输延迟,提升传输速度">
<ElIcon><QuestionFilled /></ElIcon>
</ElTooltip>
<CoreVersionWarning version="2.2.0" />
</div>
<div class="flex flex-nowrap items-center gap-[5px]">
<ElCheckbox v-model="mainStore.config.disableKcpInput">禁用KCP输入</ElCheckbox>
<ElTooltip content="禁用KCP入站流量,其他开启KCP代理的节点无法连接到本节点">
<ElTooltip content="不允许其他节点使用 KCP 代理 TCP 流到此节点。开启 KCP 代理的节点访问此节点时,依然使用原始 TCP 连接">
<ElIcon><QuestionFilled /></ElIcon>
</ElTooltip>
<CoreVersionWarning version="2.2.0" />
</div>
<div class="flex flex-nowrap items-center gap-[5px]">
<ElCheckbox
@change="handleQuicProxyChange"
v-model="mainStore.config.enableQuicProxy"
>
启用QUIC代理
</ElCheckbox>
<ElTooltip content="(不可与KCP代理同时开启)使用 QUIC 代理 TCP 流,提高在 UDP 丢包网络上的延迟和吞吐量">
<ElIcon><QuestionFilled /></ElIcon>
</ElTooltip>
<CoreVersionWarning version="2.3.2" />
</div>
<div class="flex flex-nowrap items-center gap-[5px]">
<ElCheckbox v-model="mainStore.config.disableQuicInput">禁用QUIC输入</ElCheckbox>
<ElTooltip content="不允许其他节点使用 QUIC 代理 TCP 流到此节点。开启 QUIC 代理的节点访问此节点时,依然使用原始 TCP 连接">
<ElIcon><QuestionFilled /></ElIcon>
</ElTooltip>
<CoreVersionWarning version="2.3.2" />
</div>
<div><ElCheckbox v-model="mainStore.config.disableUdpHolePunching">禁用UDP打洞功能</ElCheckbox></div>
<div><ElCheckbox v-model="mainStore.config.disableIpv6">不使用IPv6</ElCheckbox></div>
<div class="flex flex-nowrap items-center gap-[5px]">
<ElCheckbox v-model="mainStore.config.acceptDNS">魔法DNS</ElCheckbox>
<ElTooltip content="您可以使用域名访问其他节点,例如:<hostname>.et.net。魔法DNS将修改您的系统DNS设置,请谨慎启用">
<ElIcon><QuestionFilled /></ElIcon>
</ElTooltip>
<CoreVersionWarning version="2.3.0" />
</div>
<div class="flex flex-nowrap items-center gap-[5px]">
<ElCheckbox v-model="mainStore.config.privateMode">启用私有模式</ElCheckbox>
<ElTooltip content="启用后,不允许使用了与本网络不同的房间名和密码的节点通过本节点进行握手或中转">
<ElIcon><QuestionFilled /></ElIcon>
</ElTooltip>
<CoreVersionWarning version="2.3.1" />
</div>
<ElDivider />
<div class="flex items-center gap-[10px]">
<ElCheckbox v-model="mainStore.config.disbleListenner">不监听任何端口只连接到对等节点</ElCheckbox>
@@ -103,6 +141,7 @@
class="!mb-0"
v-model="listenerDialogData.visible"
:close-on-press-escape="false"
:close-on-click-modal="false"
title="自定义监听地址"
>
<ElInput
@@ -124,28 +163,65 @@
</template>
</ElDialog>
</div>
<!-- <div class="flex items-center gap-[10px]">
<ElCheckbox
:disabled="mainStore.config.disbleListenner"
:model-value="mainStore.config.enableCustomListenerV6"
@change="handleCustomListenerV6Change"
<div class="flex items-center gap-[10px]">
<ElCheckbox v-model="mainStore.config.enablePortForward">端口转发</ElCheckbox>
<ElTooltip
:disabled="mainStore.config.enablePortForward"
content="请先开启端口转发功能"
>
自定义IPV6监听地址
</ElCheckbox>
<div class="w-[200px]">
<ElInput
:disabled="mainStore.config.disbleListenner || mainStore.config.enableCustomListenerV6"
<ElButton
size="small"
:maxlength="100"
v-model="mainStore.config.customListenerV6Data"
placeholder="请输入自定义IPV6监听地址"
/>
</div>
<ElTooltip content="例如:tcp://[::]:11010,如果未设置,将在随机UDP端口上监听(内核版本2.2.3之后,ipv6监听被移除并合并到'自定义监听')">
:disabled="!mainStore.config.enablePortForward"
@click="handlePortForwardDialog"
>
配置
</ElButton>
</ElTooltip>
<ElTooltip
content="将本地端口转发到虚拟网络中的远程端口.如:udp://0.0.0.0:12345/10.126.126.1:23456,表示将本地UDP端口12345转发到虚拟网络中的10.126.126.1:23456.可以指定多个"
>
<ElIcon><QuestionFilled /></ElIcon>
</ElTooltip>
<CoreVersionWarning version="2.1.0" />
</div> -->
<CoreVersionWarning version="2.3.0" />
<ElDialog
width="95%"
top="5px"
append-to-body
:z-index="10"
class="!mb-0"
v-model="portForwardDialogData.visible"
:close-on-press-escape="false"
:close-on-click-modal="false"
title="端口转发配置"
>
<div class="mb-4">
<ElText
size="small"
type="info"
>
<div> 每行一个转发规则</div>
<div> 格式协议://本地地址:本地端口/目标地址:目标端口</div>
<div class="flex items-center">
<span class="mr-auto"> 例如udp://0.0.0.0:12345/10.126.126.1:23456</span>
<ElButton
size="default"
type="primary"
@click.stop="handleFinishInputPortForward"
>
填写完毕
</ElButton>
</div>
</ElText>
</div>
<ElInput
type="textarea"
:rows="10"
placeholder="请输入端口转发规则,每行一个&#10;例如:&#10;udp://0.0.0.0:12345/10.126.126.1:23456&#10;tcp://0.0.0.0:8080/192.168.1.100:80"
v-model="mainStore.config.portForwardData"
></ElInput>
<!-- -->
</ElDialog>
</div>
<ElDivider />
<div class="flex items-center gap-[10px]">
<ElCheckbox v-model="mainStore.config.devName">自定义虚拟网卡名称</ElCheckbox>
@@ -193,25 +269,9 @@
<div class="flex items-center gap-[5px]">
<div><ElCheckbox v-model="mainStore.config.bindDeviceEnable">绑定物理网卡</ElCheckbox></div>
<!-- <div class="flex items-center gap-[5px]"> -->
<!-- <ElSelect
placeholder="选择设备"
v-model="mainStore.config.bindDevice"
filterable
no-data-text="暂无网卡设备数据请刷新"
>
<ElOption
v-for="guid in guids"
:key="guid[0]"
:label="guid[1]"
:value="guid[0]"
></ElOption>
</ElSelect> -->
<!-- <ElButton @click="getGuids">刷新</ElButton> -->
<ElTooltip content="将连接器的套接字绑定到物理设备以避免路由问题。比如子网代理网段与某节点的网段冲突,绑定物理设备后可以与该节点正常通信">
<ElIcon><QuestionFilled /></ElIcon>
</ElTooltip>
<!-- </div> -->
<CoreVersionWarning version="2.2.3" />
</div>
@@ -304,6 +364,15 @@
loading: false
});
const portForwardDialogData = reactive<{ [key: string]: any }>({
visible: false,
loading: false
});
const handlePortForwardDialog = () => {
portForwardDialogData.visible = true;
};
const handleListenerDialog = () => {
listenerDialogData.visible = true;
};
@@ -312,19 +381,9 @@
listenerDialogData.visible = false;
};
// const handleCustomListenerV6Change = async (value: boolean) => {
// if (value) {
// const [error, _] = await ElConfirmDanger("内核版本2.2.3之后,ipv6监听被移除并合并到'自定义监听',请谨慎使用", "警告", {
// confirmButtonText: "继续使用",
// cancelButtonText: "取消"
// });
// if (!error) {
// mainStore.config.enableCustomListenerV6 = value;
// }
// } else {
// mainStore.config.enableCustomListenerV6 = value;
// }
// };
const handleFinishInputPortForward = async () => {
portForwardDialogData.visible = false;
};
const mainStore = useMainStore();
const data = ["trace", "debug", "info", "warn", "error", "off"];
@@ -353,6 +412,24 @@
}
};
const handleKcpProxyChange = () => {
if (mainStore.config.enableKcpProxy) {
if (mainStore.config.enableQuicProxy) {
ElMessage.warning("KCP代理和QUIC代理不能同时开启");
}
mainStore.config.enableQuicProxy = false;
}
};
const handleQuicProxyChange = () => {
if (mainStore.config.enableQuicProxy) {
if (mainStore.config.enableKcpProxy) {
ElMessage.warning("KCP代理和QUIC代理不能同时开启");
}
mainStore.config.enableKcpProxy = false;
}
};
// 为bind_device功能增加改方法
const getGuids = async () => {
const guidsValue = await invoke<string[][]>("get_network_adapter_guids");
+2 -1
View File
@@ -113,9 +113,10 @@
onMounted(async () => {
unlistenStart = await listenStart();
dataSubscribe();
});
dataSubscribe();
onBeforeUnmount(() => {
unlistenStart && unlistenStart();
});
+220 -120
View File
@@ -2,7 +2,7 @@
<ElForm
size="small"
label-position="top"
:model="config"
:model="mainStore.config"
>
<ElFormItem
label="服务器"
@@ -70,18 +70,18 @@
filterable
placeholder="请选择服务器地址"
default-first-option
v-model="config.serverUrl"
v-model="mainStore.config.serverUrl"
no-data-text="无服务器地址"
@change="handleServerUrlChange"
>
<template #prefix>
<div :class="config.protocol && config.protocol.length > 1 ? 'w-[120px]' : 'w-[80px]'">
<div :class="mainStore.config.protocol && mainStore.config.protocol.length > 1 ? 'w-[120px]' : 'w-[80px]'">
<ElSelect
placeholder="协议"
multiple
collapse-tags
@click.stop
v-model="config.protocol"
v-model="mainStore.config.protocol"
@change="handleServerUrlChange"
>
<ElOption
@@ -98,7 +98,7 @@
<ElLink
type="primary"
size="small"
:underline="false"
underline="never"
@click.stop="open(publicPeersLink)"
>
其他公共服务器
@@ -161,7 +161,7 @@
<ElInput
maxlength="100"
placeholder="请输入房间名"
v-model="config.networkName"
v-model="mainStore.config.networkName"
></ElInput>
</ElFormItem>
</div>
@@ -179,7 +179,7 @@
show-password
maxlength="100"
placeholder="请输入房间密码"
v-model="config.networkPassword"
v-model="mainStore.config.networkPassword"
type="password"
></ElInput>
</ElFormItem>
@@ -198,7 +198,7 @@
<ElInput
maxlength="100"
placeholder="例如: Player1"
v-model="config.hostname"
v-model="mainStore.config.hostname"
></ElInput>
</ElFormItem>
<ElFormItem
@@ -217,7 +217,7 @@
:icon="CopyDocument"
></ElButton>
<ElSwitch
v-model="config.dhcp"
v-model="mainStore.config.dhcp"
inline-prompt
inactive-text="固定IP"
active-text="动态获取"
@@ -230,21 +230,21 @@
</template>
<ElInput
maxlength="100"
:readonly="config.dhcp"
:placeholder="data.isStart && config.dhcp ? '等待动态分配IP...' : '例如: 10.126.126.1'"
v-model="config.ipv4"
:readonly="mainStore.config.dhcp"
:placeholder="data.isStart && mainStore.config.dhcp ? '等待动态分配IP...' : '例如: 10.126.126.1'"
v-model="mainStore.config.ipv4"
>
<template #prefix>
<ElTooltip
class="!text-[10px]"
placement="top-end"
:content="config.dhcp ? '动态获取无法手动填写' : '固定IP可以手动填写'"
:content="mainStore.config.dhcp ? '动态获取无法手动填写' : '固定IP可以手动填写'"
>
<ElTag
size="small"
:type="config.dhcp ? 'info' : 'success'"
:type="mainStore.config.dhcp ? 'info' : 'success'"
>
{{ config.dhcp ? "只读" : "可填" }}
{{ mainStore.config.dhcp ? "只读" : "可填" }}
</ElTag>
</ElTooltip>
</template>
@@ -272,21 +272,6 @@
{{ !data.isStart ? "启动联机" : "停止联机" }}
<template #dropdown>
<ElDropdownMenu>
<ElDropdownItem
command="import_config"
:icon="Link"
>
导入联机配置
</ElDropdownItem>
<ElDropdownItem
command="share_config"
:icon="Share"
>
分享联机配置
</ElDropdownItem>
<ElDropdownItem disabled>
<ElDivider class="!m-0 !h-[2px]" />
</ElDropdownItem>
<ElDropdownItem
:icon="SetUp"
command="create_server"
@@ -328,6 +313,27 @@
>
本地游戏列表
</ElDropdownItem>
<ElDropdownItem disabled>
<ElDivider class="!m-0 !h-[2px]" />
</ElDropdownItem>
<ElDropdownItem
command="import_config"
:icon="Link"
>
导入联机配置
</ElDropdownItem>
<ElDropdownItem
command="share_config"
:icon="Share"
>
分享联机配置
</ElDropdownItem>
<ElDropdownItem
command="reconnect"
:icon="RefreshRight"
>
重新联机
</ElDropdownItem>
</ElDropdownMenu>
</template>
</ElDropdown>
@@ -363,7 +369,7 @@
</div>
<div class="ml-auto">
<ElCheckbox
v-model="config.disbleP2p"
v-model="mainStore.config.disbleP2p"
size="small"
>
强制中转
@@ -374,7 +380,7 @@
>
<ElCheckbox
@change="handleAutoStartByTask"
:model-value="config.autoStart"
:model-value="mainStore.config.autoStart"
size="small"
>
开机自启
@@ -419,7 +425,7 @@
<ElLink
class="ml-[8px] truncate pb-[2px] !text-[9px]"
type="info"
:underline="false"
underline="never"
@click="open('https://github.com/EasyTier/EasytierGame')"
>
EasytierGame主页
@@ -720,15 +726,15 @@
import { initStartWinIpBroadcast } from "~/composables/netcard";
import useMainStore from "@/stores/index";
import { ElMessage, ElMessageBox, ElTooltip } from "element-plus";
import { getCurrentWindow, type Window } from "@tauri-apps/api/window";
import { getCurrentWindow, PhysicalSize, type Window } from "@tauri-apps/api/window";
import { getAllWebviewWindows, WebviewWindow } from "@tauri-apps/api/webviewWindow";
import etWindows, { dataSubscribe } from "@/composables/windows";
import { resourceDir as getResourceDir, join } from "@tauri-apps/api/path";
import { readDir, exists, mkdir, BaseDirectory, readTextFile, readFile, writeFile, remove as removeFile } from "@tauri-apps/plugin-fs";
import { updateConfigJson } from "~/composables/configJson";
import { readDir, exists, mkdir, BaseDirectory, readTextFile, readFile, writeFile, remove as removeFile, stat } from "@tauri-apps/plugin-fs";
import { updateConfigJson, updateConfigJsonBounce } from "~/composables/configJson";
import { writeText, readText } from "@tauri-apps/plugin-clipboard-manager";
import { sortedUniq, uniq } from "lodash-es";
import { bounce, addQQGroup, supportProtocols, preventSleep, stopPreventSleep, ATJ, copyText, isValidWindowsFileName } from "~/utils";
import { addQQGroup, supportProtocols, preventSleep, stopPreventSleep, ATJ, copyText, isValidWindowsFileName } from "~/utils";
import { ElConfirmDanger, ElConfirmPrimary } from "~/utils/element";
import { getServerArgs } from "@/composables/server";
@@ -746,12 +752,14 @@
async () => {
await handleConnection();
return data.isStart;
},
async () => {
await handleReconnect();
}
);
const mainStore = useMainStore();
const config = mainStore.config;
// console.error(config);
const protocols = supportProtocols();
const data = reactive({
//easytierGame有没有新版
@@ -816,8 +824,8 @@
};
const handleCopyIp = async () => {
if (!config.ipv4?.trim()) return;
if (data.isStart || !config.dhcp) {
if (!mainStore.config.ipv4?.trim()) return;
if (data.isStart || !mainStore.config.dhcp) {
await copyText(mainStore.config.ipv4);
} else {
await copyText(mainStore.config.ipv4, "复制成功,联机后IP可能会变化");
@@ -842,8 +850,8 @@
const newBasePeers = [...mainStore.basePeers];
const idx = newBasePeers.indexOf(url);
if (idx >= 0) {
if (config.serverUrl === url) {
config.serverUrl = "";
if (mainStore.config.serverUrl === url) {
mainStore.config.serverUrl = "";
}
newBasePeers.splice(idx, 1);
}
@@ -856,7 +864,7 @@
const handleServerUrlChange = () => {
let inputProtocols: string | null = null;
for (const p of protocols) {
if (config.serverUrl.toLowerCase().startsWith(`${p}://`)) {
if (mainStore.config.serverUrl.toLowerCase().startsWith(`${p}://`)) {
inputProtocols = p;
break;
}
@@ -1086,8 +1094,8 @@
const list = await invoke<string[][][]>("fetch_easytier_list");
data.releaseList = [
...list.flat().filter(el => {
// console.log(el, el[0], el[2]);
return el && el[0] && el[2] && !el[2].includes("gui");
// console.log(el, el[0], el[2], el[3]); // el[3] 是prerelease bool值
return el && el[0] && el[2] && !el[2].includes("gui") && (el[3] != 'true' || !el[3]);
})
] as any;
coreManagementData.loading = false;
@@ -1096,9 +1104,9 @@
const handleAutoStartByTask = async () => {
if (import.meta.env.DEV) return ElMessage.warning("开发环境不支持开机自启");
await invoke("spawn_autostart", { enabled: !config.autoStart });
await invoke("spawn_autostart", { enabled: !mainStore.config.autoStart });
const is_enable_by_task = (await invoke("autostart_is_enabled")) as boolean;
config.autoStart = is_enable_by_task;
mainStore.config.autoStart = is_enable_by_task;
};
const compatibleInitAutoStart = async () => {
@@ -1111,37 +1119,37 @@
await invoke("spawn_autostart", { enabled: true });
}
is_enable_by_task = (await invoke("autostart_is_enabled")) as boolean;
config.autoStart = is_enable_by_task;
mainStore.config.autoStart = is_enable_by_task;
} catch (err) {
console.error(err);
await invoke("spawn_autostart", { enabled: false });
const is_enable_by_task = (await invoke("autostart_is_enabled")) as boolean;
config.autoStart = is_enable_by_task;
mainStore.config.autoStart = is_enable_by_task;
}
};
const compatibleIpv6Listener = async () => {
// ipv6监听在后续版本合并到customListenner里了,这里做兼容处理
if (config.enableCustomListenerV6 && config.customListenerV6Data) {
const customListener = config.customListenerV6Data.trim();
if (mainStore.config.enableCustomListenerV6 && mainStore.config.customListenerV6Data) {
const customListener = mainStore.config.customListenerV6Data.trim();
if (customListener) {
const customListenerV4 = config.customListenerData
const customListenerV4 = mainStore.config.customListenerData
.trim()
.split("\n")
.map(el => el.trim())
.filter(el => el);
if (!customListenerV4.includes(customListener)) {
config.customListenerData += `\n${customListener}`;
mainStore.config.customListenerData += `\n${customListener}`;
}
}
}
if (config.enableCustomListenerV6) {
config.enableCustomListenerV6 = false;
if (mainStore.config.enableCustomListenerV6) {
mainStore.config.enableCustomListenerV6 = false;
}
};
const initConnectAfterStart = async () => {
if (config.connectAfterStart && data.coreVersion) {
if (mainStore.config.connectAfterStart && data.coreVersion) {
await reset();
await handleConnection();
}
@@ -1175,6 +1183,10 @@
saveServerUrl = mainStore.basePeers.length > 0 ? mainStore.basePeers[0] || "" : "";
}
data.configJsonSeverUrl = guiJson.serverUrl;
if(guiJson.enableKcpProxy && guiJson.enableQuicProxy) {
// 如果同时开启kcp代理和quic代理,则禁用quic代理
guiJson.enableQuicProxy = false;
}
mainStore.$patch({
config: {
...mainStore.config,
@@ -1225,18 +1237,29 @@
await appWindow.show();
await appWindow.setFocus();
}
const appWindow = getCurrentWindow();
const logicalAppSize = {
width: 340,
height: 305
}
const scaleFactor = await appWindow.scaleFactor();
const size = new PhysicalSize(Math.ceil(logicalAppSize.width * scaleFactor), Math.ceil(logicalAppSize.height * scaleFactor));
appWindow.setSize(size);
appWindow.onScaleChanged(({ payload: { scaleFactor } }) => {
console.log("scaleFactor", scaleFactor);
appWindow.setSize(new PhysicalSize(Math.ceil(logicalAppSize.width * scaleFactor), Math.ceil(logicalAppSize.height * scaleFactor)));
});
};
let logsTimer: NodeJS.Timeout | null = null;
let serverLogsTimer: NodeJS.Timeout | null = null;
let cidrTimer: NodeJS.Timeout | null = null;
const b = bounce(600);
onMounted(async () => {
await initGuiJson();
await compatibleInitAutoStart();
// await initAutoStart();
await initStartWinIpBroadcast();
// await initStartWinIpBroadcast(); // 对于三层tun而言,winipbroadcast没有作用,先禁用
await compatibleIpv6Listener();
await getCoreVersion();
await listenObj.listenThreadId();
@@ -1248,15 +1271,21 @@
initPreventSleep();
mountedShow(); // 不需要await
closePrevent();
dataSubscribe(async () => {
if (mainStore.createConfigInEasytier) {
b(async () => {
await updateConfigJson(data.configJsonSeverUrl);
});
}
});
getReleaseList();
checkNewVersion();
if (import.meta.env.PROD) {
getReleaseList();
checkNewVersion();
}
await storageDialog();
});
// storageEventEmitter.addEventListener("localStorageChange", () => {
// if(mainStore.createConfigInEasytier) {
// updateConfigJsonBounce(data.configJsonSeverUrl)
// }
// })
dataSubscribe(null, () => {
return data.configJsonSeverUrl;
});
onBeforeUnmount(() => {
@@ -1267,6 +1296,7 @@
serverLogsTimer && clearInterval(serverLogsTimer);
cidrTimer && clearInterval(cidrTimer);
stopPreventSleep();
// unListenStorage && unListenStorage();
});
const getArgs = async () => {
@@ -1299,42 +1329,42 @@
}
}
if (config.dhcp) {
if (mainStore.config.dhcp) {
args.push("-d");
}
if (config.hostname) {
args.push("--hostname", config.hostname);
if (mainStore.config.hostname) {
args.push("--hostname", mainStore.config.hostname);
}
if (config.networkName) {
args.push("--network-name", config.networkName);
if (mainStore.config.networkName) {
args.push("--network-name", mainStore.config.networkName);
}
if (config.networkPassword) {
args.push("--network-secret", config.networkPassword);
if (mainStore.config.networkPassword) {
args.push("--network-secret", mainStore.config.networkPassword);
}
if (config.ipv4) {
args.push("--ipv4", config.ipv4.trim());
if (mainStore.config.ipv4) {
args.push("--ipv4", mainStore.config.ipv4.trim());
}
if (config.serverUrl) {
const formatUrl = config.serverUrl.replace(/\\/g, "/");
args.push("--peers", ...config.protocol.map(protocol => `${protocol}://${formatUrl}`));
if (mainStore.config.serverUrl) {
const formatUrl = mainStore.config.serverUrl.replace(/\\/g, "/");
args.push("--peers", ...mainStore.config.protocol.map(protocol => `${protocol}://${formatUrl}`));
}
if (config.enableCustomProtocol) {
const includes = config.protocol.includes(config.customProtocol);
if (mainStore.config.enableCustomProtocol) {
const includes = mainStore.config.protocol.includes(mainStore.config.customProtocol);
if (includes) {
args.push("--default-protocol", config.customProtocol);
args.push("--default-protocol", mainStore.config.customProtocol);
}
}
if (config.disbleP2p) {
if (mainStore.config.disbleP2p) {
args.push("--disable-p2p");
}
if (config.disableIpv6) {
if (mainStore.config.disableIpv6) {
args.push("--disable-ipv6");
}
if (config.disbleListenner) {
if (mainStore.config.disbleListenner) {
args.push("--no-listener");
}
if (!config.disbleListenner && config.enableCustomListener && config.customListenerData) {
const customListener = config.customListenerData
if (!mainStore.config.disbleListenner && mainStore.config.enableCustomListener && mainStore.config.customListenerData) {
const customListener = mainStore.config.customListenerData
.trim()
.split("\n")
.map(el => el.trim())
@@ -1343,14 +1373,14 @@
args.push("-l", ...customListener);
}
}
if (!config.disbleListenner && config.enableCustomListenerV6 && config.customListenerV6Data) {
args.push("--ipv6-listener", config.customListenerV6Data);
if (!mainStore.config.disbleListenner && mainStore.config.enableCustomListenerV6 && mainStore.config.customListenerV6Data) {
args.push("--ipv6-listener", mainStore.config.customListenerV6Data);
}
if (!config.disbleListenner && !config.enableCustomListener && config.port) {
args.push("-l", config.port);
if (!mainStore.config.disbleListenner && !mainStore.config.enableCustomListener && mainStore.config.port) {
args.push("-l", mainStore.config.port);
}
if (mainStore.cidrEnable && config.proxyNetworks) {
let formatProxyNetworks = config.proxyNetworks.trim().split("\n");
if (mainStore.cidrEnable && mainStore.config.proxyNetworks) {
let formatProxyNetworks = mainStore.config.proxyNetworks.trim().split("\n");
const newformatProxyNetworks = formatProxyNetworks
.map(el => el.trim())
.filter(cidr => {
@@ -1359,61 +1389,82 @@
if (newformatProxyNetworks.length > 0) {
args.push("--proxy-networks", ...newformatProxyNetworks);
}
config.proxyNetworks = formatProxyNetworks.join("\n");
mainStore.config.proxyNetworks = formatProxyNetworks.join("\n");
}
if (config.disableEncryption) {
if (mainStore.config.disableEncryption) {
args.push("--disable-encryption");
}
if (config.multiThread) {
if (mainStore.config.multiThread) {
args.push("--multi-thread");
}
if (config.enablExitNode) {
if (mainStore.config.enablExitNode) {
args.push("--enable-exit-node");
}
if (config.noTun) {
if (mainStore.config.noTun) {
args.push("--no-tun");
}
if (config.latencyfirst) {
if (mainStore.config.latencyfirst) {
args.push("--latency-first");
}
if (config.useSmoltcp) {
if (mainStore.config.useSmoltcp) {
args.push("--use-smoltcp");
}
if (config.disableUdpHolePunching) {
if (mainStore.config.disableUdpHolePunching) {
args.push("--disable-udp-hole-punching");
}
if (config.relayAllPeerrpc) {
if (mainStore.config.relayAllPeerrpc) {
args.push("--relay-all-peer-rpc");
}
if (config.saveErrorLog) {
args.push("--file-log-level", config.logLevel, "--file-log-dir", import.meta.env.VITE_LOG_PATH);
if (mainStore.config.saveErrorLog) {
args.push("--file-log-level", mainStore.config.logLevel, "--file-log-dir", import.meta.env.VITE_LOG_PATH);
}
if (config.devName && config.devNameValue) {
args.push("--dev-name", config.devNameValue);
if (mainStore.config.devName && mainStore.config.devNameValue) {
args.push("--dev-name", mainStore.config.devNameValue);
}
if (config.compression && config.compression != "none") {
args.push("--compression", config.compression);
if (mainStore.config.compression && mainStore.config.compression != "none") {
args.push("--compression", mainStore.config.compression);
}
if (config.enableKcpProxy) {
args.push("--enable-kcp-proxy");
if (mainStore.config.enableKcpProxy) {
args.push("--enable-kcp-proxy", 'true');
}
if (config.disableKcpInput) {
args.push("--disable-kcp-input");
if (mainStore.config.disableKcpInput) {
args.push("--disable-kcp-input", 'true');
}
if (config.bindDeviceEnable) {
if (mainStore.config.enableQuicProxy) {
args.push("--enable-quic-proxy", 'true');
}
if (mainStore.config.disableQuicInput) {
args.push("--disable-quic-input", 'true');
}
if (mainStore.config.bindDeviceEnable) {
args.push("--bind-device", "true");
}
if (mainStore.proxyForwardBySystem) {
args.push("--proxy-forward-by-system");
}
if (mainStore.config.acceptDNS) {
args.push("--accept-dns", "true");
}
if (mainStore.config.enablePortForward) {
let formatPortForward = mainStore.config.portForwardData.trim().split("\n");
const newformatPortForward = formatPortForward.map(el => el.trim()).filter(el => el);
if (newformatPortForward.length > 0) {
newformatPortForward.map(el => {
args.push("--port-forward", el);
});
}
}
if (mainStore.config.privateMode) {
args.push("--private-mode", "true");
}
return args;
};
const reset = async () => {
data.isStart = false;
data.isSuccessGetIp = false;
if (config.dhcp) {
config.ipv4 = "";
if (mainStore.config.dhcp) {
mainStore.config.ipv4 = "";
}
const memberDialog = await getAllWebviewWindows();
const memberDialogs = memberDialog.filter(item => item.label === "member");
@@ -1514,7 +1565,10 @@
compression,
enablePreventSleep,
enableKcpProxy,
disableKcpInput
disableKcpInput,
enableQuicProxy,
disableQuicInput,
privateMode
} = mainStore.config;
const WT = btoa(
encodeURIComponent(
@@ -1547,7 +1601,10 @@
compression,
enablePreventSleep,
enableKcpProxy,
disableKcpInput
disableKcpInput,
enableQuicProxy,
disableQuicInput,
privateMode
}
})
)
@@ -1666,6 +1723,25 @@
}
);
}
if (command === "reconnect") {
handleReconnect();
}
};
const handleReconnect = async () => {
if (data.isStart) {
ElMessage.info({
message: "正在重新联机...",
duration: 2200
});
await handleConnection();
setTimeout(() => {
handleConnection();
}, 2000);
} else {
handleConnection();
}
};
const handleDeleteAdminConfig = async () => {
@@ -1718,7 +1794,7 @@
});
if (!err) {
const payload = JSON.parse(decodeURIComponent(atob(importConfigData.data)));
payload.config.serverUrl = payload?.config?.serverUrl?.trim() || config.serverUrl;
payload.config.serverUrl = payload?.config?.serverUrl?.trim() || mainStore.config.serverUrl;
mainStore.$patch({
config: {
...mainStore.config,
@@ -1727,7 +1803,7 @@
});
ElMessage.success("导入成功");
importConfigData.visible = false;
mainStore.basePeers = uniq([config.serverUrl, ...mainStore.basePeers].filter(el => el.trim()));
mainStore.basePeers = uniq([mainStore.config.serverUrl, ...mainStore.basePeers].filter(el => el.trim()));
} else {
console.error(err);
if (err !== "cancel") {
@@ -1902,4 +1978,28 @@
}
);
};
const storageDialog = async () => {
await etWindows(
"storage-listener",
{
title: "存储监听",
minWidth: 0,
minHeight: 0,
width: 0,
height: 0,
x: 9999,
y: 9999,
resizable: false,
transparent: true,
hiddenTitle: true,
alwaysOnBottom: true,
visible: false,
url: "#/storage-listener"
},
dialog => {
dialog.hide();
}
);
};
</script>
+149 -1
View File
@@ -48,15 +48,19 @@
width="120"
prop="ipv4"
label="虚拟网IP"
:sort-method="sortIpv4"
:sort-orders="['ascending', 'descending', null]"
></ElTableColumn>
<ElTableColumn
sortable
prop="lat_ms"
width="100"
label="延迟/ms"
:sort-method="sortLatMs"
:sort-orders="['ascending', 'descending', null]"
>
<template #default="{ row }">
{{ row.lat_ms && !isNaN(Number(row.lat_ms)) ? Number(row.lat_ms).toFixed(0) : row.lat_ms || "-" }}
{{ formatLatency(row.lat_ms) }}
</template>
</ElTableColumn>
<ElTableColumn
@@ -96,11 +100,15 @@
width="90"
prop="rx_bytes"
label="接收"
:sort-method="sortBytes"
:sort-orders="['ascending', 'descending', null]"
></ElTableColumn>
<ElTableColumn
sortable
prop="tx_bytes"
label="传输"
:sort-method="(a, b) => sortBytes(a, b, 'tx_bytes')"
:sort-orders="['ascending', 'descending', null]"
></ElTableColumn>
</ElTable>
</div>
@@ -144,6 +152,146 @@
member: []
});
// 延迟排序函数
const sortLatMs = (a: any, b: any): number => {
const getLatencyValue = (row: any): number => {
const latMs = row.lat_ms;
if (latMs === null || latMs === undefined || latMs === "") {
return Infinity;
}
const num = Number(latMs);
if (isNaN(num) || num < 0) {
return Infinity;
}
return Math.floor(num);
};
const valueA = getLatencyValue(a);
const valueB = getLatencyValue(b);
if (valueA === Infinity && valueB === Infinity) {
return 0;
}
return valueA - valueB;
};
// IP地址排序函数
const sortIpv4 = (a: any, b: any): number => {
const ipToNumber = (ip: string): number => {
if (!ip || ip === "-" || ip === "") {
return 0;
}
// 处理可能包含端口号或子网掩码的情况
const cleanIp = ip.split("/")[0].split(":")[0];
const parts = cleanIp.split(".");
if (parts.length !== 4) {
return 0;
}
try {
const nums = parts.map(part => {
const num = parseInt(part, 10);
return isNaN(num) || num < 0 || num > 255 ? 0 : num;
});
// 将IP地址转换为32位数字进行比较
return (nums[0] << 24) + (nums[1] << 16) + (nums[2] << 8) + nums[3];
} catch {
return 0;
}
};
const numA = ipToNumber(a.ipv4);
const numB = ipToNumber(b.ipv4);
return numA - numB;
};
// 字节数据排序函数
const sortBytes = (a: any, b: any, field: string = 'rx_bytes'): number => {
const parseBytes = (bytesStr: string): number => {
if (!bytesStr || bytesStr === "-" || bytesStr === "") {
return 0;
}
// 统一转换为小写并去除空格
const cleanStr = bytesStr.toLowerCase().trim();
// 使用正则表达式匹配数字和单位
const match = cleanStr.match(/^(\d+(?:\.\d+)?)\s*([a-z]*)$/);
if (!match) {
return 0;
}
const value = parseFloat(match[1]);
const unit = match[2];
if (isNaN(value)) {
return 0;
}
// 根据单位转换为字节数
switch (unit) {
case 'b':
case 'byte':
case 'bytes':
case '':
return value;
case 'k':
case 'kb':
case 'kib':
return value * 1024;
case 'm':
case 'mb':
case 'mib':
return value * 1024 * 1024;
case 'g':
case 'gb':
case 'gib':
return value * 1024 * 1024 * 1024;
case 't':
case 'tb':
case 'tib':
return value * 1024 * 1024 * 1024 * 1024;
case 'p':
case 'pb':
case 'pib':
return value * 1024 * 1024 * 1024 * 1024 * 1024;
default:
return value; // 未知单位当作字节处理
}
};
const bytesA = parseBytes(a[field]);
const bytesB = parseBytes(b[field]);
return bytesA - bytesB;
};
// 格式化延迟显示
const formatLatency = (latMs: any): string => {
if (latMs === null || latMs === undefined || latMs === "") {
return "-";
}
const num = Number(latMs);
if (isNaN(num)) {
return "-";
}
if (num < 0) {
return "-";
}
return num.toFixed(0);
};
const _showTableHeader = [
["hostname", "主机名"],
["cost", "路由"],
+6
View File
@@ -27,6 +27,12 @@
>
<ElCheckbox v-model="mainStore.serverConfig.autoStart">自动启动</ElCheckbox>
</ElTooltip>
<ElTooltip
placement="top"
content="启用后,不允许使用了与本网络不同的房间名和密码的节点通过本节点进行握手或中转"
>
<ElCheckbox v-model="mainStore.serverConfig.privateMode">私有模式</ElCheckbox>
</ElTooltip>
<ElTooltip
placement="top"
content="帮助其他虚拟网建立P2P链接"
+6
View File
@@ -0,0 +1,6 @@
<template></template>
<script setup lang="ts">
import { dataSubscribe } from "~/composables/windows";
dataSubscribe();
</script>
+33 -20
View File
@@ -10,7 +10,7 @@
name="netcard"
class="flex h-full flex-col"
>
<div>
<!-- <div>
<div>
<ElTooltip
content="找不到游戏房间时,就开启它后再尝试搜索房间(默认开启)
@@ -25,7 +25,7 @@
<ElLink
class="mr-[10px] !text-[15px]"
type="info"
:underline="false"
underline="never"
@click="open('https://github.com/dechamps/WinIPBroadcast/releases/tag/winipbroadcast-1.6')"
>
WinIPBroadcast
@@ -39,13 +39,13 @@
active-text="已开启"
inactive-text="已关闭"
></ElSwitch>
</div>
</div> -->
<div>
<ElTooltip
content="使用ForceBindIP启动应用 (强制绑定IP或者网卡),如果还没有启动联机,请先启动联机,联机成功后,点击刷新获取easytier生成的网卡"
>
<ElText>
方案2
方案1
<ElIcon class="ml-[3px]"><QuestionFilled /></ElIcon>
</ElText>
</ElTooltip>
@@ -55,7 +55,7 @@
<ElLink
class="!text-[15px]"
type="info"
:underline="false"
underline="never"
@click="open('https://r1ch.net/projects/forcebindip')"
>
ForceBindIP
@@ -131,7 +131,7 @@
<div>
<ElTooltip content="设置网卡的跃点,提升网卡优先级,尝试将您联机使用的网卡跃点设置为最小,请先查询网卡信息">
<ElText>
方案3
方案2
<ElIcon class="ml-[3px]"><QuestionFilled /></ElIcon>
</ElText>
</ElTooltip>
@@ -198,16 +198,10 @@
<ElButton
type="warning"
size="small"
@click.stop="handleCloseAllFireWall"
>
一键关闭防火墙
</ElButton>
<ElButton
@click="handleCustomFireWall"
type="danger"
size="small"
>
自定义防火墙策略
</ElButton>
</div>
<div class="mb-[10px]">
<ElText class="!mx-[10px]">域防火墙</ElText>
@@ -251,10 +245,17 @@
<ElButton
size="small"
:disabled="data.isPing"
@click="handleTestPing"
@click="handleTestPing('v4')"
>
Ping一下
</ElButton>
<!-- <ElButton
size="small"
:disabled="data.isPing"
@click="handleTestPing('v6')"
>
Ping一下(v6)
</ElButton> -->
</div>
<div class="mt-[5px] flex-1 overflow-auto">
<ElInput
@@ -305,8 +306,18 @@
forceBindStart: false
});
const handleCustomFireWall = async () => {
await open("wf.msc");
const handleCloseAllFireWall = async () => {
try {
const output = await Command.create("netsh", ["advfirewall", "set", "allprofiles", "state", "off"], {
encoding: "gb2312"
}).execute();
ElMessage.success("关闭成功");
await initFirewall();
} catch (err) {
ElMessage.error(`关闭失败${err}`);
console.error(err);
}
}
const handleTabsChange = async (tabPaneName: TabPaneName) => {
@@ -341,14 +352,15 @@
});
};
const handleTestPing = async () => {
const handleTestPing = async (type: 'v4' | 'v6' = 'v4') => {
// const is = isValidIP(data.pingIp);
if (data.pingIp) {
data.pingLog = "";
data.isPing = true;
const args = type === 'v4' ? ["-n", "1", data.pingIp] : ["-6", '-n', "1", data.pingIp]
try {
for (let i = 0; i < data.pingNum; i++) {
const output = await Command.create("ping", ["-n", "1", data.pingIp], {
const output = await Command.create("ping", args, {
encoding: "gb2312"
}).execute();
if (output.stdout) {
@@ -490,8 +502,9 @@
onMounted(() => {
data.pingIp = mainStore.config.ipv4;
initStartWinIpBroadcast();
// initStartWinIpBroadcast();
getGuids();
dataSubscribe();
});
dataSubscribe();
</script>
+3505 -1369
View File
File diff suppressed because it is too large Load Diff
+4 -4
View File
@@ -1,6 +1,6 @@
# Generated by Cargo
# will have compiled files and executables
/target/
/gen/schemas
/easytier/logs
/easytier/logs/*.*
target/
gen/schemas
./easytier/logs
easytier/logs
+11 -30
View File
@@ -1253,11 +1253,10 @@ checksum = "0d6ef0072f8a535281e4876be788938b528e9a1d43900b82c2569af7da799125"
[[package]]
name = "easytier-game"
version = "1.4.4"
version = "1.4.7"
dependencies = [
"hashbrown 0.15.2",
"log",
"planif",
"rand 0.9.0",
"reqwest",
"serde",
@@ -3496,14 +3495,6 @@ version = "0.3.31"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "953ec861398dccce10c670dfeaf3ec4911ca479e9c02154b3a215178c5f566f2"
[[package]]
name = "planif"
version = "1.0.0"
source = "git+https://github.com/mattrobineau/planif?tag=1.0.1#90e228e2bc0f142b16a0ba415ec242e1c836cc35"
dependencies = [
"windows 0.48.0",
]
[[package]]
name = "plist"
version = "1.7.0"
@@ -4724,9 +4715,9 @@ checksum = "61c41af27dd6d1e27b1b16b489db798443478cef1f06a660c96db617ba5de3b1"
[[package]]
name = "tauri"
version = "2.5.0"
version = "2.5.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "be03adf68fba02f87c4653da7bd73f40b0ecf9c6b7c2c39830f6981d0651912f"
checksum = "e7b0bc1aec81bda6bc455ea98fcaed26b3c98c1648c627ad6ff1c704e8bf8cbc"
dependencies = [
"anyhow",
"bytes",
@@ -4887,9 +4878,9 @@ dependencies = [
[[package]]
name = "tauri-plugin-dialog"
version = "2.2.1"
version = "2.2.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bcaf6e5d6062423a0f711a23c2a573ccba222b6a16a9322d8499928f27e41376"
checksum = "a33318fe222fc2a612961de8b0419e2982767f213f54a4d3a21b0d7b85c41df8"
dependencies = [
"log",
"raw-window-handle",
@@ -4905,9 +4896,9 @@ dependencies = [
[[package]]
name = "tauri-plugin-fs"
version = "2.2.1"
version = "2.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "88371e340ad2f07409a3b68294abe73f20bc9c1bc1b631a31dc37a3d0161f682"
checksum = "33ead0daec5d305adcefe05af9d970fc437bcc7996052d564e7393eb291252da"
dependencies = [
"anyhow",
"dunce",
@@ -4923,7 +4914,6 @@ dependencies = [
"thiserror 2.0.10",
"toml",
"url",
"uuid",
]
[[package]]
@@ -4971,9 +4961,9 @@ dependencies = [
[[package]]
name = "tauri-plugin-single-instance"
version = "2.2.3"
version = "2.2.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1320af4d866a7fb5f5721d299d14d0dd9e4e6bc0359ff3e263124a2bf6814efa"
checksum = "97d0e07b40fb2eb13778e30778f5979347a2bf30e1b9d47f78ff7fe92d2e4b3d"
dependencies = [
"serde",
"serde_json",
@@ -5243,9 +5233,9 @@ checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20"
[[package]]
name = "tokio"
version = "1.43.0"
version = "1.45.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3d61fa4ffa3de412bfea335c6ecff681de2b609ba3c77ef3e00e521813a9ed9e"
checksum = "75ef51a33ef1da925cea3e4eb122833cb377c61439ca401b770f54902b806779"
dependencies = [
"backtrace",
"bytes",
@@ -6000,15 +5990,6 @@ dependencies = [
"windows-version",
]
[[package]]
name = "windows"
version = "0.48.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e686886bc078bc1b0b600cac0147aadb815089b6e4da64016cbd754b6342700f"
dependencies = [
"windows-targets 0.48.5",
]
[[package]]
name = "windows"
version = "0.57.0"
+7 -7
View File
@@ -1,6 +1,6 @@
[package]
name = "easytier-game"
version = "1.4.4"
version = "1.4.7"
homepage = "https://github.com/EasyTier/EasyTier"
repository = "https://github.com/EasyTier/EasytierGame"
description = "A simple network initiator based on Easytier"
@@ -28,7 +28,7 @@ thunk-rs = { git = "https://github.com/easytier/thunk.git", default-features = f
serde_json = "1.0.137"
serde = { version = "1.0.217", features = ["derive"] }
log = "0.4.26"
tauri = { version = "2.5.0", features = [ "protocol-asset",
tauri = { version = "2.5.1", features = [ "protocol-asset",
"tray-icon",
"image-png",
"image-ico"
@@ -39,13 +39,13 @@ tauri-plugin-shell = "2.2.1"
reqwest = { version = "0.12.12", features = ["json"] }
zip = "2.2.3"
sysinfo = '0.33.1'
planif = { git = "https://github.com/mattrobineau/planif", tag = "1.0.1" }
# planif = { git = "https://github.com/mattrobineau/planif", tag = "1.0.1" }
whoami = "1.5.2"
tauri-plugin-fs = "2.2.1"
tauri-plugin-fs = "2.3.0"
tauri-plugin-clipboard-manager = "2.2.2"
rand = "0.9.0"
tokio = { version = "1.43.0", features = ["process"] }
tauri-plugin-dialog = "2.2.1"
tokio = { version = "1.45.1", features = ["process"] }
tauri-plugin-dialog = "2.2.2"
# prost = "0.13"
# prost-types = "0.13"
hashbrown = "0.15.2"
@@ -57,5 +57,5 @@ features = ["Win32_System_TaskScheduler", "Win32_System_Com", "Win32_System_Powe
[target."cfg(not(any(target_os = \"android\", target_os = \"ios\")))".dependencies]
tauri-plugin-cli = "2.2.0"
tauri-plugin-single-instance = "2.2.3"
tauri-plugin-single-instance = "2.2.4"
tauri-plugin-window-state = "2.2.2"
+2 -1
View File
@@ -2,7 +2,7 @@
"$schema": "../gen/schemas/desktop-schema.json",
"identifier": "default",
"description": "enables the default permissions",
"windows": ["main", "log", "member", "cidr", "advance", "tool", "server", "gameList"],
"windows": ["main", "log", "member", "cidr", "advance", "tool", "server", "gameList", "storage-listener"],
"permissions": [
"core:default",
"core:window:allow-minimize",
@@ -26,6 +26,7 @@
"core:tray:allow-get-by-id",
"core:tray:allow-set-icon",
"core:tray:allow-new",
"core:window:allow-set-size",
{
"identifier": "shell:allow-spawn",
"allow": [
+5 -2
View File
@@ -35,6 +35,9 @@
"netCardMetricValue": 1, // 网卡跃点
"enablePreventSleep": false, // 启用防止睡眠
"compression": "none", // 压缩算法
"enableKcpProxy": true, // 启用kcp代理
"disableKcpInput": false // 禁用kcp输入
"enableKcpProxy": true, // 启用kcp代理,就不能启用quic代理
"disableKcpInput": false, // 禁用kcp输入
"enableQuicProxy": false, // 启用quic代理,就不能启用kcp代理
"disableQuicInput": false, // 禁用quic输入
"privateMode": false // 启用私有模式
}
Binary file not shown.
Binary file not shown.
+126 -39
View File
@@ -1,7 +1,3 @@
use planif::enums::TaskCreationFlags;
use planif::schedule::TaskScheduler as planIfTaskScheduler;
use planif::schedule_builder::{Action, ScheduleBuilder};
use planif::settings::{Duration, LogonType, PrincipalSettings, RunLevel};
use reqwest::{Client, Error};
// use futures_util::StreamExt;
use serde::{Deserialize, Serialize};
@@ -17,7 +13,7 @@ use sysinfo::System;
use tauri::tray::{MouseButton, MouseButtonState, TrayIconBuilder, TrayIconEvent};
use tauri::Emitter;
use tauri::Manager;
use windows::core::{BSTR, VARIANT};
use windows::core::{Interface, BSTR, VARIANT};
use windows::Win32::Foundation::VARIANT_BOOL;
use windows::Win32::NetworkManagement::IpHelper::{
GetAdaptersAddresses, GAA_FLAG_INCLUDE_PREFIX, IP_ADAPTER_ADDRESSES_LH,
@@ -326,7 +322,11 @@ async fn get_route_by_cli() -> String {
}
#[tauri::command(rename_all = "snake_case")]
async fn download_easytier_zip(app_handle: tauri::AppHandle ,download_url: String, file_name: String) {
async fn download_easytier_zip(
app_handle: tauri::AppHandle,
download_url: String,
file_name: String,
) {
let cache_dir_path = get_tool_exe_path("\\easytier\\cache");
let cache_file_name = format!("{}\\{}", cache_dir_path, file_name);
let cache_file_name_path = path::Path::new(&cache_file_name);
@@ -359,14 +359,18 @@ async fn download_easytier_zip(app_handle: tauri::AppHandle ,download_url: Strin
while let Some(item) = response.chunk().await.unwrap() {
match file.write_all(&item) {
Ok(_) => {
app_handle.emit("download_core_progress", [item.len() as u64, context_size]).expect("error to emit download_core_progress");
},Err(why) => {
app_handle
.emit("download_core_progress", [item.len() as u64, context_size])
.expect("error to emit download_core_progress");
}
Err(why) => {
log::error!("error to write file: {}", why);
app_handle.emit("download_core_progress_error", why.to_string()).expect("error to emit download_core_progress_error");
return
app_handle
.emit("download_core_progress_error", why.to_string())
.expect("error to emit download_core_progress_error");
return;
}
};
}
println!("下载完成");
unzip(path);
@@ -516,18 +520,19 @@ fn stop_command(child_id: u32) {
}
#[tauri::command(rename_all = "snake_case")]
async fn fetch_easytier_list() -> Vec<Vec<[String; 3]>> {
async fn fetch_easytier_list() -> Vec<Vec<[String; 4]>> {
// 获取release列表
if let Ok(release) = fetch_releases().await {
let mut release_list = Vec::new();
let mut release_list: Vec<Vec<[String; 4]>> = Vec::new();
for re in release {
let mut assets_list = Vec::new();
let mut assets_list: Vec<[String; 4]> = Vec::new();
for asset in re.assets {
if asset.name.contains("windows-x86_64") {
assets_list.push([
re.tag_name.clone(),
asset.name.clone(),
asset.browser_download_url.clone(),
re.prerelease.to_string(),
]);
}
}
@@ -656,6 +661,50 @@ fn autostart_is_enabled() -> bool {
}
}
// 新增辅助函数
fn ensure_task_folder_and_cleanup(
task_service: &ITaskService,
folder_path: &BSTR,
task_name: &BSTR,
) -> Result<ITaskFolder, Box<dyn std::error::Error>> {
unsafe {
let root = BSTR::from("\\");
let root_folder: ITaskFolder = task_service.GetFolder(&root)?;
match task_service.GetFolder(folder_path) {
Ok(existing_folder) => {
println!("任务文件夹已存在: {}", folder_path);
// 检查并清理现有任务
if let Ok(_existing_task) = existing_folder.GetTask(task_name) {
println!("发现同名任务: {},准备删除", task_name);
match existing_folder.DeleteTask(task_name, 0) {
Ok(_) => println!("成功删除现有任务"),
Err(e) => {
log::error!("删除现有任务失败: {}", e);
// 继续执行,尝试覆盖
}
}
}
Ok(existing_folder)
}
Err(_) => {
println!("创建新的任务文件夹: {}", folder_path);
match root_folder.CreateFolder(folder_path, &VARIANT::default()) {
Ok(new_folder) => {
println!("成功创建任务文件夹");
Ok(new_folder)
}
Err(e) => {
log::error!("创建任务文件夹失败: {}", e);
Err(e.into())
}
}
}
}
}
}
// pub const AUTOSTART_ARG: &str = "--autostart";
pub const TASKAUTOSTART_ARG: &str = "--task-auto-start";
fn autostart(enabled: bool) -> std::result::Result<(), Box<dyn std::error::Error>> {
@@ -690,33 +739,71 @@ fn autostart(enabled: bool) -> std::result::Result<(), Box<dyn std::error::Error
CoUninitialize();
}
} else {
let ts = planIfTaskScheduler::new()?;
let com = ts.get_com();
let sb = ScheduleBuilder::new(&com).unwrap();
unsafe {
let task_service: ITaskService = CoCreateInstance(&TaskScheduler, None, CLSCTX_ALL)?;
task_service.Connect(
&VARIANT::default(),
&VARIANT::default(),
&VARIANT::default(),
&VARIANT::default(),
)?;
let exe = std::env::current_exe()?;
let exe = exe.to_str().unwrap();
let folder_path = BSTR::from("\\easytierGame");
let task_name = BSTR::from("auto start");
let settings = PrincipalSettings {
display_name: "".to_string(),
group_id: None,
id: "".to_string(),
logon_type: LogonType::InteractiveToken,
run_level: RunLevel::Highest,
user_id: Some(whoami::username()),
};
sb.create_logon()
.author("heixiansen")?
.trigger("trigger", enabled)?
.action(Action::new("auto start", exe, "", &TASKAUTOSTART_ARG))?
.in_folder("easytierGame")?
.principal(settings)?
.delay(Duration {
seconds: Some(6),
..Default::default()
})?
.build()?
.register("auto start", TaskCreationFlags::CreateOrUpdate as i32)?;
let task_definition = task_service.NewTask(0)?;
// 设置任务信息
let registration_info = task_definition.RegistrationInfo()?;
registration_info.SetDescription(&BSTR::from("EasytierGame auto start task"))?;
registration_info.SetAuthor(&BSTR::from("EasytierGame"))?;
// 改为用户登录触发
let triggers = task_definition.Triggers()?;
let trigger = triggers.Create(TASK_TRIGGER_LOGON)?;
let logon_trigger: ILogonTrigger = trigger.cast()?;
logon_trigger.SetEnabled(VARIANT_BOOL::from(true))?;
// 设置动作
let actions = task_definition.Actions()?;
let action = actions.Create(TASK_ACTION_EXEC)?;
let exec_action: IExecAction = action.cast()?;
let exe = std::env::current_exe()?;
let exe_path: &str = exe.to_str().unwrap();
exec_action.SetPath(&BSTR::from(exe_path))?;
exec_action.SetArguments(&BSTR::from("--task-auto-start"))?;
// 使用当前用户运行
let principal = task_definition.Principal()?;
principal.SetUserId(&BSTR::from(whoami::username().as_str()))?;
principal.SetLogonType(TASK_LOGON_INTERACTIVE_TOKEN)?;
principal.SetRunLevel(TASK_RUNLEVEL_HIGHEST)?;
// 设置任务设置
let settings = task_definition.Settings()?;
settings.SetEnabled(VARIANT_BOOL::from(true))?;
settings.SetCompatibility(TASK_COMPATIBILITY_V2)?; // Windows 7
settings.SetStartWhenAvailable(VARIANT_BOOL::from(true))?;
// settings.SetHidden(VARIANT_BOOL::from(true))?; // 注释掉让任务可见
settings.SetExecutionTimeLimit(&BSTR::from("PT0S"))?;
settings.SetDisallowStartIfOnBatteries(VARIANT_BOOL(0))?; // 允许在电池供电时启动
// 获取文件夹并注册任务
let task_folder =
ensure_task_folder_and_cleanup(&task_service, &folder_path, &task_name)?;
let _auto_task = task_folder.RegisterTaskDefinition(
&task_name,
&task_definition,
TASK_CREATE_OR_UPDATE.0,
&VARIANT::default(),
&VARIANT::default(),
TASK_LOGON_INTERACTIVE_TOKEN,
&VARIANT::default(),
)?;
CoUninitialize();
}
}
Ok(())
}
+4 -4
View File
@@ -1,7 +1,7 @@
{
"$schema": "../node_modules/@tauri-apps/cli/config.schema.json",
"productName": "easytier-game",
"version": "1.4.4",
"version": "1.4.7",
"identifier": "com.tauri.easytier-game",
"build": {
@@ -12,14 +12,14 @@
"app": {
"windows": [
{
"title": "easytier-game 1.4.4",
"title": "easytier-game 1.4.7",
"label": "main",
"minWidth": 340,
"width": 340,
"height": 305,
"minHeight": 305,
"maxHeight": 305,
"maxWidth": 360,
"maxHeight": 405,
"maxWidth": 460,
"resizable": true,
"fullscreen": false,
"decorations": true,
+23 -1
View File
@@ -1,4 +1,7 @@
import { acceptHMRUpdate, defineStore } from "pinia";
const store = defineStore("main", {
state() {
return {
@@ -41,7 +44,14 @@ const store = defineStore("main", {
compression: "none", //加密算法
enableKcpProxy: true, //启用kcp代理 默认开启
disableKcpInput: false, //禁用kcp输入
enableQuicProxy: false, //启用quic代理 默认开启
disableQuicInput: false, //禁用quic输入
bindDeviceEnable: false, //是否绑定设备
acceptDNS: false, //魔法dns
privateMode: false, //是否启用私有模式
enablePortForward: false, //是否启用端口转发
portForwardData: "", //端口转发数据
},
serverConfig: {
enableWhiteList: true, // 是否启用白名单
@@ -49,7 +59,8 @@ const store = defineStore("main", {
serverWhiteList: "", // 服务器流量转发白名单
// enableListener: true, // 是否启用监听
autoStart: false, //随软件自启
port: "11010" // 服务器端口
port: "11010", // 服务器端口
privateMode: false, //是否启用私有模式
},
cidrEnable: false,
proxyForwardBySystem: false, // 是否通过系统内核转发子网代理数据包,禁用内置NAT
@@ -105,6 +116,9 @@ const store = defineStore("main", {
"config.netCardMetricValue",
"config.port",
"config.enablePortForward",
"config.portForwardData",
"config.disbleListenner",
"config.enableCustomListener",
"config.customListenerData",
@@ -118,15 +132,23 @@ const store = defineStore("main", {
"config.enableKcpProxy",
"config.disableKcpInput",
"config.enableQuicProxy",
"config.disableQuicInput",
"config.bindDeviceEnable",
"config.acceptDNS",
"config.privateMode",
"serverConfig.autoStart",
// 'serverConfig.enableListener',
"serverConfig.enableWhiteList",
"serverConfig.relayAllPeerrpc",
"serverConfig.serverWhiteList",
"serverConfig.port",
"serverConfig.privateMode",
"cidrEnable",
"proxyForwardBySystem",