Commit graph

385 commits

Author SHA1 Message Date
世界
30e535973b
ping: Fix stale flows kept alive by unrelated ICMP traffic
Unconnected raw ICMP sockets receive every ICMP packet arriving at the
host, so any ICMP traffic refreshed the read deadline of every flow and
stale flows (with their raw sockets and goroutines) were only reclaimed
by LRU eviction while processing all host ICMP traffic in the meantime.

Expire flows based on their own activity only, and on Linux attach a
classic BPF ident filter to each raw socket so other flows' packets are
dropped in the kernel instead of waking every flow.
2026-07-27 23:11:48 +08:00
世界
aae2f0750c
Fix ping 2026-07-27 23:11:48 +08:00
世界
1251022fce
ping: Fix missing TTL and ICMP error handling 2026-07-27 23:11:48 +08:00
世界
3a09076491
Fix redirect routes 2026-07-27 23:11:22 +08:00
世界
eccdcee073
Fix probe GSO 2026-07-27 23:11:22 +08:00
世界
99fb96a4c8
Fix missing UDP and ICMP bypass for auto redirect 2026-07-27 23:11:22 +08:00
世界
80ea96e5b4
Reject connections to redirect listener 2026-07-27 23:11:22 +08:00
世界
add23d4844
Fix logger check 2026-07-27 23:11:22 +08:00
世界
5bb0784f61
Fix android GSO 2026-07-27 23:11:22 +08:00
世界
ebd569670d
Drain pending packets in Linux batch read 2026-07-27 23:11:22 +08:00
世界
9c6760589d
Fix redirect routes 2026-07-27 10:25:59 +08:00
H-TTTTT
7954dd6e20
Fix nftables interval end when range hits max address
When To() is 255.255.255.255 / ffff:...:ffff, Next() is invalid. Using
From() as the end key duplicated the start element and caused EEXIST.
Omit the end element so the half-open interval covers through max.

Fixes SagerNet/sing-box#4316
2026-07-27 10:25:59 +08:00
世界
8048acde1e
Fix nfqueue options 2026-07-27 10:25:59 +08:00
世界
959bd54905
Fix CalculateInterfaceName on iOS 2026-07-27 10:25:59 +08:00
世界
c569e3e92f
Fix gVisor process 2026-07-27 10:25:59 +08:00
世界
46aa536b37
Fix lint errors 2026-07-27 10:23:30 +08:00
世界
a9f4123ba2
Update .gitignore 2026-06-22 16:16:28 +08:00
世界
b1c48c12e2
Fix route address set polluted by appended default element 2026-06-20 19:47:40 +08:00
世界
8caaa93f8d
Fix system stack TCP NAT collision 2026-06-19 20:25:45 +08:00
世界
3b51857024
Support multiple registered interfaces in interface monitor 2026-06-03 10:35:01 +08:00
世界
1aa83a9f92
ping: limit ICMP read buffer size 2026-06-03 10:34:17 +08:00
世界
bebc8d67f3
stack: Add icmp timeout 2026-06-01 17:48:51 +08:00
世界
568357315c
ping: Fix unprivileged conn 2026-06-01 17:48:51 +08:00
wwqgtxx
23eaeb3198
Fix dispatcher race operation in WintunEndpoint 2026-06-01 17:48:51 +08:00
世界
1e975834ca
Reformat code 2026-06-01 17:48:51 +08:00
世界
49e4afd5c7
Handle existing Wintun adapter on restart 2026-05-19 20:56:43 +08:00
世界
1010e39d79
Fix IPv6 UDP packet leak in system stack 2026-05-19 17:00:09 +08:00
世界
47ac4d08b1
ping: Fix unprivileged conn leak 2026-05-19 16:26:55 +08:00
世界
e5d2fab035
Fix multi include/exclude interfaces 2026-04-20 07:40:18 +08:00
世界
5b7311ba58
memmod: be more resilient toward weird PE files
pick from d991925286
2026-04-19 21:53:02 +08:00
世界
4cd8fef581
Fix UDP forwarder slice allocation 2026-04-10 14:12:22 +08:00
世界
31c44bc478
Fix buffer not released in batchLoopDarwin 2026-04-10 14:12:21 +08:00
世界
1664d083fb
Reduce iOS TCP buffers 2026-04-10 14:12:21 +08:00
世界
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