MCPcopy Index your code
hub / github.com/PatchMon/PatchMon / clientIP

Method clientIP

server-source-code/internal/handler/auth.go:564–583  ·  view source on GitHub ↗
(r *http.Request)

Source from the content-addressed store, hash-verified

562}
563
564func (h *AuthHandler) clientIP(r *http.Request) string {
565 if h.resolved != nil && !h.resolved.TrustProxy {
566 host, _, _ := strings.Cut(r.RemoteAddr, ":")
567 if host != "" {
568 return host
569 }
570 return r.RemoteAddr
571 }
572 if xff := r.Header.Get("X-Forwarded-For"); xff != "" {
573 if idx := strings.Index(xff, ","); idx != -1 {
574 return strings.TrimSpace(xff[:idx])
575 }
576 return strings.TrimSpace(xff)
577 }
578 host, _, _ := strings.Cut(r.RemoteAddr, ":")
579 if host != "" {
580 return host
581 }
582 return r.RemoteAddr
583}
584
585// authBrowserSessionCookies returns whether to use session-only cookies (env -> DB -> default).
586func (h *AuthHandler) authBrowserSessionCookies() bool {

Callers 4

LoginMethod · 0.95
completeLoginMethod · 0.95
CompleteOidcLoginMethod · 0.95
CompleteDiscordLoginMethod · 0.95

Calls 1

GetMethod · 0.45

Tested by

no test coverage detected