Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BadIPObserver ¶
type BadIPObserver struct {
// contains filtered or unexported fields
}
func NewBadIPObserver ¶
func NewBadIPObserver(opts BadIPObserverOpts) (*BadIPObserver, error)
func (*BadIPObserver) Close ¶
func (o *BadIPObserver) Close() error
Close stops callback goroutine. It always returns a nil err.
func (*BadIPObserver) Observe ¶
func (o *BadIPObserver) Observe(addr netip.Addr)
Observe notifies the BadIPObserver that this addr has one error event.
func (*BadIPObserver) ServeHTTP ¶
func (o *BadIPObserver) ServeHTTP(w http.ResponseWriter, req *http.Request)
type BadIPObserverOpts ¶
type BadIPObserverOpts struct { HPLimiterOpts concurrent_limiter.HPLimiterOpts // TTL specifies the duration that a bad ip will stay in the // BadIPObserver if no error is reported. Optional. Default is 10min. TTL time.Duration // OnUpdateCallBack specifies a local cmd or url that will be called if // the bad ip list is updated. Optional. // If it starts with "http://" or "https://", BadIPObserverOpts will post // a list of bad ip/cidr, split by "/n", to this url. // Otherwise, BadIPObserverOpts trades this as a local cmd and will execute // it. User should fetch the list of bad ips themselves. OnUpdateCallBack // implements the http.Handler interface. OnUpdateCallBack string CleanerInterval time.Duration // Optional. Default is 10s. Logger *zap.Logger // Optional. Default is a noop logger. }
type IPObserver ¶
type NopObserver ¶
type NopObserver struct{}
func NewNopObserver ¶
func NewNopObserver() NopObserver
func (NopObserver) Observe ¶
func (n NopObserver) Observe(_ netip.Addr)
Click to show internal directories.
Click to hide internal directories.