refactored for maintainability

This commit is contained in:
2026-02-08 17:19:45 +11:00
parent 860cae3977
commit c16a82f2ad
40 changed files with 1211 additions and 920 deletions

View File

@@ -5,6 +5,8 @@ import (
"net/http"
"strings"
"time"
"github.com/pkg/errors"
)
// getClientIP extracts the client IP address, checking X-Forwarded-For first
@@ -93,3 +95,14 @@ func (s *Store) ClearRedirectTrack(r *http.Request, path string) {
key := redirectKey(ip, userAgent, path)
s.redirectTracks.Delete(key)
}
func (t *RedirectTrack) Error(attempts int) error {
return errors.Errorf(
"callback redirect loop detected after %d attempts | ip=%s ua=%s path=%s first_seen=%s",
attempts,
t.IP,
t.UserAgent,
t.Path,
t.FirstSeen.Format("2006-01-02T15:04:05Z07:00"),
)
}