summaryrefslogtreecommitdiff
path: root/app/config.go
Commit message (Collapse)AuthorAgeFilesLines
* update org nameChristian Cleberg47 hours1-1/+1
|
* fix: reject forged subdomains in the media proxy (#9)Christian Cleberg2026-07-151-0/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * fix: make memcache concurrency-safe and stamp the version at link time memcache was a crash waiting for traffic. Readers touched tempFS without holding mx, while a per-entry goroutine deleted from it under the lock: a concurrent map read and map write, which the runtime treats as a fatal error that recover cannot catch. The option ships in config.example.json and was the one cache key SETUP.md never documented, so it read like a free win to enable. Put every map and field access behind the mutex, and age the whole map from one janitor instead of a goroutine per cached file, each of which looped forever holding its entry alive. mx is now a plain Mutex: every operation here mutates something, and the old code took an RLock to write. Document the option, and cover it with tests that run the readers, writers and janitor concurrently. Split the disk/origin fetch out of DownloadAndSendMedia while there, so the error path returns instead of falling through to write an empty body after the error page. Release.Version was hardcoded to 1.3.2, so images tagged v1.3.6 reported 1.3.2 from --help and /api/instance, and --help linked to the wrong release. Take it from a main.version string the release workflow links in from the git tag. * fix: reject forged subdomains in the media proxy DownloadAndSendMedia built its upstream URL by concatenation, pasting the subdomain segment of the request path straight into the host position. That segment reaches the handler already percent-decoded, so it can carry "@", "#", "?" and "/" — the characters that end a host. A request for /media/file/[email protected]:8080%2F/f/x.jpg built a URL whose host parsed as 127.0.0.1:8080, with images-wixmp-x demoted to userinfo, letting any caller aim the instance's fetcher at any address it could reach, including services behind the firewall. Validate the label against ^[a-zA-Z0-9-]+$ and refuse anything else with a 400. Rejecting rather than escaping is what closes this: the label is the host, and url.URL passes a host through verbatim, so building the URL structurally is not sufficient on its own. DeviantArt's own media URLs use a hex-and-dash label, and ParseMedia already splits on the first dot, so a legitimate label cannot contain one. Build the URL from url.URL fields as well, which escapes the path, and encode the token argument, which reached the request unescaped. Reported by CodeQL as go/request-forgery (CWE-918).
* fix: refuse to start when the cache directory is not writableChristian Cleberg2026-07-151-1/+28
| | | | | | | | | | | An unwritable cache directory degraded silently: media still served, because the download succeeds before the cache write is attempted, so the only symptom was one "permission denied" line per request and a cache that never filled. Every request re-fetched from the CDN. Probe the directory at startup and exit with the uid and the chown that fixes it. The container image runs as uid 10000, which is the usual cause with a bind-mounted cache, so say so in the message and in both compose examples.
* fix: document exported API, fix naming, and harden Downloadv1.3.3Christian Cleberg2026-07-151-15/+23
| | | | | | | | | | | | | | | | | | | | | | | | | | | | The remaining golangci-lint findings. These land together because the Url -> URL rename spans util.go, parsers.go and wrapper.go, and splitting it would leave an intermediate commit that does not compile. Download() carried the most serious bug here: try() only prints an error, it does not return, so a failed request fell through to resp.Body.Close() on a nil resp and panicked. Every failure path now returns the zero Downloaded, and callers check Status. ReturnHTTPError guards against the resulting status 0, which would otherwise panic WriteHeader. Requests carry a context with a timeout (noctx), and a download-proxy now routes through ProxiedTransport so it keeps the DA throttle and timeouts. Also: - doc comments on all 48 exported symbols (revive's exported rule, with checkPrivateReceivers, since most of app is exported methods on the unexported skunkyart type), plus package docs in new doc.go files so both the embed and non-embed builds are covered. - ST1003 naming: UrlBuilder -> URLBuilder, id_search -> idSearch, cache_config -> cacheConfig, TXT_RAW -> TxtRaw, mediaUrl -> mediaURL. - explicit json tags on structs that are unmarshaled (musttag); the hyphenated keys already had tags, the rest relied on case-insensitive fallback. Behaviour is unchanged. - modernization: range-over-int, WaitGroup.Go, stale +build lines, interface{} -> any, strings.Builder over string concatenation in a loop.
* fix(cache): correct max-size megabyte conversionChristian Cleberg2026-07-151-1/+3
| | | | | | | | | | max-size is documented in SETUP.md as megabytes, but the conversion was `*= 1024 ^ 2`. In Go `^` is XOR, not exponentiation, so this multiplied by 1026 rather than 1048576 -- a configured max-size of 200 produced a ~205 KB cap instead of 200 MB, wiping the cache almost immediately. This changes runtime behaviour: the cache will now grow to the size the config actually asks for.
* deps: migrate to github.com/zerolabsco/devianter v0.3.1Christian Cleberg2026-07-141-1/+1
| | | | | | | | | | Repoint the import path from git.macaw.me/skunky/devianter, replacing a placeholder v0.0.0 require that had no go.sum entry and did not resolve. v0.3.1 reorders the last two return values of PerformSearch, Group.Get and Group.Gallery from (..., error, Error) to (..., Error, error); adapt the call sites. The two types differ, so the compiler enforces this.
* Add da.opnxng.com + lost-skunk.cc is now in Finlandlost+skunk2025-04-071-0/+0
|
* Переключатель кеша в озу, небольшие ↵lost+skunk2025-02-221-3/+4
| | | | улучшения ксс, фикс нсфв, фикс максимального размера кеша
* v1.3.2v1.3.2lost+skunk2024-09-231-2/+7
|
* отображение ошибокlost+skunk2024-09-041-1/+1
|
* Два API-эндпоинтаlost+skunk2024-09-031-0/+5
|
* темплейты в бинарнике и улучшенная ↵lost+skunk2024-08-131-7/+9
| | | | система кеша
* v1.3lost+skunk2024-08-011-42/+6
|
* Подготовка к релизу v1.3.1lost+skunk2024-07-301-16/+53
|
* Сервис для опенрцlost+skunk2024-07-131-1/+6
|
* v1.3lost+skunk2024-07-131-40/+41
|
* Реки и копирование темплейтов в озуlost+skunk2024-07-061-14/+18
|
* Реализация конфигаlost+skunk2024-07-061-19/+50
|
* альфа: работают только посты и поискlost+skunk2024-06-131-0/+48