Skip to content

Commit 7f8982f

Browse files
XrayFluent Devclaude
andcommitted
fix: TUN stability, IPv6 blackhole, status notifications, data preservation
- IPv6 blackhole route while TUN active (fixes BBC static CDN) - LAN bypass routes (fixes DHCP loss / internet drop) - Status notifications at every TUN stage - Log throttling for xhttp flood connections - Hot-swap keeps HTTP inbound alive for browser proxy extensions - build_dist3.sh with data backup/restore - Block LAN/broadcast in xray routing rules - Updated CLAUDE.md: always use subagents rule Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 626bb17 commit 7f8982f

18 files changed

Lines changed: 68856 additions & 13 deletions

CLAUDE.md

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,12 +67,22 @@ All traffic → TUN (tun2socks/wintun) → xray SOCKS:10808 → proxy server
6767
- `core/` — xray, sing-box, tun2socks, wintun.dll binaries
6868
- `build.py` — PyInstaller build script with data/ backup/restore
6969

70+
## Build for dist3 (dev)
71+
72+
```bash
73+
bash build_dist3.sh
74+
```
75+
76+
This backs up data/ before build and restores after — preserving nodes and settings.
77+
7078
## Key conventions
7179

80+
- **Always use subagents (5+)** for codebase exploration, bug investigation, and research. Never solo-explore large codebases.
7281
- Use stock `qfluentwidgets` components over custom card classes
7382
- Keep page surfaces transparent for Windows 11 Mica effect
7483
- Node switching uses deferred `QTimer.singleShot(0, ...)` to avoid UI freezes
7584
- In TUN mode, use hot-swap (restart xray only) instead of full reconnect
7685
- System proxy always disabled on exit (atexit handler in main.py)
77-
- Use subagents (5+) for thorough codebase analysis
86+
- Show status notifications at every TUN stage (starting, xray ok, TUN creating, connected, error)
87+
- Throttle xray "accepted" logs in TUN mode to prevent UI freeze
7888
- venv is at `.venv/`, created by `setup.bat`

README.md

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
# Xray Fluent GUI (PyQt6 + Fluent Widgets)
2+
3+
Windows-focused GUI shell for `xray.exe` with a Windows 11-like Fluent interface.
4+
5+
## What is included in this MVP
6+
7+
- Fast node import from clipboard (`vless://`, `vmess://`, `trojan://`, `ss://`, `socks://`, `http://`, raw outbound JSON)
8+
- Quick switch between nodes (Dashboard + system tray)
9+
- Start/stop Xray core directly (`core/xray.exe`)
10+
- System proxy mode (HTTP + SOCKS loopback)
11+
- Routing modes: `Global`, `Rule`, `Direct`
12+
- Basic routing editor (direct/proxy/block lists)
13+
- TCP ping for nodes
14+
- Real connectivity test through Xray proxy
15+
- Live mini-metrics on Dashboard (download/upload rate + RTT)
16+
- Export selected outbound JSON and full runtime `xray_config.json`
17+
- Runtime logs, diagnostics export (ZIP with redacted config)
18+
- Separate Xray core updater with channels (`stable`, `beta`, `nightly`)
19+
- DPAPI-encrypted local state storage
20+
- Master password + auto-lock
21+
- Light / dark / system theme and accent color
22+
23+
## Project layout
24+
25+
- `main.py` - app entrypoint
26+
- `xray_fluent/app_controller.py` - app orchestration
27+
- `xray_fluent/link_parser.py` - URI parser
28+
- `xray_fluent/config_builder.py` - Xray config generator
29+
- `xray_fluent/xray_manager.py` - process lifecycle
30+
- `xray_fluent/proxy_manager.py` - Windows system proxy
31+
- `xray_fluent/ui/` - all Fluent UI pages
32+
- `core/` - Xray core binaries
33+
34+
## Requirements
35+
36+
- Windows 10/11 x64
37+
- Python 3.13
38+
39+
Install deps:
40+
41+
```bash
42+
python -m pip install -r requirements.txt
43+
```
44+
45+
If `qfluentwidgets` is not in your Python env, install it explicitly:
46+
47+
`python -m pip install PyQt6-Fluent-Widgets`
48+
49+
## Run
50+
51+
```bash
52+
python main.py
53+
```
54+
55+
Start minimized to tray:
56+
57+
```bash
58+
python main.py --minimized
59+
```
60+
61+
## Build portable EXE (PyInstaller)
62+
63+
```powershell
64+
./build_portable.ps1
65+
```
66+
67+
Output:
68+
69+
- `dist/XrayFluent/` - portable folder
70+
- `dist/XrayFluent-portable.zip` - zipped portable bundle
71+
72+
## Notes
73+
74+
- No TUN mode in this version (system proxy only)
75+
- Subscription URLs are intentionally not implemented yet
76+
- App update feed and Xray core feed can be configured separately in Settings

