Commit graph

399 commits

Author SHA1 Message Date
世界
23a39c59be
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) accumulated forever,
making per-ping cost grow linearly with uptime.

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
世界
b0188bc3f1
Improve darwin forwarding 2026-07-27 23:11:48 +08:00
世界
dcfbe83ca6
Fix flow close reasons 2026-07-27 23:11:48 +08:00
世界
2de01a4c29
Reject flows on selector range exhaustion 2026-07-27 23:11:48 +08:00
世界
15b67423c3
Add flow PortWithSelectorRange 2026-07-27 23:11:48 +08:00
世界
7c92d5e53e
Add UDPTimeout option for flow 2026-07-27 23:11:48 +08:00
世界
c17af6ee8c
Minor fixes 2026-07-27 23:11:48 +08:00
世界
14c8f75f7a
Add flow tracking 2026-07-27 23:11:48 +08:00
世界
ed63adda33
Add flow dispatcher 2026-07-27 23:11:48 +08:00
世界
47bdde06c3
Add DNS mode 2026-07-27 23:11:48 +08:00
世界
3c7d6ad82f
Add read waiter support for gVisor conn 2026-07-27 23:11:48 +08:00
世界
a36276922a
Add compatibility with docker bridge 2026-07-27 23:11:48 +08:00
世界
a9027729be
Make gtcpip public for external use 2026-07-27 23:11:48 +08:00
世界
f8e7794cc2
Add MAC address include/exclude filtering for nftables auto-redirect
Support filtering traffic by source MAC address in the prerouting chain,
using ether addr payload matching with set lookups for multiple addresses.
2026-07-27 23:11:48 +08:00
世界
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