115 Commits
Author SHA1 Message Date
Zakk fd2981c998 Merge pull request #2132 from wywywywycloud/fix/geoip-cache-generation
fix: discard obsolete GeoIP cache generations
2026-11-20 18:01:06 +11:00
Zakk 7b4ad06e75 fix: reach the core's proxy ports on loopback inside Docker
In Docker, subscription and RoutingA updates through the core dialled
the default gateway instead of 127.0.0.1, a leftover from when the core
ran outside v2rayA's container. The core now runs in v2rayA's own
network namespace and, unless port sharing is on, listens on 127.0.0.1
only. With host networking the gateway is the LAN router, and on a
bridge network the request only came back to the container when port
sharing was on and the port was published, so updates in the "proxy"
and "port rules" modes failed with connection refused.

Fixes #2139
2026-11-17 23:11:30 +11:00
Mikhail Levin aab11c05a5 feat: add per-subscription update policies and explicit recovery consent 2026-11-15 14:56:04 +03:00
Mikhail Levin d3a8f97940 fix: discard obsolete GeoIP cache generations 2026-11-15 07:03:50 +03:00
Markson GuGa Beyond 5506fe1c86 test: fix the Windows socket-option readback
getsockopt(IP_UNICAST_IF) hands the interface index back in host order while
setsockopt wants it in network byte order, so the second swap in
boundProbeInterface compared 0x01000000 against 1 and the IPv4 cases of
TestBoundDirectDialerSocketOptions failed on Windows.
2026-09-29 19:39:10 +08:00
Mikhail Levin cef8fbc939 fix: bind dashboard probes to TUN egress on macOS and Windows 2026-09-25 21:34:00 +03:00
Mikhail Levin fd7a587dc2 fix: keep interception during dashboard TCP probes 2026-09-25 16:12:43 +03:00
Zakk 8b818ffc41 fix(iptables): match the transparent-proxy whitelist with ipset
The iptables path wrote each whitelisted CIDR with its own iptables
process. With the mainland China group (about 15,000 CIDRs) a core start
spent minutes on this, and every packet of a direct connection walked
the list linearly.

Load each family into one hash:net set with a single `ipset restore` and
match it with one rule at the old position. Without ipset, write the
rules with one `iptables-restore --noflush` per family; without that,
keep the per-rule commands. Cleanup destroys the sets.
2026-09-24 01:23:08 +10:00
Zakk 0872d7db62 chore: remove what nothing uses any more
copyfile, the empty ports/ss.go stub, parseDnsAddr and DnsRouting (the DNS
config is generated for the core's module now), the Inter font and the
switch-menu icon of the old GUI, the docs-site dispatch workflow (the site is
retired; the docs are in the app), the unused v2ray_arch in the docker helper,
the root .gitignore rule for a web directory that moved, and the .dockerignore
patterns for binary and test names that no longer exist. The skipped
TestFillEmpty asserts what FillEmpty does instead of what it once did.
2026-09-21 12:44:14 +10:00
Zakk 74277851bb fix(dns): the service, the module's bootstrap and the hijacked resolv.conf follow the DNS rules' direct upstreams
Node hostnames, upstream hostnames and the service's own lookups (subscriptions,
latency tests) were resolved by hard-coded public resolvers (223.5.5.5, 119.29.29.29,
...) whatever the DNS rules said; the second nameserver written into the hijacked
/etc/resolv.conf was hard-coded too. directDnsServers() now collects the plain
udp/tcp IP upstreams of the rules with the direct outbound, and

- resolv.PreferredServers hands them to the service's resolver before its public list
- the module's bootstrap_dns is the system's resolvers plus those upstreams
- the upstream for node hostnames is the first of them
- HijackResolv writes the first port-53 one as the second nameserver, and so does the
  restore when no backup exists

getSystemDnsServers reads the backup while resolv.conf is hijacked, so a restart
no longer hands the module its own listener as bootstrap.
2026-09-20 23:23:08 +10:00
Zakk 833af7dc74 refactor: use what the dependencies already provide
A read of the tree for home-grown code that a dependency or the platform
covers. Each item names what replaces it.

- IPv4 CIDR membership was a binary-string trie (infra/dataStructure/trie)
  fed with CIDRs rendered as bit strings; net.IPNet.Contains, which the
  same file already used for IPv6, does it. The trie package is gone.
