183 Commits
Author SHA1 Message Date
Markson Hon 62114510d5 Merge pull request #1961 from Zakkaus/clash-subscription
feat(subscription): import Clash/mihomo YAML subscriptions
2026-09-18 07:20:01 +08:00
Zakk 5f51d588df refactor(connect): drop the dead v2fly-only branch
checkSupport stopped returning that error when the load-balancing restriction
was removed, so the branch that cleared the connections could not run.
2026-09-18 06:42:00 +10:00
Zakk bb1f79bb87 fix(api): stop reporting results as failures
Three endpoints answered FAIL for something the caller asked for and got:

- an up-to-date GFWList came back as "could not update GFWList: latest version
  is …. GFWList is up to date", because the check returned an error;
- deleting the GFWList when it was already gone returned the raw
  "remove …: no such file or directory";
- the update check said "failed to get latest version from Package file: 1".

The up-to-date case is now a sentinel error the controller turns into a
success carrying alreadyUpToDate, deleting what is already gone succeeds, and
the two package-index messages say what was missing. "which can not be nil"
also became a sentence about the request.
2026-09-18 06:38:52 +10:00
Zakk fac66e45c7 style(router): drop a stray blank line 2026-09-18 06:03:53 +10:00
Zakk 86e01d6176 feat(inbound): let a custom inbound require a username and password
A custom inbound port was open to anyone who could reach it, and older v2rayA
versions did offer authenticated inbounds, so users who relied on them had no
replacement (v2rayA/v2rayA discussions #1894, #1907).

CustomInbound carries optional credentials, which become the inbound's account
list. Half a credential pair is rejected: it would silently leave the port open.
2026-09-18 05:57:08 +10:00
Zakk 1ea77f236a fix(import): keep bare http proxy links importable without a kind field
A client that predates the kind field sends only the URL, so an http(s) link
had to be guessed. Guessing "subscription" is right for every address a
provider hands out, but it took away the bare proxy link 3fd0e882 had added:
credentials, host, port and nothing else cannot be a subscription address, so
that one shape goes back to the server importer.

Also let the config loader ignore every -test.* flag instead of only -test.v,
so the packages that reach it can run their tests at all.
2026-09-18 05:11:17 +10:00
Zakk 280710a319 fix(service): roll back custom inbounds, ip forwarding and report what was restored
Three gaps the settings rollback left open:

- adding or deleting a custom inbound stored the new list and then reloaded the
  core; a core that refused the list stayed stopped with the rejected inbound
  stored, so every later start failed too;
- a settings save that flipped ip forwarding left the kernel flag on the new
  value after the setting itself was rolled back, so the stored setting and the
  host disagreed;
- the rollback reported "the previous ones are back" even when restoring the
  setting or restarting the core had failed as well.

The session secret now retries persistence instead of accepting a failed store
for the life of the process, and an unreadable secret row is no longer
overwritten with a fresh one, which would have signed out every session.
2026-09-18 05:09:36 +10:00
Zakk 0005649661 fix(setting): keep the working setting and the core when a save is rejected
UpdateSetting stored the new setting before asking the core to reload it. When
the core refused the new config, the controller stopped the core and left the
rejected setting in the database, so the proxy was down and the next save
reported success while nothing was running.

Snapshot the setting before storing it, and on a reload failure put it back and
restart the core with it. The response now carries INVALID_CONFIG and the
reason the core gave.
2026-09-18 04:54:19 +10:00
Zakk aaeeb9307b feat(api): attach a machine-readable errorCode and params to FAIL responses
The GUI shows backend error text as is, so errors were never localized.
common.Coded wraps an error with a stable code and scalar parameters;
ResponseError adds "errorCode" and "params" next to the unchanged English
"message" when the chain carries one. Thirty-two user-facing errors are
coded (no server selected, core start failure, port occupied, malformed
link with protocol and detail, subscription fetch failure with host,
server/subscription not found with ids, bad request with the field,
credentials, session, admin, request in progress, GFW list missing,
invalid config, asset download, transparent setup, mux range, custom
inbound fields). logError now keeps the error chain instead of
flattening it. Messages, status codes and control flow are unchanged; the
two strings the GUI matches on stay as they are.

tools_test.go becomes an external test package so the common tests
compile again; its FillEmpty equality assertion, which never ran before,
is skipped with the reason.
2026-09-18 03:52:59 +10:00
Zakk a935c35304 fix(router): serve index.html with Cache-Control: no-cache
The entry page names hashed assets that disappear on every upgrade. It
was served with "public, must-revalidate" and no max-age, which browsers
may treat as heuristically fresh, so a cached copy loaded a bundle that no
longer existed and the GUI came up blank until a hard refresh. no-cache
forces revalidation; the ETag keeps it a 304.
2026-09-18 03:06:43 +10:00
Zakk ac79c92d6c fix(service): make API error messages say what was rejected and why
Errors that reach the GUI were written for the log: "ResolveURL failed:
invalid parameters", "httpGetUsingSpecificClient: response is nil",
"LocateServerRaw: invalid TYPE", "bad request", "illegal base64 data at
input byte 18". Reword the messages that can reach a user so each names
the input that was rejected (link scheme, missing password, port, server
id, request field), states the expected form for malformed input, drops
Go function names, keeps the %w chain so errors.Is/As still work, and
never echoes passwords, tokens or full share links (hosts only).
Messages the GUI string-matches ("invalid config", "the last request is
being processed") are unchanged.
2026-09-18 02:53:32 +10:00
Zakk 4ec09ea381 fix(service): subscription update, auto-select, latency test and port checks
UpdateSubscription snapshotted the whole subscription list before the
network fetch and wrote the stale struct back by index, reverting edits
made during the fetch; re-read the subscription afterwards and replace
only Servers, Status and Info. SelectServersFromSubscription disconnected
with clearOutbound=true per node, wiping every connection of the proxy
group and restarting the core once per node; it now removes only this
subscription's nodes in one replacement. The HTTP latency test bound its
per-node SOCKS inbounds on 0.0.0.0 without auth; bind loopback unless
PortSharing is on, and restore the previous core when the test core fails
to start. SetPorts skipped the API port and never range-checked; check all
six ports. Connect and ReplaceOutboundConnections treated an existing but
empty previous list as something to restore, which OverwriteConnects
turns into a no-op, so a failed selection stayed persisted; clear the
group in that case.
2026-09-18 02:53:32 +10:00
Zakk ea21c45bae fix(controller): validate custom inbound ports and reload the core after changes
Adding or deleting a custom inbound only wrote the database: the running
core kept its old inbounds until the next unrelated restart, and a port
that collided with the configured socks5/http/pac/vmess/api ports was
accepted and broke the next core start. Reject out-of-range and colliding
ports with a message naming the port, and regenerate the config when the
core is running.
2026-09-18 02:53:31 +10:00
Zakk fc9907a6bf fix(serverObj): read the parameters the GUI emits for tuic and trojan links
ParseTuicURL read the certificate pin and name verification only as
pinnedPeerCertSha256/verifyPeerCertByName while the GUI form and other
clients emit pinned_peer_cert_sha256/verify_peer_cert_by_name, so a pin
typed into the form was dropped. ParseTrojanURL read host only for the
trojan-go scheme although ConfigurationMC uses it as the WebSocket Host
header for plain trojan as well.

ImportSubscription redeclared err with := inside the block, so a failure
of AppendSubscriptions was assigned to the shadow and the function
returned nil.
2026-09-18 02:53:31 +10:00
Zakk 5991e557fd fix(setting): keep stored values for fields the client omits
PutSetting decoded the request into a zero Setting and persisted the whole
struct, so the fields the settings dialog never sends (dnsCacheEnabled,
dnsPrefetch, dnsNegativeCache, the per-protocol backends) were saved as
false or empty on the first Save and the DNS cache silently switched off
with no control in the GUI to switch it back. Decode over the stored
setting so absent fields keep their value.
2026-09-18 02:53:31 +10:00
Zakk a2dca405c0 fix(touch): copy the connected list before editing it during deletion
DeleteWhich walked cssRaw.Get() while removing entries from cssAfter,
which was the same slice header over the same backing array. After a
non-tail removal the next touch saw the shifted list with a stale
duplicate at the end: the same Which pointer was decremented twice or
Disconnect ran on it, and cssAfter[:i] with the old length panicked with
slice bounds out of range. Work on a copy and iterate that copy.
2026-09-18 02:53:31 +10:00
Zakk 1d219d5794 fix(import): edit a subscription node inside its subscription
Import accepted which.TYPE == subscriptionServer for a modification but
then called configure.SetServer(ind), which replaces the standalone
server at that index; the subscription node itself stayed unchanged and
an unrelated server was overwritten. Write the node back through
SetSubscription with bounds checks on sub and index.
2026-09-18 02:53:31 +10:00
Zakk 262c56009e fix(service): guard crashes and silent data loss found in the sweep
- time.Ticker.Reset panics on a non-positive duration; a stored auto-update
  interval of 0 crashed every start (pre_update.go) and every settings
  save. Route both tickers through configure.IntervalHours, which falls
  back to one hour.
- The auto-updater indexes a startup snapshot; a subscription deleted
  while it runs panicked out of range in a goroutine and took the daemon
  down. UpdateSubscription now refuses an index that no longer exists.
- ResolveSubscriptionWithClient applied its 30 s timeout floor to a copy
  it never used, accepted HTTP error pages as an empty node list, and
  returned zero nodes without error, so UpdateSubscription replaced the
  stored list with nothing on a provider 403/5xx. Use the copy, reject
  status >= 400 and empty results.
- PutOutbound wrote an error response and then fell through to the
  success response, producing two JSON bodies.
- TestHttpLatency passed nil entries (servers it could not locate) to
  addHosts, which dereferenced them; skip them.
- ReqCache read the per-request mutex map after releasing the lock that
  guards writes to it (a fatal concurrent map access under load).
- The websocket writer ran one goroutine per message box on a single
  gorilla connection, which forbids concurrent writes; serialize them.
2026-09-18 02:53:31 +10:00
Zakk c5c169682e fix(connect): validate the selection before storing it and roll back on failure
Connect stored the requested Which with AddConnect before generating the
core config. A request whose body did not bind to a valid selection (empty
_type, out-of-range id) was persisted anyway; UpdateV2RayConfig then
failed with "LocateServerRaw: invalid TYPE", and because the deferred
restore ran only while the core was running, and only when the group had
a previous list, the bad entry stayed in the database and every later
connect and core start failed with the same error.

Locate the server first and refuse anything that cannot be found, and on
failure restore the previous list (or clear the group when there was
none) regardless of whether the core runs.
2026-09-18 02:53:31 +10:00
Zakk 9bb5ffbaef feat(import): let the client say whether it imports a server or a subscription
Import guessed from the URL scheme. Commit 3fd0e882 added http and https
to the server prefixes so that http proxy nodes were not stored as
subscriptions, and from then on every http(s) subscription address was
parsed as a proxy node and failed with "ResolveURL failed: invalid
parameters".

POST /api/import now takes "kind": "server" or "subscription". Import is
split into ImportServer and ImportSubscription; the old scheme-guessing
Import remains for requests without kind, with http and https back on
the subscription side as before 3fd0e882. The v4 migration calls the
explicit functions since it knows which list each address came from.
The GUI side (a server link / subscription address toggle that sends
kind) is in the gui branch.
2026-09-18 02:53:30 +10:00
Zakk cc795ace2e feat(subscription): import Clash/mihomo YAML subscriptions
A subscription that serves a Clash config went through the line parser,
which picked up a stray URL from the rules and produced a "successful"
subscription holding one bogus http node. Detect a YAML body with a
proxies list and map each proxy onto the share link v2rayA already parses
for its type: anytls, trojan, vless, vmess, ss (obfs and v2ray-plugin),
ssr, hysteria2, tuic, socks5 and http. Unsupported types are counted in
the log; a config with no usable proxy fails the import instead of
storing an empty subscription.
2026-09-18 01:24:03 +10:00
Markson Pigeonzilla Plus 3fd0e88222 fix(import): treat http(s) links as server links instead of subscriptions
Add 'http' and 'https' to supported prefixes in Import() so HTTP/HTTPS links are recognized as server links rather than subscriptions. Prevents single http://... nodes from being stored as subscriptions.
2026-09-12 17:34:06 +08:00
Markson Pigeonzilla Plus 06273efcc1 fix: cert chain sha256 not applied of juicity 2026-08-11 20:26:49 +08:00
Xing Shi CaiandClaude Fable 5 106fbbd519 🐛 (subscription): Remap connected server by unique name when IP rotates
- Providers like Just My Socks keep node names and credentials stable but rotate IPs, which defeats the endpoint match; fall back to name matching guarded by name uniqueness on both sides

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-23 08:48:27 +08:00
Xing Shi CaiandClaude Fable 5 031e664bf2 🐛 (subscription): Remap connected server by endpoint on update
- Fall back to protocol+host:port matching when the exact share URL no longer matches (providers rename nodes on refresh)

- Reload the running core after a remap so the new server config takes effect immediately

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-22 10:03:05 +08:00
Markson Joe Hon eef675f5f9 fix: persist kernel exit status across restarts and fix geosite DNS resolution
core: fix geosite.dat parsing in DNS resolver
- Replace broken GeoSiteList unmarshal with correct varint-length-delimited
  stream parser matching xray-core's format
- Add result caching to avoid re-reading the file per tag expansion

service: persist kernel exit status for proper state restoration
- Add LastKernelExitStatus (running/stopped/crashed) to DB
- Set 'running' on graceful shutdown while kernel is active so it
  is automatically restored on next startup
- Set 'stopped' when user explicitly stops the kernel via API
- Set 'crashed' when the kernel exits unexpectedly
- Check saved status at startup and log appropriate messages
- Expose lastKernelExit field via GET /api/version for the frontend
2026-07-02 13:51:44 +08:00
Markson Joe Hon 47f1462baf feat: init a new for v2raya core and fix a firewall mistake 2026-07-02 13:10:12 +08:00
yuexps 024e764313 feat(server/gui): add Unix Domain Socket and BaseUrl support for FnOS & reverse proxies 2026-06-28 20:40:07 +08:00
Markson Pigeonzilla Plus bf8aa12ace service: drop ngui and drop v2ray/xray check 2026-06-26 10:07:43 +08:00
Markson Pigeonzilla Plus ff6bf0a43d Remove v2ray/xray core version detection and comparison logic
Since v2rayA now exclusively uses the v2raya_core binary, simplify or
remove all logic that detected, compared, or branched on different
core types (v2ray, xray, merged).

- Remove CheckCoreVersion, CoreVersionMismatchError, and the
  CoreVersion check in StartCoreProcess — core v2raya version
  comparison is no longer needed.

- Remove DetectCoreTypeByBinaryName and the Unknown/V2ray/Xray/Merged
  variant aliases. The only remaining Variant constant is V2rayaCore.

- Simplify GetV2rayServiceVersion: drop all CoreType/env-config
  detection and variant mismatch verification. The function always
  returns V2rayaCore and the version string from the binary.

- Simplify CheckV5 / isVersionSatisfied to return only an error,
  dropping the unused Variant return value.

- Remove variant-branching in Shadowsocks and Trojan Configuration
  methods — both always use the MT (Xray-compatible) path.

- Remove the CheckCoreVersion call from version.go and hardcode
  coreVersionValid/ variant in the API response.

- Drop the now-unused where import from shadowsocks.go and trojan.go.
2026-06-26 09:44:14 +08:00
Markson Pigeonzilla a30c757d07 fix(service): reduce lock contention, improve Windows resilience, fix TinyTun races
ProcessManager.Start() now runs resolv/GFWList checks before acquiring
m.mu and defers afterStart (transparent-proxy setup, DNS, TinyTun,
post-start hook) to after the lock is released, eliminating multi-second
lock holds caused by DNS lookups and external hook commands.

TinyTun:
- Fix cancel/stopping ordering race in startTinyTun: assign the new
  cancel func before clearing the stopping flag so a concurrent
  stopTinyTun always sees the correct cancel
- Resolve proxy-node hostnames concurrently with sync.WaitGroup instead
  of sequentially, reducing config-generation latency
- stopTinyTun now waits up to 5 s for the process to exit via a done
  channel closed by the monitor goroutine after cmd.Wait() returns

Windows service lifecycle:
- cleanupResources enforces a 30 s hard timeout and adds panic recovery
- HTTP router is shut down before the core process on service stop
- router.Run uses an explicit http.Server + Shutdown() for graceful teardown

Connectivity monitor:
- Extend startup grace period to 15 s on Windows (5 s elsewhere)
- Replace fixed 30 s re-check ticker with exponential back-off (30/60/120 s)
- Probe TinyTun availability via TCP dial to the SOCKS5 port instead of HTTP

Platform guards:
- resolv.CheckResolvConf/WriteResolvConf: no-op on non-Linux
- DNS-hijack operations (NewResolvHijacker, HijackResolv, etc.): Linux-only
2026-05-22 15:50:14 +08:00
Markson Hon 72dad35557 feat(service): pause transparent proxy on network loss and report state 2026-05-11 23:38:32 +08:00
Markson Hon 5a3a44b65b feat: add custom inbound-to-outbound binding with per-inbound routing rules 2026-05-11 23:38:32 +08:00
Markson Hon 1d39ea65ca fix(router): harden embedded statigz route registration
Add a safe statigz handler wrapper that validates fs roots and recovers from FileServer initialization panics.\n\nUse a generic embedded route registrar for /static and /_nuxt with fallback candidates, so both gui and ngui layouts avoid startup panic: open .: file does not exist.
2026-05-05 11:39:02 +08:00
Markson Hon 72c73687f0 fix: prevent panic when _nuxt directory does not exist in embed FS
- Wrap /_nuxt/* route registration in fs.Sub() error check
- When _nuxt directory is absent (gui build without ngui),
  skip route registration entirely instead of passing an invalid
  FS to statigz.FileServer which caused panic on Open('.')
2026-05-05 11:20:29 +08:00
Markson Hon b94cb0bb2b feat: add build-with-ngui scripts and serve _nuxt/ routes
- Add build-with-ngui.sh (Linux) and build-with-ngui.ps1 (Windows)
  using pnpm + nuxt generate for ngui frontend
- Configure nuxt.config.ts with nitro.output.publicDir pointing to
  service/server/router/web/ for go:embed compatibility
- Add /_nuxt/* route in ServeGUI() to serve Nuxt 3 static assets
  alongside existing /static/* route
- Both build systems coexist: build.sh for gui, build-with-ngui.sh for
  ngui, Go router handles both
2026-05-05 09:34:55 +08:00
Markson Hon 487c511062 feat: support WebSocket Early Data, gRPC MultiMode and WireGuard protocol
- Add MaxEarlyData and EarlyDataHeaderName fields to WsSettings for WebSocket Early Data support
- Add MultiMode, IdleTimeout, HealthCheckTimeout, PermitWithoutStream, InitialWindowsSize fields to GrpcSettings
- Add WireGuardSettings and WireGuardPeer structs for WireGuard outbound configuration
- Add wireguard to supported import protocol prefixes
- Parse and export WebSocket Early Data and gRPC MultiMode parameters in V2Ray server object
2026-05-04 21:32:36 +08:00
Markson Hon fd7162e88f feat(service): add custom inbound APIs and strengthen outbound/account flows 2026-05-04 19:07:22 +08:00
Markson Hon 56c1f8fbfd try to mix cores 2026-05-02 11:58:21 +08:00
Markson Hon f94a350188 gui: use vite to build web 2026-04-14 17:33:04 +08:00
ed00d75423 feat(server): finish TinyTun rollout and backend selection
Squashed from:
- c3e8b07f feat: add GET /api/networkInterfaces controller
- 10a5dc38 try to fix null pointer
- 4fa3e6c7 Merge branch 'v2rayA:main' into main
- 5e0457e7 tun: use tinytun v0.0.1-beta.4
- ce4bfa34 shadowsocks and trojan backend choosen

Co-authored-by: Markson Pigeonzilla <marksonpigeonzilla@bugdows.cn>
Co-authored-by: Markson Hon <50002150+MarksonHon@users.noreply.github.com>
2026-03-21 15:02:13 +08:00
89aca5911c feat(tun): migrate transparent proxy from Sing-Tun to TinyTun
Squashed from:
- bc2e2215 Remove all Sing-Tun related code, frontend and build tags
- 51c11701 Add TinyTun support for TUN-based transparent proxy
- d203a9e9 Add TinyTun auto_route toggle and custom route script dialog
- 4c67a319 Improve UI consistency and add tinytun build tag
- 6e411be6 use TinyTun instead of SIng-Tun

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: Markson Hon <50002150+MarksonHon@users.noreply.github.com>
2026-03-21 15:01:17 +08:00
Markson PigeonzillaandMarkson Hon 608b44e2f8 fix(windows): carry forward env, startup, and legacy TUN follow-ups
Squashed from:
- 856a3730 ci: update go to 1.26
- 191be38f tun: fix IPv6 address under win
- 3ca4d5cd windows: v2rayA should read win env like %temp%
- 48a84438 windows: v2rayA should start after modified PATH
- c87bbf62 fix .exe ext-name under windows
- 614bfe1c dns: fix a error about dns format
- 991319ff pre.go: don't create C:\etc
- 9f31b39c translated all comments to English
- aaa269f7 try to fix Tun DNS
- 25c84ad9 面向云代理会话的 VS Code 中的检查点

Co-authored-by: Markson Hon <markson@nixos.local>
2026-03-21 15:00:28 +08:00
Markson HonandMarkson Pigeonzilla fe54c20e54 refactor(tun): modernize legacy route handling and DNS plumbing
Squashed from:
- ede4275e tun: better OS command
- 6a30c17c Tun: better route command
- 4b0f8e94 dns: rewrite DNS module

Co-authored-by: Markson Pigeonzilla <marksonpigeonzilla@bugdows.cn>
2026-03-21 14:59:01 +08:00
Markson Pigeonzilla fb3be4a454 tun: DNS shoud NOT be looped 2026-02-17 15:05:57 +08:00
Markson Pigeonzilla 7ea3024c95 gui: better log 2026-02-14 22:25:31 +08:00
Markson Pigeonzilla 4eb2807de7 service: better user account check under Windows 2026-02-12 20:19:07 +08:00
Markson Pigeonzilla ba2c2fb0c1 Add xray mutli-server support 2026-02-05 18:10:05 +08:00
Markson Hon e1d30ff924 renove PingTunnel and fix ALPN of tuic 2026-02-04 23:05:56 +08:00
Markson Hon c69f74da2d fix non-v2ray-based links creations and edit 2026-02-04 21:48:30 +08:00