blocker

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Jul 11, 2022 License: BSD-2-Clause Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type RequestBlocker

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

RequestBlocker blocks request according to rules that defines which headers are not allowed

func NewRequestBlocker

func NewRequestBlocker(blockHeaderFile string, updatePeriod time.Duration, logger *zap.Logger) *RequestBlocker

NewRequestBlocker creates a new instance of request blocker without any rules and sets name of config files that will be used as storage for rules

func (*RequestBlocker) AddNewRules

func (rl *RequestBlocker) AddNewRules(queryParams url.Values) bool

AddNewRules updates rule config file with new rules

func (*RequestBlocker) ReloadRules

func (rl *RequestBlocker) ReloadRules()

ReloadRules loads rules from config and updates blocker with these rules

func (*RequestBlocker) ScheduleRuleReload

func (rl *RequestBlocker) ScheduleRuleReload() bool

ScheduleRuleReload starts reload rules from rules config file with frequency defined by updatePeriod

func (*RequestBlocker) ShouldBlockRequest

func (rl *RequestBlocker) ShouldBlockRequest(r *http.Request) bool

ShouldBlockRequest checks request headers against block rules

func (*RequestBlocker) Unblock

func (rl *RequestBlocker) Unblock() error

Unblock deletes rule config file with all defined rules. Next time rules will be reloaded, request blocker won't block any request

type Rule

type Rule map[string]string

Rule is a request blocking rule

type RuleConfig

type RuleConfig struct {
	Rules []Rule
}

RuleConfig represents the request blocking rules

Jump to

Keyboard shortcuts

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