Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var AddForwardedFor = filters.FilterFunc(func(cs *filters.ConnectionState, req *http.Request, next filters.Next) (*http.Response, *filters.ConnectionState, error) { if req.Method != http.MethodConnect { if clientIP, _, err := net.SplitHostPort(req.RemoteAddr); err == nil { if prior, ok := req.Header[xForwardedFor]; ok { clientIP = strings.Join(prior, ", ") + ", " + clientIP } req.Header.Set(xForwardedFor, clientIP) } } return next(cs, req) })
AddForwardedFor adds an X-Forwarded-For header based on the request's RemoteAddr.
var DiscardInitialPersistentRequest = filters.FilterFunc(func(cs *filters.ConnectionState, req *http.Request, next filters.Next) (*http.Response, *filters.ConnectionState, error) { isInitialPersistent, _ := strconv.ParseBool(req.Header.Get(xLanternPersistent)) if isInitialPersistent { return filters.Discard(cs, req) } return next(cs, req) })
DiscardInitialPersistentRequest discards the initial request for persistent HTTP connections from the Lantern client.
var RecordOp = filters.FilterFunc(func(cs *filters.ConnectionState, req *http.Request, next filters.Next) (*http.Response, *filters.ConnectionState, error) { name := "proxy_http" if req.Method == http.MethodConnect { name += "s" } op := ops.Begin(name) resp, nextCtx, err := next(cs, req) if err != nil { op.FailIf(err) logFilterError(err) } op.End() return resp, nextCtx, err })
RecordOp records the proxy_http op.
Functions ¶
func BlockLocal ¶
BlockLocal blocks attempted accesses to localhost unless they're one of the listed exceptions.
func RateLimit ¶
RateLimit restricts access to only specific hosts and limits the rate at which clients (identified by IP address) are allowed to access thoses hosts.
func RestrictConnectPorts ¶
RestrictConnectPorts restricts CONNECT requests to the given list of allowed ports and returns either a 400 error if the request is missing a port or a 403 error if the port is not allowed.
Types ¶
This section is empty.