1865 Commits
Author SHA1 Message Date
Markson Pigeonzilla Plus b7da452276 ci: re-init AUR release v2.4.12 2026-08-22 09:02:48 +08:00
Markson Hon b043120363 Merge pull request #1940 from xuweizhi/fix/listget-sub-id
fix(db): use subscription id instead of index+1 to fetch servers in ListGet
2026-08-19 20:36:36 +08:00
xuweizhi ea96763911 fix(db): use subscription id instead of index+1 to fetch servers in ListGet 2026-08-19 20:25:31 +08:00
Markson Hon c17d087127 Merge pull request #1938 from v2rayA/main
ci: fix a typo from AI's auto completion
2026-08-18 22:31:11 +08:00
Markson Hon e185ac0691 ci: fix pull_request.yml 2026-08-18 22:25:11 +08:00
Markson Hon 1f33e05dff Merge pull request #1754 from fumiama/main
ci: support mips softfloat
2026-08-18 21:43:58 +08:00
Markson Hon 81f82e799b Merge branch 'main' into main
Signed-off-by: Markson Hon <50002150+MarksonHon@users.noreply.github.com>
2026-08-18 21:43:32 +08:00
Markson Hon fbd5cc2c11 ci: pr builds should include core 2026-08-18 21:41:28 +08:00
Markson Hon 6c27cc2c1d Merge pull request #1933 from xAlokyx/agent/reduce-geoip-parser-memory
fix: reduce GeoIP parser memory usage
2026-08-18 21:34:52 +08:00
Markson Hon 15b45924b8 Merge pull request #1934 from zhangthree78/fix/dns-loop-memory-blowup
fix: prevent DNS redirect loop causing unbounded memory growth and DNS failure on proxy stop
2026-08-18 21:21:33 +08:00
Markson Hon e3150af5bc Merge pull request #1931 from miaomiaoyaoqimiaomaoxian/fix/preserve-core-state-on-restart
fix: preserve core state across graceful restarts
2026-08-18 21:17:15 +08:00
zhangthree78 daa5d69261 fix(dns): make marked-client Control assertions platform-specific
Review (goal verification) found that socket_test.go asserted
Dialer.Control != nil without build tags, so 'go test ./core/dns/'
fails on Windows where markedDialer() deliberately omits Control
(SO_MARK is a Linux-only option; markFd is a no-op there).

