Skip to content

mode: bypass (side router) and ap (pure AP) (#24, #26) - #85

Merged
Cd1s merged 1 commit into
mainfrom
feat/mode-bypass-ap
Sep 26, 2026
Merged

Cd1s merged 1 commit into
mainfrom
feat/mode-bypass-ap

Conversation

@Cd1s

@Cd1s Cd1s commented Sep 26, 2026

Copy link
Copy Markdown
Owner

What

mode: is a new core setting (mr/mode.go): router (default), bypass or ap. Both new modes need lan.gateway (the main router). bypass also takes bypass: {clients: route-only | all | selected, macs, nat}. No new program.

clients gateway / DNS of the devices through this box this box down
route-only (default) the main router is still the gateway; its DHCP hands out this box as DNS and it routes the proxied ranges here proxied connections only only proxied names
all this box (DHCP, gateway, DNS) everything everything
selected this box for bypass.macs, the main router for everyone else those devices those devices
  • route-only reply path. A proxied connection's request comes in through the main router. If sing-box's transparent socket answered the client directly, the main router would see only one direction and drop the client's next packet as invalid (OpenWrt does this by default). So the proxied connection gets a connmark, and its replies are marked 0x2000000 in an output route chain and sent via table 301 (default via lan.gateway) back through the main router.
  • Main router's static routes. mr proxy routes, API proxy.routes, and the LAN page list the static routes the main router needs.
  • all / selected masquerade forwarded traffic (hairpin on br-lan), so replies come back through this box.
  • ap: one bridge; forwarding off; no NAT, DHCP, RA, proxy or flowtable.
  • Both modes
    • Default route via lan.gateway; accept_ra=2; the DNS upstream defaults to the main router.
    • Refused by validation: WANs, extra networks, multiwan, policy routes, forwards, open ports, IPv6 pinholes, access control, rules with src/dest wan, igmpproxy, lan.ipv6_ra, edge.open, and dns.upstream: isp.
    • bypass requires proxy.ipv4_only.
  • nftables: the ruleset renders without WANs, with no empty anonymous sets.
  • install.sh asks for the mode. For bypass / ap it skips the WAN questions and defaults to the current address and gateway, so an install over SSH does not drop the connection.
  • Web UI: a 工作模式 card on LAN 与网络. Docs: docs/modules/net.md (mode), MODULES.md, skill.

Verification

  • Go tests: a validation matrix, and rendering in every mode (network.sh, dnsmasq.conf, the ruleset, sysctl).
  • tools/ci.d/mode.sh: network namespaces with a main router that drops invalid packets, a side router, two clients and "the internet".
    • route-only: a client reaches a proxied range and a fake-ip address through the transparent socket, with the reply routed back through the main router.
    • Control: without the reply rule the same connection breaks, and the main router's invalid counter goes up.
    • all: the main router sees the side router's address, not the client's.
    • ap: the ruleset loads.
  • nft -c of the inet route chain passes on a 6.18 kernel.
  • sh tools/ci.sh: ALL CHECKS PASSED.

Closes #24
Closes #26

https://claude.ai/code/session_01HWeUjo1dmS7gBkCYHrVjCr

…outer, no WAN

`mode:` is core (mode.go): router (default), bypass or ap, with `lan.gateway` and, for bypass,
`bypass: {clients: route-only | all | selected, macs, nat}`. No new program.

- bypass route-only: the main router stays gateway + DHCP, hands out this box as DNS and routes the
  proxied ranges here (`mr proxy routes`); replies of proxied connections go back through the main
  router (connmark + fwmark + table 301), so its connection tracking sees both directions.
- bypass all / selected: this box serves DHCP (for everyone / bypass.macs) and masquerades forwarded
  traffic.
- ap: one bridge, forwarding off, no NAT / DHCP / RA / proxy / flowtable.
- install.sh asks for the mode and keeps the current address.

Tests, CI in network namespaces with a main router that drops invalid packets (route-only works and
breaks without the reply rule; all is masqueraded; ap loads), web UI 工作模式 card, docs.

Closes #24
Closes #26

Claude-Session: https://claude.ai/code/session_01HWeUjo1dmS7gBkCYHrVjCr
@Cd1s
Cd1s merged commit 8bdb144 into main Sep 26, 2026
2 checks passed
@Cd1s
Cd1s deleted the feat/mode-bypass-ap branch September 26, 2026 03:21
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.

提议:纯 AP 模式(mode: ap) 提议:旁路由模式(单网口,推荐“只管代理”拓扑)

1 participant