Compare commits

..
3 Commits
Author SHA1 Message Date
黑先森 70c3217ab5 #Update 增加txt协议,更新包体,修复停止联机后的依旧显示联机成功的问题 2026-01-06 22:45:52 +08:00
黑先森 e91bd07ce8 #Update 更新包体 2025-12-16 14:18:17 +08:00
黑先森 9f63d9bf2e #Update 开机自启兼容配置改为win7 优化联机是否成功的判断方式
#Update 开机自启兼容配置改为win7 优化联机是否成功的判断方式

优化联机是否成功的判断方式

版本号更新->1.5.3
2025-11-18 16:42:58 +08:00
12 changed files with 3043 additions and 3831 deletions
+24 -21
View File
@@ -3,7 +3,7 @@
"private": true,
"author": "leizi97",
"description": "A simple network initiator based on Easytier",
"version": "1.5.2",
"version": "1.5.3",
"scripts": {
"dev": "nuxt dev --dotenv env/.env.dev --host 0.0.0.0",
"build": "nuxt generate --dotenv env/.env.prod",
@@ -11,32 +11,35 @@
"release-win7": "node zip.js win7"
},
"devDependencies": {
"@element-plus/icons-vue": "^2.3.2",
"@element-plus/icons-vue": "2.3.2",
"@element-plus/nuxt": "1.1.4",
"@nuxtjs/tailwindcss": "6.13.2",
"@oxc-minify/binding-win32-x64-msvc": "^0.107.0",
"@oxc-parser/binding-win32-x64-msvc": "^0.107.0",
"@oxc-transform/binding-win32-x64-msvc": "^0.107.0",
"@pinia/nuxt": "0.11.2",
"@tauri-apps/api": "2.9.0",
"@tauri-apps/cli": "2.9.1",
"@tauri-apps/plugin-cli": "2.4.0",
"@tauri-apps/plugin-clipboard-manager": "2.3.0",
"@tauri-apps/plugin-dialog": "2.4.0",
"@tauri-apps/plugin-fs": "2.4.2",
"@tauri-apps/plugin-log": "2.7.0",
"@tauri-apps/plugin-shell": "2.3.1",
"@tauri-apps/plugin-window-state": "2.4.0",
"@types/lodash-es": "^4.17.12",
"@tauri-apps/api": "2.9.1",
"@tauri-apps/cli": "2.9.6",
"@tauri-apps/plugin-cli": "2.4.1",
"@tauri-apps/plugin-clipboard-manager": "2.3.2",
"@tauri-apps/plugin-dialog": "2.4.2",
"@tauri-apps/plugin-fs": "2.4.4",
"@tauri-apps/plugin-log": "2.7.1",
"@tauri-apps/plugin-shell": "2.3.3",
"@tauri-apps/plugin-window-state": "2.4.1",
"@types/lodash-es": "4.17.12",
"@vitejs/plugin-vue-jsx": "5.1.1",
"@vueuse/core": "12.7.0",
"archiver": "^7.0.1",
"element-plus": "2.11.7",
"archiver": "7.0.1",
"element-plus": "2.13.0",
"less": "4.2.1",
"lodash-es": "^4.17.21",
"nuxt": "3.19.2",
"pinia": "3.0.3",
"pinia-plugin-persistedstate": "4.5.0",
"postcss": "^8.4.38",
"prettier": "3.6.2",
"prettier-plugin-tailwindcss": "0.6.14"
"lodash-es": "4.17.21",
"nuxt": "3.20.2",
"pinia": "3.0.4",
"pinia-plugin-persistedstate": "4.7.1",
"postcss": "8.4.49",
"prettier": "3.7.4",
"prettier-plugin-tailwindcss": "0.7.2"
},
"dependencies": {
"is-ip": "^5.0.1"
+38 -122
View File
@@ -999,6 +999,7 @@
mainStore.basePeers = uniq([...mainStore.config.serverUrl, ...mainStore.basePeers]);
};
let getMemeberTimer: number | null = null;
const listenObj: { [key: string]: any } = {
unListenOutPut: null,
unListenThreadId: null,
@@ -1009,31 +1010,34 @@
server_thread_id: ref(null),
async listenOutput() {
// const appWindow = getCurrentWindow();
const unListen = await listen<string>("command-output", async event => {
data.isStart = true;
// console.error(event.payload);
if (event.payload) {
data.startLoading = false;
let ipv4 = /dhcp ip changed. old: None, new: Some\((\d+\.\d+\.\d+\.\d+).*\)/g.exec(event.payload as string)?.[1];
let devName = /tun device ready. dev: (.*)/g.exec(event.payload as string)?.[1];
if (mainStore.configStartEnable || mainStore.config.dhcp) {
let configIpv4 = /ipv4\s.*=\s.*[\'\"](\d+\.\d+\.\d+\.\d+).*[\'\"]/g.exec(event.payload as string)?.[1];
if (configIpv4) {
mainStore.config.ipv4 = configIpv4;
}
}
// if (event.payload.includes("peer connection removed")) {
// data.isSuccessGetIp = false;
// }
if (event.payload.includes("new peer connection added") && !data.isSuccessGetIp) {
getMemeberTimer && clearInterval(getMemeberTimer);
getMemeberTimer = setInterval(async () => {
const [error, member] = await ATJ(invoke<string>("get_members_by_cli"));
if(!data.isStart) {
getMemeberTimer && clearInterval(getMemeberTimer);
getMemeberTimer = null;
ipReset();
return;
}
if (!error && member !== "_EasytierGameCliFailedToConnect_") {
const memberJson = JSON.parse(member) as Member[];
const localData = memberJson.find(member => member?.cost == "Local");
const ipv4 = localData?.ipv4;
if (localData && ipv4) {
mainStore.config.ipv4 = ipv4;
await setTrayRunState(tray, true);
data.isSuccessGetIp = true;
await setTrayTooltip(tray, `IP: ${mainStore.config.ipv4}`);
return;
}
if (ipv4) {
mainStore.config.ipv4 = ipv4;
await setTrayTooltip(tray, `IP: ${ipv4}`);
}
ipReset();
}
}, 1000);
const unListen = await listen<string>("command-output", async event => {
data.isStart = true;
if (event.payload) {
data.startLoading = false;
let devName = /tun device ready. dev: (.*)/g.exec(event.payload as string)?.[1];
if (
devName &&
mainStore.config.enableNetCardMetric &&
@@ -1060,7 +1064,10 @@
data.log = logArr.slice(start).join("\n");
data.log += (event.payload as string) + "\n";
});
this.unListenOutPut = unListen;
this.unListenOutPut = () => {
getMemeberTimer && clearInterval(getMemeberTimer);
unListen();
};
},
async listenThreadId() {
const unListen = await listen("thread-id", event => {
@@ -1402,101 +1409,6 @@
});
};
// 过滤可用节点的函数
const filterAvailableNodes = (nodes: NodeItem[]): NodeItem[] => {
return nodes.filter(node => {
// 基本条件:节点必须激活且被批准
if (!node.is_active || !node.is_approved) {
return false;
}
// 健康状态检查
if (node.current_health_status !== "healthy") {
return false;
}
// 使用率检查:使用率不能超过95%
if (node.usage_percentage > 95) {
return false;
}
// 24小时健康率检查:必须大于90%
if (node.health_percentage_24h < 90) {
return false;
}
// 响应时间检查:响应时间不能超过60秒
if (node.last_response_time > 60000) {
return false;
}
// 连接数检查:当前连接数不能超过最大连接数的90%
if (node.current_connections > node.max_connections * 0.9) {
return false;
}
// 必须有有效的地址
if (!node.address || !node.host || !node.port) {
return false;
}
return true;
});
};
// 按优先级排序节点的函数
const sortNodesByPriority = (nodes: NodeItem[]): NodeItem[] => {
return nodes.sort((a, b) => {
// 优先级排序规则:
// 1. 响应时间越短越好
// 2. 使用率越低越好
// 3. 24小时健康率越高越好
// 4. 当前连接数越少越好
// 响应时间权重最高
const responseTimeDiff = a.last_response_time - b.last_response_time;
if (Math.abs(responseTimeDiff) > 1000) {
// 如果响应时间差异超过1秒
return responseTimeDiff;
}
// 使用率权重次之
const usageDiff = a.usage_percentage - b.usage_percentage;
if (Math.abs(usageDiff) > 5) {
// 如果使用率差异超过5%
return usageDiff;
}
// 24小时健康率
const healthDiff = b.health_percentage_24h - a.health_percentage_24h;
if (Math.abs(healthDiff) > 1) {
// 如果健康率差异超过1%
return healthDiff;
}
// 当前连接数
return a.current_connections - b.current_connections;
});
};
// 将节点添加到服务器列表的函数
const addNodesToServerList = (nodes: NodeItem[]) => {
// 提取服务器地址
const serverAddresses = nodes.map(node => node.address.replace(`${node.protocol}://`, ""));
// 去重并添加到基础服务器列表
const uniqueAddresses = uniq([...serverAddresses, ...mainStore.basePeers]);
mainStore.basePeers = uniqueAddresses;
// 如果当前没有选择服务器,自动选择第一个最佳节点
if (mainStore.config.serverUrl.length === 0 && serverAddresses.length > 0) {
mainStore.config.serverUrl = [serverAddresses[0]];
console.log(`自动选择最佳服务器: ${serverAddresses[0]}`);
}
console.log(`已添加 ${serverAddresses.length} 个可用服务器到列表`);
};
let logsTimer: number | null = null;
let serverLogsTimer: number | null = null;
let cidrTimer: number | null = null;
@@ -1724,12 +1636,17 @@
return args;
};
const reset = async () => {
data.isStart = false;
const ipReset = async () => {
data.isSuccessGetIp = false;
if (mainStore.config.dhcp) {
mainStore.config.ipv4 = "";
}
await setTrayRunState(tray, false);
await setTrayTooltip(tray);
};
const reset = async () => {
data.isStart = false;
const memberDialog = await getAllWebviewWindows();
const memberDialogs = memberDialog.filter(item => item.label === "member");
if (memberDialogs && memberDialogs.length > 0) {
@@ -1741,9 +1658,8 @@
}
}
}
await setTrayRunState(tray, false);
await setTrayTooltip(tray);
await unListenAll();
await ipReset();
};
const handleConnection = async () => {
@@ -2110,7 +2026,7 @@
const handleShowMemberDialog = async () => {
if (!data.isStart) {
return ElMessage.warning("请先开始联机");
return ElMessage.warning("请先启动联机");
}
// if (!mainStore.config.ipv4) {
// return ElMessage.warning("请等待获取IP");
+10 -73
View File
@@ -1,6 +1,6 @@
<template>
<div class="h-full overflow-auto">
<div class="w-[1200px]">
<div class="max-w-[2000px]">
<ElText
size="small"
v-if="!data.member || data.member.length <= 0"
@@ -19,7 +19,7 @@
prop="hostname"
>
<template #default="{ row }">
<div class="whitespace-pre-wrap">
<div :class="`whitespace-pre-wrap`">
<div>
{{
(row.hostname || "").toLowerCase().includes("publicserver")
@@ -44,7 +44,7 @@
</ElTableColumn>
<ElTableColumn
sortable
width="90"
width="70"
prop="cost"
label="方式"
>
@@ -87,7 +87,7 @@
<ElTableColumn
sortable
prop="lat_ms"
width="100"
width="80"
label="延迟/ms"
:sort-method="sortLatMs"
:sort-orders="['ascending', 'descending', null]"
@@ -98,7 +98,7 @@
</ElTableColumn>
<ElTableColumn
sortable
width="100"
width="70"
prop="loss_rate"
label="丢包率"
>
@@ -114,12 +114,12 @@
</ElTableColumn>
<ElTableColumn
sortable
width="110"
width="100"
label="NAT类型"
prop="nat_type"
>
<template #default="{ row }">
{{ natMaps[row.nat_type.toLowerCase() as natKyes] || row.nat_type || "-" }}
{{ natMaps[row.nat_type.toLowerCase() as NATKyes] || row.nat_type || "-" }}
</template>
</ElTableColumn>
<ElTableColumn
@@ -156,65 +156,10 @@
<script setup lang="ts">
import { invoke } from "@tauri-apps/api/core";
import { reactive, onMounted, onBeforeUnmount, computed } from "vue";
import { ATJ, parseCliInfo } from "@/utils";
import { ATJ } from "@/utils";
import { ElConfirmDanger } from "~/utils/element";
import { getCurrentWindow } from "@tauri-apps/api/window";
import { endsWith, isNaN } from "lodash-es";
type Member = {
cidr: string;
ipv4: string;
hostname: string;
cost: string;
lat_ms: string;
loss_rate: string;
rx_bytes: string;
tx_bytes: string;
tunnel_proto: string;
nat_type: string;
id: string;
version: string;
connections_addrs: string[];
proxy?: [string, "Connected" | "Closed"];
};
type ConnectionsType = {
route: {
peer_id: number;
ipv4_addr: string | null;
next_hop_peer_id: number;
cost: number;
path_latency: number;
proxy_cidrs: string[];
hostname: string;
stun_info: {
udp_nat_type: number;
tcp_nat_type: number;
last_update_time: number;
public_ip: string[];
min_port: number;
max_port: number;
};
};
peer: {
peer_id: number;
conns: {
conn_id: string;
my_peer_id: number;
peer_id: number;
features: string[];
tunnel: {
tunnel_type: string;
local_addr: {
url: string;
};
remote_addr: {
url: string;
};
};
}[];
};
};
import { isNaN } from "lodash-es";
const natMaps = {
unknown: "未知",
@@ -229,15 +174,7 @@
symUdpfirewall: "nat4-udpfirewall"
};
type Proxy = {
src: string;
dst: string;
start_time: string;
state: "Connected" | "Closed";
transport_type: string;
};
type natKyes = keyof typeof natMaps;
type NATKyes = keyof typeof natMaps;
const data = reactive<{ member: Member[]; proxy: Proxy[] }>({
member: [],
+2487 -3080
View File
File diff suppressed because it is too large Load Diff
-3
View File
@@ -1,3 +0,0 @@
{
"extends": "../.nuxt/tsconfig.server.json"
}
+405 -484
View File
File diff suppressed because it is too large Load Diff
+10 -10
View File
@@ -1,6 +1,6 @@
[package]
name = "easytier-game"
version = "1.5.2"
version = "1.5.3"
homepage = "https://github.com/EasyTier/EasyTier"
repository = "https://github.com/EasyTier/EasytierGame"
description = "A simple network initiator based on Easytier"
@@ -18,7 +18,7 @@ name = "app_lib"
crate-type = ["staticlib", "cdylib", "rlib"]
[build-dependencies]
tauri-build = { version = "2.5.1", features = [] }
tauri-build = { version = "2.5.3", features = [] }
# prost-build = "0.13.2"
[target.x86_64-pc-windows-msvc.build-dependencies]
@@ -28,21 +28,21 @@ 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.9.1", features = [ "protocol-asset",
tauri = { version = "2.9.5", features = [ "protocol-asset",
"tray-icon",
"image-png",
"image-ico"
] }
tauri-plugin-log = "2.7.0"
tauri-plugin-shell = "2.3.1"
tauri-plugin-log = "2.7.1"
tauri-plugin-shell = "2.3.3"
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" }
whoami = "1.5.2"
tauri-plugin-fs = "2.4.2"
tauri-plugin-clipboard-manager = "2.3.0"
tauri-plugin-fs = "2.4.4"
tauri-plugin-clipboard-manager = "2.3.2"
rand = "0.9.0"
tokio = { version = "1.45.1", features = ["process"] }
tauri-plugin-dialog = "2.4.0"
@@ -56,6 +56,6 @@ version = "0.61.3"
features = ["Win32_System_TaskScheduler", "Win32_System_Com", "Win32_System_Power", "Win32_NetworkManagement_IpHelper", "Win32_NetworkManagement_Ndis", "Win32_Networking_WinSock"]
[target."cfg(not(any(target_os = \"android\", target_os = \"ios\")))".dependencies]
tauri-plugin-cli = "2.4.0"
tauri-plugin-single-instance = "2.3.4"
tauri-plugin-window-state = "2.4.0"
tauri-plugin-cli = "2.4.1"
tauri-plugin-single-instance = "2.3.6"
tauri-plugin-window-state = "2.4.1"
+4 -35
View File
@@ -1,7 +1,7 @@
use reqwest::{Client, Error};
// use futures_util::StreamExt;
use serde::{Deserialize, Serialize};
use std::collections::HashMap;
use serde::{Deserialize};
// use std::collections::HashMap;
use std::fs::{self, File};
use std::io::{BufRead, BufReader, Write};
use std::os::windows::process::CommandExt;
@@ -237,38 +237,6 @@ fn get_tool_exe_path(path: &str) -> String {
return tool_path;
}
#[derive(Serialize, Deserialize, Debug)]
struct RoutePeerInfo {
peer_id: u64,
cost: u64,
hostname: Option<String>,
udp_stun_info: String,
easytier_version: String,
network_length: u64,
}
#[derive(Serialize, Deserialize, Debug)]
struct RouteTable {
peer_infos: HashMap<u32, RoutePeerInfo>,
ipv4_peer_id_map: HashMap<String, u64>,
}
#[derive(Serialize, Deserialize, Debug)]
struct PeerRouteServiceImpl {
route_table_with_cost: RouteTable,
}
#[derive(Serialize, Deserialize, Debug)]
struct PeerRoute {
my_peer_id: u64,
service_impl: PeerRouteServiceImpl,
}
#[derive(Serialize, Deserialize, Debug)]
struct MyResponse {
response: PeerRoute,
}
#[tauri::command(rename_all = "snake_case")]
async fn get_members_by_cli() -> String {
@@ -875,6 +843,7 @@ fn autostart(enabled: bool) -> std::result::Result<(), Box<dyn std::error::Error
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)?;
@@ -883,7 +852,7 @@ fn autostart(enabled: bool) -> std::result::Result<(), Box<dyn std::error::Error
// 设置任务设置
let settings = task_definition.Settings()?;
settings.SetEnabled(VARIANT_BOOL::from(true))?;
settings.SetCompatibility(TASK_COMPATIBILITY_V2)?; // Windows 7
settings.SetCompatibility(TASK_COMPATIBILITY_V2_1)?; // Windows 7
settings.SetStartWhenAvailable(VARIANT_BOOL::from(true))?;
// settings.SetHidden(VARIANT_BOOL::from(true))?; // 注释掉让任务可见
settings.SetExecutionTimeLimit(&BSTR::from("PT0S"))?;
+2 -2
View File
@@ -1,7 +1,7 @@
{
"$schema": "../node_modules/@tauri-apps/cli/config.schema.json",
"productName": "easytier-game",
"version": "1.5.2",
"version": "1.5.3",
"identifier": "com.tauri.easytier-game",
"build": {
@@ -12,7 +12,7 @@
"app": {
"windows": [
{
"title": "easytier-game 1.5.2",
"title": "easytier-game 1.5.3",
"label": "main",
"minWidth": 340,
"width": 340,
+62
View File
@@ -57,3 +57,65 @@ interface NodesResponse {
error: string | null;
message: string | null;
}
type Member = {
cidr: string;
ipv4: string;
hostname: string;
cost: string;
lat_ms: string;
loss_rate: string;
rx_bytes: string;
tx_bytes: string;
tunnel_proto: string;
nat_type: string;
id: string;
version: string;
connections_addrs: string[];
proxy?: [string, "Connected" | "Closed"];
};
type ConnectionsType = {
route: {
peer_id: number;
ipv4_addr: string | null;
next_hop_peer_id: number;
cost: number;
path_latency: number;
proxy_cidrs: string[];
hostname: string;
stun_info: {
udp_nat_type: number;
tcp_nat_type: number;
last_update_time: number;
public_ip: string[];
min_port: number;
max_port: number;
};
};
peer: {
peer_id: number;
conns: {
conn_id: string;
my_peer_id: number;
peer_id: number;
features: string[];
tunnel: {
tunnel_type: string;
local_addr: {
url: string;
};
remote_addr: {
url: string;
};
};
}[];
};
};
type Proxy = {
src: string;
dst: string;
start_time: string;
state: "Connected" | "Closed";
transport_type: string;
};
+1 -1
View File
@@ -94,7 +94,7 @@ export const ATJ = (promise: Promise<any>, errorExt: string | undefined = undefi
});
};
const _supportProtocols = ["tcp", "udp", "ws", "wss", "srv", "schema"];
const _supportProtocols = ["tcp", "udp", "ws", "wss", "srv", "schema", "txt"];
export const supportProtocols = () => {
return _supportProtocols.slice();
Binary file not shown.