Move the Control assertions to socket_unix_test.go (//go:build !windows);
socket_test.go keeps the platform-neutral assertions (Net/UDPSize/timeouts/
Dialer non-nil). Verified: Linux go build + go test all pass, and
GOOS=windows go vet compiles the test files cleanly.
2026-08-17 01:01:15 +08:00
zhangthree78 734792cfc2 fix: complete per-query log gating, clean residual DNS rules on stop, dedupe marked client
Follow-up review of 525654e found:

1. Log gating was incomplete: only the direct/route path was gated;
   cache-hit/cache-miss, proxy and dispatcher per-query logs were still
   unconditional log.Printf (the hottest paths under load). Gate them
   behind V2RAYA_DNS_DEBUG=1 too; error logs stay visible.

2. Stopping the transparent proxy left the direct nat OUTPUT/PREROUTING
   REDIRECT --to-port 52353 rules and the fwmark 0x80 exemption rules in
   place (Tproxy/Redirect GetCleanCommands only clean their own chains).
   Once the DNS module exits, local DNS queries hit a dead port and DNS
   fails. Add cleanDnsRedirectRules() and run it on the normal stop path.

3. module.go bootstrap client inlined its own markFd + marked dialer;
   reuse newMarkedDnsClient (keeping the 3s fail-fast timeout).

4. dnsLogf/dnsDebugEnabled were duplicated in socket_unix.go /
   socket_windows.go; move them to a common debug.go.

5. No unit tests for newMarkedDnsClient; add tests asserting
   Net/UDPSize/Timeout and a non-nil Dialer.Control.

Verified: go build ./dns/... ./kernel/v2ray/... ; go test ./dns/...
2026-08-17 00:49:48 +08:00
zhangthree78 dc40c97264 chore: ignore local artifacts and agent state in .gitignore
- ignore .omo/ (local agent state), /release/ (built binaries, PR
  materials), /service/web/ (generated web assets), and
  gui/package-lock.json (project uses yarn.lock; the npm lockfile is
  an accidental artifact)
- fix mangled entry 'service\core\v2ray\CORE_CONFIGURATION.mdplans'
  (missing newline; also correct the path separator)
2026-08-16 23:59:58 +08:00
zhangthree78 525654ec9b fix: prevent DNS redirect loop causing unbounded memory growth
Fixes defects in the v2.4.8+ transparent-proxy DNS path that cause the
core to exhaust memory within seconds on low-RAM hosts (see discussion
#1915: '2.4.9 内存占用过高' / '有严重的内存泄漏,别用了。本地DNS完全废掉了'):

1. core/dns: upstream queries from NewUpstreamManager /
   GetOrCreateUpstream / getClientForProtocol used bare &dns.Client{}
   with no Dialer configured, so their sockets never carried
   SO_MARK=0x80. The unmarked queries were hijacked by the module's own
   transparent-proxy DNS redirect rules and looped back into :52353 —
   an infinite self-query loop and memory snowball.

2. service/kernel/v2ray/transparent.go: the unconditional DNS hijack
   rules (REDIRECT --to-port 52353) had no fwmark-0x80 exemption, and
   being inserted with -I they sat at the head of nat OUTPUT/PREROUTING,
   so marked traffic was looped back as well.

3. core/dns: per-query info logging (query/route/upstream) produced
   thousands of lines/second under load, amplifying CPU/IO/memory
   pressure.

Fix:
- Route every upstream client through newMarkedDnsClient, whose
  net.Dialer sets SO_MARK=0x80 on all sockets. miekg/dns dials UDP
  through net.Dialer too, so Dialer.Control covers UDP sockets — no
  manual socket path is needed. UDPSize=4096 keeps a sane receive
  buffer for queries without an EDNS0 OPT record.
- Append the DNS redirects with -A and insert the mark exemption with
  -I so the exemption is matched first; also delete the exemption
  rules in the residual-rule cleanup so they don't accumulate across
  restarts.
- redirect mode: insert the DNS_REDIRECT jumps after the TP_PRE/TP_OUT
  jumps so they actually take precedence (-I inserts at chain head),
  keeping local and LAN TCP DNS flowing to the DNS module (:52353)
  instead of the proxy inbound (:52345).
- Gate per-query info logs behind V2RAYA_DNS_DEBUG=1; error logs stay
  always visible.

Verified: unpatched v2.4.11 core RSS 230MB->1GB in ~6s then OOM/hang;
patched build stable at ~25MB idle / ~243MB loaded, DNS and SOCKS proxy
working.
2026-08-16 23:59:43 +08: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
Codex contributor 8d11cdb6ca fix: preserve core state across graceful restarts 2026-08-14 18:57:12 +08:00
Markson Pigeonzilla Plus 1550d843d0 fix(gui): drop xtls option and treat v2raya_core as xray variant v2.4.11 2026-08-11 21:59:44 +08:00
Markson Pigeonzilla Plus f3249f6346 fix: normalize vmess:// payload field types on export and import 2026-08-11 21:59:42 +08:00
Markson Pigeonzilla Plus e363546bf1 fix: normalize peer cert pin to lowercase hex for xray-core pinnedPeerCertSha256 2026-08-11 21:59:39 +08:00
Markson Pigeonzilla Plus 3d86c775a5 feat: add shared cert-chain pinning helpers for native protocols 2026-08-11 21:59:36 +08:00
Markson Pigeonzilla Plus 0bdd83345d chore: bump xray-core and core module dependencies 2026-08-11 21:59:34 +08:00
Markson Pigeonzilla Plus 06273efcc1 fix: cert chain sha256 not applied of juicity 2026-08-11 20:26:49 +08:00
Markson GuGa Beyond b25cc46c80 ci: update checkout to v7 v2.4.10 2026-08-09 15:42:07 +08:00
Markson Hon 3ce0b2f215 Merge pull request #1924 from v2rayA/fix_hy2
fix: hysteria2 should not be plugin-based
2026-08-09 15:30:10 +08:00
Markson GuGa Beyond 26a48d9909 fix: hysteria2 not import SHA256 2026-08-09 15:16:25 +08:00
Markson GuGa Beyond 1b94f178d9 fix: hysteria2 should not be plugin-based 2026-08-09 13:15:38 +08:00
Markson Hon eb7ec6624e Merge pull request #1913 from newptcai/fix-tproxy-dns-redirect-hijack
fix(iptables): exempt DNS module port from generic TPROXY hijack (local UDP DNS dead in tproxy mode)
2026-07-23 10:58:41 +08:00
Markson Hon b5a7e6e315 Merge pull request #1911 from newptcai/fix-subscription-connected-server-remap
fix(subscription): remap connected servers by endpoint when provider renames nodes
2026-07-23 10:56:47 +08:00
Xing Shi CaiandClaude Fable 5 cfe0e877a0 🐛 (iptables): Exempt DNS module port from generic TPROXY hijack
Locally originated DNS queries are marked 0x40 by DNS_MARK in mangle OUTPUT, then nat OUTPUT REDIRECT rewrites their destination port from 53 to 52353. When the packet re-enters PREROUTING via loopback, the dport-53 TPROXY rule no longer matches, so the generic mark-0x40 rule diverts it to the transparent proxy port 52345 where it is dropped. All local UDP DNS times out and transparent proxy appears completely broken (TCP DNS survives because the proxied connection still reaches 52353).

Add TP_PRE RETURN rules for dport 52353 ahead of the TPROXY rules in the legacy IPv4, legacy IPv6, and nftables variants so already-redirected DNS traffic is delivered to the DNS module untouched.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-23 10:48:41 +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
Markson Pigeonzilla Plus 1edc9c868b ci: disable AUR release v2.4.9 2026-07-22 20:29:37 +08:00
Markson Joe Hon e80cab2a59 fix(configure): change default fallback DNS from 8.8.8.8 to 1.0.0.1
Use Cloudflare's secondary DNS (1.0.0.1) as the default fallback
instead of Google DNS (8.8.8.8) for better privacy and reliability.
2026-07-22 14:11:06 +08:00
Markson Joe Hon 62edf08c24 fix(core/dns): increase UDP receive buffer from 512 to 65535
exchangeUDPWithMark used dns.DefaultMsgSize (512 bytes) as the UDP
receive buffer. The query sets EDNS0 UDP size 4096, so the upstream
may respond with up to 4096 bytes. With a 512-byte buffer, UDP
datagram data beyond 512 bytes is silently discarded (UDP datagram
property), causing truncated/corrupted DNS responses.

Fix: use dns.MaxMsgSize (65535) as the receive buffer, matching the
maximum possible UDP datagram size. This ensures large DNS responses
(common with DNSSEC or many A/AAAA records) are fully received.
2026-07-22 14:05:32 +08:00
Markson Joe Hon 9fcbd6a5db fix(core/dns): fix DNS split routing, bootstrap loop, and response corruption
## Issue 1: DNS rule matching logic (MatchAll + OrMatcher)

BuildMatchers flattened all geosite-expanded domains into a single list,
and the old MatchAny used AND logic (all matchers must match). This
made geosite:cn rules impossible to hit (e.g. qq.com and baidu.com
can never match simultaneously).

Fix: introduce OrMatcher to group matchers from the same rule field
with OR semantics, while different field groups use AND. The thousands
of domains from geosite:cn expansion are wrapped in a single OrMatcher
so matching any one domain satisfies the rule.

## Issue 2: Bootstrap self-reference loop (SO_MARK + public DNS fallback)

Bootstrap resolution runs before the DNS listener starts, but iptables
already hijacks :53 traffic:
- bootstrap query to system DNS(:53) → iptables redirects to 127.2.0.17:53
- DNS module not yet listening → connection refused → bootstrap fails
- Domain upstreams (e.g. dns.google) remain unresolved → relies on proxy
- Proxy DNS may re-enter DNS module → loop or REFUSED

Fix:
1. Add SO_MARK=0x80 to bootstrap DNS client to bypass iptables redirect
2. collectBootstrapDns() with 3-tier priority (config > system > hardcoded)
3. Hardcoded fallback includes Alibaba/Tencent/Google/Cloudflare: 13 servers
4. isOwnAddress() filters self-referencing addresses (127.0.0.1:53 etc.)

## Issue 3: handlePacket mutates cached response in-place

m = resp.RawMsg; m.SetReply(msg) directly modifies the *dns.Msg shared
with the cache, corrupting subsequent cache hits. SetReply also forces
Rcode=RcodeSuccess, overwriting NXDOMAIN etc. from upstream.

Fix: Pack/Unpack deep copy before modification; preserve original Rcode.

## Issue 4: Double OPT record causes FORMERR

Three exchange functions called AddECSSubnet BEFORE SetEdns0.
miekg/dns v1.1.72's SetEdns0 always appends a new OPT record without
checking for existing ones, producing a malformed query with two OPT
records.

Fix: call SetEdns0 before AddECSSubnet; use UDP size 4096 in
AddECSSubnet instead of 512 to preserve the size set by SetEdns0.

## Issue 5: localhost upstream skipped in template (template_dns.go)

localhost upstream was continue-skipped during config generation,
making the geosite:private rule reference a non-existent upstream.

Fix: map localhost to 127.0.0.1, keep it as a valid upstream.

## Incidental fixes

- handler.go: remove duplicate :53 in log format (dns.google:53:53)
- response.go: use 4096 instead of dns.DefaultMsgSize(512) for ECS
2026-07-22 14:01:39 +08:00
Markson Joe Hon 1bcd63eb1f fix(iptables): resolve firewall rule bugs and improve cleanup reliability
- Fix nftTproxy.GetCleanCommands using wrong table name ('ip' instead of
  'inet') when IPv6 is disabled, causing nftables table to persist after
  teardown
- Fix legacyRedirect.RemoveIPWhitelist not handling IPv6 CIDRs (always
  used iptables even for IPv6 addresses, causing silent delete failure)
- Suppress errors in ip rule/route del cleanup commands with
  2>/dev/null || true (applies to both legacy and nft TProxy modes)
- Normalize mixed tab/space indentation in nftRedirect's tp_rule chain
  for consistency
2026-07-22 13:09:01 +08:00
Markson Hon 45fabfce39 Merge pull request #1912 from newptcai/fix-sqlite-subscription-server-duplication
fix(db): subscription update duplicates server list on installs migrated from BoltDB
2026-07-22 10:12:38 +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
Xing Shi CaiandClaude Fable 5 6ccf42f9e0 🐛 (db): Fix subscription update duplicating servers on migrated installs
- ListSet ignored the DELETE error when replacing a subscription's servers; on installs migrated from BoltDB, outbound_connections rows hold a foreign key to servers, the delete fails, and every update re-inserts the full list alongside the old rows

- Delete referencing outbound_connections rows first (same pattern as ListRemove) and propagate delete errors

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-22 10:03:05 +08:00
Markson Hon f28111364b Merge pull request #1905 from chiyuki0325/fix/empty-sniffing
fix(core): ignore empty sniffing exclusions
v2.4.8
2026-07-20 20:06:17 +08:00
Kirikaze Chiyuki 5d7157503d fix(core): ignore empty sniffing exclusions 2026-07-11 23:09:33 +08:00
Markson Hon 11f052676e Merge pull request #1904 from fnMrRice/fix-subscription-subid-update
fix: update subscription servers by real sub id
2026-07-07 19:34:55 +08:00
fnRice 0f384933cd fix: update subscription servers by real sub id 2026-07-06 10:09:02 +08:00
Markson Hon b6540a0465 Merge pull request #1897 from MarksonHon/main
Fix firewall rule issues, enhance security, and improve proxy handling
v2.4.7
2026-07-02 22:18:22 +08:00
Markson Pigeonzilla Plus 2069b477d4 fix(windows): fix syscall.SetsockoptInt type mismatch on Windows
syscall.SetsockoptInt takes int (Linux) vs syscall.Handle (Windows)
as its first argument. The existing code used int(fd) which fails on
Windows where fd is uintptr and syscall.Handle = uintptr.

Fix: extract a platform-specific setSocketMark(fd uintptr) helper:
  - socket_unix.go (!windows) : calls SetsockoptInt(int(fd), ...)
  - socket_windows.go (windows): no-op (SO_MARK is Linux-only)
2026-07-02 21:32:37 +08:00
Markson Pigeonzilla Plus 1fdeb62bbe fix(windows): fix type mismatch in readRegistryProxyState
k.GetIntegerValue() returns uint64 on Windows, but proxyEnable was
declared as uint32. Add explicit uint32() conversion to fix the
cross-compilation error:

  cannot use k.GetIntegerValue("ProxyEnable") (value of type uint64)
  as uint32 value in assignment
2026-07-02 21:24:31 +08:00
Markson Pigeonzilla Plus 54efcae3ac fix(iptables): fix interface exclusion for OUTPUT path and rename nftables sets
Two fixes for the redirect/tproxy interface exclusion feature:

1. Add missing -o/oifname rules for the OUTPUT path
   - The TP_RULE chain is jumped from both PREROUTING (tp_pre) and
     OUTPUT (tp_out). The existing -i/iifname rules only match the
     PREROUTING path correctly (packets arriving on a given interface).
   - For the OUTPUT path (locally-originated traffic), the input
     interface is always 'lo', so -i never matches the excluded
     interface. Add corresponding -o/oifname rules so that locally-
     originated traffic going out through an excluded interface is
     also bypassed (RETURN before the final REDIRECT/TPROXY action).
   - Applies to both redirect and tproxy modes, legacy iptables and
     nftables implementations, for both IPv4 and IPv6.

2. Rename nftables set 'interface'/'interface6' to 'local_ips'/'local_ips6'
   - These sets store IPv4/IPv6 addresses of local interfaces,
     dynamically maintained by the LocalIPWatcher to prevent proxy
     loops (traffic destined to local IPs returns early).
   - The old name 'interface' was misleading: it suggested it stores
     interface names, but the type is ipv4_addr/ipv6_addr.
   - The rename affects nftRedirect and nftTproxy, including the
     set definitions, chain references (ip daddr @local_ips), and
     AddIPWhitelist/RemoveIPWhitelist nft command strings.
2026-07-02 21:21:18 +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