refactored for maintainability
This commit is contained in:
@@ -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"),
|
||||
)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user