From dd941681ce6ce3951fa7de0d19b2234f74ad727e Mon Sep 17 00:00:00 2001 From: m1m1sha <18262227804@163.com> Date: Sat, 12 Oct 2024 19:57:36 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=F0=9F=8E=88=20perf:=20event=20log?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- EasyTier.code-workspace | 81 +++---------------- easytier-gui/.vscode/settings.json | 7 +- easytier-gui/locales/cn.yml | 20 +++++ easytier-gui/locales/en.yml | 20 +++++ .../src-tauri/capabilities/migrated.json | 3 +- easytier-gui/src/App.vue | 9 +++ easytier-gui/src/auto-imports.d.ts | 2 + easytier-gui/src/components/HumanEvent.vue | 32 ++++++++ easytier-gui/src/components/Status.vue | 8 +- easytier-gui/src/types/network.ts | 25 ++++++ easytier/build.rs | 7 +- 11 files changed, 129 insertions(+), 85 deletions(-) create mode 100644 easytier-gui/src/components/HumanEvent.vue diff --git a/EasyTier.code-workspace b/EasyTier.code-workspace index f84aed6..68d0252 100644 --- a/EasyTier.code-workspace +++ b/EasyTier.code-workspace @@ -4,84 +4,23 @@ "path": "." }, { + "name": "gui", "path": "easytier-gui" }, { + "name": "core", "path": "easytier" + }, + { + "name": "vpnservice", + "path": "tauri-plugin-vpnservice" } ], "settings": { - "eslint.useFlatConfig": true, + "i18n-ally.sourceLanguage": "cn", + "i18n-ally.keystyle": "nested", + "i18n-ally.sortKeys": true, + // Disable the default formatter "prettier.enable": false, - "editor.formatOnSave": false, - "editor.codeActionsOnSave": { - "source.fixAll.eslint": "explicit", - "source.organizeImports": "never" - }, - "eslint.rules.customizations": [ - { - "rule": "style/*", - "severity": "off" - }, - { - "rule": "style/eol-last", - "severity": "error" - }, - { - "rule": "format/*", - "severity": "off" - }, - { - "rule": "*-indent", - "severity": "off" - }, - { - "rule": "*-spacing", - "severity": "off" - }, - { - "rule": "*-spaces", - "severity": "off" - }, - { - "rule": "*-order", - "severity": "off" - }, - { - "rule": "*-dangle", - "severity": "off" - }, - { - "rule": "*-newline", - "severity": "off" - }, - { - "rule": "*quotes", - "severity": "off" - }, - { - "rule": "*semi", - "severity": "off" - } - ], - "eslint.validate": [ - "code-workspace", - "javascript", - "javascriptreact", - "typescript", - "typescriptreact", - "vue", - "html", - "markdown", - "json", - "jsonc", - "yaml", - "toml", - "gql", - "graphql" - ], - "i18n-ally.localesPaths": [ - "easytier-gui/locales" - ] } } \ No newline at end of file diff --git a/easytier-gui/.vscode/settings.json b/easytier-gui/.vscode/settings.json index 2a4315c..f335e35 100644 --- a/easytier-gui/.vscode/settings.json +++ b/easytier-gui/.vscode/settings.json @@ -12,12 +12,7 @@ "unplugin", "pnpm" ], - "i18n-ally.sourceLanguage": "en", - "i18n-ally.keystyle": "nested", "i18n-ally.localesPaths": "locales", - "i18n-ally.sortKeys": true, - // Disable the default formatter - "prettier.enable": false, "editor.formatOnSave": false, // Auto fix "editor.codeActionsOnSave": { @@ -83,4 +78,4 @@ "jsonc", "yaml" ] -} +} \ No newline at end of file diff --git a/easytier-gui/locales/cn.yml b/easytier-gui/locales/cn.yml index bb66a04..f6936d2 100644 --- a/easytier-gui/locales/cn.yml +++ b/easytier-gui/locales/cn.yml @@ -91,3 +91,23 @@ about: license: 许可证 description: 一个简单、安全、去中心化的内网穿透 VPN 组网方案,使用 Rust 语言和 Tokio 框架实现。 check_update: 检查更新 + +event: + Unknown: 未知 + TunDeviceReady: Tun设备就绪 + TunDeviceError: Tun设备错误 + PeerAdded: 对端添加 + PeerRemoved: 对端移除 + PeerConnAdded: 对端连接添加 + PeerConnRemoved: 对端连接移除 + ListenerAdded: 监听器添加 + ListenerAddFailed: 监听器添加失败 + ListenerAcceptFailed: 监听器接受连接失败 + ConnectionAccepted: 连接已接受 + ConnectionError: 连接错误 + Connecting: 正在连接 + ConnectError: 连接错误 + VpnPortalClientConnected: VPN门户客户端已连接 + VpnPortalClientDisconnected: VPN门户客户端已断开连接 + DhcpIpv4Changed: DHCP IPv4地址更改 + DhcpIpv4Conflicted: DHCP IPv4地址冲突 diff --git a/easytier-gui/locales/en.yml b/easytier-gui/locales/en.yml index a0fe185..7f5a495 100644 --- a/easytier-gui/locales/en.yml +++ b/easytier-gui/locales/en.yml @@ -90,3 +90,23 @@ about: license: License description: 'EasyTier is a simple, safe and decentralized VPN networking solution implemented with the Rust language and Tokio framework.' check_update: Check Update + +event: + Unknown: Unknown + TunDeviceReady: TunDeviceReady + TunDeviceError: TunDeviceError + PeerAdded: PeerAdded + PeerRemoved: PeerRemoved + PeerConnAdded: PeerConnAdded + PeerConnRemoved: PeerConnRemoved + ListenerAdded: ListenerAdded + ListenerAddFailed: ListenerAddFailed + ListenerAcceptFailed: ListenerAcceptFailed + ConnectionAccepted: ConnectionAccepted + ConnectionError: ConnectionError + Connecting: Connecting + ConnectError: ConnectError + VpnPortalClientConnected: VpnPortalClientConnected + VpnPortalClientDisconnected: VpnPortalClientDisconnected + DhcpIpv4Changed: DhcpIpv4Changed + DhcpIpv4Conflicted: DhcpIpv4Conflicted diff --git a/easytier-gui/src-tauri/capabilities/migrated.json b/easytier-gui/src-tauri/capabilities/migrated.json index 7c39961..86c761a 100644 --- a/easytier-gui/src-tauri/capabilities/migrated.json +++ b/easytier-gui/src-tauri/capabilities/migrated.json @@ -1,4 +1,5 @@ { + "$schema": "../gen/schemas/desktop-schema.json", "identifier": "migrated", "description": "permissions that were migrated from v1", "local": true, @@ -13,6 +14,7 @@ "core:window:allow-show", "core:window:allow-hide", "core:window:allow-set-focus", + "core:window:allow-set-title", "core:app:default", "core:resources:default", "core:menu:default", @@ -24,7 +26,6 @@ "shell:default", "process:default", "clipboard-manager:default", - "core:tray:default", "core:tray:allow-new", "core:tray:allow-set-menu", "core:tray:allow-set-title", diff --git a/easytier-gui/src/App.vue b/easytier-gui/src/App.vue index 7c2aa3f..818fba8 100644 --- a/easytier-gui/src/App.vue +++ b/easytier-gui/src/App.vue @@ -1,3 +1,12 @@ + + diff --git a/easytier-gui/src/auto-imports.d.ts b/easytier-gui/src/auto-imports.d.ts index 34fe659..0f1d863 100644 --- a/easytier-gui/src/auto-imports.d.ts +++ b/easytier-gui/src/auto-imports.d.ts @@ -21,6 +21,7 @@ declare global { const definePage: typeof import('unplugin-vue-router/runtime')['definePage'] const defineStore: typeof import('pinia')['defineStore'] const effectScope: typeof import('vue')['effectScope'] + const event2human: typeof import('./composables/utils')['event2human'] const generateMenuItem: typeof import('./composables/tray')['generateMenuItem'] const getActivePinia: typeof import('pinia')['getActivePinia'] const getCurrentInstance: typeof import('vue')['getCurrentInstance'] @@ -83,6 +84,7 @@ declare global { const shallowReadonly: typeof import('vue')['shallowReadonly'] const shallowRef: typeof import('vue')['shallowRef'] const storeToRefs: typeof import('pinia')['storeToRefs'] + const timeAgoCn: typeof import('./composables/utils')['timeAgoCn'] const toRaw: typeof import('vue')['toRaw'] const toRef: typeof import('vue')['toRef'] const toRefs: typeof import('vue')['toRefs'] diff --git a/easytier-gui/src/components/HumanEvent.vue b/easytier-gui/src/components/HumanEvent.vue new file mode 100644 index 0000000..83e69d0 --- /dev/null +++ b/easytier-gui/src/components/HumanEvent.vue @@ -0,0 +1,32 @@ + + + + + + + {{ `${eventValue[0]} -> ${eventValue[1]}` }} + + {{ eventValue }} + + {{ eventValue }} + + diff --git a/easytier-gui/src/components/Status.vue b/easytier-gui/src/components/Status.vue index 099563b..eb16ea2 100644 --- a/easytier-gui/src/components/Status.vue +++ b/easytier-gui/src/components/Status.vue @@ -325,7 +325,7 @@ function showEventLogs() { {{ useTimeAgo(Date.parse(slotProps.item[0])) }} - {{ slotProps.item[1] }} + @@ -433,3 +433,9 @@ function showEventLogs() { + + diff --git a/easytier-gui/src/types/network.ts b/easytier-gui/src/types/network.ts index a5a22eb..47adfbe 100644 --- a/easytier-gui/src/types/network.ts +++ b/easytier-gui/src/types/network.ts @@ -183,3 +183,28 @@ export interface PeerConnStats { tx_packets: number latency_us: number } + +export enum EventType { + TunDeviceReady = 'TunDeviceReady', // string + TunDeviceError = 'TunDeviceError', // string + + PeerAdded = 'PeerAdded', // number + PeerRemoved = 'PeerRemoved', // number + PeerConnAdded = 'PeerConnAdded', // PeerConnInfo + PeerConnRemoved = 'PeerConnRemoved', // PeerConnInfo + + ListenerAdded = 'ListenerAdded', // any + ListenerAddFailed = 'ListenerAddFailed', // any, string + ListenerAcceptFailed = 'ListenerAcceptFailed', // any, string + ConnectionAccepted = 'ConnectionAccepted', // string, string + ConnectionError = 'ConnectionError', // string, string, string + + Connecting = 'Connecting', // any + ConnectError = 'ConnectError', // string, string, string + + VpnPortalClientConnected = 'VpnPortalClientConnected', // string, string + VpnPortalClientDisconnected = 'VpnPortalClientDisconnected', // string, string, string + + DhcpIpv4Changed = 'DhcpIpv4Changed', // ipv4 | null, ipv4 | null + DhcpIpv4Conflicted = 'DhcpIpv4Conflicted', // ipv4 | null +} diff --git a/easytier/build.rs b/easytier/build.rs index 9caa1b3..0ca1840 100644 --- a/easytier/build.rs +++ b/easytier/build.rs @@ -1,10 +1,5 @@ #[cfg(target_os = "windows")] -use std::{ - env, - fs::File, - io::{copy, Cursor}, - path::PathBuf, -}; +use std::{env, io::Cursor, path::PathBuf}; #[cfg(target_os = "windows")] struct WindowsBuild {} From 70a41275c194420490378ac32c3f3e1793e49822 Mon Sep 17 00:00:00 2001 From: m1m1sha <18262227804@163.com> Date: Sat, 12 Oct 2024 20:17:45 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E2=9C=A8=20feat:=20display?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Display server tag and whether server supports relay --- easytier-gui/locales/cn.yml | 2 ++ easytier-gui/locales/en.yml | 2 ++ easytier-gui/src/components/Status.vue | 34 ++++++++++++++++++-------- easytier-gui/src/types/network.ts | 1 + 4 files changed, 29 insertions(+), 10 deletions(-) diff --git a/easytier-gui/locales/cn.yml b/easytier-gui/locales/cn.yml index f6936d2..da44a6c 100644 --- a/easytier-gui/locales/cn.yml +++ b/easytier-gui/locales/cn.yml @@ -72,6 +72,8 @@ loss_rate: 丢包率 status: version: 内核版本 local: 本机 + server: 服务器 + relay: 中继 run_network: 运行网络 stop_network: 停止网络 diff --git a/easytier-gui/locales/en.yml b/easytier-gui/locales/en.yml index 7f5a495..23bfdf7 100644 --- a/easytier-gui/locales/en.yml +++ b/easytier-gui/locales/en.yml @@ -71,6 +71,8 @@ loss_rate: Loss Rate status: version: Version local: Local + server: Server + relay: Relay run_network: Run Network stop_network: Stop Network diff --git a/easytier-gui/src/components/Status.vue b/easytier-gui/src/components/Status.vue index eb16ea2..27799e0 100644 --- a/easytier-gui/src/components/Status.vue +++ b/easytier-gui/src/components/Status.vue @@ -410,19 +410,33 @@ function showEventLogs() { {{ t('peer_info') }} - - - + + + - {{ slotProps.data.route.hostname }} + + {{ + slotProps.data.route.hostname }} + + + + {{ t('status.server') }} + + + {{ t('status.relay') }} + + - - - - - - + + + + + + {{ version(slotProps.data) }} diff --git a/easytier-gui/src/types/network.ts b/easytier-gui/src/types/network.ts index 47adfbe..8422328 100644 --- a/easytier-gui/src/types/network.ts +++ b/easytier-gui/src/types/network.ts @@ -158,6 +158,7 @@ export interface PeerInfo { export interface PeerConnInfo { conn_id: string my_peer_id: number + is_client: boolean peer_id: number features: string[] tunnel?: TunnelInfo
{{ eventValue }}