Commit graph

402 commits

Author SHA1 Message Date
世界
24b12270db
Fix system stack rewriting TUN subnet destinations to loopback
The acceptLoop was rewriting any TCP destination within the TUN
address prefix to 127.0.0.1/::1. This incorrectly caught the
gateway address and other subnet addresses, not just the interface
address itself.
2026-03-23 19:37:57 +08:00
世界
0e624a007c
Add PackagesByID for android package manager 2026-03-23 18:25:08 +08:00
Andrew Novikov
0e4cdbbc61
fix: use NF_REPEAT for NFQUEUE bypass/reset verdicts
NF_ACCEPT is a terminal verdict in nftables — when a packet returns
from NFQUEUE with NF_ACCEPT, it exits the current chain immediately
and continues to the next hook priority. Rules placed after the queue
statement in the same chain are never evaluated.

This meant that the `ct mark set meta mark` rule (which saves the
bypass decision to conntrack for subsequent packets) was dead code.
The first SYN packet received the correct mark from NFQUEUE, but
conntrack never stored it, so all subsequent packets of the same
connection were redirected to sing-box userspace.

Fix: use NF_REPEAT instead of NF_ACCEPT for bypass and reset verdicts.
NF_REPEAT re-enters the chain from the beginning with the mark already
set on skb->mark. Reorder the prematch chain rules so mark-checking
rules (ct mark set, reject) come before the queue statement:

  1. meta mark == outputMark → ct mark set meta mark, return
  2. meta mark == resetMark → reject with tcp reset
  3. ct mark == outputMark → return
  4. TCP SYN → queue to NFQUEUE

This is the standard pattern used by Suricata and other NFQUEUE-based
systems (NF_REPEAT + mark-based skip).

Tested on Orange Pi Zero 3 (arm64, kernel 6.12.58) with sing-box 1.13.3.
Bypass correctly saves ct mark, subsequent packets skip NFQUEUE entirely.
2026-03-17 10:58:45 +08:00
世界
1ab008e1e6
Improve error messages for Linux TUN and redirect operations 2026-03-15 14:43:38 +08:00
世界
82d14b26de
Fix nftables single include_uid not working
The single UID code path incorrectly used BigEndian to encode the UID
for nft_cmp, but the kernel stores SKUIDs in native endian.
2026-03-15 14:15:22 +08:00
世界
0329538ecd
Fix "Fix auto_redirect dropping SO_BINDTODEVICE traffic" 2026-03-14 20:58:43 +08:00
世界
caaf8469e0
Fix auto_redirect dropping SO_BINDTODEVICE traffic
REDIRECT in the OUTPUT chain rewrites the destination to 127.0.0.1,
then ip_route_me_harder() reroutes with the socket's bound interface
constraint (flowi4_oif). Since 127.0.0.1 is only reachable via lo,
the routing lookup fails and the packet is silently dropped.

Add a fallback routing table with `local 127.0.0.1` entries for each
non-loopback interface. When the local table lookup fails due to OIF
mismatch, the fallback table provides a matching RTN_LOCAL route.
The kernel then overrides dev_out to loopback (route.c:2857), so the
packet is delivered locally to the redirect server as intended.

This fixes NetworkManager connectivity checks and other tools that
use SO_BINDTODEVICE (e.g. curl --interface).
2026-03-11 21:15:11 +08:00
世界
c81ce6d358
Fix darwin batch loop not exit on EBADF 2026-03-05 20:35:38 +08:00
wwqgtxx
90ea7a0b69
Fix udp/icmp not work on gso with mixed stack 2026-03-03 23:48:15 +08:00
世界
6ee3db839d
Update dependencies 2026-03-02 06:50:15 +08:00
eronez
1fb8456021
Fix DNS not revert while close tun 2026-03-02 06:46:28 +08:00
世界
5715a3919a
Fix nftablesCreateLocalAddressSets 2026-02-23 17:52:46 +08:00
wwqgtxx
2a33d64abc Fix logging maybe panic 2026-02-13 00:28:14 +08:00
wwqgtxx
3144f43fc2 Fix udp/icmp not work on gso with system stack 2026-02-13 00:27:34 +08:00
世界
635920688d
Add back random iproute2 table index 2026-02-02 14:15:26 +08:00
世界
2e21cd99ef
Revert "Disable rp filter atomically"
This reverts commit 983b3caf40.
2026-02-02 14:15:10 +08:00
世界
983b3caf40
Disable rp filter atomically 2026-02-01 10:46:55 +08:00
世界
1d02d635b9
Fix auto_redirect fallback rule 2026-01-29 13:34:49 +08:00
世界
e88ed52dbc
Fix auto_redirect on IPv6-only or IPv4-only servers 2026-01-28 18:27:44 +08:00
世界
381bf9d40d
Skip tun interface traffic in prerouting UDP/ICMP chain 2026-01-28 18:27:44 +08:00
世界
2377e62d4a
Fix IPv6 ULA addresses excluded from local address set
The filter condition `IsGlobalUnicast() && !IsPrivate()` incorrectly
excluded ULA addresses (fc00::/7) from inet6_local_address_set,
causing DNS hijack to fail for IPv6 ULA addresses.

