mirror of
https://github.com/EasyTier/EasytierGame.git
synced 2026-09-20 03:21:59 +00:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
0da1ab85cd | ||
|
|
b1d1144e78 | ||
|
|
d71b93c1a8 | ||
|
|
9e83ca7d91 |
+12
-12
@@ -3,7 +3,7 @@
|
||||
"private": true,
|
||||
"author": "leizi97",
|
||||
"description": "A simple network initiator based on Easytier",
|
||||
"version": "1.5.0",
|
||||
"version": "1.5.1",
|
||||
"scripts": {
|
||||
"dev": "nuxt dev --dotenv env/.env.dev --host 0.0.0.0",
|
||||
"build": "nuxt generate --dotenv env/.env.prod",
|
||||
@@ -11,29 +11,29 @@
|
||||
"release-win7": "node zip.js win7"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@element-plus/icons-vue": "^2.3.1",
|
||||
"@element-plus/icons-vue": "^2.3.2",
|
||||
"@element-plus/nuxt": "1.1.4",
|
||||
"@nuxtjs/tailwindcss": "6.13.2",
|
||||
"@pinia/nuxt": "0.11.1",
|
||||
"@tauri-apps/api": "2.7.0",
|
||||
"@tauri-apps/cli": "2.7.1",
|
||||
"@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.3.1",
|
||||
"@tauri-apps/plugin-fs": "2.4.1",
|
||||
"@tauri-apps/plugin-log": "2.6.0",
|
||||
"@tauri-apps/plugin-shell": "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",
|
||||
"@vitejs/plugin-vue-jsx": "5.0.1",
|
||||
"@vitejs/plugin-vue-jsx": "5.1.1",
|
||||
"@vueuse/core": "12.7.0",
|
||||
"archiver": "^7.0.1",
|
||||
"element-plus": "2.10.7",
|
||||
"element-plus": "2.11.5",
|
||||
"less": "4.2.1",
|
||||
"lodash-es": "^4.17.21",
|
||||
"nuxt": "3.19.2",
|
||||
"pinia": "3.0.3",
|
||||
"pinia-plugin-persistedstate": "4.4.1",
|
||||
"pinia-plugin-persistedstate": "4.5.0",
|
||||
"postcss": "^8.4.38",
|
||||
"prettier": "3.6.2",
|
||||
"prettier-plugin-tailwindcss": "0.6.14"
|
||||
|
||||
+2
-11
@@ -69,7 +69,7 @@
|
||||
data.isRunning = true;
|
||||
const [error, member] = await ATJ(invoke<string>("get_route_by_cli"));
|
||||
data.isRunning = false;
|
||||
// if(!member) return;
|
||||
if(!member) return;
|
||||
if (error) {
|
||||
data.route = [];
|
||||
return "";
|
||||
@@ -79,16 +79,7 @@
|
||||
await listenOutput();
|
||||
return;
|
||||
}
|
||||
const routeInfo = parseCliInfo(member);
|
||||
routeInfo.forEach(value => {
|
||||
if (value.cost === "Local") {
|
||||
value.cost = "本机";
|
||||
}
|
||||
if (value.ipv4 && value.ipv4.includes("/")) {
|
||||
value.ipv4 = value.ipv4.split("/")[0];
|
||||
}
|
||||
});
|
||||
data.route = routeInfo;
|
||||
data.route = JSON.parse(member);
|
||||
};
|
||||
|
||||
const listenStart = async () => {
|
||||
|
||||
+4
-50
@@ -67,6 +67,7 @@
|
||||
</template>
|
||||
<ElSelect
|
||||
allow-create
|
||||
:reserve-keyword="false"
|
||||
filterable
|
||||
multiple
|
||||
collapse-tags
|
||||
@@ -962,7 +963,7 @@
|
||||
// console.log(mainStore.config.serverUrl);
|
||||
for (const p of protocols) {
|
||||
for (const url of mainStore.config.serverUrl) {
|
||||
if (url.toLowerCase().startsWith(`${p}://`)) {
|
||||
if (url.replace(/\\/g, "/").toLowerCase().startsWith(`${p}://`)) {
|
||||
inputProtocols.push(p);
|
||||
}
|
||||
}
|
||||
@@ -971,8 +972,8 @@
|
||||
mainStore.config.protocol = uniq([...mainStore.config.protocol, ...inputProtocols]);
|
||||
mainStore.config.serverUrl = (mainStore.config.serverUrl || []).map(url => {
|
||||
for (const p of protocols) {
|
||||
if (url.toLowerCase().startsWith(`${p}://`)) {
|
||||
return url.slice(inputProtocols.length + 3);
|
||||
if (url.replace(/\\/g, "/").toLowerCase().startsWith(`${p}://`)) {
|
||||
return url.slice(p.length + 3);
|
||||
}
|
||||
}
|
||||
return url;
|
||||
@@ -1385,52 +1386,6 @@
|
||||
});
|
||||
};
|
||||
|
||||
// 节点参数含义解析:
|
||||
// - is_active: 节点是否激活运行
|
||||
// - is_approved: 节点是否被管理员批准
|
||||
// - allow_relay: 是否允许中继转发
|
||||
// - current_health_status: 当前健康状态 ("healthy", "unhealthy", "unknown")
|
||||
// - usage_percentage: 使用率百分比 (0-100)
|
||||
// - health_percentage_24h: 24小时健康率 (0-100)
|
||||
// - last_response_time: 最后响应时间(毫秒),越小越好
|
||||
// - current_connections: 当前连接数
|
||||
// - max_connections: 最大连接数
|
||||
// - protocol: 协议类型 ("tcp", "udp", "quic" 等)
|
||||
|
||||
const initNodesList = async () => {
|
||||
let nodesList = await invoke<string>("fetch_nodes_list", { page: 1, limit: 1000 });
|
||||
if (nodesList === "_EasytierGameFetchNodesError_") {
|
||||
nodesList = "";
|
||||
}
|
||||
try {
|
||||
const nodesListData: NodesResponse = JSON.parse(nodesList);
|
||||
console.log("节点数据:", nodesListData);
|
||||
|
||||
if (nodesListData.success && nodesListData.data.items) {
|
||||
// 过滤可用节点
|
||||
const availableNodes = filterAvailableNodes(nodesListData.data.items);
|
||||
console.log(`总节点数: ${nodesListData.data.items.length}, 可用节点数: ${availableNodes.length}`);
|
||||
|
||||
// 按优先级排序
|
||||
const sortedNodes = sortNodesByPriority(availableNodes);
|
||||
|
||||
// 处理过滤后的节点数据
|
||||
sortedNodes.forEach((node, index) => {
|
||||
console.log(`${index + 1}. ${node.name} (${node.protocol}) - ${node.address}`);
|
||||
console.log(
|
||||
` 状态: ${node.current_health_status}, 使用率: ${node.usage_percentage.toFixed(1)}%, 响应时间: ${node.last_response_time}ms`
|
||||
);
|
||||
console.log(` 连接: ${node.current_connections}/${node.max_connections}, 24h健康率: ${node.health_percentage_24h}%`);
|
||||
});
|
||||
|
||||
// 将可用节点添加到服务器列表
|
||||
// addNodesToServerList(sortedNodes);
|
||||
}
|
||||
} catch (err) {
|
||||
console.error("解析节点数据失败:", err);
|
||||
}
|
||||
};
|
||||
|
||||
// 过滤可用节点的函数
|
||||
const filterAvailableNodes = (nodes: NodeItem[]): NodeItem[] => {
|
||||
return nodes.filter(node => {
|
||||
@@ -1532,7 +1487,6 @@
|
||||
|
||||
onMounted(async () => {
|
||||
await compatibleInitServerUrl();
|
||||
initNodesList();
|
||||
await initGuiJson();
|
||||
await compatibleInitAutoStart();
|
||||
// await initAutoStart();
|
||||
|
||||
+96
-47
@@ -15,16 +15,31 @@
|
||||
>
|
||||
<ElTableColumn
|
||||
sortable
|
||||
width="140"
|
||||
label="成员名"
|
||||
prop="hostname"
|
||||
>
|
||||
<template #default="{ row }">
|
||||
{{
|
||||
(row.hostname || "").toLowerCase().includes("publicserver")
|
||||
? (row.hostname || "").replace("PublicServer", "服务器")
|
||||
: row.hostname || "-"
|
||||
}}
|
||||
<div class="whitespace-pre-wrap">
|
||||
<div>
|
||||
{{
|
||||
(row.hostname || "").toLowerCase().includes("publicserver")
|
||||
? (row.hostname || "").replace("PublicServer", "服务器")
|
||||
: row.hostname || "-"
|
||||
}}
|
||||
</div>
|
||||
<div
|
||||
class="space-y-1"
|
||||
v-if="row?.connections_addrs?.length > 0"
|
||||
>
|
||||
<ElTag
|
||||
:key="url"
|
||||
v-for="url in row.connections_addrs"
|
||||
class="!flex !h-auto !whitespace-pre-wrap !break-all !py-[5px]"
|
||||
>
|
||||
{{ url }}
|
||||
</ElTag>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
</ElTableColumn>
|
||||
<ElTableColumn
|
||||
@@ -113,7 +128,7 @@
|
||||
sortable
|
||||
prop="tx_bytes"
|
||||
label="传输"
|
||||
:sort-method="(a, b) => sortBytes(a, b, 'tx_bytes')"
|
||||
:sort-method="(a: any, b: any) => sortBytes(a, b, 'tx_bytes')"
|
||||
:sort-orders="['ascending', 'descending', null]"
|
||||
></ElTableColumn>
|
||||
</ElTable>
|
||||
@@ -127,19 +142,61 @@
|
||||
import { ElConfirmDanger } from "~/utils/element";
|
||||
import { getCurrentWindow } from "@tauri-apps/api/window";
|
||||
import { endsWith, isNaN } from "lodash-es";
|
||||
// enum NatType {
|
||||
// // has NAT; but own a single public IP, port is not changed
|
||||
// Unknown = 0;
|
||||
// OpenInternet = 1;
|
||||
// NoPAT = 2;
|
||||
// FullCone = 3;
|
||||
// Restricted = 4;
|
||||
// PortRestricted = 5;
|
||||
// Symmetric = 6;
|
||||
// SymUdpFirewall = 7;
|
||||
// SymmetricEasyInc = 8;
|
||||
// SymmetricEasyDec = 9;
|
||||
// }
|
||||
|
||||
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[];
|
||||
};
|
||||
|
||||
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;
|
||||
};
|
||||
};
|
||||
}[];
|
||||
};
|
||||
};
|
||||
|
||||
const natMaps = {
|
||||
unknown: "未知",
|
||||
OpenInternet: "nat0-openinternet",
|
||||
@@ -154,13 +211,13 @@
|
||||
};
|
||||
type natKyes = keyof typeof natMaps;
|
||||
|
||||
const data = reactive<{ member: { hostname: string; cost: string; ipv4: string; lat_msg: string; loss_rate: string; nat_type: string }[] }>({
|
||||
const data = reactive<{ member: Member[] }>({
|
||||
member: []
|
||||
});
|
||||
|
||||
// 延迟排序函数
|
||||
const sortLatMs = (a: any, b: any): number => {
|
||||
const getLatencyValue = (row: any): number => {
|
||||
const sortLatMs = (a: Member, b: Member): number => {
|
||||
const getLatencyValue = (row: Member): number => {
|
||||
const latMs = row.lat_ms;
|
||||
|
||||
if (latMs === null || latMs === undefined || latMs === "") {
|
||||
@@ -298,19 +355,6 @@
|
||||
return num.toFixed(0);
|
||||
};
|
||||
|
||||
const _showTableHeader = [
|
||||
["hostname", "主机名"],
|
||||
["cost", "路由"],
|
||||
["ipv4", "虚拟网IP"],
|
||||
["lat_ms", "延迟/ms"],
|
||||
["loss_rate", "丢包率"],
|
||||
["nat_type", "NAT类型"],
|
||||
["version", "版本"],
|
||||
["tunnel_proto", "隧道协议"],
|
||||
["rx_bytes", "接收"],
|
||||
["tx_bytes", "传输"]
|
||||
];
|
||||
|
||||
let timer: number | null = null;
|
||||
|
||||
const listenOutput = async () => {
|
||||
@@ -334,18 +378,23 @@
|
||||
}
|
||||
return;
|
||||
}
|
||||
// const peerInfo = parseCliInfo(member);
|
||||
// peerInfo.forEach(value => {
|
||||
// if (value.cost === "Local") {
|
||||
// value.cost = "本机";
|
||||
// }
|
||||
// if (value.ipv4 && value.ipv4.includes("/")) {
|
||||
// value.ipv4 = value.ipv4.split("/")[0];
|
||||
// }
|
||||
// });
|
||||
// data.member = peerInfo;
|
||||
const [errorConnections, connections] = await ATJ(invoke<string>("get_members_connections_cli"));
|
||||
const memberConnections: ConnectionsType[] = JSON.parse(connections) as ConnectionsType[];
|
||||
|
||||
data.member = JSON.parse(member);
|
||||
if (errorConnections != "_EasytierGameCliFailedToGetConnections_") {
|
||||
data.member = (JSON.parse(member) as Member[]).map(member => {
|
||||
const connection = memberConnections.find(conn => String(conn.route.peer_id) === member.id);
|
||||
if (connection) {
|
||||
member.connections_addrs = connection?.peer?.conns?.map(conn => conn?.tunnel?.remote_addr?.url || "") || [];
|
||||
} else {
|
||||
member.connections_addrs = [];
|
||||
}
|
||||
return member;
|
||||
});
|
||||
} else {
|
||||
data.member = JSON.parse(member) as Member[];
|
||||
}
|
||||
// console.log(data.member);
|
||||
startTimer();
|
||||
};
|
||||
|
||||
|
||||
+4
-4
@@ -87,7 +87,7 @@
|
||||
:type="getResponseTimeType(row.last_response_time)"
|
||||
size="small"
|
||||
>
|
||||
{{ row.last_response_time }}ms
|
||||
{{ Number(row.last_response_time / 1000).toFixed(2) }}ms
|
||||
</ElTag>
|
||||
</template>
|
||||
</ElTableColumn>
|
||||
@@ -176,8 +176,8 @@ import { uniq } from "lodash-es";
|
||||
|
||||
// 获取响应时间类型
|
||||
const getResponseTimeType = (responseTime: number) => {
|
||||
if (responseTime < 1000) return "success";
|
||||
if (responseTime < 5000) return "warning";
|
||||
if (responseTime < 60 * 1000) return "success";
|
||||
if (responseTime < 100 * 1000) return "warning";
|
||||
return "danger";
|
||||
};
|
||||
|
||||
@@ -196,9 +196,9 @@ import { uniq } from "lodash-es";
|
||||
if (nodesList === "_EasytierGameFetchNodesError_") {
|
||||
nodesList = "";
|
||||
}
|
||||
|
||||
if (nodesList) {
|
||||
const nodesListData: NodesResponse = JSON.parse(nodesList);
|
||||
console.log(nodesListData);
|
||||
if (nodesListData.success && nodesListData.data.items) {
|
||||
// 过滤可用节点
|
||||
const availableNodes = filterAvailableNodes(nodesListData.data.items);
|
||||
|
||||
Generated
+612
-788
File diff suppressed because it is too large
Load Diff
Generated
+245
-312
File diff suppressed because it is too large
Load Diff
@@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "easytier-game"
|
||||
version = "1.5.0"
|
||||
version = "1.5.1"
|
||||
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.3.1", features = [] }
|
||||
tauri-build = { version = "2.5.1", features = [] }
|
||||
# prost-build = "0.13.2"
|
||||
|
||||
[target.x86_64-pc-windows-msvc.build-dependencies]
|
||||
@@ -28,24 +28,24 @@ 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.7.0", features = [ "protocol-asset",
|
||||
tauri = { version = "2.9.1", features = [ "protocol-asset",
|
||||
"tray-icon",
|
||||
"image-png",
|
||||
"image-ico"
|
||||
] }
|
||||
|
||||
tauri-plugin-log = "2.6.0"
|
||||
tauri-plugin-shell = "2.3.0"
|
||||
tauri-plugin-log = "2.7.0"
|
||||
tauri-plugin-shell = "2.3.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" }
|
||||
whoami = "1.5.2"
|
||||
tauri-plugin-fs = "2.4.1"
|
||||
tauri-plugin-fs = "2.4.2"
|
||||
tauri-plugin-clipboard-manager = "2.3.0"
|
||||
rand = "0.9.0"
|
||||
tokio = { version = "1.45.1", features = ["process"] }
|
||||
tauri-plugin-dialog = "2.3.1"
|
||||
tauri-plugin-dialog = "2.4.0"
|
||||
# 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.4.0"
|
||||
tauri-plugin-single-instance = "2.3.2"
|
||||
tauri-plugin-single-instance = "2.3.4"
|
||||
tauri-plugin-window-state = "2.4.0"
|
||||
|
||||
+35
-4
@@ -299,10 +299,41 @@ async fn get_members_by_cli() -> String {
|
||||
}
|
||||
}
|
||||
|
||||
#[tauri::command(rename_all = "snake_case")]
|
||||
async fn get_members_connections_cli() -> String {
|
||||
let cli_path = get_tool_exe_path("\\easytier\\easytier-cli.exe");
|
||||
match tokioCommand::new(&cli_path)
|
||||
.arg("-v")
|
||||
.arg("-o")
|
||||
.arg("json")
|
||||
.arg("peer")
|
||||
.creation_flags(0x08000000)
|
||||
.output()
|
||||
.await
|
||||
{
|
||||
Ok(output) => {
|
||||
if output.status.success() {
|
||||
let output_str = String::from_utf8_lossy(&output.stdout);
|
||||
return output_str.trim().to_string();
|
||||
} else {
|
||||
let output_str = String::from_utf8_lossy(&output.stderr);
|
||||
log::error!("{}", output_str.trim().to_string());
|
||||
return "_EasytierGameCliFailedToGetConnections_".to_string();
|
||||
}
|
||||
}
|
||||
Err(_e) => {
|
||||
log::error!("get member list error");
|
||||
return "".to_string();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[tauri::command(rename_all = "snake_case")]
|
||||
async fn get_route_by_cli() -> String {
|
||||
let cli_path = get_tool_exe_path("\\easytier\\easytier-cli.exe");
|
||||
match tokioCommand::new(&cli_path)
|
||||
.arg("-o")
|
||||
.arg("json")
|
||||
.arg("route")
|
||||
.creation_flags(0x08000000)
|
||||
.output()
|
||||
@@ -694,11 +725,11 @@ fn autostart_enabled() -> Result<bool, Box<dyn std::error::Error>> {
|
||||
fn autostart_is_enabled() -> bool {
|
||||
match autostart_enabled() {
|
||||
Ok(enabled) => {
|
||||
println!("autostart enabled: {}", enabled);
|
||||
// println!("autostart enabled: {}", enabled);
|
||||
return enabled;
|
||||
}
|
||||
Err(e) => {
|
||||
log::error!("autostart enabled: false -> {}", e);
|
||||
Err(_e) => {
|
||||
// log::error!("autostart enabled: false -> {}", e);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -816,7 +847,6 @@ 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)?;
|
||||
@@ -929,6 +959,7 @@ pub fn run() {
|
||||
fetch_game_releases,
|
||||
download_easytier_zip,
|
||||
get_members_by_cli,
|
||||
get_members_connections_cli,
|
||||
get_route_by_cli,
|
||||
fetch_nodes_list,
|
||||
search_pid_by_pname,
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"$schema": "../node_modules/@tauri-apps/cli/config.schema.json",
|
||||
"productName": "easytier-game",
|
||||
"version": "1.5.0",
|
||||
"version": "1.5.1",
|
||||
"identifier": "com.tauri.easytier-game",
|
||||
|
||||
"build": {
|
||||
@@ -12,7 +12,7 @@
|
||||
"app": {
|
||||
"windows": [
|
||||
{
|
||||
"title": "easytier-game 1.5.0",
|
||||
"title": "easytier-game 1.5.1",
|
||||
"label": "main",
|
||||
"minWidth": 340,
|
||||
"width": 340,
|
||||
|
||||
Reference in New Issue
Block a user