mod_prison

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Apr 8, 2021 License: Apache-2.0 Imports: 22 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ModPrison        = "mod_prison"
	ReqCtxPrisonInfo = "mod_prison.prison_info"
)

Variables

View Source
var (
	ErrPrison = errors.New("PRISON") // deny by mod_prison
)

Functions

func ConfModPrisonCheck

func ConfModPrisonCheck(cfg *ConfModPrison, confRoot string) error

ConfModPrisonCheck check conf of mod_prison

func PrisonRuleCheck

func PrisonRuleCheck(conf *PrisonRuleConf) error

PrisonRuleCheck check prisonRule

func PrisonRuleListCheck

func PrisonRuleListCheck(conf *PrisonRuleConfList) error

PrisonRuleListCheck check prisonRuleList

func ProductRulesCheck

func ProductRulesCheck(conf map[string]*PrisonRuleConfList) error

ProductRulesCheck check ProductRules

Types

type AccessCounter

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

func NewAccessCounter

func NewAccessCounter() *AccessCounter

func (*AccessCounter) IncAndCheck

func (c *AccessCounter) IncAndCheck(checkPeriodNs int64, threshold int32) (bool, int64)

type AccessSign

type AccessSign [16]byte

type AccessSignConf

type AccessSignConf struct {
	UseSocketIP  bool     // if true, add socketip to input of signature
	UseClientIP  bool     // if true, add clientip to input of signature
	UseConnectID bool     // if true, add connect id to input of signature
	UseUrl       bool     // if true, add url to input of signature
	UseHost      bool     // if true, add host to input of signature
	UsePath      bool     // if true, add path to input of signature
	UseHeaders   bool     // if true, use all request headers
	UrlRegexp    string   // url regmatch str
	Query        []string // query key list
	Header       []string // header key list
	Cookie       []string // cookie key list
}

type AccessSigner

type AccessSigner struct {
	AccessSignConf                // basic conf for signature
	UrlReg         *regexp.Regexp // url regular expression
}

func (*AccessSigner) Sign

func (s *AccessSigner) Sign(label string, req *bfe_basic.Request) (AccessSign, error)

type ConfModPrison

type ConfModPrison struct {
	Basic struct {
		ProductRulePath string // path for product rule
	}

	Log struct {
		OpenDebug bool // whether open debug
	}
}

func ConfLoad

func ConfLoad(filePath string, confRoot string) (*ConfModPrison, error)

ConfLoad load config from file

type ModulePrison

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

func NewModulePrison

func NewModulePrison() *ModulePrison

func (*ModulePrison) Init

func (*ModulePrison) Name

func (m *ModulePrison) Name() string

type ModulePrisonState

type ModulePrisonState struct {
	AllChecked *metrics.Counter // count of checked requests
	AllPrison  *metrics.Counter // count of blocked requests
}

type PrisonInfo

type PrisonInfo struct {
	PrisonType string    // type of prison, mod_prison
	PrisonName string    // name of prison rule
	FreeTime   time.Time // free time
	IsExpired  bool      // is expired
	Action     string    // action
}

type PrisonRuleConf

type PrisonRuleConf struct {
	Cond           *string         // condition for prison rule
	Action         *action.Action  // action for prison rule
	AccessSignConf *AccessSignConf // sign conf for prison rule
	Name           *string         // rule name
	CheckPeriod    *int64          // check period in seconds
	StayPeriod     *int64          // stayPeriod in seconds
	Threshold      *int32          // threshold
	AccessDictSize *int            // size of access dict
	PrisonDictSize *int            // size of prison dict
}

type PrisonRuleConfList

type PrisonRuleConfList []*PrisonRuleConf

type ProductRuleConf

type ProductRuleConf struct {
	Version *string                         // version of the config
	Config  *map[string]*PrisonRuleConfList // product name => list of prison rules
}

Jump to

Keyboard shortcuts

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