Commit Graph

8 Commits

Author SHA1 Message Date
winlin
7ede26453e Claude: Add HTTP API proxy seams, unit tests, and proxyfakes. 2026-05-17 10:39:07 -04:00
winlin
0a18a4a13b Claude: Add HTTP proxy seams and unit tests.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-16 21:27:24 -04:00
winlin
f42921d7b1 Claude: Add SRT proxy seams and unit tests.
Mirror the listener and backend dial seams already in place on rtc.go so
the SRT proxy is unit-testable without binding real UDP sockets:
- srsSRTProxyServer.listener: *net.UDPConn -> net.PacketConn, with a
  new listenUDP factory injected via functional option.
- SRTConnection.backendUDP: *net.UDPConn -> io.ReadWriteCloser, with a
  new dialBackendUDP factory; connectBackend uses it instead of
  building a net.UDPAddr and calling net.DialUDP directly.
- handleClientUDP / HandlePacket / handleHandshake take net.Addr
  instead of *net.UDPAddr; writes go through PacketConn.WriteTo.
- Fix a latent SA4001: v.handshake3 = &*handshake3p was no copy at
  all, so the subsequent SynCookie rewrite mutated the just-decoded
  backend packet. Replace with an explicit value copy.

Adds internal/proxy/srt_test.go covering SRTHandshakePacket marshal
roundtrip and stream-id parsing (100%), SRTConnection handshake-0,
handshake-2 full replay, and connectBackend error paths, plus
srsSRTProxyServer constructor/lifecycle and handleClientUDP routing.
Reuses fakeBackendUDP / fakePacketConn / blockingUDPListener from
rtc_test.go for consistency.

Verified with proxy-utest.sh and the full proxy-e2e suite (rtmp,
cluster, redis, transmux, srt, whip).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-16 20:30:22 -04:00
winlin
953b0d63ca Claude: Add WebRTC proxy seams and unit tests.
Introduce listenUDP and backendURL functional-option seams on
webRTCProxyServer and a dialBackendUDP seam on rtcConnection, mirroring
the pattern already used by rtmpProxyServer. The seams default to the
real net.ListenUDP / http URL builder / net.Dialer so production
behavior is unchanged, but unit tests can now inject fakes.

Cover webRTCProxyServer with focused tests: constructor defaults
(including the three default-backendURL branches), Close with no
listener, Run's listen error / endpoint normalization / graceful
shutdown, HandleApiForWHIP and HandleApiForWHEP CORS preflight, Pick
error, full happy-path against an httptest backend asserting SDP port
rewrite and StoreWebRTC wiring, proxyApiToBackend error paths
(backendURL error, non-2xx, malformed answer), and handleClientUDP's
non-STUN, RTP-like, short-STUN, cached-username, LB-load, LB-error,
and cached-address paths. internal/proxy package coverage rises from
~23% to 43.4%.

Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-16 19:21:34 -04:00
winlin
7b4c4dc999 Claude: Add RTMP proxy seams and unit tests.
Refactor internal/proxy/rtmp.go to expose functional-option seams
(listen, newConnection, newHandshake, newProtocol, newBackend, dial)
and widen the proxy server and connection to net.Listener / net.Conn
so fakes can be injected. Tighten the identify switch in serve() to
a real switch on CommandName.

Add internal/proxy/rtmp_test.go covering rtmpProxyServer (constructor
defaults, options, Close, listen error, endpoint normalization,
accept-loop, graceful shutdown), rtmpConnection (defaults, serve
handshake/protocol error paths, identify-loop branches, newBackend
invocation contract), and rtmpClientToBackend (Close, Connect happy
and error paths, publish, play). rtmp.go statement coverage rises to
76.9% with every function exercised.
2026-05-16 16:54:11 -04:00
winlin
f45bf30b46 Codex: Remove global proxy load balancer.
Create the origin load balancer in proxy bootstrap and pass it explicitly into protocol servers and system API handlers. Also keep load balancer implementations package-private and rename the default debugging origin helper.

Co-authored-by: chatgpt-codex-connector[bot] <199175422+chatgpt-codex-connector[bot]@users.noreply.github.com>
2026-05-10 21:00:17 -04:00
winlin
3b93ddfddf Codex: Rename origin load balancer types. 2026-05-10 20:43:56 -04:00
winlin
8db8f8d9b4 Proxy: Rename internal/server package to internal/proxy
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-10 18:09:48 -04:00