Compare commits

...
8 Commits
16 changed files with 1388 additions and 1466 deletions
+1
View File
@@ -10,6 +10,7 @@ dist
.idea .idea
.vscode .vscode
release release
target
src-tauri/easytier/logs src-tauri/easytier/logs
src-tauri/easytier/tool/ResourcesExtract.exe src-tauri/easytier/tool/ResourcesExtract.exe
+13 -5
View File
@@ -1,12 +1,20 @@
pnpm run build pnpm run build
rustup default nightly rustup default nightly
@REM rem 使用rust nightly构建支持win7的版本,请先将根目录的windows.0.48.5 放入以下目录
@REM rem C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\你自己的版本\lib\x64
@REM rem C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\你自己的版本\lib\x86
@REM rem C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\你自己的版本\atlmfc\lib\x64
@REM rem C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\你自己的版本\atlmfc\lib\x86
pnpm tauri build -- -Z build-std --target x86_64-win7-windows-msvc pnpm tauri build -- -Z build-std --target x86_64-win7-windows-msvc
rustup default stable rustup default stable
pnpm tauri build pnpm tauri build
@REM 复制文件夹src-tauri\easytier 到 src-tauri\target\release目录下 覆盖目录下同名目录
xcopy /s /y /i src-tauri\easytier src-tauri\target\release\easytier
@REM 复制 src-tauri\帮助.txt 和 src-tauri\uninstall.exe 到 src-tauri\target\release目录下 覆盖目录下同名文件
xcopy /y src-tauri\帮助.txt src-tauri\target\release\帮助.txt
xcopy /y src-tauri\uninstall.exe src-tauri\target\release\uninstall.exe
@REM 复制文件夹src-tauri\easytier到 src-tauri\target\x86_64-win7-windows-msvc\release目录下 覆盖目录下同名目录
@REM 复制 src-tauri\帮助.txt 和 src-tauri\uninstall.exe 到 src-tauri\target\x86_64-win7-windows-msvc\release目录下 覆盖目录下同名文件
xcopy /y src-tauri\帮助.txt src-tauri\target\x86_64-win7-windows-msvc\release\帮助.txt
xcopy /y src-tauri\uninstall.exe src-tauri\target\x86_64-win7-windows-msvc\release\uninstall.exe
xcopy /s /y /i src-tauri\easytier src-tauri\target\x86_64-win7-windows-msvc\release\easytier
pnpm run release pnpm run release
pnpm run release-win7 pnpm run release-win7
+2 -7
View File
@@ -7,7 +7,7 @@ import { bounce } from "~/utils";
const b = bounce(600); const b = bounce(600);
export type ConfigServerUrlType = Array<string>; export type ConfigServerUrlType = Array<string>;
export const updateConfigJsonBounce = (configJsonSeverUrl?: ConfigServerUrlType) => { export const updateConfigJsonBounce = (configJsonSeverUrl?: ConfigServerUrlType | null) => {
b(async () => { b(async () => {
const mainStore = useMainStore(); const mainStore = useMainStore();
if (mainStore.createConfigInEasytier) { if (mainStore.createConfigInEasytier) {
@@ -16,7 +16,7 @@ export const updateConfigJsonBounce = (configJsonSeverUrl?: ConfigServerUrlType)
}); });
}; };
export const updateConfigJson = async (configJsonSeverUrl?: ConfigServerUrlType) => { export const updateConfigJson = async (configJsonSeverUrl?: ConfigServerUrlType | null) => {
const mainStore = useMainStore(); const mainStore = useMainStore();
const path = import.meta.env.VITE_CONFIG_FILE_NAME; const path = import.meta.env.VITE_CONFIG_FILE_NAME;
if (isNil(configJsonSeverUrl)) { if (isNil(configJsonSeverUrl)) {
@@ -30,7 +30,6 @@ export const updateConfigJson = async (configJsonSeverUrl?: ConfigServerUrlType)
const { const {
proxyNetworks, proxyNetworks,
autoStart, autoStart,
connectAfterStart,
saveErrorLog, saveErrorLog,
serverUrl, serverUrl,
enableCustomListener, enableCustomListener,
@@ -39,10 +38,6 @@ export const updateConfigJson = async (configJsonSeverUrl?: ConfigServerUrlType)
acceptDNS, acceptDNS,
enablePortForward, enablePortForward,
portForwardData, portForwardData,
tcpWhitelist,
udpWhitelist,
tcpWhitelistEnable,
udpWhitelistEnable,
...otherConfig ...otherConfig
} = mainStore.config; } = mainStore.config;
let writeServerUrl: Array<string> = serverUrl; let writeServerUrl: Array<string> = serverUrl;
+12 -12
View File
@@ -3,7 +3,7 @@
"private": true, "private": true,
"author": "leizi97", "author": "leizi97",
"description": "A simple network initiator based on Easytier", "description": "A simple network initiator based on Easytier",
"version": "1.5.0", "version": "1.5.2",
"scripts": { "scripts": {
"dev": "nuxt dev --dotenv env/.env.dev --host 0.0.0.0", "dev": "nuxt dev --dotenv env/.env.dev --host 0.0.0.0",
"build": "nuxt generate --dotenv env/.env.prod", "build": "nuxt generate --dotenv env/.env.prod",
@@ -11,29 +11,29 @@
"release-win7": "node zip.js win7" "release-win7": "node zip.js win7"
}, },
"devDependencies": { "devDependencies": {
"@element-plus/icons-vue": "^2.3.1", "@element-plus/icons-vue": "^2.3.2",
"@element-plus/nuxt": "1.1.4", "@element-plus/nuxt": "1.1.4",
"@nuxtjs/tailwindcss": "6.13.2", "@nuxtjs/tailwindcss": "6.13.2",
"@pinia/nuxt": "0.11.1", "@pinia/nuxt": "0.11.2",
"@tauri-apps/api": "2.7.0", "@tauri-apps/api": "2.9.0",
"@tauri-apps/cli": "2.7.1", "@tauri-apps/cli": "2.9.1",
"@tauri-apps/plugin-cli": "2.4.0", "@tauri-apps/plugin-cli": "2.4.0",
"@tauri-apps/plugin-clipboard-manager": "2.3.0", "@tauri-apps/plugin-clipboard-manager": "2.3.0",
"@tauri-apps/plugin-dialog": "2.3.1", "@tauri-apps/plugin-dialog": "2.4.0",
"@tauri-apps/plugin-fs": "2.4.1", "@tauri-apps/plugin-fs": "2.4.2",
"@tauri-apps/plugin-log": "2.6.0", "@tauri-apps/plugin-log": "2.7.0",
"@tauri-apps/plugin-shell": "2.3.0", "@tauri-apps/plugin-shell": "2.3.1",
"@tauri-apps/plugin-window-state": "2.4.0", "@tauri-apps/plugin-window-state": "2.4.0",
"@types/lodash-es": "^4.17.12", "@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", "@vueuse/core": "12.7.0",
"archiver": "^7.0.1", "archiver": "^7.0.1",
"element-plus": "2.10.7", "element-plus": "2.11.7",
"less": "4.2.1", "less": "4.2.1",
"lodash-es": "^4.17.21", "lodash-es": "^4.17.21",
"nuxt": "3.19.2", "nuxt": "3.19.2",
"pinia": "3.0.3", "pinia": "3.0.3",
"pinia-plugin-persistedstate": "4.4.1", "pinia-plugin-persistedstate": "4.5.0",
"postcss": "^8.4.38", "postcss": "^8.4.38",
"prettier": "3.6.2", "prettier": "3.6.2",
"prettier-plugin-tailwindcss": "0.6.14" "prettier-plugin-tailwindcss": "0.6.14"
+2 -11
View File
@@ -69,7 +69,7 @@
data.isRunning = true; data.isRunning = true;
const [error, member] = await ATJ(invoke<string>("get_route_by_cli")); const [error, member] = await ATJ(invoke<string>("get_route_by_cli"));
data.isRunning = false; data.isRunning = false;
// if(!member) return; if(!member) return;
if (error) { if (error) {
data.route = []; data.route = [];
return ""; return "";
@@ -79,16 +79,7 @@
await listenOutput(); await listenOutput();
return; return;
} }
const routeInfo = parseCliInfo(member); data.route = JSON.parse(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;
}; };
const listenStart = async () => { const listenStart = async () => {
+49 -79
View File
@@ -67,6 +67,7 @@
</template> </template>
<ElSelect <ElSelect
allow-create allow-create
:reserve-keyword="false"
filterable filterable
multiple multiple
collapse-tags collapse-tags
@@ -336,6 +337,12 @@
<ElDivider class="!m-0 !h-[2px]" /> <ElDivider class="!m-0 !h-[2px]" />
</ElDropdownItem> </ElDropdownItem>
<ElDropdownItem <ElDropdownItem
command="cidr"
:icon="Share"
>
子网代理
</ElDropdownItem>
<!-- <ElDropdownItem
command="import_config" command="import_config"
:icon="Link" :icon="Link"
> >
@@ -346,7 +353,7 @@
:icon="Share" :icon="Share"
> >
分享联机配置 分享联机配置
</ElDropdownItem> </ElDropdownItem> -->
<ElDropdownItem <ElDropdownItem
command="reconnect" command="reconnect"
:icon="RefreshRight" :icon="RefreshRight"
@@ -405,21 +412,32 @@
开机自启 开机自启
</ElCheckbox> </ElCheckbox>
</ElTooltip> </ElTooltip>
<div> <div class="flex items-center gap-[0_2px]">
<ElButton <ElDropdown
@click="handleShowCidrDialog" @command="handleStartCommand"
:icon="Share" trigger="click"
size="small" :show-arrow="false"
> >
子网代理 <ElButton
</ElButton> :icon="Share"
<ElButton size="small"
@click="handleShowAdvanceDialog" >
:icon="Setting" 分享/导入
size="small" </ElButton>
> <template #dropdown>
高级选项 <el-dropdown-item command="share_config">分享联机配置</el-dropdown-item>
</ElButton> <el-dropdown-item command="import_config">导入联机配置</el-dropdown-item>
</template>
</ElDropdown>
<div>
<ElButton
@click="handleShowAdvanceDialog"
:icon="Setting"
size="small"
>
高级选项
</ElButton>
</div>
</div> </div>
<div class="flex items-center gap-[0_5px]"> <div class="flex items-center gap-[0_5px]">
<div> <div>
@@ -962,7 +980,7 @@
// console.log(mainStore.config.serverUrl); // console.log(mainStore.config.serverUrl);
for (const p of protocols) { for (const p of protocols) {
for (const url of mainStore.config.serverUrl) { for (const url of mainStore.config.serverUrl) {
if (url.toLowerCase().startsWith(`${p}://`)) { if (url.replace(/\\/g, "/").toLowerCase().startsWith(`${p}://`)) {
inputProtocols.push(p); inputProtocols.push(p);
} }
} }
@@ -971,8 +989,8 @@
mainStore.config.protocol = uniq([...mainStore.config.protocol, ...inputProtocols]); mainStore.config.protocol = uniq([...mainStore.config.protocol, ...inputProtocols]);
mainStore.config.serverUrl = (mainStore.config.serverUrl || []).map(url => { mainStore.config.serverUrl = (mainStore.config.serverUrl || []).map(url => {
for (const p of protocols) { for (const p of protocols) {
if (url.toLowerCase().startsWith(`${p}://`)) { if (url.replace(/\\/g, "/").toLowerCase().startsWith(`${p}://`)) {
return url.slice(inputProtocols.length + 3); return url.slice(p.length + 3);
} }
} }
return url; return url;
@@ -1171,7 +1189,6 @@
); );
}; };
let unlistenDownload: UnlistenFn | null = null; let unlistenDownload: UnlistenFn | null = null;
let unlistenDownloadError: UnlistenFn | null = null; let unlistenDownloadError: UnlistenFn | null = null;
let progress = ref<number>(0); let progress = ref<number>(0);
@@ -1385,52 +1402,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[] => { const filterAvailableNodes = (nodes: NodeItem[]): NodeItem[] => {
return nodes.filter(node => { return nodes.filter(node => {
@@ -1532,7 +1503,6 @@
onMounted(async () => { onMounted(async () => {
await compatibleInitServerUrl(); await compatibleInitServerUrl();
initNodesList();
await initGuiJson(); await initGuiJson();
await compatibleInitAutoStart(); await compatibleInitAutoStart();
// await initAutoStart(); // await initAutoStart();
@@ -1552,7 +1522,6 @@
checkNewVersion(); checkNewVersion();
} }
await storageDialog(); await storageDialog();
}); });
// storageEventEmitter.addEventListener("localStorageChange", () => { // storageEventEmitter.addEventListener("localStorageChange", () => {
@@ -1565,7 +1534,6 @@
return data.configJsonSeverUrl; return data.configJsonSeverUrl;
}); });
onBeforeUnmount(() => { onBeforeUnmount(() => {
unListenAll(); unListenAll();
listenObj.unListenReleaseList && listenObj.unListenReleaseList(); listenObj.unListenReleaseList && listenObj.unListenReleaseList();
@@ -1575,7 +1543,6 @@
cidrTimer && clearInterval(cidrTimer); cidrTimer && clearInterval(cidrTimer);
stopPreventSleep(); stopPreventSleep();
// unListenStorage && unListenStorage(); // unListenStorage && unListenStorage();
}); });
const getArgs = async () => { const getArgs = async () => {
@@ -1646,7 +1613,7 @@
args.push("--disable-p2p"); args.push("--disable-p2p");
} }
if (mainStore.config.disableIpv6) { if (mainStore.config.disableIpv6) {
args.push("--disable-ipv6"); args.push("--disable-ipv6", "true");
} }
if (mainStore.config.disbleListenner) { if (mainStore.config.disbleListenner) {
args.push("--no-listener"); args.push("--no-listener");
@@ -1678,28 +1645,28 @@
mainStore.config.proxyNetworks = formatProxyNetworks.join("\n"); mainStore.config.proxyNetworks = formatProxyNetworks.join("\n");
} }
if (mainStore.config.disableEncryption) { if (mainStore.config.disableEncryption) {
args.push("--disable-encryption"); args.push("--disable-encryption", "true");
} }
if (mainStore.config.multiThread) { if (mainStore.config.multiThread) {
args.push("--multi-thread"); args.push("--multi-thread", "true");
} }
if (mainStore.config.enablExitNode) { if (mainStore.config.enablExitNode) {
args.push("--enable-exit-node"); args.push("--enable-exit-node", "true");
} }
if (mainStore.config.noTun) { if (mainStore.config.noTun) {
args.push("--no-tun"); args.push("--no-tun", "true");
} }
if (mainStore.config.latencyfirst) { if (mainStore.config.latencyfirst) {
args.push("--latency-first"); args.push("--latency-first", "true");
} }
if (mainStore.config.useSmoltcp) { if (mainStore.config.useSmoltcp) {
args.push("--use-smoltcp"); args.push("--use-smoltcp", "true");
} }
if (mainStore.config.disableUdpHolePunching) { if (mainStore.config.disableUdpHolePunching) {
args.push("--disable-udp-hole-punching"); args.push("--disable-udp-hole-punching", "true");
} }
if (mainStore.config.relayAllPeerrpc) { if (mainStore.config.relayAllPeerrpc) {
args.push("--relay-all-peer-rpc"); args.push("--relay-all-peer-rpc", "true");
} }
if (mainStore.config.saveErrorLog) { if (mainStore.config.saveErrorLog) {
args.push("--file-log-level", mainStore.config.logLevel, "--file-log-dir", import.meta.env.VITE_LOG_PATH); args.push("--file-log-level", mainStore.config.logLevel, "--file-log-dir", import.meta.env.VITE_LOG_PATH);
@@ -1726,7 +1693,7 @@
args.push("--bind-device", "true"); args.push("--bind-device", "true");
} }
if (mainStore.proxyForwardBySystem) { if (mainStore.proxyForwardBySystem) {
args.push("--proxy-forward-by-system"); args.push("--proxy-forward-by-system", "true");
} }
if (mainStore.config.acceptDNS) { if (mainStore.config.acceptDNS) {
args.push("--accept-dns", "true"); args.push("--accept-dns", "true");
@@ -1925,6 +1892,9 @@
if (command === "create_server") { if (command === "create_server") {
await handleShowServerDialog(); await handleShowServerDialog();
} }
if (command === "cidr") {
await handleShowCidrDialog();
}
if (command === "config_admin") { if (command === "config_admin") {
configAdminData.visible = true; configAdminData.visible = true;
const path = import.meta.env.VITE_CONFIG_ADMIN_PATH; const path = import.meta.env.VITE_CONFIG_ADMIN_PATH;
+162 -51
View File
@@ -10,21 +10,36 @@
<ElTable <ElTable
stripe stripe
border border
:data="data.member" :data="computedMember"
v-else v-else
> >
<ElTableColumn <ElTableColumn
sortable sortable
width="140"
label="成员名" label="成员名"
prop="hostname" prop="hostname"
> >
<template #default="{ row }"> <template #default="{ row }">
{{ <div class="whitespace-pre-wrap">
(row.hostname || "").toLowerCase().includes("publicserver") <div>
? (row.hostname || "").replace("PublicServer", "服务器") {{
: row.hostname || "-" (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> </template>
</ElTableColumn> </ElTableColumn>
<ElTableColumn <ElTableColumn
@@ -50,7 +65,25 @@
label="虚拟网IP" label="虚拟网IP"
:sort-method="sortIpv4" :sort-method="sortIpv4"
:sort-orders="['ascending', 'descending', null]" :sort-orders="['ascending', 'descending', null]"
></ElTableColumn> >
<template #default="{ row }">
<div class="space-y-[5px]">
<div>
{{ row.ipv4 || "-" }}
</div>
<div v-if="row.proxy?.[0]">
<ElTooltip :content="row.proxy?.[1] == 'Connected' ? '已连接' : '已断开'">
<ElTag
size="small"
:type="row.proxy?.[1] == 'Connected' ? 'success' : 'danger'"
>
{{ row.proxy?.[0] || "-" }}代理
</ElTag>
</ElTooltip>
</div>
</div>
</template>
</ElTableColumn>
<ElTableColumn <ElTableColumn
sortable sortable
prop="lat_ms" prop="lat_ms"
@@ -113,7 +146,7 @@
sortable sortable
prop="tx_bytes" prop="tx_bytes"
label="传输" 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]" :sort-orders="['ascending', 'descending', null]"
></ElTableColumn> ></ElTableColumn>
</ElTable> </ElTable>
@@ -122,24 +155,67 @@
</template> </template>
<script setup lang="ts"> <script setup lang="ts">
import { invoke } from "@tauri-apps/api/core"; import { invoke } from "@tauri-apps/api/core";
import { reactive, onMounted, onBeforeUnmount } from "vue"; import { reactive, onMounted, onBeforeUnmount, computed } from "vue";
import { ATJ, parseCliInfo } from "@/utils"; import { ATJ, parseCliInfo } from "@/utils";
import { ElConfirmDanger } from "~/utils/element"; import { ElConfirmDanger } from "~/utils/element";
import { getCurrentWindow } from "@tauri-apps/api/window"; import { getCurrentWindow } from "@tauri-apps/api/window";
import { endsWith, isNaN } from "lodash-es"; import { endsWith, isNaN } from "lodash-es";
// enum NatType {
// // has NAT; but own a single public IP, port is not changed type Member = {
// Unknown = 0; cidr: string;
// OpenInternet = 1; ipv4: string;
// NoPAT = 2; hostname: string;
// FullCone = 3; cost: string;
// Restricted = 4; lat_ms: string;
// PortRestricted = 5; loss_rate: string;
// Symmetric = 6; rx_bytes: string;
// SymUdpFirewall = 7; tx_bytes: string;
// SymmetricEasyInc = 8; tunnel_proto: string;
// SymmetricEasyDec = 9; 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;
};
};
}[];
};
};
const natMaps = { const natMaps = {
unknown: "未知", unknown: "未知",
OpenInternet: "nat0-openinternet", OpenInternet: "nat0-openinternet",
@@ -152,15 +228,40 @@
symmetriceasyinc: "nat4-easyinc", symmetriceasyinc: "nat4-easyinc",
symUdpfirewall: "nat4-udpfirewall" 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: { hostname: string; cost: string; ipv4: string; lat_msg: string; loss_rate: string; nat_type: string }[] }>({ const data = reactive<{ member: Member[]; proxy: Proxy[] }>({
member: [] member: [],
proxy: []
});
const computedMember = computed(() => {
const localMember = data.member.find(member => member?.cost == "Local");
if (!localMember) return data.member;
const ipv4 = localMember.ipv4;
const proxyMember = data.proxy?.filter(proxy => proxy.src.startsWith(`${ipv4}:`));
const proxyObj: Record<string, [string, "Connected" | "Closed"]> = {};
for (const proxy of proxyMember) {
proxyObj[proxy.dst.split(":")[0]] = [proxy.transport_type, proxy.state];
}
return data.member.map(m => {
m.proxy = proxyObj?.[m.ipv4.split(":")?.[0]] || m?.proxy || ["", "Closed"];
return m;
});
}); });
// 延迟排序函数 // 延迟排序函数
const sortLatMs = (a: any, b: any): number => { const sortLatMs = (a: Member, b: Member): number => {
const getLatencyValue = (row: any): number => { const getLatencyValue = (row: Member): number => {
const latMs = row.lat_ms; const latMs = row.lat_ms;
if (latMs === null || latMs === undefined || latMs === "") { if (latMs === null || latMs === undefined || latMs === "") {
@@ -298,19 +399,6 @@
return num.toFixed(0); 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; let timer: number | null = null;
const listenOutput = async () => { const listenOutput = async () => {
@@ -334,21 +422,44 @@
} }
return; return;
} }
// const peerInfo = parseCliInfo(member); const [errorConnections, connections] = await ATJ(invoke<string>("get_members_connections_cli"));
// peerInfo.forEach(value => { const memberConnections: ConnectionsType[] = JSON.parse(connections) as ConnectionsType[];
// if (value.cost === "Local") {
// value.cost = "本机";
// }
// if (value.ipv4 && value.ipv4.includes("/")) {
// value.ipv4 = value.ipv4.split("/")[0];
// }
// });
// data.member = peerInfo;
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);
getMembersProxy();
startTimer(); startTimer();
}; };
const getMembersProxy = async () => {
const [error, proxy] = await ATJ(invoke<string>("get_members_proxy"));
if (error) {
data.proxy = [];
return "";
}
if (proxy === "_EasytierGameCliFailedToGetProxy_") {
data.proxy = [];
return "";
}
try {
data.proxy = JSON.parse(proxy) as Proxy[];
} catch (error) {
data.proxy = [];
}
};
const startTimer = () => { const startTimer = () => {
timer && clearTimeout(timer); timer && clearTimeout(timer);
timer = setTimeout(() => { timer = setTimeout(() => {
+65 -40
View File
@@ -1,46 +1,53 @@
<template> <template>
<div class="relative flex h-full flex-col flex-wrap gap-[0] overflow-hidden"> <div class="relative flex h-full flex-col flex-wrap gap-[0] overflow-hidden">
<div class="flex h-[40px] w-full flex-nowrap items-center gap-[0_5px]"> <div class="flex h-[40px] w-full flex-nowrap items-center gap-[0_8px]">
<div class="ml-[5px] mr-auto flex flex-1"> <div class="ml-[5px] mr-auto flex">
<ElText class="text-lg font-semibold">公共服务器节点列表</ElText> <ElText class="text-lg font-semibold">公共服务器节点列表</ElText>
</div> </div>
<div> <div class="flex w-fit flex-nowrap items-center gap-[0_8px]">
<ElButton <div>
:loading="loading" <ElInput
size="small" placeholder="搜索名称/地址"
type="primary" v-model="searchName"
class="mr-[5px]" clearable
@click="refreshNodes" ></ElInput>
> </div>
刷新 <div>
</ElButton> <ElButton
<ElButton size="small"
:disabled="selectedNodes.length === 0" type="primary"
size="small" @click="refreshNodes"
type="success" >
class="mr-[5px]" 刷新
@click="addSelectedToServerList" </ElButton>
> <ElButton
添加选中 ({{ selectedNodes.length }}) :disabled="selectedNodes.length === 0"
</ElButton> size="small"
<ElTag type="success"
v-if="lastUpdateTime" class="mr-[8px]"
size="small" @click="addSelectedToServerList"
type="info" >
> 添加选中 ({{ selectedNodes.length }})
最后更新: {{ lastUpdateTime }} </ElButton>
</ElTag> <ElTag
size="small"
type="info"
>
最后更新: {{ lastUpdateTime || "00:00:00" }}
</ElTag>
</div>
</div> </div>
</div> </div>
<div class="flex w-full flex-1 flex-wrap gap-[0] overflow-auto"> <div class="flex w-full flex-1 flex-wrap gap-[0] overflow-auto">
<ElTable <ElTable
:data="nodes" :data="computedNodes"
stripe stripe
height="100%" height="100%"
ref="tableRef" ref="tableRef"
:empty-text="loading ? '加载中...' : '暂无可用服务器'" :empty-text="loading ? '加载中...' : '暂无可用服务器'"
:default-sort="{ prop: 'last_response_time', order: 'ascending' }" :default-sort="{ prop: 'last_response_time', order: 'ascending' }"
@selection-change="handleSelectionChange" @select-all="handleSelectChange"
@select="handleSelectChange"
@row-click="handleRowClick" @row-click="handleRowClick"
> >
<ElTableColumn <ElTableColumn
@@ -87,7 +94,7 @@
:type="getResponseTimeType(row.last_response_time)" :type="getResponseTimeType(row.last_response_time)"
size="small" size="small"
> >
{{ row.last_response_time }}ms {{ Number(row.last_response_time / 1000).toFixed(2) }}ms
</ElTag> </ElTag>
</template> </template>
</ElTableColumn> </ElTableColumn>
@@ -136,7 +143,6 @@
<ElTableColumn <ElTableColumn
prop="description" prop="description"
label="描述" label="描述"
width="300"
sortable sortable
> >
<template #default="{ row }"> <template #default="{ row }">
@@ -151,10 +157,11 @@
<script setup lang="ts"> <script setup lang="ts">
import useMainStore from "@/stores/index"; import useMainStore from "@/stores/index";
import { invoke } from "@tauri-apps/api/core"; import { invoke } from "@tauri-apps/api/core";
import { reactive, onMounted, onBeforeUnmount, ref, useTemplateRef } from "vue"; import { reactive, onMounted, onBeforeUnmount, ref, useTemplateRef, computed, nextTick } from "vue";
import { ElMessage, type TableInstance } from "element-plus"; import { ElMessage, type TableInstance } from "element-plus";
import { dataSubscribe } from "~/composables/windows"; import { dataSubscribe } from "~/composables/windows";
import { uniq } from "lodash-es"; import { inputBounceRef } from "@/utils";
import { uniq } from "lodash-es";
const mainStore = useMainStore(); const mainStore = useMainStore();
// 节点数据 // 节点数据
@@ -162,6 +169,21 @@ import { uniq } from "lodash-es";
const loading = ref(false); const loading = ref(false);
const lastUpdateTime = ref(""); const lastUpdateTime = ref("");
const selectedNodes = ref<NodeItem[]>([]); const selectedNodes = ref<NodeItem[]>([]);
const searchName = ref<string>("");
const computedNodes = computed(() => {
const v = searchName.value.trim();
let result = nodes;
if (v) {
result = nodes.filter(node => node.name.includes(v) || node.address.includes(v));
}
nextTick(() => {
for (const node of selectedNodes.value) {
const nodeItem = nodes?.find(n => n.id === node.id);
tableRef.value?.toggleRowSelection(nodeItem, true);
}
});
return result;
});
const tableRef = useTemplateRef<TableInstance>("tableRef"); const tableRef = useTemplateRef<TableInstance>("tableRef");
// 定时器 // 定时器
@@ -176,8 +198,8 @@ import { uniq } from "lodash-es";
// 获取响应时间类型 // 获取响应时间类型
const getResponseTimeType = (responseTime: number) => { const getResponseTimeType = (responseTime: number) => {
if (responseTime < 1000) return "success"; if (responseTime < 60 * 1000) return "success";
if (responseTime < 5000) return "warning"; if (responseTime < 100 * 1000) return "warning";
return "danger"; return "danger";
}; };
@@ -191,14 +213,15 @@ import { uniq } from "lodash-es";
// 刷新节点数据 // 刷新节点数据
const refreshNodes = async () => { const refreshNodes = async () => {
loading.value = true; loading.value = true;
let nodesList = await invoke<string>("fetch_nodes_list", { page: 1, limit: 1000 });
try { try {
let nodesList = await invoke<string>("fetch_nodes_list", { page: 1, limit: 1000 });
if (nodesList === "_EasytierGameFetchNodesError_") { if (nodesList === "_EasytierGameFetchNodesError_") {
nodesList = ""; nodesList = "";
return;
} }
if (nodesList) { if (nodesList) {
const nodesListData: NodesResponse = JSON.parse(nodesList); const nodesListData: NodesResponse = JSON.parse(nodesList);
// console.log(nodesListData);
if (nodesListData.success && nodesListData.data.items) { if (nodesListData.success && nodesListData.data.items) {
// 过滤可用节点 // 过滤可用节点
const availableNodes = filterAvailableNodes(nodesListData.data.items); const availableNodes = filterAvailableNodes(nodesListData.data.items);
@@ -215,6 +238,7 @@ import { uniq } from "lodash-es";
} }
} }
} catch (err) { } catch (err) {
console.log(nodesList);
console.error("获取节点数据失败:", err); console.error("获取节点数据失败:", err);
ElMessage.error("获取节点数据失败"); ElMessage.error("获取节点数据失败");
} finally { } finally {
@@ -303,7 +327,7 @@ import { uniq } from "lodash-es";
const startRefreshTimer = () => { const startRefreshTimer = () => {
refreshTimer = setInterval(() => { refreshTimer = setInterval(() => {
refreshNodes(); refreshNodes();
}, 10000); // 10秒刷新一次 }, 60000); // 10秒刷新一次
}; };
// 停止定时器 // 停止定时器
@@ -315,12 +339,13 @@ import { uniq } from "lodash-es";
}; };
// 处理选择变化 // 处理选择变化
const handleSelectionChange = (selection: NodeItem[]) => { const handleSelectChange = (selection: NodeItem[]) => {
selectedNodes.value = selection; selectedNodes.value = selection;
}; };
const handleRowClick = (row: NodeItem) => { const handleRowClick = (row: NodeItem) => {
tableRef.value?.toggleRowSelection(row); tableRef.value?.toggleRowSelection(row);
selectedNodes.value = tableRef.value?.getSelectionRows() || [];
}; };
// 添加选中的服务器到主页面服务器列表 // 添加选中的服务器到主页面服务器列表
+641 -822
View File
File diff suppressed because it is too large Load Diff
+332 -419
View File
File diff suppressed because it is too large Load Diff
+8 -8
View File
@@ -1,6 +1,6 @@
[package] [package]
name = "easytier-game" name = "easytier-game"
version = "1.5.0" version = "1.5.2"
homepage = "https://github.com/EasyTier/EasyTier" homepage = "https://github.com/EasyTier/EasyTier"
repository = "https://github.com/EasyTier/EasytierGame" repository = "https://github.com/EasyTier/EasytierGame"
description = "A simple network initiator based on Easytier" description = "A simple network initiator based on Easytier"
@@ -18,7 +18,7 @@ name = "app_lib"
crate-type = ["staticlib", "cdylib", "rlib"] crate-type = ["staticlib", "cdylib", "rlib"]
[build-dependencies] [build-dependencies]
tauri-build = { version = "2.3.1", features = [] } tauri-build = { version = "2.5.1", features = [] }
# prost-build = "0.13.2" # prost-build = "0.13.2"
[target.x86_64-pc-windows-msvc.build-dependencies] [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_json = "1.0.137"
serde = { version = "1.0.217", features = ["derive"] } serde = { version = "1.0.217", features = ["derive"] }
log = "0.4.26" log = "0.4.26"
tauri = { version = "2.7.0", features = [ "protocol-asset", tauri = { version = "2.9.1", features = [ "protocol-asset",
"tray-icon", "tray-icon",
"image-png", "image-png",
"image-ico" "image-ico"
] } ] }
tauri-plugin-log = "2.6.0" tauri-plugin-log = "2.7.0"
tauri-plugin-shell = "2.3.0" tauri-plugin-shell = "2.3.1"
reqwest = { version = "0.12.12", features = ["json"] } reqwest = { version = "0.12.12", features = ["json"] }
zip = "2.2.3" zip = "2.2.3"
sysinfo = '0.33.1' 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" whoami = "1.5.2"
tauri-plugin-fs = "2.4.1" tauri-plugin-fs = "2.4.2"
tauri-plugin-clipboard-manager = "2.3.0" tauri-plugin-clipboard-manager = "2.3.0"
rand = "0.9.0" rand = "0.9.0"
tokio = { version = "1.45.1", features = ["process"] } tokio = { version = "1.45.1", features = ["process"] }
tauri-plugin-dialog = "2.3.1" tauri-plugin-dialog = "2.4.0"
# prost = "0.13" # prost = "0.13"
# prost-types = "0.13" # prost-types = "0.13"
hashbrown = "0.15.2" 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] [target."cfg(not(any(target_os = \"android\", target_os = \"ios\")))".dependencies]
tauri-plugin-cli = "2.4.0" 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" tauri-plugin-window-state = "2.4.0"
+1 -1
View File
@@ -2,7 +2,7 @@
"$schema": "../gen/schemas/desktop-schema.json", "$schema": "../gen/schemas/desktop-schema.json",
"identifier": "default", "identifier": "default",
"description": "enables the default permissions", "description": "enables the default permissions",
"windows": ["main", "log", "member", "cidr", "advance", "tool", "server", "gameList", "storage-listener"], "windows": ["main", "log", "member", "nodesList", "cidr", "advance", "tool", "server", "gameList", "storage-listener"],
"permissions": [ "permissions": [
"core:default", "core:default",
"core:window:allow-minimize", "core:window:allow-minimize",
+7 -1
View File
@@ -14,7 +14,13 @@
"networkName": "", //房间名 "networkName": "", //房间名
"networkPassword": "", //房间密码 "networkPassword": "", //房间密码
"hostname": "", //主机名 "hostname": "", //主机名
"ipv4": "", // 虚拟IP地址 "ipv4": "", // 虚拟IPv4地址
"ipv6": "", // 虚拟IPv6地址
"tcpWhitelistEnable": false, // 启用TCP白名单
"udpWhitelistEnable": false, // 启用UDP白名单
"tcpWhitelist": "", // TCP端口白名单,格式为 "80" 或者 范围 "8000-9000"
"udpWhitelist": "", // UDP端口白名单,格式为 "53" 或者 范围 "5000-6000"
"connectAfterStart": false, // 启动后自动连接
"disableIpv6": false, // 禁用ipv6 "disableIpv6": false, // 禁用ipv6
"disbleListenner": false, // 禁用监听 "disbleListenner": false, // 禁用监听
"disableEncryption": false, // 禁用加密 "disableEncryption": false, // 禁用加密
+64 -4
View File
@@ -299,10 +299,69 @@ async fn get_members_by_cli() -> String {
} }
} }
#[tauri::command(rename_all = "snake_case")]
async fn get_members_proxy() -> String {
let cli_path = get_tool_exe_path("\\easytier\\easytier-cli.exe");
match tokioCommand::new(&cli_path)
.arg("-o")
.arg("json")
.arg("proxy")
.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 "_EasytierGameCliFailedToGetProxy_".to_string();
}
}
Err(_e) => {
log::error!("get member list error");
return "".to_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")] #[tauri::command(rename_all = "snake_case")]
async fn get_route_by_cli() -> String { async fn get_route_by_cli() -> String {
let cli_path = get_tool_exe_path("\\easytier\\easytier-cli.exe"); let cli_path = get_tool_exe_path("\\easytier\\easytier-cli.exe");
match tokioCommand::new(&cli_path) match tokioCommand::new(&cli_path)
.arg("-o")
.arg("json")
.arg("route") .arg("route")
.creation_flags(0x08000000) .creation_flags(0x08000000)
.output() .output()
@@ -694,11 +753,11 @@ fn autostart_enabled() -> Result<bool, Box<dyn std::error::Error>> {
fn autostart_is_enabled() -> bool { fn autostart_is_enabled() -> bool {
match autostart_enabled() { match autostart_enabled() {
Ok(enabled) => { Ok(enabled) => {
println!("autostart enabled: {}", enabled); // println!("autostart enabled: {}", enabled);
return enabled; return enabled;
} }
Err(e) => { Err(_e) => {
log::error!("autostart enabled: false -> {}", e); // log::error!("autostart enabled: false -> {}", e);
return false; return false;
} }
} }
@@ -816,7 +875,6 @@ fn autostart(enabled: bool) -> std::result::Result<(), Box<dyn std::error::Error
exec_action.SetPath(&BSTR::from(exe_path))?; exec_action.SetPath(&BSTR::from(exe_path))?;
exec_action.SetArguments(&BSTR::from("--task-auto-start"))?; exec_action.SetArguments(&BSTR::from("--task-auto-start"))?;
// 使用当前用户运行
let principal = task_definition.Principal()?; let principal = task_definition.Principal()?;
principal.SetUserId(&BSTR::from(whoami::username().as_str()))?; principal.SetUserId(&BSTR::from(whoami::username().as_str()))?;
principal.SetLogonType(TASK_LOGON_INTERACTIVE_TOKEN)?; principal.SetLogonType(TASK_LOGON_INTERACTIVE_TOKEN)?;
@@ -929,6 +987,8 @@ pub fn run() {
fetch_game_releases, fetch_game_releases,
download_easytier_zip, download_easytier_zip,
get_members_by_cli, get_members_by_cli,
get_members_connections_cli,
get_members_proxy,
get_route_by_cli, get_route_by_cli,
fetch_nodes_list, fetch_nodes_list,
search_pid_by_pname, search_pid_by_pname,
+6 -4
View File
@@ -1,7 +1,7 @@
{ {
"$schema": "../node_modules/@tauri-apps/cli/config.schema.json", "$schema": "../node_modules/@tauri-apps/cli/config.schema.json",
"productName": "easytier-game", "productName": "easytier-game",
"version": "1.5.0", "version": "1.5.2",
"identifier": "com.tauri.easytier-game", "identifier": "com.tauri.easytier-game",
"build": { "build": {
@@ -12,7 +12,7 @@
"app": { "app": {
"windows": [ "windows": [
{ {
"title": "easytier-game 1.5.0", "title": "easytier-game 1.5.2",
"label": "main", "label": "main",
"minWidth": 340, "minWidth": 340,
"width": 340, "width": 340,
@@ -49,7 +49,7 @@
} }
}, },
"bundle": { "bundle": {
"active": true, "active": false,
"targets": "all", "targets": "all",
"resources": [ "resources": [
"easytier/config/", "easytier/config/",
@@ -72,7 +72,9 @@
"windows": { "windows": {
"webviewInstallMode": { "webviewInstallMode": {
"type": "embedBootstrapper" "type": "embedBootstrapper"
} },
"wix": null,
"nsis": null
}, },
"createUpdaterArtifacts": false, "createUpdaterArtifacts": false,
"icon": ["icons/icon.png", "icons/icon.rgba", "icons/icon.icns", "icons/icon.ico"] "icon": ["icons/icon.png", "icons/icon.rgba", "icons/icon.icns", "icons/icon.ico"]
+23 -2
View File
@@ -3,10 +3,11 @@ import { writeText } from "@tauri-apps/plugin-clipboard-manager";
import { open } from "@tauri-apps/plugin-shell"; import { open } from "@tauri-apps/plugin-shell";
import { ElMessage } from "element-plus"; import { ElMessage } from "element-plus";
import { flatMap, map } from "lodash-es"; import { flatMap, map } from "lodash-es";
import { customRef, ref } from "vue";
export const ENV = import.meta.env; export const ENV = import.meta.env;
export const mixedArray = (a: Array<string>, b: Array<string>, split:string="") => { export const mixedArray = (a: Array<string>, b: Array<string>, split: string = "") => {
return flatMap(a, protocol => map(b, port => `${protocol}${split}${port}`)); return flatMap(a, protocol => map(b, port => `${protocol}${split}${port}`));
}; };
@@ -21,6 +22,26 @@ export const bounce = (time = 3000) => {
}; };
}; };
export const inputBounceRef = (value: string, cb?: Function, delay = 650) => {
let timeout: number | null = null;
return customRef((track, trigger) => {
return {
get() {
track();
return value;
},
set(newValue) {
value = newValue;
trigger();
timeout && clearTimeout(timeout);
timeout = setTimeout(() => {
cb?.(newValue);
}, delay);
}
};
});
};
/** /**
* *
* @param {number} size byte number * @param {number} size byte number
@@ -73,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"];
export const supportProtocols = () => { export const supportProtocols = () => {
return _supportProtocols.slice(); return _supportProtocols.slice();