Repository navigation
Refactor: Split forwardproxy/server.go into six files by job - #1690
Conversation
server.go had 3834 lines and six jobs. This change moves code only. It changes no signature and no statement. Each declaration moves with its doc comment to a file in the same package: - tunnel.go: CONNECT handling, the pre-dial and its memo, tunnelLog - bridging.go: the TLS bridge path, its CA and handshake helpers - upgrade.go: WebSocket upgrades (decline, splice, relay) - identity.go: session identity and attribution - record.go: session rows for requests, responses and refusals - stream.go: the SSE relay and the buffered fallback server.go keeps the Server type, NewServer, the mTLS dialer, serveOutbound and the header helpers. It has 1322 lines now. serveOutbound alone has 645 lines, and a pure move cannot split it. Two test files change, and no test logic changes: - dispatch_audit_test.go keys each dispatch site by file name. Six keys now say stream.go in place of server.go. - A comment in session_identity_test.go now says identity.go. Check: a script parsed the package before and after the move. It compared every top-level declaration (with its doc comment) and every free comment, as text. The two sets are equal. golangci-lint gives the same 42 findings before and after the move. Part of rossoctl#1584. Signed-off-by: Hai Huang <huang195@gmail.com> Assisted-By: Claude (Anthropic AI) <noreply@anthropic.com>
|
Warning Review limit reachedYou've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Next included review available in 29 minutes. View limit details
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. |
clawgenti
left a comment
There was a problem hiding this comment.
Summary
Pure move, verified independently. I parsed core/listener/forwardproxy (non-test files) at base dc15da6b and at head with go/ast: the sorted set of every top-level declaration (with its doc comment) and every free comment is byte-identical before and after. There are no init funcs or //go: directives in the package, and the package-level vars that moved (dialTCP, errIdleCut) have no cross-var initialization dependencies, so file order can't change init order. The two test edits are rename-only: the six dispatch_audit_test.go keys point at stream.go, which is where handleStreamingResponse / streamPassthrough / streamFallbackBuffered now live, and the serveOutbound keys correctly stay on server.go.
Locally: GOWORK=off go build ./..., go vet ./listener/..., and go test ./listener/forwardproxy/... ./listener/parity/... all pass at head.
Non-blocking, outside this diff: the existing line-number pointer forwardproxy/server.go:377 and :880 in core/session/intern.go was already stale on base, so the move doesn't affect it. A follow-up could swap it for function names (serveOutbound, the response-phase snapshot) so the next split doesn't strand it again.
Author: @huang195 (MEMBER, maintainer)
Areas reviewed: Go (forwardproxy package split, parity audit test)
Agent/IDE config (.claude/.vscode): none
Commits: 1 commit, all signed-off: yes
CI status: passing, except the CodeQL summary check. Its 31 annotations are all in core/plugins/* and core/pipeline/context.go, files this PR doesn't touch. They look like the "change too large" re-attribution the check itself warns about, not new findings. agentop and macOS peerproc jobs were still pending when I checked.
Only stream.go uses the idle read cutoff. The code was in tunnel.go, and its time limit was in server.go. This change moves both into stream.go: - idleReadCloser, idleReader and errIdleCut, from tunnel.go - streamReadIdleTimeout, from server.go It moves code only, with each doc comment. It changes no statement. Part of rossoctl#1584. Assisted-By: Claude (Anthropic AI) <noreply@anthropic.com> Signed-off-by: Hai Huang <huang195@gmail.com>
clawgenti
left a comment
There was a problem hiding this comment.
Summary
Re-review at d74b887d. My earlier approval covered fe20e431. The only new commit, d74b887d, moves streamReadIdleTimeout (from server.go) and idleReadCloser / idleReader / errIdleCut (from tunnel.go) into stream.go, each with its doc comment, and updates the import blocks (sync/atomic dropped from tunnel.go; sync, sync/atomic, time added to stream.go). The move fits: the two idleReader call sites and the errIdleCut match in classifyBrokenStream are all in stream.go, and the only other user is truncated_stream_test.go, which is in the same package.
I re-ran the same go/ast check against base dc15da6b: the sorted set of top-level declarations (with doc comments) and free comments in the package's non-test files is byte-identical at base, at fe20e431 and at d74b887d. errIdleCut is a plain errors.New var with no init dependencies, so moving it to another file can't change init order. No test files changed in this commit, and the dispatch_audit_test.go keys from the first commit still match.
Locally at head: GOWORK=off go build ./..., go vet ./listener/... and gofmt -l are clean, and go test -count=1 ./listener/forwardproxy/... ./listener/parity/... ./session/... passes.
The earlier review had no findings to address. Its one non-blocking note (the stale server.go:377 and :880 pointer in core/session/intern.go) is outside this diff and still applies as an optional follow-up.
Author: @huang195 (MEMBER, maintainer)
Areas reviewed: Go (forwardproxy package split, parity audit test)
Agent/IDE config (.claude/.vscode): none
Commits: 2 commits, all signed-off: yes
CI status: all checks passing (CodeRabbit and Spellcheck skipped)
Summary
Part of #1584. This PR moves code only. It changes no signature and no statement.
core/listener/forwardproxy/server.gohad 3834 lines and six jobs. Each declaration moves, with its doc comment, to a new file in the same package:tunnel.gotunnelLogbridging.goupgrade.goidentity.gorecord.gostream.goserver.gokeeps theServertype,NewServer, the mTLS dialer,serveOutboundand the header helpers. The issue expected about 600 lines. The result is 1322 lines, becauseserveOutboundalone has 645 lines, and a pure move cannot split one function.upgrade.gois not in the issue. The WebSocket upgrade code arrived after the audit.Test changes
No test logic changes.
core/listener/parity/dispatch_audit_test.gokeys each dispatch site by file name. Six keys now saystream.goin place ofserver.go.session_identity_test.gonow saysidentity.go.How to review
The only lines that are not dimmed are the new file headers (package clause and imports), the import block of
server.go, and the two test changes.Checks
GOWORK=off go build ./...,go vetandgo test ./...pass incore.golangci-lint --max-same-issues=0 --max-issues-per-linter=0gives the same 149 findings before and after the move.CodeQL
CodeQL reported 31 new alerts (
go/clear-text-logging,go/log-injection). All of them are in files that this PR does not change:inferencerouter,sessionbudget,pipeline/context.goand the parsers.mainhas none of these alerts. The doc comment ofhydrateSession(now inidentity.go) records the same result from #1569. When a source line moves, the diff-informed analysis of CodeQL reports its old taint paths as new. The alerts on this PR are now dismissed as false positives.Assisted-By: Claude (Anthropic AI) noreply@anthropic.com