- The response replay cache was an LRU with its own linked list, indexes
  and timeout strategy (infra/dataStructure/lru), of which one fixed-size
  instance existed; hashicorp/golang-lru/v2, already in go.mod, is that
  cache, typed. go mod tidy also dropped go-nanoid, which nothing imported.
- The HTTP client for subscription updates through the local proxy carried
  a CONNECT dialer of its own (pkg/util/proxyWithHttp); http.Transport's
  Proxy handles socks5:// and http:// URLs, resolves hostnames on the
  SOCKS proxy and uses CONNECT for https. Verified on the VM: a
  subscription update succeeds in both "pac" and "proxy" modes.
- core/dns/qtype.go listed nine type names in two switches before falling
  back to miekg/dns tables that contain the same names; dns.Type.String
  and dns.StringToType are the tables.
- The GUI tracked prefers-color-scheme with its own media query and
  toggled a theme-dark class nothing reads any more; Vuetify's "system"
  theme follows the OS itself. Verified in headless Chrome: auto follows
  the OS in both directions, an explicit choice overrides it.
- The AUR packages carried .INSTALL hooks whose only content was a
  coloured "Completed!" banner, duplicated in the deb/rpm after-install
  scripts; pacman and apt report that themselves. The hooks are gone, the
  release workflow stops copying them, and after_install/after_upgrade
  keep only daemon-reload and the restart.
- The tap release job downloaded eight artifacts in eight steps;
  actions/download-artifact takes a pattern with merge-multiple.
2026-09-20 16:40:34 +10:00
Zakk ad509ce51b fix(service): the confirmed findings of four independent backend scans
A custom latency test URL that http.NewRequest rejects made a spawned
goroutine dereference nil and exit the process; the URL is validated
before any goroutine starts and the request error is handled. A
Shadowsocks link whose plugin field has no ";" panicked the parser, and
from the automatic subscription update that goroutine was unrecovered;
the parser accepts it and each updater recovers and logs.

The DNS module took the last non-bootstrap upstream as the fallback
while the template emitted upstreams in rule order with deduplication,
so a catch-all rule anywhere but last, or one whose upstream was
deduplicated, was not the fallback. The template names the fallback in
a new default_upstream field and the module honours it.

PUT /routingA stored the rules without regenerating the running core.
It goes through ApplyCoreConfig like the other config writers, with
restore on failure. UpdateSubscription logged a failed core reload and
answered success; it returns the error. PATCH /subscription joins the
mutation turn.

Subscription fetching retried through a direct connection when the
selected proxy failed, leaking the subscription URL; it returns the
error. Subscription documents are capped at 32 MiB and downloaded
assets at 256 MiB. PUT /gfwList validates the downloaded file as a
geosite list before replacing the working one.

The login handler took its one-at-a-time semaphore before reading the
body, so a client sending headers and no body blocked every login; the
body is read first and the HTTP server has header and idle timeouts.

Share links: a VLESS or VMess link without a numeric port is rejected
at parse time instead of producing port 0; an SSR link with a password
that is not base64 is rejected instead of importing empty; the SIP003
path gets its leading slash prepended, not a trailing one appended.

The macOS system proxy quoted shell arguments with strconv.Quote,
which leaves $(...) live; values are single-quoted. The Windows system
proxy snapshot includes AutoConfigURL, which teardown deleted and never
restored. Latency test responses with a non-2xx status are closed. The
version response carries the docker flag the GUI's port hints read.
2026-09-20 09:59:29 +10:00
Zakk ae8e5a5047 chore: drop what nothing reaches
Three service packages outside the executable's dependency graph
(common/antiPollution, pkg/util/gopeed, kernel/vmessInfo), a blank
import of miekg/dns the core already imports, the --core-type flag no
code read, the PutAccount handler whose route was commented out, two GUI
API wrappers without a caller, two .SRCINFO files the release regenerates
and an unreferenced runit sample. The workflow path filters watched a
root go.mod that does not exist and the PR build skipped core/.
2026-09-20 09:17:11 +10:00
Zakk d66c3927a5 fix(server): requests that change state apply or restore; requests that fetch have deadlines
PUT /dnsRules regenerates the running core's config and restores the
previous rules when that fails; SetPorts restores the previous ports
when the restart fails. The HTTP latency test drops subscription
entries as intended. The remote GFWList version request has a deadline
and its cache a one-hour TTL. CheckUpdate picks the index of the running
architecture and closes the body on every path.
2026-09-19 22:04:11 +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
ALOKY bea993880c test incremental GeoIP parsing
Cover early exit, fake-IP filtering, IPv6 output, and malformed data.

