Documentation ¶
Index ¶
- Constants
- Variables
- func NewCloudflareClient(token string, logger *log.Logger) (*cloudflare.API, error)
- type CloudflareState
- type CloudflareWorker
- func (worker *CloudflareWorker) CollectLAPIStream(streamDecision *models.DecisionsStreamResponse)
- func (worker *CloudflareWorker) DeleteASBans() error
- func (worker *CloudflareWorker) DeleteCountryBans() error
- func (worker *CloudflareWorker) DeleteExistingIPList() error
- func (worker *CloudflareWorker) Init() error
- func (worker *CloudflareWorker) Run() error
- func (worker *CloudflareWorker) SendASBans() error
- func (worker *CloudflareWorker) SendCountryBans() error
- func (worker *CloudflareWorker) SetUpCloudflareResources() error
- func (worker *CloudflareWorker) UpdateIPLists() error
- func (worker *CloudflareWorker) UpdateRules() error
- type IPListState
- type IPSetItem
- type InterceptLogger
- type ZoneLock
Constants ¶
View Source
const CallsPerSecondLimit uint32 = 4
Variables ¶
View Source
var CloudflareActionByDecisionType = map[string]string{
"captcha": "managed_challenge",
"ban": "block",
"js_challenge": "js_challenge",
}
View Source
var ResponseTime prometheus.Histogram = promauto.NewHistogram(prometheus.HistogramOpts{ Name: "response_time", Help: "response time by cloudflare", Buckets: prometheus.LinearBuckets(0, 100, 50), }, )
View Source
var TotalAPICalls prometheus.Counter = promauto.NewCounter(prometheus.CounterOpts{
Name: "cloudflare_api_calls",
Help: "The total number of API calls to cloudflare made by CrowdSec bouncer",
},
)
Functions ¶
Types ¶
type CloudflareState ¶
type CloudflareState struct { Action string AccountID string FilterIDByZoneID map[string]string // this contains all the zone ID -> filter ID which represent this state CurrExpr string IPListState IPListState CountrySet map[string]struct{} AutonomousSystemSet map[string]struct{} }
one firewall rule per state.
func (*CloudflareState) UpdateExpr ¶
func (cfState *CloudflareState) UpdateExpr() bool
updates the expression for the state. Returns true if new rule is different than the previous rule.
type CloudflareWorker ¶
type CloudflareWorker struct { Logger *log.Entry APILogger *log.Logger Account cfg.AccountConfig ZoneLocks []ZoneLock Zones []cloudflare.Zone FirewallRulesByZoneID map[string]*[]cloudflare.FirewallRule CFStateByAction map[string]*CloudflareState Ctx context.Context LAPIStream chan *models.DecisionsStreamResponse UpdateFrequency time.Duration NewIPDecisions []*models.Decision ExpiredIPDecisions []*models.Decision NewASDecisions []*models.Decision ExpiredASDecisions []*models.Decision NewCountryDecisions []*models.Decision ExpiredCountryDecisions []*models.Decision API cloudflareAPI Count prometheus.Counter TokenCallCount *uint32 }
func (*CloudflareWorker) CollectLAPIStream ¶
func (worker *CloudflareWorker) CollectLAPIStream(streamDecision *models.DecisionsStreamResponse)
func (*CloudflareWorker) DeleteASBans ¶
func (worker *CloudflareWorker) DeleteASBans() error
func (*CloudflareWorker) DeleteCountryBans ¶
func (worker *CloudflareWorker) DeleteCountryBans() error
func (*CloudflareWorker) DeleteExistingIPList ¶
func (worker *CloudflareWorker) DeleteExistingIPList() error
func (*CloudflareWorker) Init ¶
func (worker *CloudflareWorker) Init() error
func (*CloudflareWorker) Run ¶
func (worker *CloudflareWorker) Run() error
func (*CloudflareWorker) SendASBans ¶
func (worker *CloudflareWorker) SendASBans() error
func (*CloudflareWorker) SendCountryBans ¶
func (worker *CloudflareWorker) SendCountryBans() error
func (*CloudflareWorker) SetUpCloudflareResources ¶
func (worker *CloudflareWorker) SetUpCloudflareResources() error
func (*CloudflareWorker) UpdateIPLists ¶
func (worker *CloudflareWorker) UpdateIPLists() error
func (*CloudflareWorker) UpdateRules ¶
func (worker *CloudflareWorker) UpdateRules() error
type IPListState ¶
type InterceptLogger ¶
type InterceptLogger struct { Tripper http.RoundTripper // contains filtered or unexported fields }
Click to show internal directories.
Click to hide internal directories.