From 9db7d4604fb43d6b6705232318b06b5d99da05ea Mon Sep 17 00:00:00 2001 From: Amy Gale Ruth Bowersox Date: Sun, 8 Nov 2026 18:48:30 -0700 Subject: [PATCH] updates to rate limiter --- errors.go | 4 +++- main.go | 1 + 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/errors.go b/errors.go index c13396b..eb38e77 100644 --- a/errors.go +++ b/errors.go @@ -16,6 +16,7 @@ import ( "fmt" "net/http" "time" + "uuid" "git.erbosoft.com/amy/amsterdam/config" "git.erbosoft.com/amy/amsterdam/ui" @@ -95,8 +96,9 @@ func rateLimitErrorHandler(c *echo.Context, err error) error { // rateLimitDenyHandler is called if the rate limit is exceeded by a connection. func rateLimitDenyHandler(c *echo.Context, identifier string, err error) error { + log.Errorf("request %s tripped rate limiter", c.Request().Context().Value(CONTEXTVAL_REQUESTID).(uuid.UUID).String()) return ui.AmWithTempContext(c, func(ctxt ui.AmContext) (string, any) { - ctxt.VarMap().Set("identifier", identifier) + ctxt.VarMap().Set("identifier", fmt.Sprintf("%s/%s", identifier, ctxt.RemoteIP())) return "ratelimit", err }) } diff --git a/main.go b/main.go index fa0adc7..f03d828 100644 --- a/main.go +++ b/main.go @@ -64,6 +64,7 @@ func setupEcho() *echo.Echo { e.Logger = slog.New(NewSlogLogrusHandler()) e.Renderer = &ui.TemplateRenderer{} e.HTTPErrorHandler = AmErrorHandler + e.IPExtractor = echo.LegacyIPExtractor() if !config.CommandLine.DebugPanic { e.Use(middleware.RecoverWithConfig(middleware.RecoverConfig{ StackSize: int(config.GlobalComputedConfig.PanicRecoveryStack),