Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ba914125f2 | ||
|
|
2bbd370e02 | ||
|
|
a8d803168f | ||
|
|
57e6ba8e1e | ||
|
|
3694d157d1 |
@@ -1,7 +1,8 @@
|
||||
name: Build Windows Portable Package
|
||||
|
||||
on:
|
||||
push:
|
||||
release:
|
||||
types: [published]
|
||||
workflow_dispatch:
|
||||
|
||||
jobs:
|
||||
@@ -25,6 +26,6 @@ jobs:
|
||||
with:
|
||||
name: super-n2n-${{ github.sha }}
|
||||
path: |
|
||||
release/super-n2n-portable.zip
|
||||
release/super-n2n-portable.zip.sha256
|
||||
release/super-n2n-portable-*.zip
|
||||
release/super-n2n-portable-*.zip.sha256
|
||||
if-no-files-found: error
|
||||
|
||||
@@ -45,15 +45,42 @@ Install dependencies, then start the Tauri development window:
|
||||
npm install
|
||||
npm run tauri dev
|
||||
|
||||
The portable build creates `release/super-n2n-portable.zip`. It contains
|
||||
`n2n/edge.exe` and `n2n/supernode.exe`; on Windows Super N2N starts them with
|
||||
the relative paths `./n2n/edge.exe` and `./n2n/supernode.exe`.
|
||||
The portable build creates a versioned archive such as
|
||||
`release/super-n2n-portable-1.2.zip`. It contains
|
||||
`n2n/edge.exe`, `n2n/supernode.exe`, and the official TAP-Windows installer in
|
||||
`drivers/tap-windows-9.24.7-I601-Win10.exe`; on Windows Super N2N starts the n2n
|
||||
programs with the relative paths `./n2n/edge.exe` and `./n2n/supernode.exe`.
|
||||
|
||||
### Windows TAP requirement
|
||||
|
||||
N2N uses an installed TAP-Windows virtual adapter; it does not create a new
|
||||
adapter itself. Super N2N checks for an adapter on first launch, offers the
|
||||
bundled installer when one is missing, and automatically selects an available
|
||||
adapter before starting Edge. The optional TAP device field is only needed to
|
||||
select a specific existing adapter. Connection settings, including advanced
|
||||
settings, are stored beside `super-n2n.exe` in `super-n2n.config.json` and are
|
||||
restored on the next application launch.
|
||||
|
||||
### Supernode and special server
|
||||
|
||||
The `创建服务器` home starts Supernode on the configured UDP port and can
|
||||
optionally restrict communities and the Supernode address-assignment pool.
|
||||
The optional special server listens on its own TCP port. A special client only
|
||||
needs that server address and port; it receives the community, static TAP IP,
|
||||
gateway, DNS, and Supernode port automatically. The client username is sent as
|
||||
the n2n edge description (`-I`) and defaults to the Windows computer name.
|
||||
|
||||
The special address pool must be a subnet inside the normal Supernode pool, and
|
||||
its community must be present in the allowed-community list when that list is
|
||||
restricted. Supernode's compact client window polls the management API and
|
||||
marks addresses issued by the special server.
|
||||
|
||||
## Gitea Actions
|
||||
|
||||
`.gitea/workflows/build-windows.yml` runs on every push and uploads the portable
|
||||
zip plus its checksum as workflow artifacts. Configure a dedicated Gitea runner
|
||||
with the `windows-host` label and the Windows build prerequisites above.
|
||||
`.gitea/workflows/build-windows.yml` runs when a Release is published and uploads
|
||||
the portable zip plus its checksum as workflow artifacts. Configure a dedicated
|
||||
Gitea runner with the `windows-host` label and the Windows build prerequisites
|
||||
above. It can also be run manually from the Actions page.
|
||||
|
||||
The native command layer can start and stop edge/supernode processes, query the n2n UDP management API, run ping and TCPing checks, and inspect the local firewall state. Browser preview does not fabricate native process, management, or network-check results.
|
||||
|
||||
|
||||
Generated
+2
-2
@@ -1,12 +1,12 @@
|
||||
{
|
||||
"name": "super-n2n",
|
||||
"version": "0.1.0",
|
||||
"version": "1.2.0",
|
||||
"lockfileVersion": 3,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "super-n2n",
|
||||
"version": "0.1.0",
|
||||
"version": "1.2.0",
|
||||
"dependencies": {
|
||||
"@tauri-apps/api": "^2.8.0",
|
||||
"lucide-react": "^0.468.0",
|
||||
|
||||
+1
-1
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "super-n2n",
|
||||
"private": true,
|
||||
"version": "0.1.0",
|
||||
"version": "1.2.0",
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
"dev": "vite --host 127.0.0.1 --port 1420",
|
||||
|
||||
@@ -8,4 +8,17 @@ them as .\n2n\edge.exe and .\n2n\supernode.exe, so no PATH configuration is requ
|
||||
Windows WebView2 is required. It is included by default on current Windows 10 and
|
||||
Windows 11 installations.
|
||||
|
||||
N2N requires a TAP-Windows virtual network adapter installed on the computer.
|
||||
Super N2N automatically selects an available adapter when connecting. It does
|
||||
not create a TAP adapter itself. On the first launch it checks for a TAP-Windows
|
||||
adapter and shows an install prompt when one is missing. The official installer
|
||||
is included at drivers\tap-windows-9.24.7-I601-Win10.exe. Click the install
|
||||
button in the app (or run the installer as Administrator), complete the wizard,
|
||||
and restart Super N2N.
|
||||
|
||||
The app stores connection settings beside super-n2n.exe as
|
||||
super-n2n.config.json. Its absence is used to identify the first launch. Do not
|
||||
add this file to a release archive if you want the first-launch check to run.
|
||||
|
||||
The bundled n2n programs are distributed under n2n\LICENSE-n2n.txt.
|
||||
The bundled TAP-Windows installer and its license information are in drivers\.
|
||||
|
||||
+3
-1
@@ -12,7 +12,9 @@ $n2nRoot = Join-Path $projectRoot 'third_party\n2n'
|
||||
$cargoManifest = Join-Path $projectRoot 'src-tauri\Cargo.toml'
|
||||
$packageScript = Join-Path $PSScriptRoot 'package-portable.ps1'
|
||||
$n2nBuildScript = Join-Path $PSScriptRoot 'build-n2n.sh'
|
||||
$archivePath = Join-Path $projectRoot 'release\super-n2n-portable.zip'
|
||||
$packageJson = Get-Content (Join-Path $projectRoot 'package.json') -Raw | ConvertFrom-Json
|
||||
$artifactVersion = (($packageJson.version -split '\.')[0..1] -join '.')
|
||||
$archivePath = Join-Path $projectRoot "release\super-n2n-portable-$artifactVersion.zip"
|
||||
$checksumPath = $archivePath + '.sha256'
|
||||
|
||||
function Get-RequiredCommand {
|
||||
|
||||
@@ -9,7 +9,9 @@ $n2nRoot = Join-Path $projectRoot 'third_party\n2n'
|
||||
$releaseRoot = Join-Path $projectRoot 'release'
|
||||
$portableRoot = Join-Path $projectRoot 'release\super-n2n-portable'
|
||||
$stagingRoot = Join-Path $releaseRoot 'super-n2n-portable-staging'
|
||||
$archivePath = Join-Path $releaseRoot 'super-n2n-portable.zip'
|
||||
$packageJson = Get-Content (Join-Path $projectRoot 'package.json') -Raw | ConvertFrom-Json
|
||||
$artifactVersion = (($packageJson.version -split '\.')[0..1] -join '.')
|
||||
$archivePath = Join-Path $releaseRoot "super-n2n-portable-$artifactVersion.zip"
|
||||
$releaseRootFull = [System.IO.Path]::GetFullPath($releaseRoot)
|
||||
$portableRootFull = [System.IO.Path]::GetFullPath($portableRoot)
|
||||
$stagingRootFull = [System.IO.Path]::GetFullPath($stagingRoot)
|
||||
@@ -21,7 +23,7 @@ if ((Split-Path -Parent $portableRootFull) -ne $releaseRootFull -or (Split-Path
|
||||
if ((Split-Path -Parent $stagingRootFull) -ne $releaseRootFull -or (Split-Path -Leaf $stagingRootFull) -ne 'super-n2n-portable-staging') {
|
||||
throw "Refusing to replace an unexpected staging directory: $stagingRootFull"
|
||||
}
|
||||
if ((Split-Path -Parent $archivePathFull) -ne $releaseRootFull -or (Split-Path -Leaf $archivePathFull) -ne 'super-n2n-portable.zip') {
|
||||
if ((Split-Path -Parent $archivePathFull) -ne $releaseRootFull -or (Split-Path -Leaf $archivePathFull) -ne "super-n2n-portable-$artifactVersion.zip") {
|
||||
throw "Refusing to replace an unexpected portable archive: $archivePathFull"
|
||||
}
|
||||
|
||||
@@ -46,6 +48,11 @@ try {
|
||||
'n2n\edge.exe' = Join-Path $n2nRoot 'edge.exe'
|
||||
'n2n\supernode.exe' = Join-Path $n2nRoot 'supernode.exe'
|
||||
'n2n\LICENSE-n2n.txt' = Join-Path $n2nRoot 'LICENSE'
|
||||
'drivers\tap-windows-9.24.7-I601-Win10.exe' = Join-Path $projectRoot 'third_party\tap-windows\tap-windows-9.24.7-I601-Win10.exe'
|
||||
'drivers\TAP-WINDOWS-README.txt' = Join-Path $projectRoot 'third_party\tap-windows\README.txt'
|
||||
'drivers\TAP-WINDOWS-SHA256SUMS.txt' = Join-Path $projectRoot 'third_party\tap-windows\SHA256SUMS.txt'
|
||||
'drivers\TAP-WINDOWS-LICENSE.txt' = Join-Path $projectRoot 'third_party\tap-windows\LICENSE.txt'
|
||||
'drivers\TAP-WINDOWS-GPLv2.txt' = Join-Path $projectRoot 'third_party\tap-windows\COPYRIGHT.GPL.txt'
|
||||
'README.txt' = Join-Path $projectRoot 'scripts\PORTABLE-README.txt'
|
||||
}
|
||||
|
||||
|
||||
Generated
+1
-1
@@ -2919,7 +2919,7 @@ checksum = "7da8b5736845d9f2fcb837ea5d9e2628564b3b043a70948a3f0b778838c5fb4f"
|
||||
|
||||
[[package]]
|
||||
name = "super-n2n"
|
||||
version = "0.1.0"
|
||||
version = "1.2.0"
|
||||
dependencies = [
|
||||
"serde",
|
||||
"serde_json",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "super-n2n"
|
||||
version = "0.1.0"
|
||||
version = "1.2.0"
|
||||
description = "N2N desktop control plane"
|
||||
authors = ["Super N2N"]
|
||||
edition = "2021"
|
||||
@@ -9,11 +9,17 @@ edition = "2021"
|
||||
name = "super_n2n_lib"
|
||||
crate-type = ["staticlib", "cdylib", "rlib"]
|
||||
|
||||
[[bin]]
|
||||
name = "super-n2n"
|
||||
path = "src/main.rs"
|
||||
test = false
|
||||
bench = false
|
||||
|
||||
[build-dependencies]
|
||||
tauri-build = { version = "2", features = [] }
|
||||
|
||||
[dependencies]
|
||||
tauri = { version = "2", features = [] }
|
||||
tauri = { version = "2", features = ["tray-icon"] }
|
||||
serde = { version = "1", features = ["derive"] }
|
||||
serde_json = "1"
|
||||
|
||||
|
||||
+3
-1
@@ -1,3 +1,5 @@
|
||||
fn main() {
|
||||
tauri_build::build()
|
||||
let windows = tauri_build::WindowsAttributes::new().app_manifest(include_str!("manifest.xml"));
|
||||
let attributes = tauri_build::Attributes::new().windows_attributes(windows);
|
||||
tauri_build::try_build(attributes).expect("failed to run build script");
|
||||
}
|
||||
|
||||
@@ -2,6 +2,15 @@
|
||||
"$schema": "../gen/schemas/desktop-schema.json",
|
||||
"identifier": "default",
|
||||
"description": "Default permissions for the Super N2N desktop window",
|
||||
"windows": ["main"],
|
||||
"permissions": ["core:default"]
|
||||
"windows": ["main", "supernode-users"],
|
||||
"permissions": [
|
||||
"core:default",
|
||||
"core:window:allow-create",
|
||||
"core:window:allow-show",
|
||||
"core:window:allow-hide",
|
||||
"core:window:allow-set-focus",
|
||||
"core:window:allow-close",
|
||||
"core:window:allow-destroy",
|
||||
"core:webview:allow-create-webview-window"
|
||||
]
|
||||
}
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
||||
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
|
||||
<dependency>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity
|
||||
type="win32"
|
||||
name="Microsoft.Windows.Common-Controls"
|
||||
version="6.0.0.0"
|
||||
processorArchitecture="*"
|
||||
publicKeyToken="6595b64144ccf1df"
|
||||
language="*"
|
||||
/>
|
||||
</dependentAssembly>
|
||||
</dependency>
|
||||
<trustInfo xmlns="urn:schemas-microsoft-com:asm.v3">
|
||||
<security>
|
||||
<requestedPrivileges>
|
||||
<requestedExecutionLevel level="requireAdministrator" uiAccess="false" />
|
||||
</requestedPrivileges>
|
||||
</security>
|
||||
</trustInfo>
|
||||
</assembly>
|
||||
+985
-28
File diff suppressed because it is too large
Load Diff
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"$schema": "https://schema.tauri.app/config/2",
|
||||
"productName": "Super N2N",
|
||||
"version": "0.1.0",
|
||||
"version": "1.2.0",
|
||||
"identifier": "com.supern2n.control",
|
||||
"build": {
|
||||
"beforeDevCommand": "npm run dev",
|
||||
|
||||
@@ -14,10 +14,18 @@ export async function nativeCall(command, args, fallback) {
|
||||
export const startService = (request) => nativeCall('start_service', { request }, () => {
|
||||
throw new Error('浏览器预览无法启动原生服务')
|
||||
})
|
||||
export const startSupernode = (request) => nativeCall('start_supernode', { request }, () => {
|
||||
throw new Error('浏览器预览无法启动 Supernode')
|
||||
})
|
||||
|
||||
export const stopService = (service) => nativeCall('stop_service', { service }, () => {
|
||||
throw new Error('浏览器预览没有受管进程')
|
||||
})
|
||||
export const stopSpecialService = () => nativeCall('stop_special_service', {}, () => null)
|
||||
export const fetchSpecialConfig = (request) => nativeCall('fetch_special_config', { request }, () => {
|
||||
throw new Error('浏览器预览无法连接特殊服务端')
|
||||
})
|
||||
export const fetchSpecialUsers = (request) => nativeCall('fetch_special_users', { request }, () => [])
|
||||
|
||||
export const serviceStatus = (service) => nativeCall('service_status', { service }, () => ({
|
||||
service,
|
||||
@@ -36,4 +44,22 @@ export const checkFirewall = (fallback) => nativeCall('firewall_status', {}, fal
|
||||
export const tapTraffic = (tapDevice) => nativeCall('tap_traffic', { request: { tapDevice } }, () => {
|
||||
throw new Error('浏览器预览无法读取 TAP 流量')
|
||||
})
|
||||
export const resolveTapAdapter = (tapDevice) => nativeCall('resolve_tap_adapter', { request: { tapDevice } }, () => {
|
||||
throw new Error('浏览器预览无法识别 TAP 网卡')
|
||||
})
|
||||
export const configureTapAdapter = (request) => nativeCall('configure_tap_adapter', { request }, () => {
|
||||
throw new Error('浏览器预览无法配置 TAP 网卡')
|
||||
})
|
||||
export const startupStatus = () => nativeCall('startup_status', {}, () => ({
|
||||
configExists: false,
|
||||
firstLaunch: false,
|
||||
configPath: '',
|
||||
tapDriverPresent: true,
|
||||
tapInstallerPath: null,
|
||||
}))
|
||||
export const readConfig = () => nativeCall('read_config', {}, () => null)
|
||||
export const writeConfig = (contents) => nativeCall('write_config', { contents }, () => null)
|
||||
export const openTapInstaller = () => nativeCall('open_tap_installer', {}, () => {
|
||||
throw new Error('浏览器预览无法打开 TAP-Windows 安装程序')
|
||||
})
|
||||
export const exportLog = (contents) => nativeCall('export_log', { contents }, () => null)
|
||||
|
||||
+482
-34
@@ -1,10 +1,17 @@
|
||||
import { useEffect, useRef, useState } from 'react'
|
||||
import { createRoot } from 'react-dom/client'
|
||||
import { getCurrentWindow } from '@tauri-apps/api/window'
|
||||
import { WebviewWindow } from '@tauri-apps/api/webviewWindow'
|
||||
import { listen } from '@tauri-apps/api/event'
|
||||
import {
|
||||
ArrowDown, ArrowUp, CheckCircle2, ChevronDown, CircleAlert, Gauge, Globe2, Network, Play,
|
||||
Download, Router, ScrollText, Server, Settings2, Square, Wifi,
|
||||
Download, Router, ScrollText, Server, Settings2, Square, Users, Wifi,
|
||||
} from 'lucide-react'
|
||||
import { exportLog, isTauri, serviceStatus, startService, stopService, tapTraffic } from './lib/tauri'
|
||||
import {
|
||||
configureTapAdapter, exportLog, fetchSpecialConfig, fetchSpecialUsers, isTauri, openTapInstaller,
|
||||
queryManagement, readConfig, resolveTapAdapter, runPing, serviceStatus, startService, startSupernode, startupStatus, stopService,
|
||||
stopSpecialService, tapTraffic, writeConfig,
|
||||
} from './lib/tauri'
|
||||
import './styles.css'
|
||||
|
||||
const initialEdge = {
|
||||
@@ -15,39 +22,254 @@ const initialEdge = {
|
||||
ip: '',
|
||||
encryptionKey: '',
|
||||
managementPort: '5644',
|
||||
tapDevice: 'n2n0',
|
||||
tapDevice: '',
|
||||
specialClient: false,
|
||||
specialServerPort: '7788',
|
||||
username: '',
|
||||
}
|
||||
|
||||
const initialSupernode = {
|
||||
port: '7777',
|
||||
dhcp: true,
|
||||
dhcpPool: '10.10.10.0/24',
|
||||
allowedCommunities: '',
|
||||
specialEnabled: false,
|
||||
specialPort: '7788',
|
||||
specialCommunity: '',
|
||||
specialPool: '10.10.10.128/25',
|
||||
specialGateway: '10.10.10.1',
|
||||
specialDns: '10.10.10.1',
|
||||
}
|
||||
|
||||
const edgeConfigStorageKey = 'super-n2n.edge-config.v1'
|
||||
const isWindowsRuntime = typeof navigator !== 'undefined' && /Windows/i.test(navigator.userAgent)
|
||||
|
||||
function parseEdgeConfig(value) {
|
||||
const fallback = { ...initialEdge }
|
||||
const saved = value && typeof value === 'object' && !Array.isArray(value) && value.edge
|
||||
&& typeof value.edge === 'object' ? value.edge : value
|
||||
if (!saved || typeof saved !== 'object' || Array.isArray(saved)) return fallback
|
||||
for (const [field, defaultValue] of Object.entries(initialEdge)) {
|
||||
if (typeof saved[field] === typeof defaultValue) fallback[field] = saved[field]
|
||||
}
|
||||
return fallback
|
||||
}
|
||||
|
||||
function parseSupernodeConfig(value) {
|
||||
const fallback = { ...initialSupernode }
|
||||
const saved = value && typeof value === 'object' && value.supernode && typeof value.supernode === 'object'
|
||||
? value.supernode : null
|
||||
if (!saved) return fallback
|
||||
for (const [field, defaultValue] of Object.entries(initialSupernode)) {
|
||||
if (typeof saved[field] === typeof defaultValue) fallback[field] = saved[field]
|
||||
}
|
||||
return fallback
|
||||
}
|
||||
|
||||
function loadBrowserEdgeConfig() {
|
||||
if (typeof window === 'undefined') return { ...initialEdge }
|
||||
try {
|
||||
return parseEdgeConfig(JSON.parse(window.localStorage.getItem(edgeConfigStorageKey) || 'null'))
|
||||
} catch {
|
||||
// A damaged or unavailable browser store must not block the connection form.
|
||||
return { ...initialEdge }
|
||||
}
|
||||
}
|
||||
|
||||
function loadBrowserSupernodeConfig() {
|
||||
if (typeof window === 'undefined') return { ...initialSupernode }
|
||||
try {
|
||||
return parseSupernodeConfig(JSON.parse(window.localStorage.getItem(edgeConfigStorageKey) || 'null'))
|
||||
} catch {
|
||||
return { ...initialSupernode }
|
||||
}
|
||||
}
|
||||
|
||||
function saveBrowserAppConfig(edge, supernode) {
|
||||
try {
|
||||
window.localStorage.setItem(edgeConfigStorageKey, JSON.stringify({ version: 2, edge, supernode }))
|
||||
} catch {
|
||||
// The form stays usable when the platform denies local storage access.
|
||||
}
|
||||
}
|
||||
|
||||
function serializeEdgeConfig(config) {
|
||||
return JSON.stringify({ version: 1, edge: config }, null, 2)
|
||||
}
|
||||
|
||||
function serializeAppConfig(edge, supernode) {
|
||||
return JSON.stringify({ version: 2, edge, supernode }, null, 2)
|
||||
}
|
||||
|
||||
function App() {
|
||||
const [home, setHome] = useState('edge')
|
||||
const [edge, setEdge] = useState(initialEdge)
|
||||
const [edge, setEdge] = useState(loadBrowserEdgeConfig)
|
||||
const [supernode, setSupernode] = useState(loadBrowserSupernodeConfig)
|
||||
const [edgeRunning, setEdgeRunning] = useState(false)
|
||||
const [supernodeRunning, setSupernodeRunning] = useState(false)
|
||||
const [activeTapDevice, setActiveTapDevice] = useState('')
|
||||
const [advancedOpen, setAdvancedOpen] = useState(false)
|
||||
const [logOpen, setLogOpen] = useState(false)
|
||||
const [logs, setLogs] = useState([])
|
||||
const [traffic, setTraffic] = useState(null)
|
||||
const [specialUsers, setSpecialUsers] = useState([])
|
||||
const [specialLatencies, setSpecialLatencies] = useState({})
|
||||
const [message, setMessage] = useState(null)
|
||||
const [startupInfo, setStartupInfo] = useState(null)
|
||||
const [configReady, setConfigReady] = useState(!isTauri)
|
||||
const lastTapSample = useRef(null)
|
||||
const configWriteFailed = useRef(false)
|
||||
|
||||
const appendLog = (text, level = 'info') => {
|
||||
const time = new Date().toLocaleTimeString('zh-CN', { hour12: false })
|
||||
setLogs((current) => [{ time, level, text }, ...current].slice(0, 100))
|
||||
}
|
||||
|
||||
useEffect(() => {
|
||||
if (!configReady) return
|
||||
if (!isTauri) {
|
||||
saveBrowserAppConfig(edge, supernode)
|
||||
return
|
||||
}
|
||||
writeConfig(serializeAppConfig(edge, supernode)).catch((error) => {
|
||||
if (configWriteFailed.current) return
|
||||
configWriteFailed.current = true
|
||||
appendLog('配置保存失败:' + error.message, 'warning')
|
||||
})
|
||||
}, [edge, supernode, configReady])
|
||||
|
||||
useEffect(() => {
|
||||
let active = true
|
||||
serviceStatus('edge')
|
||||
.then((status) => {
|
||||
const loadStartup = async () => {
|
||||
try {
|
||||
const status = await startupStatus()
|
||||
if (!active) return
|
||||
setEdgeRunning(Boolean(status.running))
|
||||
appendLog(status.running ? '检测到 Edge 已连接' : 'Edge 已就绪,等待连接', status.running ? 'success' : 'info')
|
||||
setStartupInfo(status)
|
||||
if (isTauri && status.configExists) {
|
||||
const contents = await readConfig()
|
||||
if (active && contents) {
|
||||
const parsed = JSON.parse(contents)
|
||||
setEdge(parseEdgeConfig(parsed))
|
||||
setSupernode(parseSupernodeConfig(parsed))
|
||||
}
|
||||
}
|
||||
if (active) {
|
||||
setConfigReady(true)
|
||||
if (status.firstLaunch) {
|
||||
appendLog(
|
||||
status.tapDriverPresent ? '首次启动:已检测到 TAP-Windows 网卡' : '首次启动:未检测到 TAP-Windows 网卡',
|
||||
status.tapDriverPresent ? 'success' : 'warning',
|
||||
)
|
||||
}
|
||||
}
|
||||
} catch (error) {
|
||||
if (!active) return
|
||||
setConfigReady(true)
|
||||
appendLog('读取启动配置失败:' + error.message, 'warning')
|
||||
}
|
||||
}
|
||||
loadStartup()
|
||||
return () => { active = false }
|
||||
}, [])
|
||||
|
||||
useEffect(() => {
|
||||
if (!isTauri) return undefined
|
||||
let active = true
|
||||
let unlistenConnect
|
||||
let unlistenDisconnect
|
||||
let unlistenStopped
|
||||
const bindTrayEvents = async () => {
|
||||
unlistenConnect = await listen('tray-connect', async () => {
|
||||
if (!active) return
|
||||
await getCurrentWindow().show()
|
||||
await getCurrentWindow().setFocus()
|
||||
if (!edgeRunning) await toggleEdge()
|
||||
})
|
||||
unlistenDisconnect = await listen('tray-disconnect', async () => {
|
||||
if (!active || !edgeRunning) return
|
||||
await toggleEdge()
|
||||
})
|
||||
unlistenStopped = await listen('tray-service-stopped', () => {
|
||||
if (!active) return
|
||||
setEdgeRunning(false)
|
||||
setSupernodeRunning(false)
|
||||
setActiveTapDevice('')
|
||||
setSpecialUsers([])
|
||||
})
|
||||
}
|
||||
bindTrayEvents()
|
||||
return () => {
|
||||
active = false
|
||||
unlistenConnect?.()
|
||||
unlistenDisconnect?.()
|
||||
unlistenStopped?.()
|
||||
}
|
||||
}, [edgeRunning, edge])
|
||||
|
||||
useEffect(() => {
|
||||
let active = true
|
||||
Promise.all([serviceStatus('edge'), serviceStatus('supernode')])
|
||||
.then(([edgeStatus, supernodeStatus]) => {
|
||||
if (!active) return
|
||||
setEdgeRunning(Boolean(edgeStatus.running))
|
||||
setSupernodeRunning(Boolean(supernodeStatus.running))
|
||||
appendLog(edgeStatus.running ? '检测到 Edge 已连接' : 'Edge 已就绪,等待连接', edgeStatus.running ? 'success' : 'info')
|
||||
})
|
||||
.catch(() => {})
|
||||
return () => { active = false }
|
||||
}, [])
|
||||
|
||||
useEffect(() => {
|
||||
if (!edgeRunning) {
|
||||
if (!edgeRunning || !edge.specialClient) {
|
||||
setSpecialUsers([])
|
||||
return undefined
|
||||
}
|
||||
let active = true
|
||||
let timer
|
||||
const poll = async () => {
|
||||
try {
|
||||
const users = await fetchSpecialUsers({
|
||||
host: edge.serverHost,
|
||||
port: Number(edge.specialServerPort),
|
||||
username: edge.username,
|
||||
})
|
||||
if (active) setSpecialUsers(Array.isArray(users) ? users : [])
|
||||
} catch {
|
||||
if (active) setSpecialUsers([])
|
||||
} finally {
|
||||
if (active) timer = window.setTimeout(poll, 2000)
|
||||
}
|
||||
}
|
||||
poll()
|
||||
return () => { active = false; window.clearTimeout(timer) }
|
||||
}, [edgeRunning, edge.specialClient, edge.serverHost, edge.specialServerPort, edge.username])
|
||||
|
||||
useEffect(() => {
|
||||
if (!edgeRunning || !edge.specialClient || specialUsers.length === 0) {
|
||||
setSpecialLatencies({})
|
||||
return undefined
|
||||
}
|
||||
let active = true
|
||||
let timer
|
||||
const poll = async () => {
|
||||
const entries = await Promise.all(specialUsers.map(async (user) => {
|
||||
try {
|
||||
const result = await runPing({ host: user.ip, count: 1 }, () => ({ ok: false, output: '' }))
|
||||
const match = String(result?.output || '').match(/(?:time|时间)[=<]\s*(\d+)/i)
|
||||
return [user.ip, match ? Number(match[1]) : null]
|
||||
} catch {
|
||||
return [user.ip, null]
|
||||
}
|
||||
}))
|
||||
if (active) setSpecialLatencies(Object.fromEntries(entries))
|
||||
if (active) timer = window.setTimeout(poll, 3000)
|
||||
}
|
||||
poll()
|
||||
return () => { active = false; window.clearTimeout(timer) }
|
||||
}, [edgeRunning, edge.specialClient, specialUsers])
|
||||
|
||||
useEffect(() => {
|
||||
if (!edgeRunning || !activeTapDevice) {
|
||||
lastTapSample.current = null
|
||||
setTraffic(null)
|
||||
return undefined
|
||||
@@ -57,7 +279,7 @@ function App() {
|
||||
let timer
|
||||
const poll = async () => {
|
||||
try {
|
||||
const sample = await tapTraffic(edge.tapDevice)
|
||||
const sample = await tapTraffic(activeTapDevice)
|
||||
const sampledAt = Date.now()
|
||||
const previous = lastTapSample.current
|
||||
const elapsedSeconds = previous ? Math.max((sampledAt - previous.sampledAt) / 1000, .25) : 1
|
||||
@@ -76,9 +298,10 @@ function App() {
|
||||
active = false
|
||||
window.clearTimeout(timer)
|
||||
}
|
||||
}, [edgeRunning, edge.tapDevice])
|
||||
}, [activeTapDevice, edgeRunning])
|
||||
|
||||
const updateEdge = (field, value) => setEdge((current) => ({ ...current, [field]: value }))
|
||||
const updateSupernode = (field, value) => setSupernode((current) => ({ ...current, [field]: value }))
|
||||
const notify = (text, tone = 'error') => {
|
||||
setMessage({ text, tone })
|
||||
window.setTimeout(() => setMessage(null), 3200)
|
||||
@@ -89,6 +312,7 @@ function App() {
|
||||
try {
|
||||
const status = await stopService('edge')
|
||||
setEdgeRunning(Boolean(status.running))
|
||||
setActiveTapDevice('')
|
||||
appendLog('已断开 N2N 网络')
|
||||
notify('已断开 N2N 网络', 'neutral')
|
||||
} catch (error) {
|
||||
@@ -103,36 +327,111 @@ function App() {
|
||||
notify('请填写服务器 IP 或域名')
|
||||
return
|
||||
}
|
||||
if (!edge.community.trim()) {
|
||||
if (!edge.specialClient && !edge.community.trim()) {
|
||||
appendLog('连接校验:未填写群组名称', 'warning')
|
||||
notify('请填写群组名称')
|
||||
return
|
||||
}
|
||||
if (!edge.dhcp && !edge.ip.trim()) {
|
||||
if (!edge.specialClient && !edge.dhcp && !edge.ip.trim()) {
|
||||
appendLog('连接校验:静态 IP 未填写', 'warning')
|
||||
notify('关闭 DHCP 后,请填写本机 IP')
|
||||
return
|
||||
}
|
||||
|
||||
try {
|
||||
let runtimeEdge = edge
|
||||
if (edge.specialClient) {
|
||||
const special = await fetchSpecialConfig({
|
||||
host: edge.serverHost,
|
||||
port: Number(edge.specialServerPort),
|
||||
username: edge.username || '',
|
||||
})
|
||||
runtimeEdge = {
|
||||
...edge,
|
||||
community: special.community,
|
||||
serverPort: String(special.supernodePort),
|
||||
dhcp: false,
|
||||
ip: special.ip,
|
||||
gateway: special.gateway,
|
||||
dns: special.dns,
|
||||
}
|
||||
if (!edge.username.trim() && special.username) {
|
||||
setEdge((current) => ({ ...current, username: special.username }))
|
||||
}
|
||||
appendLog('已从特殊服务端获取网络配置', 'success')
|
||||
}
|
||||
const tapAdapter = await resolveTapAdapter(edge.tapDevice)
|
||||
appendLog('已选择 TAP 设备:' + tapAdapter.name)
|
||||
if (isWindowsRuntime) {
|
||||
await configureTapAdapter({
|
||||
tapDevice: tapAdapter.guid || tapAdapter.name,
|
||||
dhcp: runtimeEdge.dhcp,
|
||||
ip: runtimeEdge.ip,
|
||||
gateway: runtimeEdge.gateway || '',
|
||||
dns: runtimeEdge.dns || '',
|
||||
})
|
||||
appendLog('已配置 TAP 网卡地址', 'success')
|
||||
}
|
||||
const status = await startService({
|
||||
service: 'edge',
|
||||
binaryPath: './n2n/edge.exe',
|
||||
args: buildEdgeArgs(edge),
|
||||
args: buildEdgeArgs(runtimeEdge, tapAdapter.guid || tapAdapter.name),
|
||||
})
|
||||
setEdgeRunning(Boolean(status.running))
|
||||
appendLog('已连接到群组 ' + edge.community, 'success')
|
||||
notify('已连接到 ' + edge.community, 'success')
|
||||
setActiveTapDevice(tapAdapter.name)
|
||||
appendLog('已连接到群组 ' + runtimeEdge.community, 'success')
|
||||
notify('已连接到 ' + runtimeEdge.community, 'success')
|
||||
} catch (error) {
|
||||
appendLog('连接失败:' + error.message, 'error')
|
||||
notify('无法建立连接:' + error.message)
|
||||
}
|
||||
}
|
||||
|
||||
const toggleSupernode = async () => {
|
||||
if (supernodeRunning) {
|
||||
try {
|
||||
await stopService('supernode')
|
||||
await stopSpecialService()
|
||||
await hideSupernodeUsersWindow()
|
||||
setSupernodeRunning(false)
|
||||
appendLog('Supernode 已停止')
|
||||
notify('Supernode 已停止', 'neutral')
|
||||
} catch (error) {
|
||||
notify('停止 Supernode 失败:' + error.message)
|
||||
}
|
||||
return
|
||||
}
|
||||
try {
|
||||
const status = await startSupernode({
|
||||
...supernode,
|
||||
port: Number(supernode.port),
|
||||
specialPort: Number(supernode.specialPort),
|
||||
})
|
||||
setSupernodeRunning(Boolean(status.running))
|
||||
await openSupernodeUsersWindow()
|
||||
appendLog('Supernode 已启动', 'success')
|
||||
notify('Supernode 已启动', 'success')
|
||||
} catch (error) {
|
||||
appendLog('启动 Supernode 失败:' + error.message, 'error')
|
||||
notify('无法启动 Supernode:' + error.message)
|
||||
}
|
||||
}
|
||||
|
||||
const installTapDriver = async () => {
|
||||
try {
|
||||
const path = await openTapInstaller()
|
||||
appendLog('已打开 TAP-Windows 安装程序:' + path, 'info')
|
||||
notify('请按安装向导完成驱动安装,然后重新打开应用', 'neutral')
|
||||
} catch (error) {
|
||||
appendLog('打开 TAP-Windows 安装程序失败:' + error.message, 'error')
|
||||
notify('无法打开驱动安装程序:' + error.message)
|
||||
}
|
||||
}
|
||||
|
||||
return <main className="app-shell">
|
||||
<header className="app-header">
|
||||
<div className="brand"><span className="brand-icon"><Network size={19} /></span><span>Super N2N</span></div>
|
||||
<div className="runtime"><span className={edgeRunning ? 'status-light live' : 'status-light'} />{edgeRunning ? '已连接' : '未连接'}</div>
|
||||
<div className="runtime"><span className={edgeRunning || supernodeRunning ? 'status-light live' : 'status-light'} />{edgeRunning ? 'Edge 已连接' : supernodeRunning ? 'Supernode 运行中' : '未连接'}</div>
|
||||
</header>
|
||||
|
||||
<section className="workspace" aria-label="N2N 连接设置">
|
||||
@@ -146,8 +445,8 @@ function App() {
|
||||
</div>
|
||||
|
||||
{home === 'edge'
|
||||
? <EdgeHome edge={edge} updateEdge={updateEdge} running={edgeRunning} traffic={traffic} advancedOpen={advancedOpen} setAdvancedOpen={setAdvancedOpen} logOpen={logOpen} setLogOpen={setLogOpen} logs={logs} onToggle={toggleEdge} onExportLog={() => exportLogs(logs, notify)} />
|
||||
: <SupernodeHome />}
|
||||
? <EdgeHome edge={edge} updateEdge={updateEdge} running={edgeRunning} traffic={traffic} activeTapDevice={activeTapDevice} specialUsers={specialUsers} specialLatencies={specialLatencies} startupInfo={startupInfo} advancedOpen={advancedOpen} setAdvancedOpen={setAdvancedOpen} logOpen={logOpen} setLogOpen={setLogOpen} logs={logs} onToggle={toggleEdge} onInstallTap={installTapDriver} onExportLog={() => exportLogs(logs, notify)} />
|
||||
: <SupernodeHome config={supernode} update={updateSupernode} running={supernodeRunning} onToggle={toggleSupernode} />}
|
||||
</section>
|
||||
|
||||
<footer className="app-footer"><span>{isTauri ? '本机服务控制已就绪' : '浏览器预览模式'}</span><span>n2n 3.1.1</span></footer>
|
||||
@@ -155,7 +454,108 @@ function App() {
|
||||
</main>
|
||||
}
|
||||
|
||||
function EdgeHome({ edge, updateEdge, running, traffic, advancedOpen, setAdvancedOpen, logOpen, setLogOpen, logs, onToggle, onExportLog }) {
|
||||
async function openSupernodeUsersWindow() {
|
||||
if (!isTauri) return
|
||||
const existing = await WebviewWindow.getByLabel('supernode-users')
|
||||
if (existing) {
|
||||
await existing.destroy()
|
||||
}
|
||||
const window = new WebviewWindow('supernode-users', {
|
||||
url: 'supernode-users.html',
|
||||
title: 'Supernode 在线用户',
|
||||
width: 320,
|
||||
height: 460,
|
||||
minWidth: 320,
|
||||
minHeight: 360,
|
||||
maxWidth: 420,
|
||||
maxHeight: 720,
|
||||
resizable: true,
|
||||
visible: true,
|
||||
})
|
||||
window.once('tauri://error', (event) => console.error('无法打开 Supernode 在线用户窗口', event))
|
||||
}
|
||||
|
||||
async function hideSupernodeUsersWindow() {
|
||||
if (!isTauri) return
|
||||
const existing = await WebviewWindow.getByLabel('supernode-users')
|
||||
if (existing) await existing.hide()
|
||||
}
|
||||
|
||||
function SupernodeUsersWindow() {
|
||||
const [users, setUsers] = useState([])
|
||||
const [running, setRunning] = useState(false)
|
||||
const [specialPort, setSpecialPort] = useState(7788)
|
||||
const [specialEnabled, setSpecialEnabled] = useState(false)
|
||||
|
||||
useEffect(() => {
|
||||
let active = true
|
||||
let timer
|
||||
const poll = async () => {
|
||||
try {
|
||||
const status = await serviceStatus('supernode')
|
||||
if (!active) return
|
||||
setRunning(Boolean(status.running))
|
||||
const configText = await readConfig()
|
||||
const config = configText ? JSON.parse(configText).supernode || {} : {}
|
||||
const enabled = Boolean(config.specialEnabled)
|
||||
const port = Number(config.specialPort) || 7788
|
||||
setSpecialEnabled(enabled)
|
||||
setSpecialPort(port)
|
||||
if (!status.running) {
|
||||
setUsers([])
|
||||
return
|
||||
}
|
||||
const rows = await queryManagement({ host: '127.0.0.1', port: 5645, command: 'edges' })
|
||||
const merged = (Array.isArray(rows) ? rows : [])
|
||||
.filter((row) => row?._type === 'row' && row.ip4addr)
|
||||
.map((row) => ({ username: row.desc || '未知主机', ip: row.ip4addr, special: false }))
|
||||
if (enabled) {
|
||||
const leased = await fetchSpecialUsers({ host: '127.0.0.1', port, username: '' })
|
||||
const knownIps = new Set(merged.map((user) => user.ip))
|
||||
;(Array.isArray(leased) ? leased : []).forEach((user) => {
|
||||
const current = merged.find((entry) => entry.ip === user.ip)
|
||||
if (current) current.special = true
|
||||
else if (!knownIps.has(user.ip)) merged.push({ username: user.username, ip: user.ip, special: true })
|
||||
})
|
||||
}
|
||||
if (active) setUsers(merged)
|
||||
} catch {
|
||||
if (active) setUsers([])
|
||||
} finally {
|
||||
if (active) timer = window.setTimeout(poll, 2000)
|
||||
}
|
||||
}
|
||||
poll()
|
||||
return () => { active = false; window.clearTimeout(timer) }
|
||||
}, [])
|
||||
|
||||
return <main className="friends-window">
|
||||
<header className="friends-header">
|
||||
<div><span className={'status-light ' + (running ? 'live' : '')} /><strong>Supernode 在线用户</strong></div>
|
||||
<span className="friends-count">{users.length}</span>
|
||||
</header>
|
||||
<div className="friends-subtitle">{running ? (specialEnabled ? `特殊服务端 :${specialPort}` : '当前连接的客户端') : 'Supernode 未运行'}</div>
|
||||
{users.length === 0
|
||||
? <div className="friends-empty"><Users size={30} /><span>{running ? '暂无在线用户' : '启动 Supernode 后显示在线用户'}</span></div>
|
||||
: <ul className="friends-list">{users.map((user) => <li key={user.username + user.ip}>
|
||||
<span className="friend-avatar">{(user.username || '?').slice(0, 1).toUpperCase()}</span>
|
||||
<span className="friend-main"><strong>{user.username}</strong><small>{user.ip}</small></span>
|
||||
{user.special && <span className="friend-badge">特殊</span>}
|
||||
</li>)}</ul>}
|
||||
</main>
|
||||
}
|
||||
|
||||
function Root() {
|
||||
const queryView = typeof window !== 'undefined'
|
||||
? new URLSearchParams(window.location.search).get('view')
|
||||
: null
|
||||
const label = isTauri ? getCurrentWindow().label : 'main'
|
||||
return queryView === 'supernode-users' || label === 'supernode-users'
|
||||
? <SupernodeUsersWindow />
|
||||
: <App />
|
||||
}
|
||||
|
||||
function EdgeHome({ edge, updateEdge, running, traffic, activeTapDevice, specialUsers, specialLatencies, startupInfo, advancedOpen, setAdvancedOpen, setLogOpen, logOpen, logs, onToggle, onInstallTap, onExportLog }) {
|
||||
const toggleAdvanced = () => {
|
||||
setLogOpen(false)
|
||||
setAdvancedOpen((current) => !current)
|
||||
@@ -182,10 +582,13 @@ function EdgeHome({ edge, updateEdge, running, traffic, advancedOpen, setAdvance
|
||||
<span className="server-inputs">
|
||||
<input value={edge.serverHost} onChange={(event) => updateEdge('serverHost', event.target.value)} placeholder="IP 地址或域名" autoComplete="off" disabled={running} aria-label="服务器 IP 或域名" />
|
||||
<span className="port-separator">:</span>
|
||||
<input className="port-input" inputMode="numeric" value={edge.serverPort} onChange={(event) => updateEdge('serverPort', event.target.value)} placeholder="7777" disabled={running} aria-label="服务器端口" />
|
||||
<input className="port-input" inputMode="numeric" value={edge.specialClient ? edge.specialServerPort : edge.serverPort} onChange={(event) => updateEdge(edge.specialClient ? 'specialServerPort' : 'serverPort', event.target.value)} placeholder={edge.specialClient ? '7788' : '7777'} disabled={running} aria-label={edge.specialClient ? '特殊服务端端口' : '服务器端口'} />
|
||||
</span>
|
||||
</label>
|
||||
|
||||
{edge.specialClient
|
||||
? <div className="special-client-note"><Users size={16} /><span>特殊客户端模式:社区、IP、网关和 DNS 由服务端下发。</span></div>
|
||||
: <>
|
||||
<label className="input-group">
|
||||
<span className="field-title"><Network size={18} />群组名称</span>
|
||||
<input value={edge.community} onChange={(event) => updateEdge('community', event.target.value)} placeholder="例如:my-network" autoComplete="off" disabled={running} />
|
||||
@@ -196,14 +599,18 @@ function EdgeHome({ edge, updateEdge, running, traffic, advancedOpen, setAdvance
|
||||
<input value={edge.dhcp ? '' : edge.ip} onChange={(event) => updateEdge('ip', event.target.value)} placeholder={edge.dhcp ? '开启 DHCP 后由服务器分配' : '例如:10.0.0.2'} autoComplete="off" disabled={edge.dhcp || running} aria-describedby="ip-help" />
|
||||
<small id="ip-help">{edge.dhcp ? 'DHCP 已开启,连接后自动获取 IP。' : '使用静态 IP 时,请确保它没有被其他设备占用。'}</small>
|
||||
</div>
|
||||
</>}
|
||||
</div>
|
||||
|
||||
<TapSetupPrompt status={startupInfo} onInstall={onInstallTap} />
|
||||
|
||||
<button className={running ? 'connect-button stop' : 'connect-button'} onClick={onToggle}>
|
||||
{running ? <Square size={19} fill="currentColor" /> : <Play size={20} fill="currentColor" />}
|
||||
{running ? '断开连接' : '连接网络'}
|
||||
</button>
|
||||
|
||||
{running && <TrafficStrip traffic={traffic} tapDevice={edge.tapDevice} />}
|
||||
{running && <TrafficStrip traffic={traffic} tapDevice={activeTapDevice} />}
|
||||
{running && edge.specialClient && <SpecialUsersPanel users={specialUsers} latencies={specialLatencies} />}
|
||||
</section>
|
||||
|
||||
<div className="secondary-actions">
|
||||
@@ -214,7 +621,9 @@ function EdgeHome({ edge, updateEdge, running, traffic, advancedOpen, setAdvance
|
||||
{advancedOpen && <div className="advanced-fields">
|
||||
<label><span>加密密钥</span><input type="password" value={edge.encryptionKey} onChange={(event) => updateEdge('encryptionKey', event.target.value)} placeholder="可选" disabled={running} /></label>
|
||||
<label><span>管理端口</span><input inputMode="numeric" value={edge.managementPort} onChange={(event) => updateEdge('managementPort', event.target.value)} disabled={running} /></label>
|
||||
<label><span>TAP 设备名称</span><input value={edge.tapDevice} onChange={(event) => updateEdge('tapDevice', event.target.value)} disabled={running} /></label>
|
||||
<label><span>TAP 设备(可选)</span><input value={edge.tapDevice} onChange={(event) => updateEdge('tapDevice', event.target.value)} placeholder="留空自动选择" disabled={running} /></label>
|
||||
<label className="switch-field"><span>特殊客户端</span><DhcpToggle label="启用" checked={edge.specialClient} disabled={running} onChange={(checked) => updateEdge('specialClient', checked)} /></label>
|
||||
{edge.specialClient && <label><span>用户名</span><input value={edge.username} onChange={(event) => updateEdge('username', event.target.value)} placeholder="留空使用主机名" disabled={running} /></label>}
|
||||
</div>}
|
||||
</section>
|
||||
|
||||
@@ -223,6 +632,17 @@ function EdgeHome({ edge, updateEdge, running, traffic, advancedOpen, setAdvance
|
||||
</div>
|
||||
}
|
||||
|
||||
function TapSetupPrompt({ status, onInstall }) {
|
||||
if (!status?.firstLaunch || status.tapDriverPresent) return null
|
||||
return <aside className="tap-setup" role="alert">
|
||||
<div className="tap-setup-copy">
|
||||
<CircleAlert size={16} />
|
||||
<span><strong>需要安装 TAP-Windows</strong><small>未检测到虚拟网卡,安装后重新打开应用。</small></span>
|
||||
</div>
|
||||
{status.tapInstallerPath && <button className="tap-install" onClick={onInstall} title="打开随包 TAP-Windows 安装程序"><Download size={14} />安装</button>}
|
||||
</aside>
|
||||
}
|
||||
|
||||
function TrafficStrip({ traffic, tapDevice }) {
|
||||
if (!traffic || traffic.error) {
|
||||
return <div className="traffic-strip pending" role="status" title={traffic?.error || ''}>
|
||||
@@ -244,21 +664,46 @@ function TrafficMetric({ direction, label, rate, total }) {
|
||||
</output>
|
||||
}
|
||||
|
||||
function DhcpToggle({ checked, disabled, onChange }) {
|
||||
function DhcpToggle({ checked, disabled, onChange, label = 'DHCP' }) {
|
||||
return <label className="dhcp-toggle">
|
||||
<input type="checkbox" checked={checked} disabled={disabled} onChange={(event) => onChange(event.target.checked)} />
|
||||
<span className="toggle-track" aria-hidden="true"><i /></span>
|
||||
<span>DHCP</span>
|
||||
<span>{label}</span>
|
||||
</label>
|
||||
}
|
||||
|
||||
function SupernodeHome() {
|
||||
return <div className="coming-soon">
|
||||
<div className="coming-icon"><Server size={29} /></div>
|
||||
<p className="eyebrow">SUPERNODE</p>
|
||||
<h1>创建服务器</h1>
|
||||
<p>服务器配置即将加入此页面。</p>
|
||||
function SupernodeHome({ config, update, running, onToggle }) {
|
||||
return <div className="supernode-flow">
|
||||
<section className="supernode-card">
|
||||
<div className="supernode-heading"><span className="intro-icon"><Server size={23} /></span><span><p className="eyebrow">SUPERNODE</p><h1>创建服务器</h1></span></div>
|
||||
<div className="supernode-fields">
|
||||
<label><span>UDP 监听端口</span><input inputMode="numeric" value={config.port} onChange={(event) => update('port', event.target.value)} disabled={running} /></label>
|
||||
<label className="supernode-dhcp"><span>DHCP 服务</span><DhcpToggle checked={config.dhcp} disabled={running} onChange={(checked) => update('dhcp', checked)} /></label>
|
||||
<label className="wide"><span>DHCP 地址池</span><input value={config.dhcp ? config.dhcpPool : ''} onChange={(event) => update('dhcpPool', event.target.value)} placeholder="10.10.10.0/24" disabled={!config.dhcp || running} /></label>
|
||||
<label className="wide"><span>允许的社区名</span><textarea value={config.allowedCommunities} onChange={(event) => update('allowedCommunities', event.target.value)} placeholder="每行一个;留空时不限制" disabled={running} /></label>
|
||||
</div>
|
||||
<section className="special-server">
|
||||
<div className="special-server-toggle"><span><Users size={16} />特殊服务端</span><DhcpToggle label="启用" checked={config.specialEnabled} disabled={running} onChange={(checked) => update('specialEnabled', checked)} /></div>
|
||||
{config.specialEnabled && <div className="special-server-fields">
|
||||
<label><span>TCP 端口</span><input inputMode="numeric" value={config.specialPort} onChange={(event) => update('specialPort', event.target.value)} disabled={running} /></label>
|
||||
<label><span>下发社区</span><input value={config.specialCommunity} onChange={(event) => update('specialCommunity', event.target.value)} disabled={running} /></label>
|
||||
<label><span>下发地址池</span><input value={config.specialPool} onChange={(event) => update('specialPool', event.target.value)} placeholder="10.10.10.128/25" disabled={running} /></label>
|
||||
<label><span>网关</span><input value={config.specialGateway} onChange={(event) => update('specialGateway', event.target.value)} placeholder="可选" disabled={running} /></label>
|
||||
<label><span>DNS</span><input value={config.specialDns} onChange={(event) => update('specialDns', event.target.value)} placeholder="可选" disabled={running} /></label>
|
||||
</div>}
|
||||
</section>
|
||||
<button className={running ? 'connect-button stop' : 'connect-button'} onClick={onToggle}>{running ? <Square size={18} fill="currentColor" /> : <Play size={19} fill="currentColor" />}{running ? '停止 Supernode' : '启动 Supernode'}</button>
|
||||
</section>
|
||||
</div>
|
||||
}
|
||||
|
||||
function SpecialUsersPanel({ users, latencies = {} }) {
|
||||
return <section className="special-users" aria-label="社区在线用户">
|
||||
<header><span><Users size={16} />社区在线用户</span><small>{users.length} 人</small></header>
|
||||
{users.length === 0
|
||||
? <p>暂无客户端向特殊服务端请求配置。</p>
|
||||
: <ol>{users.map((user) => <li key={user.username + user.ip}><strong>{user.username}</strong><span>{user.ip}</span><small>{latencies[user.ip] == null ? '延迟 --' : `延迟 ${latencies[user.ip]} ms`}</small></li>)}</ol>}
|
||||
</section>
|
||||
}
|
||||
|
||||
function LogPanel({ open, onToggle, logs, onExport }) {
|
||||
@@ -323,15 +768,18 @@ function addOption(args, flag, value) {
|
||||
if (String(value ?? '').trim()) args.push(flag, String(value).trim())
|
||||
}
|
||||
|
||||
function buildEdgeArgs(config) {
|
||||
function buildEdgeArgs(config, tapDevice) {
|
||||
const args = []
|
||||
addOption(args, '-c', config.community)
|
||||
addOption(args, '-l', config.serverHost + ':' + (config.serverPort || '7777'))
|
||||
addOption(args, '-a', config.dhcp ? 'dhcp:0.0.0.0' : config.ip)
|
||||
addOption(args, '-d', config.tapDevice)
|
||||
addOption(args, '-d', tapDevice)
|
||||
addOption(args, '-t', config.managementPort)
|
||||
addOption(args, '-I', config.username)
|
||||
if (config.encryptionKey) addOption(args, '-k', config.encryptionKey)
|
||||
args.push('-f', '-v', '-v')
|
||||
// Windows edge does not implement the POSIX-only -f daemon flag.
|
||||
if (!isWindowsRuntime) args.push('-f')
|
||||
args.push('-v', '-v')
|
||||
return args
|
||||
}
|
||||
|
||||
|
||||
+106
-1
@@ -21,7 +21,7 @@
|
||||
* { box-sizing: border-box; }
|
||||
html, body, #root { min-width: 320px; min-height: 100%; margin: 0; }
|
||||
body { min-height: 100vh; background: var(--canvas); }
|
||||
button, input { font: inherit; }
|
||||
button, input, textarea { font: inherit; }
|
||||
button { border: 0; cursor: pointer; }
|
||||
button:focus-visible, input:focus-visible { outline: 3px solid rgba(43, 108, 176, .35); outline-offset: 2px; }
|
||||
button:disabled, input:disabled { cursor: not-allowed; }
|
||||
@@ -49,6 +49,8 @@ h1 { margin: 0; color: var(--ink); font-size: 24px; line-height: 1.2; letter-spa
|
||||
.intro-copy { margin: 4px 0 0; color: var(--muted); font-size: 13px; line-height: 1.45; }
|
||||
|
||||
.connection-card { overflow: hidden; background: var(--surface); border: 1px solid var(--line); border-radius: 7px; box-shadow: 0 7px 20px rgba(21, 53, 57, .07); }
|
||||
.special-client-note { display: flex; align-items: center; gap: 8px; margin: 8px 0 2px; padding: 9px 10px; color: #245c78; background: #edf7fb; border: 1px solid #c9e1ed; border-radius: 5px; font-size: 12px; line-height: 1.4; }
|
||||
.special-client-note svg { flex: 0 0 auto; color: var(--blue); }
|
||||
.field-stack { display: grid; padding: 18px 22px 6px; }
|
||||
.input-group { display: grid; gap: 7px; padding: 14px 0; border-bottom: 1px solid #e7eeee; }
|
||||
.input-group:last-child { border-bottom: 0; }
|
||||
@@ -64,6 +66,15 @@ h1 { margin: 0; color: var(--ink); font-size: 24px; line-height: 1.2; letter-spa
|
||||
.ip-heading { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
|
||||
.input-group small { color: var(--muted); font-size: 12px; line-height: 1.4; }
|
||||
|
||||
.tap-setup { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 8px; margin: 0 22px 10px; padding: 8px 9px; color: #855f16; background: #fff8e8; border: 1px solid #ecd59c; border-radius: 5px; }
|
||||
.tap-setup-copy { min-width: 0; display: flex; align-items: flex-start; gap: 7px; }
|
||||
.tap-setup-copy > svg { flex: 0 0 auto; margin-top: 1px; }
|
||||
.tap-setup-copy > span { min-width: 0; display: grid; gap: 2px; }
|
||||
.tap-setup-copy strong { color: #76500d; font-size: 12px; line-height: 1.2; }
|
||||
.tap-setup-copy small { overflow: hidden; color: #927642; font-size: 11px; line-height: 1.25; text-overflow: ellipsis; white-space: nowrap; }
|
||||
.tap-install { min-height: 28px; display: inline-flex; align-items: center; justify-content: center; gap: 4px; padding: 0 8px; color: #76500d; background: #fff; border: 1px solid #dfc57d; border-radius: 4px; font-size: 11px; font-weight: 700; white-space: nowrap; }
|
||||
.tap-install:hover { background: #fffdf5; border-color: #caa64d; }
|
||||
|
||||
.dhcp-toggle { display: inline-flex; align-items: center; gap: 7px; min-height: 28px; color: var(--muted); font-size: 13px; font-weight: 600; cursor: pointer; }
|
||||
.dhcp-toggle input { position: absolute; width: 1px; height: 1px; opacity: 0; }
|
||||
.toggle-track { position: relative; width: 36px; height: 22px; flex: 0 0 auto; background: #a8b7ba; border-radius: 14px; transition: background 180ms ease; }
|
||||
@@ -132,6 +143,38 @@ h1 { margin: 0; color: var(--ink); font-size: 24px; line-height: 1.2; letter-spa
|
||||
.coming-soon h1 { margin-bottom: 10px; }
|
||||
.coming-soon p:last-child { margin: 0; color: var(--muted); font-size: 14px; }
|
||||
|
||||
.supernode-flow { display: grid; gap: 8px; animation: reveal 220ms ease-out; }
|
||||
.supernode-card { overflow: hidden; background: var(--surface); border: 1px solid var(--line); border-radius: 7px; box-shadow: 0 7px 20px rgba(21, 53, 57, .07); }
|
||||
.supernode-heading { display: flex; align-items: center; gap: 10px; padding: 14px 16px 10px; border-bottom: 1px solid #e7eeee; }
|
||||
.supernode-heading .intro-icon { width: 36px; height: 36px; border-radius: 7px; }
|
||||
.supernode-heading h1 { font-size: 18px; }
|
||||
.supernode-fields { display: grid; grid-template-columns: 1fr 1fr; gap: 9px 10px; padding: 12px 16px; }
|
||||
.supernode-fields label, .special-server-fields label { display: grid; gap: 5px; color: var(--muted); font-size: 12px; font-weight: 600; }
|
||||
.supernode-fields .wide { grid-column: 1 / -1; }
|
||||
.supernode-fields input, .supernode-fields textarea, .special-server-fields input { width: 100%; height: 34px; padding: 0 9px; color: var(--ink); background: #fbfdfd; border: 1px solid var(--line-strong); border-radius: 5px; font-size: 13px; }
|
||||
.supernode-fields textarea { height: 58px; padding: 8px 9px; resize: vertical; }
|
||||
.supernode-fields input:disabled, .supernode-fields textarea:disabled, .special-server-fields input:disabled { color: #83969b; background: #f0f5f5; border-color: #dce6e7; }
|
||||
.supernode-dhcp { align-content: space-between; }
|
||||
.special-server { margin: 0 16px; border: 1px solid #cbdede; border-radius: 6px; background: #f7fbfb; }
|
||||
.special-server-toggle { min-height: 38px; display: flex; align-items: center; justify-content: space-between; padding: 0 10px; color: var(--ink); font-size: 12px; font-weight: 700; }
|
||||
.special-server-toggle > span { display: inline-flex; align-items: center; gap: 6px; }
|
||||
.special-server-toggle svg { color: var(--blue); }
|
||||
.special-server-fields { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; padding: 0 10px 10px; border-top: 1px solid #dbe8e8; }
|
||||
.special-server-fields label { padding-top: 8px; }
|
||||
.special-server-fields label:nth-child(n + 3) { grid-column: 1 / -1; }
|
||||
.supernode-card .connect-button { margin-top: 11px; margin-bottom: 13px; }
|
||||
.special-users { overflow: hidden; background: var(--surface); border: 1px solid var(--line); border-radius: 7px; }
|
||||
.special-users header { min-height: 38px; display: flex; align-items: center; justify-content: space-between; padding: 0 12px; color: var(--ink); background: #f5fbfa; border-bottom: 1px solid var(--line); font-size: 12px; font-weight: 700; }
|
||||
.special-users header span { display: inline-flex; align-items: center; gap: 6px; color: var(--teal-dark); }
|
||||
.special-users header small { color: var(--faint); font-size: 11px; }
|
||||
.special-users > p { margin: 0; padding: 13px; color: var(--muted); font-size: 12px; }
|
||||
.special-users ol { max-height: 130px; margin: 0; padding: 0; overflow-y: auto; list-style: none; }
|
||||
.special-users li { display: grid; grid-template-columns: minmax(0, 1fr) 94px 76px; gap: 8px; align-items: center; min-height: 34px; padding: 7px 12px; border-bottom: 1px solid #e7eeee; font-size: 12px; }
|
||||
.special-users li:last-child { border-bottom: 0; }
|
||||
.special-users li strong { overflow: hidden; color: var(--ink); text-overflow: ellipsis; white-space: nowrap; }
|
||||
.special-users li span { color: var(--blue); font-family: ui-monospace, "Cascadia Code", Consolas, monospace; font-size: 11px; }
|
||||
.special-users li small { color: var(--faint); font-size: 10px; text-align: right; }
|
||||
|
||||
.app-footer { color: var(--faint); border-top: 1px solid var(--line); font-size: 12px; }
|
||||
.notice { position: fixed; right: 24px; bottom: 24px; max-width: min(420px, calc(100vw - 48px)); display: flex; align-items: center; gap: 10px; padding: 14px 16px; color: #803035; background: #fff7f7; border: 1px solid #e6b9bb; border-radius: 7px; box-shadow: 0 8px 22px rgba(44, 44, 44, .13); font-size: 14px; animation: reveal 200ms ease-out; }
|
||||
.notice.success { color: #0d6a5e; background: #f0fbf8; border-color: #a8d9cd; }
|
||||
@@ -153,6 +196,7 @@ h1 { margin: 0; color: var(--ink); font-size: 24px; line-height: 1.2; letter-spa
|
||||
.input-group { padding: 12px 0; }
|
||||
.server-inputs { grid-template-columns: minmax(0, 1fr) auto 74px; gap: 5px; }
|
||||
.input-group input { height: 38px; font-size: 14px; }
|
||||
.tap-setup { margin: 0 16px 8px; }
|
||||
.connect-button { width: calc(100% - 32px); margin: 10px 16px 14px; }
|
||||
.connection-summary { grid-template-columns: 1fr; }
|
||||
.connection-summary div { grid-template-columns: 80px 1fr; align-items: baseline; padding: 9px 14px; border-right: 0; border-bottom: 1px solid var(--line); }
|
||||
@@ -194,6 +238,13 @@ h1 { margin: 0; color: var(--ink); font-size: 24px; line-height: 1.2; letter-spa
|
||||
.field-title { gap: 0; font-size: 12px; }
|
||||
.field-title svg { display: none; }
|
||||
.input-group input { height: 30px; padding: 0 7px; border-radius: 4px; font-size: 12px; }
|
||||
.tap-setup { gap: 5px; margin: 0 8px 3px; padding: 6px 7px; border-radius: 4px; }
|
||||
.tap-setup-copy { gap: 5px; }
|
||||
.tap-setup-copy > svg { width: 14px; height: 14px; }
|
||||
.tap-setup-copy strong { font-size: 10px; }
|
||||
.tap-setup-copy small { font-size: 9px; }
|
||||
.tap-install { min-height: 24px; gap: 3px; padding: 0 6px; font-size: 10px; }
|
||||
.tap-install svg { width: 12px; height: 12px; }
|
||||
.server-inputs { grid-template-columns: minmax(0, 1fr) auto 58px; gap: 4px; }
|
||||
.port-separator { font-size: 15px; }
|
||||
.input-group small { display: none; }
|
||||
@@ -237,6 +288,27 @@ h1 { margin: 0; color: var(--ink); font-size: 24px; line-height: 1.2; letter-spa
|
||||
.advanced-fields label { gap: 4px; font-size: 11px; }
|
||||
.advanced-fields input { height: 30px; padding: 0 7px; border-radius: 4px; font-size: 12px; }
|
||||
|
||||
.supernode-flow { height: calc(100% - 41px); grid-template-rows: minmax(0, 1fr) auto; overflow: hidden; }
|
||||
.supernode-card { min-height: 0; overflow-y: auto; box-shadow: none; border-radius: 6px; }
|
||||
.supernode-heading { display: none; }
|
||||
.supernode-fields { grid-template-columns: 1fr; gap: 5px; padding: 7px 8px; }
|
||||
.supernode-fields label, .special-server-fields label { gap: 3px; font-size: 10px; }
|
||||
.supernode-fields input, .supernode-fields textarea, .special-server-fields input { height: 28px; padding: 0 7px; border-radius: 4px; font-size: 11px; }
|
||||
.supernode-fields textarea { height: 42px; padding: 5px 7px; }
|
||||
.supernode-fields .wide { grid-column: auto; }
|
||||
.supernode-dhcp { display: flex !important; align-items: center; justify-content: space-between; }
|
||||
.special-server { margin: 0 8px; border-radius: 4px; }
|
||||
.special-server-toggle { min-height: 31px; padding: 0 7px; font-size: 11px; }
|
||||
.special-server-fields { grid-template-columns: 1fr; gap: 5px; padding: 0 7px 7px; }
|
||||
.special-server-fields label { grid-column: auto !important; padding-top: 5px; }
|
||||
.supernode-card .connect-button { width: calc(100% - 16px); min-height: 32px; margin: 6px 8px; font-size: 12px; }
|
||||
.special-users { border-radius: 5px; }
|
||||
.special-users header { min-height: 30px; padding: 0 8px; font-size: 11px; }
|
||||
.special-users > p { padding: 8px; font-size: 10px; }
|
||||
.special-users ol { max-height: 64px; }
|
||||
.special-users li { grid-template-columns: minmax(0, 1fr) 78px 60px; min-height: 26px; gap: 4px; padding: 4px 8px; font-size: 10px; }
|
||||
.special-users li span, .special-users li small { font-size: 9px; }
|
||||
|
||||
.log-content { padding: 8px 0 0; }
|
||||
.log-toolbar { min-height: 32px; padding: 0 4px; gap: 8px; }
|
||||
.log-toolbar > span { font-size: 11px; }
|
||||
@@ -259,3 +331,36 @@ h1 { margin: 0; color: var(--ink); font-size: 24px; line-height: 1.2; letter-spa
|
||||
@media (prefers-reduced-motion: reduce) {
|
||||
*, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; transition-duration: .01ms !important; }
|
||||
}
|
||||
|
||||
.friends-window {
|
||||
min-height: 100vh;
|
||||
box-sizing: border-box;
|
||||
padding: 0 0 10px;
|
||||
overflow: hidden;
|
||||
background: #eef5f5;
|
||||
color: #163238;
|
||||
}
|
||||
.friends-header {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
min-height: 58px;
|
||||
padding: 0 16px;
|
||||
color: #f6ffff;
|
||||
background: #173f46;
|
||||
border-bottom: 3px solid #16a394;
|
||||
}
|
||||
.friends-header > div { display: flex; align-items: center; gap: 9px; min-width: 0; }
|
||||
.friends-header strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 14px; letter-spacing: .01em; }
|
||||
.friends-count { display: grid; place-items: center; min-width: 25px; height: 25px; border-radius: 50%; color: #173f46; background: #a7eee2; font-size: 12px; font-weight: 800; }
|
||||
.friends-subtitle { padding: 11px 16px 7px; color: #698084; font-size: 11px; font-weight: 600; }
|
||||
.friends-list { display: grid; gap: 2px; margin: 0; padding: 0 8px; list-style: none; }
|
||||
.friends-list li { display: flex; align-items: center; gap: 10px; min-height: 53px; padding: 0 9px; border: 1px solid transparent; border-radius: 7px; background: rgba(255,255,255,.72); transition: background .15s ease, border-color .15s ease; }
|
||||
.friends-list li:hover { border-color: #a6d9d3; background: #fff; }
|
||||
.friend-avatar { display: grid; place-items: center; width: 30px; height: 30px; flex: 0 0 30px; border-radius: 8px; color: #fff; background: #0b8d82; font-size: 14px; font-weight: 800; }
|
||||
.friend-main { display: grid; min-width: 0; gap: 3px; }
|
||||
.friend-main strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 12px; }
|
||||
.friend-main small { color: #6c8588; font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: 10px; }
|
||||
.friend-badge { margin-left: auto; padding: 3px 6px; border-radius: 4px; color: #08786f; background: #d1f3ee; font-size: 9px; font-weight: 800; }
|
||||
.friends-empty { display: grid; justify-items: center; gap: 10px; padding: 60px 20px; color: #7c9295; text-align: center; font-size: 12px; }
|
||||
.friends-empty svg { color: #8fb2b2; }
|
||||
|
||||
@@ -0,0 +1,71 @@
|
||||
import { useEffect, useState } from 'react'
|
||||
import { createRoot } from 'react-dom/client'
|
||||
import { Users } from 'lucide-react'
|
||||
import { fetchSpecialUsers, isTauri, queryManagement, readConfig, serviceStatus } from './lib/tauri'
|
||||
import './styles.css'
|
||||
|
||||
function SupernodeUsersWindow() {
|
||||
const [users, setUsers] = useState([])
|
||||
const [running, setRunning] = useState(false)
|
||||
const [specialPort, setSpecialPort] = useState(7788)
|
||||
const [specialEnabled, setSpecialEnabled] = useState(false)
|
||||
|
||||
useEffect(() => {
|
||||
let active = true
|
||||
let timer
|
||||
const poll = async () => {
|
||||
try {
|
||||
const status = await serviceStatus('supernode')
|
||||
if (!active) return
|
||||
setRunning(Boolean(status.running))
|
||||
const configText = await readConfig()
|
||||
const config = configText ? JSON.parse(configText).supernode || {} : {}
|
||||
const enabled = Boolean(config.specialEnabled)
|
||||
const port = Number(config.specialPort) || 7788
|
||||
setSpecialEnabled(enabled)
|
||||
setSpecialPort(port)
|
||||
if (!status.running) {
|
||||
setUsers([])
|
||||
return
|
||||
}
|
||||
const rows = await queryManagement({ host: '127.0.0.1', port: 5645, command: 'edges' })
|
||||
const merged = (Array.isArray(rows) ? rows : [])
|
||||
.filter((row) => row?._type === 'row' && row.ip4addr)
|
||||
.map((row) => ({ username: row.desc || '未知主机', ip: row.ip4addr, special: false }))
|
||||
if (enabled) {
|
||||
const leased = await fetchSpecialUsers({ host: '127.0.0.1', port, username: '' })
|
||||
const knownIps = new Set(merged.map((user) => user.ip))
|
||||
;(Array.isArray(leased) ? leased : []).forEach((user) => {
|
||||
const current = merged.find((entry) => entry.ip === user.ip)
|
||||
if (current) current.special = true
|
||||
else if (!knownIps.has(user.ip)) merged.push({ username: user.username, ip: user.ip, special: true })
|
||||
})
|
||||
}
|
||||
if (active) setUsers(merged)
|
||||
} catch {
|
||||
if (active) setUsers([])
|
||||
} finally {
|
||||
if (active) timer = window.setTimeout(poll, 2000)
|
||||
}
|
||||
}
|
||||
poll()
|
||||
return () => { active = false; window.clearTimeout(timer) }
|
||||
}, [])
|
||||
|
||||
return <main className="friends-window">
|
||||
<header className="friends-header">
|
||||
<div><span className={'status-light ' + (running ? 'live' : '')} /><strong>Supernode 在线用户</strong></div>
|
||||
<span className="friends-count">{users.length}</span>
|
||||
</header>
|
||||
<div className="friends-subtitle">{running ? (specialEnabled ? `特殊服务端 :${specialPort}` : '当前连接的客户端') : 'Supernode 未运行'}</div>
|
||||
{users.length === 0
|
||||
? <div className="friends-empty"><Users size={30} /><span>{running ? '暂无在线用户' : '启动 Supernode 后显示在线用户'}</span></div>
|
||||
: <ul className="friends-list">{users.map((user) => <li key={user.username + user.ip}>
|
||||
<span className="friend-avatar">{(user.username || '?').slice(0, 1).toUpperCase()}</span>
|
||||
<span className="friend-main"><strong>{user.username}</strong><small>{user.ip}</small></span>
|
||||
{user.special && <span className="friend-badge">特殊</span>}
|
||||
</li>)}</ul>}
|
||||
</main>
|
||||
}
|
||||
|
||||
createRoot(document.getElementById('root')).render(<SupernodeUsersWindow />)
|
||||
@@ -0,0 +1,13 @@
|
||||
<!doctype html>
|
||||
<html lang="zh-CN">
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<meta name="theme-color" content="#173f46" />
|
||||
<title>Supernode 在线用户</title>
|
||||
</head>
|
||||
<body>
|
||||
<div id="root"></div>
|
||||
<script type="module" src="/src/supernode-users.jsx"></script>
|
||||
</body>
|
||||
</html>
|
||||
+339
@@ -0,0 +1,339 @@
|
||||
GNU GENERAL PUBLIC LICENSE
|
||||
Version 2, June 1991
|
||||
|
||||
Copyright (C) 1989, 1991 Free Software Foundation, Inc.,
|
||||
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
Everyone is permitted to copy and distribute verbatim copies
|
||||
of this license document, but changing it is not allowed.
|
||||
|
||||
Preamble
|
||||
|
||||
The licenses for most software are designed to take away your
|
||||
freedom to share and change it. By contrast, the GNU General Public
|
||||
License is intended to guarantee your freedom to share and change free
|
||||
software--to make sure the software is free for all its users. This
|
||||
General Public License applies to most of the Free Software
|
||||
Foundation's software and to any other program whose authors commit to
|
||||
using it. (Some other Free Software Foundation software is covered by
|
||||
the GNU Lesser General Public License instead.) You can apply it to
|
||||
your programs, too.
|
||||
|
||||
When we speak of free software, we are referring to freedom, not
|
||||
price. Our General Public Licenses are designed to make sure that you
|
||||
have the freedom to distribute copies of free software (and charge for
|
||||
this service if you wish), that you receive source code or can get it
|
||||
if you want it, that you can change the software or use pieces of it
|
||||
in new free programs; and that you know you can do these things.
|
||||
|
||||
To protect your rights, we need to make restrictions that forbid
|
||||
anyone to deny you these rights or to ask you to surrender the rights.
|
||||
These restrictions translate to certain responsibilities for you if you
|
||||
distribute copies of the software, or if you modify it.
|
||||
|
||||
For example, if you distribute copies of such a program, whether
|
||||
gratis or for a fee, you must give the recipients all the rights that
|
||||
you have. You must make sure that they, too, receive or can get the
|
||||
source code. And you must show them these terms so they know their
|
||||
rights.
|
||||
|
||||
We protect your rights with two steps: (1) copyright the software, and
|
||||
(2) offer you this license which gives you legal permission to copy,
|
||||
distribute and/or modify the software.
|
||||
|
||||
Also, for each author's protection and ours, we want to make certain
|
||||
that everyone understands that there is no warranty for this free
|
||||
software. If the software is modified by someone else and passed on, we
|
||||
want its recipients to know that what they have is not the original, so
|
||||
that any problems introduced by others will not reflect on the original
|
||||
authors' reputations.
|
||||
|
||||
Finally, any free program is threatened constantly by software
|
||||
patents. We wish to avoid the danger that redistributors of a free
|
||||
program will individually obtain patent licenses, in effect making the
|
||||
program proprietary. To prevent this, we have made it clear that any
|
||||
patent must be licensed for everyone's free use or not licensed at all.
|
||||
|
||||
The precise terms and conditions for copying, distribution and
|
||||
modification follow.
|
||||
|
||||
GNU GENERAL PUBLIC LICENSE
|
||||
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
|
||||
|
||||
0. This License applies to any program or other work which contains
|
||||
a notice placed by the copyright holder saying it may be distributed
|
||||
under the terms of this General Public License. The "Program", below,
|
||||
refers to any such program or work, and a "work based on the Program"
|
||||
means either the Program or any derivative work under copyright law:
|
||||
that is to say, a work containing the Program or a portion of it,
|
||||
either verbatim or with modifications and/or translated into another
|
||||
language. (Hereinafter, translation is included without limitation in
|
||||
the term "modification".) Each licensee is addressed as "you".
|
||||
|
||||
Activities other than copying, distribution and modification are not
|
||||
covered by this License; they are outside its scope. The act of
|
||||
running the Program is not restricted, and the output from the Program
|
||||
is covered only if its contents constitute a work based on the
|
||||
Program (independent of having been made by running the Program).
|
||||
Whether that is true depends on what the Program does.
|
||||
|
||||
1. You may copy and distribute verbatim copies of the Program's
|
||||
source code as you receive it, in any medium, provided that you
|
||||
conspicuously and appropriately publish on each copy an appropriate
|
||||
copyright notice and disclaimer of warranty; keep intact all the
|
||||
notices that refer to this License and to the absence of any warranty;
|
||||
and give any other recipients of the Program a copy of this License
|
||||
along with the Program.
|
||||
|
||||
You may charge a fee for the physical act of transferring a copy, and
|
||||
you may at your option offer warranty protection in exchange for a fee.
|
||||
|
||||
2. You may modify your copy or copies of the Program or any portion
|
||||
of it, thus forming a work based on the Program, and copy and
|
||||
distribute such modifications or work under the terms of Section 1
|
||||
above, provided that you also meet all of these conditions:
|
||||
|
||||
a) You must cause the modified files to carry prominent notices
|
||||
stating that you changed the files and the date of any change.
|
||||
|
||||
b) You must cause any work that you distribute or publish, that in
|
||||
whole or in part contains or is derived from the Program or any
|
||||
part thereof, to be licensed as a whole at no charge to all third
|
||||
parties under the terms of this License.
|
||||
|
||||
c) If the modified program normally reads commands interactively
|
||||
when run, you must cause it, when started running for such
|
||||
interactive use in the most ordinary way, to print or display an
|
||||
announcement including an appropriate copyright notice and a
|
||||
notice that there is no warranty (or else, saying that you provide
|
||||
a warranty) and that users may redistribute the program under
|
||||
these conditions, and telling the user how to view a copy of this
|
||||
License. (Exception: if the Program itself is interactive but
|
||||
does not normally print such an announcement, your work based on
|
||||
the Program is not required to print an announcement.)
|
||||
|
||||
These requirements apply to the modified work as a whole. If
|
||||
identifiable sections of that work are not derived from the Program,
|
||||
and can be reasonably considered independent and separate works in
|
||||
themselves, then this License, and its terms, do not apply to those
|
||||
sections when you distribute them as separate works. But when you
|
||||
distribute the same sections as part of a whole which is a work based
|
||||
on the Program, the distribution of the whole must be on the terms of
|
||||
this License, whose permissions for other licensees extend to the
|
||||
entire whole, and thus to each and every part regardless of who wrote it.
|
||||
|
||||
Thus, it is not the intent of this section to claim rights or contest
|
||||
your rights to work written entirely by you; rather, the intent is to
|
||||
exercise the right to control the distribution of derivative or
|
||||
collective works based on the Program.
|
||||
|
||||
In addition, mere aggregation of another work not based on the Program
|
||||
with the Program (or with a work based on the Program) on a volume of
|
||||
a storage or distribution medium does not bring the other work under
|
||||
the scope of this License.
|
||||
|
||||
3. You may copy and distribute the Program (or a work based on it,
|
||||
under Section 2) in object code or executable form under the terms of
|
||||
Sections 1 and 2 above provided that you also do one of the following:
|
||||
|
||||
a) Accompany it with the complete corresponding machine-readable
|
||||
source code, which must be distributed under the terms of Sections
|
||||
1 and 2 above on a medium customarily used for software interchange; or,
|
||||
|
||||
b) Accompany it with a written offer, valid for at least three
|
||||
years, to give any third party, for a charge no more than your
|
||||
cost of physically performing source distribution, a complete
|
||||
machine-readable copy of the corresponding source code, to be
|
||||
distributed under the terms of Sections 1 and 2 above on a medium
|
||||
customarily used for software interchange; or,
|
||||
|
||||
c) Accompany it with the information you received as to the offer
|
||||
to distribute corresponding source code. (This alternative is
|
||||
allowed only for noncommercial distribution and only if you
|
||||
received the program in object code or executable form with such
|
||||
an offer, in accord with Subsection b above.)
|
||||
|
||||
The source code for a work means the preferred form of the work for
|
||||
making modifications to it. For an executable work, complete source
|
||||
code means all the source code for all modules it contains, plus any
|
||||
associated interface definition files, plus the scripts used to
|
||||
control compilation and installation of the executable. However, as a
|
||||
special exception, the source code distributed need not include
|
||||
anything that is normally distributed (in either source or binary
|
||||
form) with the major components (compiler, kernel, and so on) of the
|
||||
operating system on which the executable runs, unless that component
|
||||
itself accompanies the executable.
|
||||
|
||||
If distribution of executable or object code is made by offering
|
||||
access to copy from a designated place, then offering equivalent
|
||||
access to copy the source code from the same place counts as
|
||||
distribution of the source code, even though third parties are not
|
||||
compelled to copy the source along with the object code.
|
||||
|
||||
4. You may not copy, modify, sublicense, or distribute the Program
|
||||
except as expressly provided under this License. Any attempt
|
||||
otherwise to copy, modify, sublicense or distribute the Program is
|
||||
void, and will automatically terminate your rights under this License.
|
||||
However, parties who have received copies, or rights, from you under
|
||||
this License will not have their licenses terminated so long as such
|
||||
parties remain in full compliance.
|
||||
|
||||
5. You are not required to accept this License, since you have not
|
||||
signed it. However, nothing else grants you permission to modify or
|
||||
distribute the Program or its derivative works. These actions are
|
||||
prohibited by law if you do not accept this License. Therefore, by
|
||||
modifying or distributing the Program (or any work based on the
|
||||
Program), you indicate your acceptance of this License to do so, and
|
||||
all its terms and conditions for copying, distributing or modifying
|
||||
the Program or works based on it.
|
||||
|
||||
6. Each time you redistribute the Program (or any work based on the
|
||||
Program), the recipient automatically receives a license from the
|
||||
original licensor to copy, distribute or modify the Program subject to
|
||||
these terms and conditions. You may not impose any further
|
||||
restrictions on the recipients' exercise of the rights granted herein.
|
||||
You are not responsible for enforcing compliance by third parties to
|
||||
this License.
|
||||
|
||||
7. If, as a consequence of a court judgment or allegation of patent
|
||||
infringement or for any other reason (not limited to patent issues),
|
||||
conditions are imposed on you (whether by court order, agreement or
|
||||
otherwise) that contradict the conditions of this License, they do not
|
||||
excuse you from the conditions of this License. If you cannot
|
||||
distribute so as to satisfy simultaneously your obligations under this
|
||||
License and any other pertinent obligations, then as a consequence you
|
||||
may not distribute the Program at all. For example, if a patent
|
||||
license would not permit royalty-free redistribution of the Program by
|
||||
all those who receive copies directly or indirectly through you, then
|
||||
the only way you could satisfy both it and this License would be to
|
||||
refrain entirely from distribution of the Program.
|
||||
|
||||
If any portion of this section is held invalid or unenforceable under
|
||||
any particular circumstance, the balance of the section is intended to
|
||||
apply and the section as a whole is intended to apply in other
|
||||
circumstances.
|
||||
|
||||
It is not the purpose of this section to induce you to infringe any
|
||||
patents or other property right claims or to contest validity of any
|
||||
such claims; this section has the sole purpose of protecting the
|
||||
integrity of the free software distribution system, which is
|
||||
implemented by public license practices. Many people have made
|
||||
generous contributions to the wide range of software distributed
|
||||
through that system in reliance on consistent application of that
|
||||
system; it is up to the author/donor to decide if he or she is willing
|
||||
to distribute software through any other system and a licensee cannot
|
||||
impose that choice.
|
||||
|
||||
This section is intended to make thoroughly clear what is believed to
|
||||
be a consequence of the rest of this License.
|
||||
|
||||
8. If the distribution and/or use of the Program is restricted in
|
||||
certain countries either by patents or by copyrighted interfaces, the
|
||||
original copyright holder who places the Program under this License
|
||||
may add an explicit geographical distribution limitation excluding
|
||||
those countries, so that distribution is permitted only in or among
|
||||
countries not thus excluded. In such case, this License incorporates
|
||||
the limitation as if written in the body of this License.
|
||||
|
||||
9. The Free Software Foundation may publish revised and/or new versions
|
||||
of the General Public License from time to time. Such new versions will
|
||||
be similar in spirit to the present version, but may differ in detail to
|
||||
address new problems or concerns.
|
||||
|
||||
Each version is given a distinguishing version number. If the Program
|
||||
specifies a version number of this License which applies to it and "any
|
||||
later version", you have the option of following the terms and conditions
|
||||
either of that version or of any later version published by the Free
|
||||
Software Foundation. If the Program does not specify a version number of
|
||||
this License, you may choose any version ever published by the Free Software
|
||||
Foundation.
|
||||
|
||||
10. If you wish to incorporate parts of the Program into other free
|
||||
programs whose distribution conditions are different, write to the author
|
||||
to ask for permission. For software which is copyrighted by the Free
|
||||
Software Foundation, write to the Free Software Foundation; we sometimes
|
||||
make exceptions for this. Our decision will be guided by the two goals
|
||||
of preserving the free status of all derivatives of our free software and
|
||||
of promoting the sharing and reuse of software generally.
|
||||
|
||||
NO WARRANTY
|
||||
|
||||
11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
|
||||
FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
|
||||
OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
|
||||
PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
|
||||
OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
|
||||
TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
|
||||
PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
|
||||
REPAIR OR CORRECTION.
|
||||
|
||||
12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
||||
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
|
||||
REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
|
||||
INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
|
||||
OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
|
||||
TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
|
||||
YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
|
||||
PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
|
||||
POSSIBILITY OF SUCH DAMAGES.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
How to Apply These Terms to Your New Programs
|
||||
|
||||
If you develop a new program, and you want it to be of the greatest
|
||||
possible use to the public, the best way to achieve this is to make it
|
||||
free software which everyone can redistribute and change under these terms.
|
||||
|
||||
To do so, attach the following notices to the program. It is safest
|
||||
to attach them to the start of each source file to most effectively
|
||||
convey the exclusion of warranty; and each file should have at least
|
||||
the "copyright" line and a pointer to where the full notice is found.
|
||||
|
||||
<one line to give the program's name and a brief idea of what it does.>
|
||||
Copyright (C) <year> <name of author>
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License along
|
||||
with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
|
||||
Also add information on how to contact you by electronic and paper mail.
|
||||
|
||||
If the program is interactive, make it output a short notice like this
|
||||
when it starts in an interactive mode:
|
||||
|
||||
Gnomovision version 69, Copyright (C) year name of author
|
||||
Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
|
||||
This is free software, and you are welcome to redistribute it
|
||||
under certain conditions; type `show c' for details.
|
||||
|
||||
The hypothetical commands `show w' and `show c' should show the appropriate
|
||||
parts of the General Public License. Of course, the commands you use may
|
||||
be called something other than `show w' and `show c'; they could even be
|
||||
mouse-clicks or menu items--whatever suits your program.
|
||||
|
||||
You should also get your employer (if you work as a programmer) or your
|
||||
school, if any, to sign a "copyright disclaimer" for the program, if
|
||||
necessary. Here is a sample; alter the names:
|
||||
|
||||
Yoyodyne, Inc., hereby disclaims all copyright interest in the program
|
||||
`Gnomovision' (which makes passes at compilers) written by James Hacker.
|
||||
|
||||
<signature of Ty Coon>, 1 April 1989
|
||||
Ty Coon, President of Vice
|
||||
|
||||
This General Public License does not permit incorporating your program into
|
||||
proprietary programs. If your program is a subroutine library, you may
|
||||
consider it more useful to permit linking proprietary applications with the
|
||||
library. If this is what you want to do, use the GNU Lesser General
|
||||
Public License instead of this License.
|
||||
Vendored
+25
@@ -0,0 +1,25 @@
|
||||
tap-windows6 license
|
||||
--------------------
|
||||
|
||||
The source and object code of the tap-windows6 project
|
||||
is Copyright (C) 2002-2014 OpenVPN Technologies, Inc. The
|
||||
NSIS installer is Copyright (C) 2014 OpenVPN Technologies,
|
||||
Inc. and (C) 2012 Alon Bar-Lev. The installer.dll MSI helper
|
||||
is Copyright (C) 2018-2019 WireGuard LLC. All are released
|
||||
under the GPL version 2. See COPYRIGHT.GPL for the full GPL
|
||||
license. The licensors also make the following statement
|
||||
borrowed from the SPICE project:
|
||||
|
||||
With respect to binaries built using the Microsoft(R)
|
||||
Windows Driver Kit (WDK), GPLv2 does not extend to any code
|
||||
contained in or derived from the WDK ("WDK Code"). As to
|
||||
WDK Code, by using or distributing such binaries you agree
|
||||
to be bound by the Microsoft Software License Terms for the
|
||||
WDK. All WDK Code is considered by the GPLv2 licensors to
|
||||
qualify for the special exception stated in section 3 of
|
||||
GPLv2 (commonly known as the system library exception).
|
||||
|
||||
The tap-windows.h file has been released under the MIT
|
||||
license (see COPYRIGHT.MIT) as well as under GPLv2 (see
|
||||
COPYRIGHT.GPL). This has been done to allow the use of the
|
||||
header file in non-GPLv2 compatible projects.
|
||||
Vendored
+13
@@ -0,0 +1,13 @@
|
||||
TAP-Windows driver installer
|
||||
|
||||
File: tap-windows-9.24.7-I601-Win10.exe
|
||||
Version: 9.24.7-I601
|
||||
Official source: https://build.openvpn.net/downloads/releases/tap-windows-9.24.7-I601-Win10.exe
|
||||
SHA-256: 1C44E77AB148DDFB174DE8041100EFC38C4F23500183FAFF88F9BADAC5782E3C
|
||||
|
||||
The installer is distributed unchanged from the official OpenVPN release
|
||||
directory. Windows may request administrator approval during installation.
|
||||
After installation completes, restart Super N2N so it can detect the adapter.
|
||||
|
||||
The TAP-Windows6 project is released under GPLv2. See LICENSE.txt for its
|
||||
license notice and COPYRIGHT.GPL.txt for the complete GPLv2 text.
|
||||
+1
@@ -0,0 +1 @@
|
||||
1C44E77AB148DDFB174DE8041100EFC38C4F23500183FAFF88F9BADAC5782E3C tap-windows-9.24.7-I601-Win10.exe
|
||||
Binary file not shown.
@@ -4,6 +4,14 @@ import react from '@vitejs/plugin-react'
|
||||
export default defineConfig({
|
||||
plugins: [react()],
|
||||
clearScreen: false,
|
||||
build: {
|
||||
rollupOptions: {
|
||||
input: {
|
||||
main: 'index.html',
|
||||
supernodeUsers: 'supernode-users.html',
|
||||
},
|
||||
},
|
||||
},
|
||||
server: {
|
||||
strictPort: true,
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user