summaryrefslogtreecommitdiff
path: root/internal/router
AgeCommit message (Collapse)AuthorFiles
2025-01-31[bugfix] shut down LE server nicely (#3714)Libravatar tobi1
* [bugfix] shut down LE server nicely
2024-09-20[chore] ensure consistent caller name fetching regardless of compiler ↵Libravatar kim1
inlining (#3323) * move logging levels into log package itself * ensure inconsistent inlining doesn't mess with log calling function name * remove unused global variable * fix log level
2024-05-29[chore] improved startup / shutdown (#2925)Libravatar kim1
* improved server shutdown with more precise shutdown of modules + deferring of ALL of it * make the same changes to the testrig server * use testrig specific func * update variable name to fix nilptr * fix removal of setting db on state
2023-12-27[chore] Refactor HTML templates and CSS (#2480)Libravatar tobi3
* [chore] Refactor HTML templates and CSS * eslint * ignore "Local" * rss tests * fiddle with OG just a tiny bit * dick around with polls a bit more so SR stops saying "clickable" * remove break * oh lord * don't lazy load avatar * fix ogmeta tests * clean up some cruft * catch remaining calls to c.HTML * fix error rendering + stack overflow in tag * allow templating attributes * fix indent * set aria-hidden on status complementary content, since it's already present in the label anyway * tidy up templating calls a little * try to make styling a bit more consistent + readable * fix up some remaining CSS issues * fix up reports
2023-12-12[bugfix] Let templates deref pointers, as a treat (#2448)v0.13.0-rc2Libravatar tobi1
2023-12-12[bugfix] poll vote count fixes (#2444)Libravatar kim1
* don't drop all vote counts if hideCounts is set, refactors poll option extraction slightly * omit voters_count when not set * make voters_count a ptr to ensure it is omit unless definitely needed * handle case of expires_at, voters_count and option.votes_count being nilable * faster isNil check * remove omitempty tags since mastodon API marks things as nullable but still sets them in outgoing json
2023-11-22[feature] Poll web view (#2377)Libravatar tobi1
* [feature] Render polls nicely on the web view * use figure for poll, other small tweaks * reverse share + count (lines up better) * poll options list entries * fix up some remaining things
2023-11-13[feature/performance] Wrap incoming HTTP requests in timeout handler (#2353)Libravatar tobi3
* deinterface router, start messing about with deadlines * weeeee * thanks linter (thinter) * write Connection: close when timing out requests * update wording * don't replace req * don't bother with fancy Cause functions (I'll use them one day...)
2023-08-02[bugfix] handle HEAD requests more elegantly (#2055)Libravatar kim1
Signed-off-by: kim <grufwub@gmail.com>
2023-05-11[frontend] Profiles with fields & more (#1764)Libravatar f0x521
* redesign status template * separate index page styling * redesign profile template * fix header styling/wrapping * remove old spoiler js * fix status cw button wrapping * fix status info variables * profile responsiveness, accessibility tweaks * fix variable use, mobile * remove duplicate id's * rss icon, fix indent * fix toot border-radius * fix toot spacing * emojify and html profile fields * refactor (sensitive) media rendering * plaintext profile fields * bundle plyr icon svg * only pause video when switching photoswipe slides * yarn upgrade * profile fields formatting * replace uglifyify with @browserify updated fork * fix profile field templating (yet again) * fix React classes * testrig: add testing profile field for admin user * fix sensitive media interactions * Revert "testrig: add testing profile field for admin user" This reverts commit 80490c183e6639ce5b57fcfca6772d8f96df8706. * settings interface wrapping * fix reported toot styling * add role to profile sr-only text * comment fallback rule * remove currently unused image description lacking indicator
2023-03-12[chore] Improve copyright header handling (#1608)Libravatar Daenney3
* [chore] Remove years from all license headers Years or year ranges aren't required in license headers. Many projects have removed them in recent years and it avoids a bit of yearly toil. In many cases our copyright claim was also a bit dodgy since we added the 2021-2023 header to files created after 2021 but you can't claim copyright into the past that way. * [chore] Add license header check This ensures a license header is always added to any new file. This avoids maintainers/reviewers needing to remember to check for and ask for it in case a contribution doesn't include it. * [chore] Add missing license headers * [chore] Further updates to license header * Use the more common // indentend comment format * Remove the hack we had for the linter now that we use the // format * Add SPDX license identifier
2023-03-04[feature] Allow loading TLS certs from disk (#1586)Libravatar Daenney1
Currently, GtS only supports using the built-in LE client directly for TLS. However, admins may still want to use GtS directly (so without a reverse proxy) but with certificates provided through some other mechanism. They may have some centralised way of provisioning these things themselves, or simply prefer to use LE but with a different challenge like DNS-01 which is not supported by autocert. This adds support for loading a public/private keypair from disk instead of using LE and reconfigures the server to use a TLS listener if we succeed in doing so. Additionally, being able to load TLS keypair from disk opens up the path to using a custom CA for testing purposes avoinding the need for a constellation of containers and something like Pebble or Step CA to provide LE APIs.
2023-02-17[feature] Add a request ID and include it in logs (#1476)Libravatar Daenney2
This adds a lightweight form of tracing to GTS. Each incoming request is assigned a Request ID which we then pass on and log in all our log lines. Any function that gets called downstream from an HTTP handler should now emit a requestID=value pair whenever it logs something. Co-authored-by: kim <grufwub@gmail.com>
2023-02-13[performance] processing media and scheduled jobs improvements (#1482)Libravatar kim1
* replace media workers with just runners.WorkerPool, move to state structure, use go-sched for global task scheduling * improved code comment * fix worker tryUntil function, update go-runners/go-sched * make preprocess functions package public, use these where possible to stop doubled up processing * remove separate emoji worker pool * limit calls to time.Now() during media preprocessing * use Processor{} to manage singular runtime of processing media * ensure workers get started when media manager is used * improved error setting in processing media, fix media test * port changes from processingmedia to processing emoji * finish code commenting * finish code commenting and comment-out client API + federator worker pools until concurrency worker pools replaced * linterrrrrrrrrrrrrrrr --------- Signed-off-by: kim <grufwub@gmail.com>
2023-01-05[chore] Update/add license headers for 2023 (#1304)Libravatar tobi3
2023-01-02[chore] The Big Middleware and API Refactor (tm) (#1250)Libravatar tobi8
* interim commit: start refactoring middlewares into package under router * another interim commit, this is becoming a big job * another fucking massive interim commit * refactor bookmarks to new style * ambassador, wiz zeze commits you are spoiling uz * she compiles, we're getting there * we're just normal men; we're just innocent men * apiutil * whoopsie * i'm glad noone reads commit msgs haha :blob_sweat: * use that weirdo go-bytesize library for maxMultipartMemory * fix media module paths
2022-10-08[feature] Add opt-in RSS feed for account's latest Public posts (#897)Libravatar tobi1
* start adding rss functionality * add gorilla/feeds dependency * first bash at building rss feed still needs work, this is an interim commit * tidy up a bit * add publicOnly option to GetAccountLastPosted * implement rss endpoint * fix test * add initial user docs for rss * update rss logo * docs update * add rssFeed to frontend * feed -> feed.rss * enableRSS * increase rss logo size a lil bit * add rss toggle * move emojify to text package * fiddle with rss feed formatting * add Text field to test statuses * move status to rss item to typeconverter * update bun schema for enablerss * simplify 304 checking * assume account not rss * update tests * update swagger docs * allow more characters in title, trim nicer * update last posted to be more consistent
2022-10-02[chore] Use shorter timestamps in frontend for replies (#875)Libravatar tobi1
* rename timestampShort -> timestampVague * add ParseISO8601 * start fiddling with timestamp * pad/margin a bit more consistently * remove visibilty icon, change timestamp use * update timestamp logic * check + log errors * properly cut-off long display- and usernames Co-authored-by: f0x <f0x@cthu.lu>
2022-09-19[bugfix] Server and closer bugfixes (#839)Libravatar tobi1
* defer streaming from storage more forcefully * shut down Server more gracefully * use command context as server BaseContext
2022-09-17[bugfix] Fix domains not being unblockable, log internal server errors from ↵Libravatar tobi1
API (#833) * log internal server errors from 500 api calls * don't exec into nil dest * don't exec into nil dest * log error in router logger not api errorhandling * update logging a tad * linter
2022-09-07[feature] opengraph meta tags (#806)Libravatar f0x521
* f0x gitignore additions * better meta title and descriptions * user avatar icon for thread and profile meta tags * use proper tag for image * whitespace * add noescapeAttr template function * use ogMeta struct for opengraph * maxOGDescriptionLength = 300 Co-authored-by: tsmethurst <tobi.smethurst@protonmail.com>
2022-09-02[feature] Emojify spoiler and content in web templates (#785)Libravatar Blackle Morisanchetto1
* Emojify spoiler and content in web templates * Use more performance emojify code (thanks NyaaaWhatsUpDoc!)
2022-07-19[chore] use our own logging implementation (#716)Libravatar kim3
* first commit Signed-off-by: kim <grufwub@gmail.com> * replace logging with our own log library Signed-off-by: kim <grufwub@gmail.com> * fix imports Signed-off-by: kim <grufwub@gmail.com> * fix log imports Signed-off-by: kim <grufwub@gmail.com> * add license text Signed-off-by: kim <grufwub@gmail.com> * fix package import cycle between config and log package Signed-off-by: kim <grufwub@gmail.com> * fix empty kv.Fields{} being passed to WithFields() Signed-off-by: kim <grufwub@gmail.com> * fix uses of log.WithFields() with whitespace issues and empty slices Signed-off-by: kim <grufwub@gmail.com> * *linter related grumbling* Signed-off-by: kim <grufwub@gmail.com> * gofmt the codebase! also fix more log.WithFields() formatting issues Signed-off-by: kim <grufwub@gmail.com> * update testrig code to match new changes Signed-off-by: kim <grufwub@gmail.com> * fix error wrapping in non fmt.Errorf function Signed-off-by: kim <grufwub@gmail.com> * add benchmarking of log.Caller() vs non-cached Signed-off-by: kim <grufwub@gmail.com> * fix syslog tests, add standard build tags to test runner to ensure consistency Signed-off-by: kim <grufwub@gmail.com> * make syslog tests more robust Signed-off-by: kim <grufwub@gmail.com> * fix caller depth arithmatic (is that how you spell it?) Signed-off-by: kim <grufwub@gmail.com> * update to use unkeyed fields in kv.Field{} instances Signed-off-by: kim <grufwub@gmail.com> * update go-kv library Signed-off-by: kim <grufwub@gmail.com> * update libraries list Signed-off-by: kim <grufwub@gmail.com> * fuck you linter get nerfed Signed-off-by: kim <grufwub@gmail.com> Co-authored-by: tobi <31960611+tsmethurst@users.noreply.github.com>
2022-07-18[feature] Implement `cache-control` and etags for static assets (#711)Libravatar tobi2
* start working on etag stuff * add + use cache middleware * generate etags on the fly * remove unused field * clean up filepath * add license headers to cache files * add attachgroup function to router interface * move cache into web module * rename a couple things * remove attachStaticFS function from router * rename + tidy up a few things * mount assets filesystem * create assetsFileInfoCache * update comment * simplify hash * fix string fmt * skip last mod chk, prefer strong etags w/long cache * move base handler to its own file this matches the modules in the api folder * generate new etag if file was modified * wrap strong etag in quotation marks as per spec * clarify logic in avatar search * make hashing a little niftier
2022-07-12[chore] improved router logging, recovery and error handling (#705)Libravatar kim3
* move panic recovery to logging middleware, improve logging + panic recovery logic Signed-off-by: kim <grufwub@gmail.com> * remove dead code Signed-off-by: kim <grufwub@gmail.com> * remove skip paths code Signed-off-by: kim <grufwub@gmail.com> * re-enable log quoting Signed-off-by: kim <grufwub@gmail.com> * use human-friendly bytesize in logging body size Signed-off-by: kim <grufwub@gmail.com> * only disable quoting in debug builds Signed-off-by: kim <grufwub@gmail.com> * use logrus level instead of debug.DEBUG() to enable/disable quoting Signed-off-by: kim <grufwub@gmail.com> * shutup linter Signed-off-by: kim <grufwub@gmail.com> * fix instance tests Signed-off-by: kim <grufwub@gmail.com> * fix gin test contexts created with missing engine HTML renderer Signed-off-by: kim <grufwub@gmail.com> * add note regarding not logging query parameters Signed-off-by: kim <grufwub@gmail.com> * better explain 'DisableQuoting' logic Signed-off-by: kim <grufwub@gmail.com> * add license text Signed-off-by: kim <grufwub@gmail.com>
2022-06-03[feature] Start adding advanced configuration options, starting with ↵Libravatar tobi1
`samesite` (#628) * fix incorrect port being used for db * start adding advanced config flags * use samesite lax by default
2022-05-30[chore] Global server configuration overhaul (#575)Libravatar kim4
* move config flag names and usage to config package, rewrite config package to use global Configuration{} struct Signed-off-by: kim <grufwub@gmail.com> * improved code comment Signed-off-by: kim <grufwub@gmail.com> * linter Signed-off-by: kim <grufwub@gmail.com> * fix unmarshaling Signed-off-by: kim <grufwub@gmail.com> * remove kim's custom go compiler changes Signed-off-by: kim <grufwub@gmail.com> * generate setter and flag-name functions, implement these in codebase Signed-off-by: kim <grufwub@gmail.com> * update deps Signed-off-by: kim <grufwub@gmail.com> * small change Signed-off-by: kim <grufwub@gmail.com> * appease the linter... Signed-off-by: kim <grufwub@gmail.com> * move configuration into ConfigState structure, ensure reloading to/from viper settings to keep in sync Signed-off-by: kim <grufwub@gmail.com> * lint Signed-off-by: kim <grufwub@gmail.com> * update code comments Signed-off-by: kim <grufwub@gmail.com> * fix merge issue Signed-off-by: kim <grufwub@gmail.com> * fix merge issue Signed-off-by: kim <grufwub@gmail.com> * improved version string (removes time + go version) Signed-off-by: kim <grufwub@gmail.com> * fix version string build to pass test script + consolidate logic in func Signed-off-by: kim <grufwub@gmail.com> * add license text, update config.Defaults comment Signed-off-by: kim <grufwub@gmail.com> * add license text to generated config helpers file Signed-off-by: kim <grufwub@gmail.com> * defer unlock on config.Set___(), to ensure unlocked on panic Signed-off-by: kim <grufwub@gmail.com> * make it more obvious which cmd flags are being attached Signed-off-by: kim <grufwub@gmail.com>
2022-05-25[security] Set SameSite to `strict` instead of browser default (#606)Libravatar tobi1
2022-05-15[chore] Update LE server to use copy of main http.Server{} to maintain ↵Libravatar kim1
server timeouts etc (#571) * update LE server to use copy of main HTTP server to maintain server timeouts etc Signed-off-by: kim <grufwub@gmail.com> * shutup linter Signed-off-by: kim <grufwub@gmail.com>
2022-05-12[bugfix] Fix server trying to listen twice on same address when l.e. enabled ↵v0.3.3Libravatar tobi1
(#557)
2022-05-02[bugfix] Fix panic when relative tmpl path given to router (#528)Libravatar tobi1
2022-04-29[feature] allow absolute path to templates (#507)Libravatar Terin Stock1
Only attempt to join the `WebTemplateBaseDir` with the current working directory if the user has not configured an absolute path to the template directory. This changeset also makes a similar change to the testrig, allowing tests to configure an alternative location for the templates directory. Fixes #411 Signed-off-by: Terin Stock <terinjokes@gmail.com>
2022-04-28Add support for running profiling when debug build-tags provided (#491)Libravatar kim1
* wrap root HTTP handler in debug.WithPprof(), rearrange router.Start() to support this * remove unused code * set debug buildtag in build script when $DEBUG set * update go-debug version with fixed handler * use clone of router.srv for LE cert manager, reset server timeouts in debug * add kim's other libraries to README
2022-04-16[bugfix] Convert IDNs to punycode before using as session name (#458)Libravatar tobi2
* convert hostname to punycode for session name * test punycode
2022-04-15[feature] Web profile pages for accounts (#449)Libravatar tobi1
* add default avatars * allow webModule to error * return errWithCode from account get * add AccountGetLocalByUsername * check nil requesting account * add timestampShort function for just month/year * move loading logic to New + add default avatars * add profile page view * update swagger docs * add excludeReblogs to GetAccountStatuses * ignore casing when selecting local account by username * appropriate redirects * css fiddling * add 'about' heading * adjust thread page to work with routing * return AP representation if requested + authorized * simplify auth check * go fmt * golangci-lint ignore math/rand
2022-03-13[bugfix] Fix bug where admin panel could not be accessed at `/admin` (#427)Libravatar tobi1
* clarify comments * tidy up static serving + add /admin redirect
2022-02-19[feature] Gin enable gzip encoding (#405)Libravatar tobi2
* add gin gzip dependency * add gzip middleware to router * go mod tidy
2022-02-15[bugfix] Only mark cookies as Secure on https (#398)Libravatar Shadowfacts1
Fixes cookies not being stored/sent by Safari when serving over plain http
2022-02-07[feature] add authorization to the already-existing authentication (#365)Libravatar Forest Johnson3
* add ensureUserIsAuthorizedOrRedirect to /oauth/authorize * adding authorization (email confirm, account approve, etc) to TokenCheck * revert un-needed changes to signin.go * oops what happened here * error css * add account.SuspendedAt check * remove redundant checks from oauth util Authed function * wip tests * tests passing * stop stripping useful information from ErrAlreadyExists * that feeling of scraping the dryer LINT off the screen * oops I didn't mean to get rid of this NewTestRouter function * make tests work with recorder * re-add ConfigureTemplatesWithGin to handle template path err Co-authored-by: tsmethurst <tobi.smethurst@protonmail.com>
2021-12-20Extend license notices to 2022 (#354)Libravatar tobi7
2021-12-20Log when listening (#350)Libravatar embr1
* Log when starting letsencrypt endpoint + clearer errors Running `gotosocial server` with the default configuration will try to bind to :80 and listen for letsencrypt challenges, which will fail if running as non-root (w/o capabilities), or if eg. nginx hogs the port. When that happens, this should make it more obvious what's wrong. * Log what address/port we're listening on Always nice not to have to guess. Also feels more consistent than just doing it for the letsencrypt endpoint.
2021-12-07Implement Cobra CLI tooling, Viper config tooling (#336)Libravatar tobi5
* start pulling out + replacing urfave and config * replace many many instances of config * move more stuff => viper * properly remove urfave * move some flags to root command * add testrig commands to root * alias config file keys * start adding cli parsing tests * reorder viper init * remove config path alias * fmt * change config file keys to non-nested * we're more or less in business now * tidy up the common func * go fmt * get tests passing again * add note about the cliparsing tests * reorganize * update docs with changes * structure cmd dir better * rename + move some files around * fix dangling comma
2021-11-22add bindAddress configuration option (#320)Libravatar tobi1
* add bindAddress configuration option * clarify that bindAddress can be a hostname
2021-11-22Enable stricter linting with golangci-lint (#316)Libravatar tobi1
* update golangci-lint * add golangci config file w/ more linters * correct issues flagged by stricter linters * add more generous timeout for golangci-lint * add some style + formatting guidelines * move timeout to config file * go fmt
2021-10-11reference global logrus (#274)Libravatar R. Aidan Campbell2
* reference logrus' global logger instead of passing and storing a logger reference everywhere * always directly use global logrus logger instead of referencing an instance * test suites should also directly use the global logrus logger * rename gin logging function to clarify that it's middleware * correct comments which erroneously referenced removed logger parameter * setting log level for tests now uses logrus' exported type instead of the string value, to guarantee error isn't possible
2021-10-04Refactor/tidy (#261)Libravatar tobi1
* tidy up streaming * cut down code duplication * test get followers/following * test streaming processor * fix some test models * add TimeMustParse * fix uri / url typo * make trace logging less verbose * make logging more consistent * disable quote on logging * remove context.Background * remove many extraneous mastodon references * regenerate swagger * don't log query on no rows result * log latency first for easier reading
2021-09-30Golint (#255)Libravatar tobi1
2021-09-13Thread views on the web (#207)Libravatar f0x521
* Webviews for status threads * fix up templates * add ForkAwesome and gotosocial-styling into repo * clean up gotosocial-styling, old styling * update CONTRIBUTING with new css building, and nodemon recommendation * update Dockerfile with new css bundling * those weren't supposed to make it in * upgrade gotosocial-styling deps * update authorize template with main wrapper * update css pipeline * abstract status from thread to avoid copy-pasting * basic CW implementation * fix PR review suggestions * fix no-image-desc icon alignment * remove template loading println * remove println * remove changes to testmodels * reset changes to testmodels
2021-09-01session name fix (#185)Libravatar tobi3
2021-08-27Gin logging (#165)Libravatar tobi2
* start messing around with logger * more messing about * fix error with instance not created on startup (#156) * set logger * log user agent * finalize logging * go fmt * start messing around with logger * more messing about * set logger * log user agent * finalize logging * go fmt