Repository navigation
Compress only routes that opt in, share one rate limiter and one guarded art fetcher - #558
Merged
Merged
Conversation
…ded art fetcher, and stop warning on a cancelled scope
Community covers and podcast discovery each built their own netguard-dialled transport, so a change to the dial guard or the no-proxy rule had to land twice. netguard.Transport now owns the guarded dialer, the nil proxy and the idle pool; discovery only adds HTTP/2. A cover URL is checked with the meta package's absoluteHTTP rule, and discovery's artwork fetch is bounded by its own per-fetch context again instead of a second, fixed client timeout. Part of #219.
Scope reads, search and the upcoming reads each repeated the context.Canceled test that keeps a cancelled request out of the warning log. requestGaveUp is that rule in one place. Part of #260.
CONVENTIONS still described the deleted compression deny list (compressExcluded), the old limiter and the podcast quota package, and code comments still named a compress middleware. They now describe compressJSON at registration, internal/quota and media.ArtFetcher. Two test rows that registered a plain handler like the new-route row, and so proved nothing about streams or upgrades, are gone. Part of #270 and #219.
These four admin GETs were gzipped before compression became a per-route opt-in, and none returns a credential, but they were registered without compressJSON: a Logs page of up to 1000 entries or a large library export went out uncompressed. They opt in again, and TestCompressExclusions now checks GET and HEAD for every route that stays out. Part of #270.
netguard.Transport left MaxResponseHeaderBytes at net/http's 10 MiB default, so only the body was capped: a hostile cover, artwork or directory host could make each fetch slot hold megabytes of headers before the body cap applied. Both guarded transports now read at most netguard.MaxHeaderBytes (64 KiB). Part of #219.
CONVENTIONS said every compressJSON route sits inside requireAuth or requireAdmin and that every JSON answer on an opted-in route carries Vary; the public GET /server is wrapped bare, and a Range or Upgrade request gets neither gzip nor Vary. The read-along doc still said any gzip client gets the gzipped map, and discovery's comment named fetchImage where queuedImage sets the per-fetch budget. Part of #270.
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.
Security hardening from #270, #219 and #260.
Compression fails closed (#270). A route compresses only when it opts in at registration. Every JSON read that compressed on main still does, and that was checked live on all 123 GET routes: no encoding differences, apart from two intended ones. A read-along request with Range is now identity, as is a request carrying
Upgrade. These never compress:/auth/*responses,GET /auth/tokens, the calendar link);HEAD sends the same headers as GET with no body.
One rate limiter, one art fetcher (#219).
internal/quotais the one token bucket for the API and podcast limits. Every budget and key is unchanged, including server#553's per-Bridge-token 2,000/s with a 20,000 burst (unproved tokens pay the address bucket first) and the 10-wrong-codes lockout (429, Retry-After 900).internal/media/remoteart.go,netguard.Transport). It refuses a non-public dial, including after redirects and DNS names that resolve to private addresses, and uses no proxy, with size and time caps. It now also refuses URLs carrying user info (main sent those credentials) and caps response headers at 64 KiB.Cancelled scope reads (#260). A scope read the client cancelled no longer logs a warning: 1,404 warnings on main became 0 in a live run of 4,000 dropped reads. Real failures still log. Cancelled list reads that go through
writeCatalogErrorstill warn, as on main; that is a follow-up.Verified live against main:
Gates green on both SQLite engines, and the wire goldens are untouched.