Documentation
¶
Overview ¶
Package traefik_plugin_fail2ban plugin for traefik reverse proxy.
Index ¶
- func New(_ context.Context, next http.Handler, config *Config, name string) (http.Handler, error)
- func NewLogger(logLevel string) *logf.Logger
- type Cache
- func (c *Cache) CleanEntries(findTime, banTime time.Duration) (removedEntries int)
- func (c *Cache) CleanEntryIfPossible(key string, findTime, banTime time.Duration, now time.Time)
- func (c *Cache) CreateEntry(key string, firstSeen time.Time) *CacheEntry
- func (c *Cache) GetEntry(key string) *CacheEntry
- type CacheEntry
- func (ce *CacheEntry) GetFirstSeen() time.Time
- func (ce *CacheEntry) GetLastSeen() time.Time
- func (ce *CacheEntry) GetTimesSeen() uint32
- func (ce *CacheEntry) IncrementTimesSeen()
- func (ce *CacheEntry) IsBanned() bool
- func (ce *CacheEntry) IssueBan()
- func (ce *CacheEntry) SetFirstSeen(t time.Time)
- func (ce *CacheEntry) SetLastSeen(t time.Time)
- type Config
- type Fail2Ban
- type ResponseWriter
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Cache ¶
type Cache struct {
// contains filtered or unexported fields
}
Cache implementation for caching of IP entries.
func (*Cache) CleanEntries ¶
CleanEntries garbage collect entries.
func (*Cache) CleanEntryIfPossible ¶
CleanEntryIfPossible removes entry from cache by key and limits.
func (*Cache) CreateEntry ¶
func (c *Cache) CreateEntry(key string, firstSeen time.Time) *CacheEntry
CreateEntry retrieve entry from cache or create new entry with firstSeen.
func (*Cache) GetEntry ¶
func (c *Cache) GetEntry(key string) *CacheEntry
GetEntry retrieve entry from cache.
type CacheEntry ¶
type CacheEntry struct {
// contains filtered or unexported fields
}
CacheEntry represents single entry/IP in cache.
func (*CacheEntry) GetFirstSeen ¶
func (ce *CacheEntry) GetFirstSeen() time.Time
GetFirstSeen gets firstSeen.
func (*CacheEntry) GetLastSeen ¶
func (ce *CacheEntry) GetLastSeen() time.Time
GetLastSeen gets lastSeen.
func (*CacheEntry) GetTimesSeen ¶
func (ce *CacheEntry) GetTimesSeen() uint32
GetTimesSeen gets timesSeen.
func (*CacheEntry) IncrementTimesSeen ¶
func (ce *CacheEntry) IncrementTimesSeen()
IncrementTimesSeen increments timesSeen.
func (*CacheEntry) IsBanned ¶
func (ce *CacheEntry) IsBanned() bool
IsBanned checks if entry is banned.
func (*CacheEntry) IssueBan ¶
func (ce *CacheEntry) IssueBan()
IssueBan issues a ban for the entry/ip.
func (*CacheEntry) SetFirstSeen ¶
func (ce *CacheEntry) SetFirstSeen(t time.Time)
SetFirstSeen sets firstSeen.
func (*CacheEntry) SetLastSeen ¶
func (ce *CacheEntry) SetLastSeen(t time.Time)
SetLastSeen sets lastSeen.
type Config ¶
type Config struct {
Enabled bool `yaml:"enabled"`
AlwaysAllowed configIPSpec `yaml:"alwaysAllowed"`
AlwaysDenied configIPSpec `yaml:"alwaysDenied"`
LogLevel string `yaml:"logLevel"`
Rules configRules `yaml:"rules"`
}
Config plugin configuration.
func CreateConfig ¶
func CreateConfig() *Config
CreateConfig creates the default plugin configuration.
type Fail2Ban ¶
type Fail2Ban struct {
// contains filtered or unexported fields
}
Fail2Ban plugin data structure.
type ResponseWriter ¶
type ResponseWriter struct {
http.ResponseWriter
// contains filtered or unexported fields
}
ResponseWriter wrapping original ResponseWriter with response check handling.
func (*ResponseWriter) Write ¶
func (rw *ResponseWriter) Write(data []byte) (status int, err error)
Write wraps original Write whilst checking for response body.
func (*ResponseWriter) WriteHeader ¶
func (rw *ResponseWriter) WriteHeader(code int)
WriteHeader wraps original WriteHeader whilst checking for response status code.