Skip to content

xforward: TCP/UDP packet forwarder - #350

Draft
soypat wants to merge 3 commits into
mainfrom
xforward
Draft

soypat wants to merge 3 commits into
mainfrom
xforward

Conversation

@soypat

@soypat soypat commented Nov 14, 2026 •

Copy link
Copy Markdown
Owner
/*
Package xforward terminates TCP and relays UDP for IP packets addressed to
any destination, answering as that destination. It owns IP framing: replies
are sourced from the address the peer originally targeted.

The *Handler types are synchronous and unsynchronized: no goroutines, locks,
deadlines or blocking. Work happens only when the caller calls in, so a
microcontroller can drive everything from one loop:

	for {
		n := dev.Recv(buf)
		pkt, err := xforward.ValidatePacket(buf[:n], &vld)
		if err == nil && pkt.Proto() == lneto.IPProtoTCP {
			flow, isNew, _ := th.Demux(pkt)
			if isNew {
				th.Accept(flow, rxbuf, txbuf) // Or dial upstream first, then Accept/Reject.
			}
		}
		for {
			n, _ = th.Encapsulate(out[:mtu], 0)
			if n == 0 {
				break
			}
			dev.Send(out[:n])
		}
	}
*/

@codecov

codecov Bot commented Nov 14, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 84.95093% with 138 lines in your changes missing coverage. Please review.
✅ Project coverage is 71.50%. Comparing base (94d0932) to head (502a906).

Files with missing lines Patch % Lines
x/xforward/tcp.go 83.46% 35 Missing and 26 partials ⚠️
x/xforward/tcpforwarder.go 75.14% 31 Missing and 11 partials ⚠️
x/xforward/packet.go 82.40% 10 Missing and 12 partials ⚠️
x/xforward/rst.go 81.81% 2 Missing and 2 partials ⚠️
x/xforward/udp.go 96.26% 2 Missing and 2 partials ⚠️
x/xforward/flowtable.go 95.31% 2 Missing and 1 partial ⚠️
x/xforward/xforward.go 96.72% 1 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #350      +/-   ##
==========================================
+ Coverage   70.54%   71.50%   +0.96%     
==========================================
  Files         152      159       +7     
  Lines       17611    18528     +917     
==========================================
+ Hits        12423    13248     +825     
- Misses       4189     4236      +47     
- Partials      999     1044      +45     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@github-actions

Copy link
Copy Markdown

memci size/alloc report xforward vs. main@94d0932

No change across 2 binaries and 20 benchmarks.

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.

1 participant