Fixes: sagernet/sing-box#3698
2026-01-17 20:42:31 +08:00
世界
a23b66f721
Skip strict routing on Windows versions below 10 2026-01-17 18:16:51 +08:00
世界
2f53768be2
Fix darwin batch read not exit on stop 2026-01-15 02:08:56 +08:00
世界
9d97d95a9c
Fix TUN interface restart fails with existing addresses 2026-01-15 02:08:55 +08:00
世界
525f783d00
Add EXP_ExternalConfiguration for Tailscale 2026-01-07 14:05:47 +08:00
世界
a5db80d710
Fix nfqueue fallback when kernel module unavailable 2025-12-31 03:47:36 +08:00
世界
a850c4f8a1
Add pre-matching support for auto redirect 2025-12-26 14:44:55 +08:00
世界
6516c2d8f1
Fix race condition in ReadPacket 2025-12-17 19:45:01 +08:00
wwqgtxx
e9e3fbf0c1 Apply ping destination filter for Windows 2025-12-01 08:47:38 +08:00
世界
20161f3059
redirect: Fix compatibility with /product/bin/su 2025-10-21 20:41:16 +08:00
世界
b49e63f8ef
Fix compatibility with MPTCP 2025-10-17 16:26:45 +08:00
世界
b42efe2516
Update golangci-lint 2025-09-22 12:51:12 +08:00
世界
09d1d97313
Update gVisor to v20250811.0 2025-09-15 23:55:16 +08:00
世界
67013b321e
Fix race codes 2025-09-12 18:02:59 +08:00
世界
0381a06643
ping: Add destination rewriter 2025-09-11 18:51:00 +08:00
世界
960457abba
Update dependencies 2025-09-10 22:52:15 +08:00
世界
7de8ff7f20
ping: Fix read ICMPv6 from gVisor 2025-09-09 23:22:25 +08:00
世界
a8cb01e6df
Prevent panic when wintun dll fails to load 2025-09-09 18:04:19 +08:00
世界
b76e852f59
ping: Fix reject 2025-08-27 20:29:08 +08:00
世界
d5865f2135
Fix gvisor loopback address 2025-08-27 16:35:53 +08:00
世界
ff49ece55d
Fix checksum changes 2025-08-27 15:47:20 +08:00
世界
adc106bcf6
Improve checksum usages 2025-08-27 11:07:26 +08:00
wwqgtxx
f9bbb15bfb ping: Reduce the cost of readMsg 2025-08-27 08:45:12 +08:00
世界
4c43f4af12
ping: Fix not handling reject 2025-08-27 00:30:40 +08:00
世界
055fe13ec0
Revert "ping: Increate mapping capacity"
This reverts commit a24ab73aca.
2025-08-26 23:54:57 +08:00
世界
e8d7fc1bb2
ping: Do not use connected socket on macOS 2025-08-26 23:43:37 +08:00
世界
a24ab73aca
ping: Increate mapping capacity 2025-08-26 14:41:14 +08:00
世界
b5f3fecc25
ping: Fix linux route rules 2025-08-26 14:30:21 +08:00
wwqgtxx
4fb5702443 ping: Add needFilter 2025-08-26 13:20:50 +08:00
wwqgtxx
6e4e045620 ping: Limit old requests 2025-08-26 11:47:14 +08:00