Documentation
¶
Index ¶
- Variables
- func FastHash(text string) string
- func GetFilteredHTTPLogger() *log.Logger
- func GetHealth(svc string) (healthv1.HealthCheckResponse_ServingStatus, bool)
- func GetRequestLogger(base *slog.Logger, r *http.Request) *slog.Logger
- func GzipMiddleware(level int, next http.Handler) http.Handler
- func InitSlog(level string)
- func JA4H(next http.Handler) http.Handler
- func NoBrowsing(next http.Handler) http.Handler
- func NoStoreCache(next http.Handler) http.Handler
- func RemoteXRealIP(useRemoteAddress bool, bindNetwork string, next http.Handler) http.Handler
- func SHA256sum(text string) string
- func SetHealth(svc string, status healthv1.HealthCheckResponse_ServingStatus)
- func UnbreakDocker()
- func UnchangingCache(next http.Handler) http.Handler
- func XForwardedForToXRealIP(next http.Handler) http.Handler
- func XForwardedForUpdate(stripPrivate bool, next http.Handler) http.Handler
- type ErrorLogFilter
- type XFFComputePreferences
Constants ¶
This section is empty.
Variables ¶
var ( ErrCantSplitHostParse = errors.New("internal: unable to net.SplitHostParse") ErrCantParseRemoteIP = errors.New("internal: unable to parse remote IP") )
var CGNat = netip.MustParsePrefix("100.64.0.0/10")
var HealthSrv = health.NewServer()
Functions ¶
func FastHash ¶
FastHash is a high-performance non-cryptographic hash function suitable for internal caching, policy rule identification, and other performance-critical use cases where cryptographic security is not required.
func GetFilteredHTTPLogger ¶
func NoBrowsing ¶
NoBrowsing prevents directory browsing by returning a 404 for any request that ends with a "/".
func NoStoreCache ¶
NoStoreCache sets the Cache-Control header to no-store for the response.
func RemoteXRealIP ¶
RemoteXRealIP sets the X-Real-Ip header to the request's real IP if the setting is enabled by the user.
func SHA256sum ¶
SHA256sum computes a cryptographic hash. Still used for proof-of-work challenges where we need the security properties of a cryptographic hash function.
func SetHealth ¶
func SetHealth(svc string, status healthv1.HealthCheckResponse_ServingStatus)
func UnbreakDocker ¶
func UnbreakDocker()
func UnchangingCache ¶
UnchangingCache sets the Cache-Control header to cache a response for 1 year if and only if the application is compiled in "release" mode by Docker.
func XForwardedForToXRealIP ¶
XForwardedForToXRealIP sets the X-Real-Ip header based on the contents of the X-Forwarded-For header.
Types ¶
type ErrorLogFilter ¶
ErrorLogFilter is used to suppress "context canceled" logs from the http server when a request is canceled (e.g., when a client disconnects).