Skip to content

System defaults: sysctl hardening, proxy-path tuning, MGLRU, per-node TFO (#39) - #57

Merged
Cd1s merged 1 commit into
mainfrom
feat/system-defaults
Sep 25, 2026
Merged

Cd1s merged 1 commit into
mainfrom
feat/system-defaults

Conversation

@Cd1s

@Cd1s Cd1s commented Sep 25, 2026

Copy link
Copy Markdown
Owner

What

Hardening (/etc/sysctl.d/90-mini-router.conf): kernel.kptr_restrict=2, kernel.dmesg_restrict=1 (mr reads the kernel log as root, unaffected), net.core.bpf_jit_harden=2 (nothing on the router uses BPF). kexec_load_disabled stays off (sysupgrade needs kexec); Spectre/Meltdown switches make no difference on Cortex-A53.

Proxy path — the one bulk path through the CPU: net.core.rmem_max / wmem_max = 7500000 (what quic-go asks for; hysteria2 and tuic), net.ipv4.tcp_notsent_lowat=131072 (less data parked in send buffers → lower latency through the proxy), net.ipv4.tcp_slow_start_after_idle=0.

Memory: mr-zram sets MGLRU min_ttl_ms=1000 when the kernel has it: the working set of the last second is never evicted; when memory cannot hold it the OOM killer acts instead of the system thrashing. The Go daemons (tailscaled, lucky, dstatus-agent, sing-box) already run with GOMEMLIMIT / GOGC from their init scripts — unchanged.

TCP Fast Open per node: tfo: true on shadowsocks / vless / vmess / trojan / anytls / socks / http nodes renders sing-box tcp_fast_open — one round trip less per connection to a server that enables TFO too (own servers). Refused for QUIC types and custom nodes; switch in the web UI node editor; documented.

Verification

  • On a running router (read only): every key exists; current values 0 / 1 / 0 / 4194304 / unlimited / 1; MGLRU enabled with min_ttl_ms=0; the Go daemons' environments show GOMEMLIMIT / GOGC.
  • Unit tests: rendered sysctl lines; tcp_fast_open rendered exactly for the nodes that set tfo; tfo refused for hysteria2, tuic and custom.
  • The lab config turns tfo on for one Shadowsocks node: CI's real sing-box 1.14.1 accepts the config and carries TCP and UDP end to end through that node.
  • tools/ci.sh passes (private and public trees).

Closes #39

https://claude.ai/code/session_01HWeUjo1dmS7gBkCYHrVjCr

…min_ttl, per-node TCP Fast Open

- sysctl: kptr_restrict=2, dmesg_restrict=1, bpf_jit_harden=2; rmem_max / wmem_max 7500000 (QUIC:
  hysteria2, tuic), tcp_notsent_lowat=131072, tcp_slow_start_after_idle=0.
- mr-zram: MGLRU min_ttl_ms=1000 — OOM kill instead of thrashing.
- Go daemons already had GOMEMLIMIT / GOGC: unchanged.
- proxy nodes: `tfo: true` -> sing-box tcp_fast_open (TCP protocols; the server must enable TFO);
  web UI switch; one lab node uses it (real sing-box check + traffic in CI).

Closes #39
@Cd1s
Cd1s merged commit 910c2b6 into main Sep 25, 2026
2 checks passed
@Cd1s
Cd1s deleted the feat/system-defaults branch September 25, 2026 17:08
@Cd1s Cd1s mentioned this pull request Sep 25, 2026
52 tasks done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

系统默认值:加固 sysctl、Go 程序内存上限、代理路径调优

1 participant