66 Commits
Author SHA1 Message Date
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 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 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 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 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 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 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 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
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
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 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 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
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 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 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 6c9737f334 fix UDP based connections 2026-02-04 21:29:07 +08:00
Markson Hon aad7e17195 update daeuniverse/outbound 2026-02-04 21:11:26 +08:00
unknown-o afef751c18 feat: support custom tproxy direct ip 2025-11-05 20:08:10 +00:00
unknown-o 99bd664827 feat(backend): support setting tproxy white ip group 2025-11-05 16:30:24 +00:00
unknown-o bbc7e1c0ee feat(backend): suport download gfwlist form custom link 2025-02-09 01:54:15 +00:00
unknown-o 6cf02e4afb feat(backend): add delete gfwlist func 2025-02-09 00:51:44 +00:00
unknown-o a0c88bb57f feat(backend): add domain excluded setting 2025-02-07 06:00:23 +00:00
陈鼫RWHTYFZ 0459bad0f0 feat: 'testUrl' queryparam for api/httpLatency (#1193) 2023-12-02 15:20:24 +08:00
mzz 5c224d3674 fix: port occupation when latency test (#1058) 2023-08-31 23:36:08 +08:00
mzz2017 1b57d55739 fix: flow and xtls 2023-05-11 21:55:45 +08:00
mzz2017 1803403e0f fix: should connect instead of unselect and select when using xray 2023-03-30 21:20:08 +08:00
mzz2017 241f43deec feat: try to re-support xray 2023-03-18 18:14:56 +08:00
mzz2017 bcadc53dd3 optimize: increse concurrency of http latency test 2022-12-09 21:34:09 +08:00
mzz2017 dd5d10d22b optimize: rename /api/log to /api/logger to avoid ublock's blocking 2022-01-26 14:59:47 +08:00
mzz2017 3c41ca8361 feat: check sha256sum for geosite.dat and geoip.dat 2022-01-24 00:39:12 +08:00
高渐离 9c7b3ef4ef feat: add view log (#379) 2022-01-21 17:42:39 +08:00
mzz2017 403402f0d8 optimize: replace nutsdb with more stable boltdb 2021-10-01 23:56:41 +08:00
mzz2017 a2d0270af8 optimize: replace vlessGrpc inbound with vmess inbound 2021-09-29 17:23:13 +08:00
mzz2017 efd11d24fb feat: observatory window 2021-09-29 15:26:13 +08:00
mzz2017 50a870df96 feat(gui): support v5 and configure outbound 2021-09-28 21:54:22 +08:00
mzz2017 17297aafdd feat(service): bump to the version v5 of v2ray-core and support MultiObservatory 2021-09-28 20:37:13 +08:00
mzz2017 e3fb1331e6 feat(routingA): support hard code by environment variable 2021-09-27 16:31:42 +08:00
mzz2017 523445cf64 feat: update RoutingA to support "_" in name 2021-09-27 16:01:31 +08:00
mzz2017 d2831f6a4c fix: shadowsocks SIP002 sharing link 2021-09-23 22:29:36 +08:00
mzz2017 76e49263ad optimize: add checking for grpc support 2021-09-08 14:51:14 +08:00
mzz2017 69b2f8833f fix: http latency test would fail when v2ray with tproxy is running 2021-09-08 14:33:30 +08:00
mzz2017 e4dd0eaa76 refactor: server, subscription, api, plugin 2021-09-06 12:32:47 +08:00