Proxy: Modernize internal packages on stdlib and add unit tests. v7.0.145#4667
Merged
Conversation
Replaces the pkg/errors fork with a thin wrapper over the standard
library's errors package. A single withStack struct captures stack
traces via runtime.Callers, while fmt.Errorf("%w", ...) handles all
message wrapping. This enables errors.Is/As/Unwrap chain traversal
(the fork silently broke them) and deletes ~190 lines of stack/frame
formatting code. Adds table-driven tests at 100% statement coverage.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Drop the deprecated io/ioutil and the stdlib errors alias — the internal errors package already re-exports Is, As, Unwrap, and Join, so callers can keep a single import. Add a utils_test.go covering every exported helper (API response/error/CORS, ParseBody, BuildStreamURL, peer/closed network classifiers, URL→stream conversion, RTC/SRT packet sniffers, ICE/SRT parsers, and ParseListenEndpoint) for 96.3% statement coverage. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Cover all five version helpers (VersionMajor, VersionMinor, VersionRevision, Version, Signature). The revision assertion checks that the value is positive rather than pinning an exact number so the test survives future version bumps. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Introduce signalNotify and osExit indirections so InstallSignals and InstallForceQuit can be exercised without real OS signal delivery or process termination. Coverage is 100% in isolation. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Replaces the stdlib log.Logger with log/slog JSON handlers (UTC timestamps, semantic level labels via custom slog.Level values), hides withContextID since it has no external callers, and adds unit tests reaching 100% statement coverage for the package. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Update the internal/env entry to reflect the in-tree .env parser (replacing godotenv) and the counterfeiter-generated envfakes package. Update the internal/version entry to use the SRSX signature and align with the SRS project version, dropping the stale SRSProxy v1.5.0 label. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
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.
Modernizes several
internal/*packages under the Go proxy, replacesthird-party forks with standard-library primitives, and brings the
test suite from near-zero to high coverage across the touched packages.
Package changes
internal/errors— Rewrites thepkg/errorsfork as a thin wrapperover stdlib
errors. A singlewithStackstruct captures stacktraces via
runtime.Callers;fmt.Errorf("%w", ...)handles allmessage wrapping. Restores
errors.Is/As/Unwrapchain traversal(silently broken in the fork) and deletes ~190 lines of stack/frame
formatting.
Is,As,Unwrap, andJoinare re-exported socallers need a single import.
internal/logger— Swaps stdliblog.Loggerforlog/slogJSONhandlers with UTC timestamps and custom level labels (
verb,debug,warn,error). HideswithContextID(no external callers).internal/sync— ConvertsMap[K, V]from a concrete struct toan interface with a
NewMapconstructor for testability.internal/signal— AddssignalNotify/osExitindirections soInstallSignalsandInstallForceQuitcan be exercised without realOS signals or process termination.
internal/utils— Drops deprecatedio/ioutiland the stdliberrorsalias (the internalerrorspackage re-exports what'sneeded).
internal/version— No code changes; fully covered by new tests.