utils

package
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: May 3, 2025 License: MIT Imports: 30 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ResponseGood    = DNSBLResponse(0)
	ResponseUnknown = DNSBLResponse(255)
)
View Source
const RADBServer = "whois.radb.net:43"

Variables

View Source
var DefaultCookiePrefix = ".go-away-"
View Source
var ErrExpired = errors.New("key expired")

Functions

func CacheBust added in v0.5.0

func CacheBust() string

func ClearCookie

func ClearCookie(name string, w http.ResponseWriter, r *http.Request)

func EnsureNoOpenRedirect

func EnsureNoOpenRedirect(redirect string) (string, error)

func FetchTags added in v0.7.0

func FetchTags(backend http.Handler, uri *url.URL, kinds ...string) (result []html.Node)

func GetRemoteAddress added in v0.6.0

func GetRemoteAddress(ctx context.Context) *netip.AddrPort

func GetRequestAddress added in v0.5.0

func GetRequestAddress(r *http.Request, clientHeader string) netip.AddrPort

func GetRequestScheme added in v0.5.0

func GetRequestScheme(r *http.Request) string

func MakeReverseProxy

func MakeReverseProxy(target string, goDns bool, dialTimeout time.Duration) (*httputil.ReverseProxy, error)

func NewServer added in v0.4.0

func NewServer(handler http.Handler, tlsConfig *tls.Config) *http.Server

func SelectHTTPHandler added in v0.5.0

func SelectHTTPHandler(backends map[string]http.Handler, host string) http.Handler

func SetCookie

func SetCookie(name, value string, expiry time.Time, w http.ResponseWriter, r *http.Request)

func SetRemoteAddress added in v0.6.0

func SetRemoteAddress(r *http.Request, addrPort netip.AddrPort) *http.Request

Types

type Cache added in v0.5.0

type Cache interface {
	Get(key string, maxAge time.Duration) ([]byte, error)

	Set(key string, value []byte) error
}

func CacheDirectory added in v0.5.0

func CacheDirectory(directory string) (Cache, error)

func CachePrefix added in v0.5.0

func CachePrefix(c Cache, prefix string) Cache

type DNSBL added in v0.3.0

type DNSBL struct {
	// contains filtered or unexported fields
}

func NewDNSBL added in v0.3.0

func NewDNSBL(target string, resolver *net.Resolver) *DNSBL

func (DNSBL) Lookup added in v0.3.0

func (bl DNSBL) Lookup(ctx context.Context, ip net.IP) (DNSBLResponse, error)

type DNSBLResponse added in v0.3.0

type DNSBLResponse uint8

func (DNSBLResponse) Bad added in v0.3.0

func (r DNSBLResponse) Bad() bool

type DecayMap added in v0.3.0

type DecayMap[K comparable, V any] struct {
	// contains filtered or unexported fields
}

func NewDecayMap added in v0.3.0

func NewDecayMap[K comparable, V any]() *DecayMap[K, V]

func (*DecayMap[K, V]) Decay added in v0.3.0

func (m *DecayMap[K, V]) Decay()

func (*DecayMap[K, V]) Get added in v0.3.0

func (m *DecayMap[K, V]) Get(key K) (V, bool)

func (*DecayMap[K, V]) Set added in v0.3.0

func (m *DecayMap[K, V]) Set(key K, value V, ttl time.Duration)

type DecayMapEntry added in v0.3.0

type DecayMapEntry[V any] struct {
	Value V
	// contains filtered or unexported fields
}

type RADb added in v0.5.0

type RADb struct {
	// contains filtered or unexported fields
}

func NewRADb added in v0.5.0

func NewRADb() (*RADb, error)

func (*RADb) FetchASNets added in v0.5.0

func (db *RADb) FetchASNets(asn int) (result []net.IPNet, err error)

func (*RADb) FetchIPInfo added in v0.5.0

func (db *RADb) FetchIPInfo(ip net.IP) (result []string, err error)

type Strings added in v0.7.0

type Strings map[string]string

func NewStrings added in v0.7.0

func NewStrings[T ~map[string]string](v T) Strings

func (Strings) Get added in v0.7.0

func (s Strings) Get(value string) template.HTML

type TLSFingerprint added in v0.4.0

type TLSFingerprint struct {
	// contains filtered or unexported fields
}

func GetTLSFingerprint added in v0.4.0

func GetTLSFingerprint(r *http.Request) *TLSFingerprint

func (*TLSFingerprint) JA3N added in v0.4.0

func (*TLSFingerprint) JA4 added in v0.4.0

type TLSFingerprintJA3N added in v0.4.0

type TLSFingerprintJA3N [md5.Size]byte

func (TLSFingerprintJA3N) String added in v0.4.0

func (f TLSFingerprintJA3N) String() string

type TLSFingerprintJA4 added in v0.4.0

type TLSFingerprintJA4 struct {
	A [10]byte
	B [6]byte
	C [6]byte
}

func (TLSFingerprintJA4) String added in v0.4.0

func (f TLSFingerprintJA4) String() string

type UnixRoundTripper

type UnixRoundTripper struct {
	Transport *http.Transport
}

UnixRoundTripper https://github.com/oauth2-proxy/oauth2-proxy/blob/master/pkg/upstream/http.go#L124

func (UnixRoundTripper) RoundTrip

func (t UnixRoundTripper) RoundTrip(req *http.Request) (*http.Response, error)

RoundTrip set bare minimum stuff

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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