security

package
v0.21.1 Latest Latest
Warning

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

Go to latest
Published: Dec 29, 2022 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ConnContext

func ConnContext(ctx context.Context, c net.Conn) context.Context

func DirectClientIP

func DirectClientIP(r *http.Request) (ip net.IP)

DirectClientIP assumes that there is no intermediate proxy between the ls3 server and the client. It takes the remote IP from the connection. Requires that the HTTP server was set with ConnContext.

func DirectClientTLS

func DirectClientTLS(r *http.Request) bool

DirectClientTLS returns true if the given HTTP request has a valid TLS connection state.

func ForwardedClientTLS

func ForwardedClientTLS(r *http.Request) bool

ForwardedClientTLS returns true if the first X-Forwarded-Proto HTTP header is `https`. It returns false if the header is missing or is any other value.

func ForwardedRealIP

func ForwardedRealIP(r *http.Request) net.IP

ForwardedRealIP takes the value of the X-Real-Ip header from the HTTP request. If the header is missing or does not contain a valid IP then DirectClientIP is used instead.

func GetConn

func GetConn(ctx context.Context) (net.Conn, bool)

Types

type ClientIP

type ClientIP func(r *http.Request) net.IP

ClientIP provides the remote IP for an HTTP request by inspecting the contents of the request. The returned IP address may be an IPv4 or IPv6 address.

type ClientTLS

type ClientTLS func(r *http.Request) bool

ClientTLS returns true if the given request is being served over secure transport.

Jump to

Keyboard shortcuts

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