build_dist3.sh

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
#!/bin/bash
2+
# Build XrayFluent to dist3 with data preservation
3+
set -e
4+
5+
cd "G:/bin/Xray-windows-64"
6+
7+
# Kill processes
8+
wmic process where "name='XrayFluent.exe'" call terminate 2>/dev/null || true
9+
wmic process where "name='tun2socks.exe'" call terminate 2>/dev/null || true
10+
wmic process where "name='xray.exe'" call terminate 2>/dev/null || true
11+
sleep 3
12+
13+
# Backup data from dist3 if exists
14+
if [ -d "dist3/XrayFluent/data" ]; then
15+
rm -rf dist3/_data_backup 2>/dev/null
16+
cp -r dist3/XrayFluent/data dist3/_data_backup
17+
echo "Backed up dist3 data"
18+
fi
19+
20+
# Clean and build
21+
rm -rf dist3/XrayFluent 2>/dev/null
22+
.venv/Scripts/python -m PyInstaller main.py --name XrayFluent --distpath dist3 \
23+
--noconfirm --console --onedir --uac-admin --manifest uac_admin.manifest \
24+
--hidden-import win32comext --hidden-import win32comext.shell --hidden-import win32comext.shell.shellcon
25+
26+
# Copy core
27+
cp -r core dist3/XrayFluent/
28+
29+
# Restore data
30+
if [ -d "dist3/_data_backup" ]; then
31+
cp -r dist3/_data_backup dist3/XrayFluent/data
32+
echo "Restored dist3 data"
33+
elif [ -d "dist/_data_backup" ]; then
34+
cp -r dist/_data_backup dist3/XrayFluent/data
35+
echo "Copied data from dist backup"
36+
fi
37+
38+
ls dist3/XrayFluent/XrayFluent.exe && echo "BUILD OK"

build_portable.ps1

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
$ErrorActionPreference = "Stop"
2+
3+
$venvPython = Join-Path $PSScriptRoot ".venv\Scripts\python.exe"
4+
5+
if (-not (Test-Path $venvPython)) {
6+
Write-Error "Virtual environment not found. Run setup.bat first."
7+
exit 1
8+
}
9+
10+
& $venvPython -m PyInstaller main.py `
11+
--name XrayFluent `
12+
--noconfirm `
13+
--clean `
14+
--noconsole `
15+
--onedir `
16+
--uac-admin `
17+
--manifest uac_admin.manifest `
18+
--hidden-import win32comext `
19+
--hidden-import win32comext.shell `
20+
--hidden-import win32comext.shell.shellcon
21+
22+
Copy-Item -Path ".\core" -Destination ".\dist\XrayFluent\core" -Recurse -Force
23+
24+
$zipPath = ".\dist\XrayFluent-portable.zip"
25+
if (Test-Path $zipPath) {
26+
Remove-Item $zipPath -Force
27+
}
28+
29+
Compress-Archive -Path ".\dist\XrayFluent\*" -DestinationPath $zipPath
30+
Write-Host "Portable build created: $zipPath"

core/LICENSE

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
Copyright (C) 2022 by nekohasekai <contact-sagernet@sekai.icu>
2+
3+
This program is free software: you can redistribute it and/or modify
4+
it under the terms of the GNU General Public License as published by
5+
the Free Software Foundation, either version 3 of the License, or
6+
(at your option) any later version.
7+
8+
This program is distributed in the hope that it will be useful,
9+
but WITHOUT ANY WARRANTY; without even the implied warranty of
10+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11+
GNU General Public License for more details.
12+
13+
You should have received a copy of the GNU General Public License
14+
along with this program. If not, see <http://www.gnu.org/licenses/>.
15+
16+
In addition, no derivative work may use the name or imply association
17+
with this application without prior consent.

