Repository navigation
feat(mitm): TPROXY IP_TRANSPARENT native addon + conditional loader (Epic A) - #4148
Merged
Merged
Conversation
…Epic A)
Node's net module cannot setsockopt(IP_TRANSPARENT) before bind(), which TPROXY
requires. src/mitm/tproxy/native/transparent.c is a tiny N-API addon that does
socket()+SO_REUSEADDR+IP_TRANSPARENT+bind()+listen() and returns the raw fd for
Node to adopt via server.listen({ fd }); the original destination is then read
from socket.localAddress/localPort (TPROXY preserves it — no SO_ORIGINAL_DST).
transparentSocket.ts loads the addon CONDITIONALLY (Linux-only, optional build)
so a JS-only install keeps working — TPROXY mode is gated on availability.
Injected require/platform make the load logic unit-testable; the addon is not
committed (build/ is git-ignored), so CI exercises the graceful-unavailable path.
Viability proven on the VPS (kernel 6.8.0-124): the prebuilt .node compiled here
loaded under a different Node version (N-API ABI-stable) and, as root, created
the IP_TRANSPARENT socket which Node adopted. Build is opt-in
(npm run build:native:tproxy). Listener wiring, route, UI, prebuild
distribution, and a live intercept stay gated as follow-ups. 6/6 tests.
Contributor
|
Warning You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again! |
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
This was referenced Jun 18, 2026
Merged
tkgo11
pushed a commit
to tkgo11/OmniRoute
that referenced
this pull request
Sep 23, 2026
…Epic A) (cheaper-inference#4148) TPROXY IP_TRANSPARENT native addon + conditional loader (Epic A). Opt-in (não compila no npm install; loader degrada gracioso non-Linux/sem-toolchain). Groundwork — listener/captura/UI = follow-ups gated. Integrado em release/v3.8.29.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Resolves the architectural blocker for Fase 3 / Epic A (TPROXY transparent capture mode): Node's
netcannotsetsockopt(IP_TRANSPARENT)beforebind(), which TPROXY requires (the kernel drops the redirected packets otherwise). This PR adds a tiny N-API addon that creates the transparent socket, plus a conditional loader so it never breaks a JS-only install.src/mitm/tproxy/native/transparent.c—socket()+SO_REUSEADDR+IP_TRANSPARENT+bind()+listen(), returns the raw fd. Node adopts it viaserver.listen({ fd })and reads the original destination fromsocket.localAddress/localPort(TPROXY preserves it — noSO_ORIGINAL_DST/NAT).src/mitm/tproxy/transparentSocket.ts— loads the prebuilt addon conditionally (Linux-only, optional build).isTransparentSocketAvailable()gates the TPROXY mode;createTransparentListenerFd()throws a clear, actionable error when unavailable. Injectedrequire/platformmake the load logic unit-testable.npm run build:native:tproxy);build/+prebuilds/are git-ignored, so the addon is not committed and CI exercises the graceful-unavailable path.Viability proven on the VPS (Hard Rule #18)
Validated on
root@192.168.0.15(kernel6.8.0-124-generic):Together with the iptables/ip-rule apply+revert already validated on the same kernel (#4139), both Epic A blockers — the TPROXY rules and the transparent socket — are now proven on a real kernel.
Not in this PR (gated follow-ups)
repairMitm()callingrevertTproxy()(feat(mitm): TPROXY setup layer — transactional apply/revert (Epic A) #4144) so a crash flushes the mangle rules.prebuildify, linux-x64/arm64 only — IP_TRANSPARENT is Linux-only).Test Plan
node --test tproxy-transparent-socket.test.ts— 6/6 (non-Linux skip, absent-addon graceful, well-shaped load, bad-shape reject, unavailable-throws)npm run build:native:tproxycompiles the addon cleanly (node-gyp)typecheck:core— 0 errors ·eslint— 0🤖 Generated with Claude Code