Signed-off-by: ALOKY <ajm1055@uomustansiriyah.edu.iq>
2026-08-16 15:35:44 +03:00
ALOKY 43b6e55b67 reduce GeoIP parser memory usage
Decode one GeoIP entry at a time and cache successful results.

Signed-off-by: ALOKY <ajm1055@uomustansiriyah.edu.iq>
2026-08-16 15:34:30 +03: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 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 fd7162e88f feat(service): add custom inbound APIs and strengthen outbound/account flows 2026-05-04 19:07:22 +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 Hon aad7e17195 update daeuniverse/outbound 2026-02-04 21:11:26 +08:00
unknown-o 99bd664827 feat(backend): support setting tproxy white ip group 2025-11-05 16:30:24 +00:00
unknown-o c6cb176aa3 feat(backend): add geoip parser 2025-11-05 14:08:11 +00:00
mzz2017 195c84de2c fix(ntp): assume network error as no error 2023-09-02 19:35:21 +08:00
mzz 5c224d3674 fix: port occupation when latency test (#1058) 2023-08-31 23:36:08 +08:00
Farhad Jafari d94e64cadb Add more flow and fix sni (#930)
* Add more flow and fix sni

* Set tcp settings header to none only for TCP network

* Clean v2rayTmpl.go and create antiPollution common

* Set flow only to tls and xtls on vless urls

* Restore back .lock files

* Set host and if it's empty set sni as host
2023-05-09 21:43:18 +08:00
mzz2017 18dcfd94f9 fix: not delete tables rules after http test 2023-03-30 20:54:02 +08:00
mzz2017 e2e7ca9917 fix: ntp should only cache no error result 2022-12-10 22:14:57 +08:00
mzz2017 bcadc53dd3 optimize: increse concurrency of http latency test 2022-12-09 21:34:09 +08:00
mzz2017 030b5c0374 feat: support customized plugin manager 2022-08-03 23:12:29 +08:00
mzz2017 6bb8903758 feat: support multiline base64 encoded subscription. #405 2022-06-18 17:46:41 +08:00
mzz2017 6b757c74b1 optimize: sync time is only required if the protocol is vmess. #564 2022-06-07 09:36:06 +08:00
mzz2017 42f4713aee optimize: remove waiting network 2022-05-28 00:04:56 +08:00
mzz2017 3f4327b0f9 fix: resolv.LookupHost problem and non-A/AAAA/CNAME problem in tproxy #188 2022-04-24 18:50:16 +08:00
mzz2017 b02666bd19 optimize: remove gopeed to avoid 429 2022-03-13 18:05:24 +08:00
高渐离 f8ffdebf52 fix: resolving subscription for line-breaked base64 string (#406) 2022-02-08 18:00:00 +08:00
mzz2017 e99523cf80 fix: xray compatition 2022-01-31 20:04:10 +08:00
mzz2017 1eafeef243 feat(macOS,windows): support system proxy. Thanks @Johnshall #338 2022-01-25 21:18:24 +08:00
mzz2017 eea5e51276 fix: when no addr found, lookup again 2021-12-11 15:34:17 +08:00
Markson Hon a113d4d7a0 Set PreferGo to false (#323) 2021-12-09 13:22:37 +08:00
mzz2017 65bed99656 optimize: expand '~' with user home 2021-10-04 23:19:48 +08:00
mzz2017 403402f0d8 optimize: replace nutsdb with more stable boltdb 2021-10-01 23:56:41 +08:00
mzz2017 c4077f5cc8 fix: slow dns query if all dns is DoH in Advanced DNS 2021-09-27 20:26:33 +08:00
mzz2017 367b15d119 feat: support print connection report 2021-09-24 23:11:42 +08:00
mzz2017 8d43255162 optimize: Split IntranetSharing into IPForward and PortSharing. #266 2021-09-24 11:05:24 +08:00
mzz2017 958cbee014 fix: failed latency test if plugin is needed 2021-09-15 00:39:30 +08:00
mzz2017 8f94446ee5 fix: duplicated servers after update subscriptions 2021-09-10 10:59:24 +08:00
mzz2017 159c542272 fix(transparent proxy): conflict mark 2021-09-07 22:21:37 +08:00