core/LICENSE-wintun.txt

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
Prebuilt Binaries License
2+
-------------------------
3+
4+
1. DEFINITIONS. "Software" means the precise contents of the "wintun.dll"
5+
files that are included in the .zip file that contains this document as
6+
downloaded from wintun.net/builds.
7+
8+
2. LICENSE GRANT. WireGuard LLC grants to you a non-exclusive and
9+
non-transferable right to use Software for lawful purposes under certain
10+
obligations and limited rights as set forth in this agreement.
11+
12+
3. RESTRICTIONS. Software is owned and copyrighted by WireGuard LLC. It is
13+
licensed, not sold. Title to Software and all associated intellectual
14+
property rights are retained by WireGuard. You must not:
15+
a. reverse engineer, decompile, disassemble, extract from, or otherwise
16+
modify the Software;
17+
b. modify or create derivative work based upon Software in whole or in
18+
parts, except insofar as only the API interfaces of the "wintun.h" file
19+
distributed alongside the Software (the "Permitted API") are used;
20+
c. remove any proprietary notices, labels, or copyrights from the Software;
21+
d. resell, redistribute, lease, rent, transfer, sublicense, or otherwise
22+
transfer rights of the Software without the prior written consent of
23+
WireGuard LLC, except insofar as the Software is distributed alongside
24+
other software that uses the Software only via the Permitted API;
25+
e. use the name of WireGuard LLC, the WireGuard project, the Wintun
26+
project, or the names of its contributors to endorse or promote products
27+
derived from the Software without specific prior written consent.
28+
29+
4. LIMITED WARRANTY. THE SOFTWARE IS PROVIDED "AS IS" AND WITHOUT WARRANTY OF
30+
ANY KIND. WIREGUARD LLC HEREBY EXCLUDES AND DISCLAIMS ALL IMPLIED OR
31+
STATUTORY WARRANTIES, INCLUDING ANY WARRANTIES OF MERCHANTABILITY, FITNESS
32+
FOR A PARTICULAR PURPOSE, QUALITY, NON-INFRINGEMENT, TITLE, RESULTS,
33+
EFFORTS, OR QUIET ENJOYMENT. THERE IS NO WARRANTY THAT THE PRODUCT WILL BE
34+
ERROR-FREE OR WILL FUNCTION WITHOUT INTERRUPTION. YOU ASSUME THE ENTIRE
35+
RISK FOR THE RESULTS OBTAINED USING THE PRODUCT. TO THE EXTENT THAT
36+
WIREGUARD LLC MAY NOT DISCLAIM ANY WARRANTY AS A MATTER OF APPLICABLE LAW,
37+
THE SCOPE AND DURATION OF SUCH WARRANTY WILL BE THE MINIMUM PERMITTED UNDER
38+
SUCH LAW. ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND
39+
WARRANTIES, INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR
40+
A PARTICULAR PURPOSE OR NON-INFRINGEMENT ARE DISCLAIMED, EXCEPT TO THE
41+
EXTENT THAT THESE DISCLAIMERS ARE HELD TO BE LEGALLY INVALID.
42+
43+
5. LIMITATION OF LIABILITY. To the extent not prohibited by law, in no event
44+
WireGuard LLC or any third-party-developer will be liable for any lost
45+
revenue, profit or data or for special, indirect, consequential, incidental
46+
or punitive damages, however caused regardless of the theory of liability,
47+
arising out of or related to the use of or inability to use Software, even
48+
if WireGuard LLC has been advised of the possibility of such damages.
49+
Solely you are responsible for determining the appropriateness of using
50+
Software and accept full responsibility for all risks associated with its
51+
exercise of rights under this agreement, including but not limited to the
52+
risks and costs of program errors, compliance with applicable laws, damage
53+
to or loss of data, programs or equipment, and unavailability or
54+
interruption of operations. The foregoing limitations will apply even if
55+
the above stated warranty fails of its essential purpose. You acknowledge,
56+
that it is in the nature of software that software is complex and not
57+
completely free of errors. In no event shall WireGuard LLC or any
58+
third-party-developer be liable to you under any theory for any damages
59+
suffered by you or any user of Software or for any special, incidental,
60+
indirect, consequential or similar damages (including without limitation
61+
damages for loss of business profits, business interruption, loss of
62+
business information or any other pecuniary loss) arising out of the use or
63+
inability to use Software, even if WireGuard LLC has been advised of the
64+
possibility of such damages and regardless of the legal or quitable theory
65+
(contract, tort, or otherwise) upon which the claim is based.
66+
67+
6. TERMINATION. This agreement is affected until terminated. You may
68+
terminate this agreement at any time. This agreement will terminate
69+
immediately without notice from WireGuard LLC if you fail to comply with
70+
the terms and conditions of this agreement. Upon termination, you must
71+
delete Software and all copies of Software and cease all forms of
72+
distribution of Software.
73+
74+
7. SEVERABILITY. If any provision of this agreement is held to be
75+
unenforceable, this agreement will remain in effect with the provision
76+
omitted, unless omission would frustrate the intent of the parties, in
77+
which case this agreement will immediately terminate.
78+
79+
8. RESERVATION OF RIGHTS. All rights not expressly granted in this agreement
80+
are reserved by WireGuard LLC. For example, WireGuard LLC reserves the
81+
right at any time to cease development of Software, to alter distribution
82+
details, features, specifications, capabilities, functions, licensing
83+
terms, release dates, APIs, ABIs, general availability, or other
84+
characteristics of the Software.

0 commit comments

Comments
 (0)