internal

package
v0.0.0-...-7550a95 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 26, 2025 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrCantSplitHostParse = errors.New("internal: unable to net.SplitHostParse")
	ErrCantParseRemoteIP  = errors.New("internal: unable to parse remote IP")
)
View Source
var CGNat = netip.MustParsePrefix("100.64.0.0/10")

Functions

func FastHash

func FastHash(text string) string

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 GetFilteredHTTPLogger() *log.Logger

func GetRequestLogger

func GetRequestLogger(r *http.Request) *slog.Logger

func GzipMiddleware

func GzipMiddleware(level int, next http.Handler) http.Handler

func InitSlog

func InitSlog(level string)

func NoBrowsing

func NoBrowsing(next http.Handler) http.Handler

NoBrowsing prevents directory browsing by returning a 404 for any request that ends with a "/".

func NoStoreCache

func NoStoreCache(next http.Handler) http.Handler

NoStoreCache sets the Cache-Control header to no-store for the response.

func RemoteXRealIP

func RemoteXRealIP(useRemoteAddress bool, bindNetwork string, next http.Handler) http.Handler

RemoteXRealIP sets the X-Real-Ip header to the request's real IP if the setting is enabled by the user.

func SHA256sum

func SHA256sum(text string) string

SHA256sum computes a cryptographic hash. Still used for proof-of-work challenges where we need the security properties of a cryptographic hash function.

func UnchangingCache

func UnchangingCache(next http.Handler) http.Handler

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

func XForwardedForToXRealIP(next http.Handler) http.Handler

XForwardedForToXRealIP sets the X-Real-Ip header based on the contents of the X-Forwarded-For header.

func XForwardedForUpdate

func XForwardedForUpdate(stripPrivate bool, next http.Handler) http.Handler

XForwardedForUpdate sets or updates the X-Forwarded-For header, adding the known remote address to an existing chain if present

Types

type ErrorLogFilter

type ErrorLogFilter struct {
	Unwrap *log.Logger
}

ErrorLogFilter is used to suppress "context canceled" logs from the http server when a request is canceled (e.g., when a client disconnects).

func (*ErrorLogFilter) Write

func (elf *ErrorLogFilter) Write(p []byte) (n int, err error)

type XFFComputePreferences

type XFFComputePreferences struct {
	StripPrivate  bool
	StripLoopback bool
	StripCGNAT    bool
	StripLLU      bool
	Flatten       bool
}

TODO: move into config

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL