Documentation ¶
Index ¶
Constants ¶
View Source
const ( MAX_SOCKET_SHARE_OF_SHARED_WINDOW = 0.50 REQUEST_ID_LOG_FIELD_NAME = "reqID" )
Variables ¶
This section is empty.
Functions ¶
func NewSharedRateLimitingWindow ¶
func NewSharedRateLimitingWindow(params WindowParameters) *sharedRateLimitingWindow
Types ¶
type IWindow ¶
type IWindow interface {
AllowRequest(rInfo WindowRequestInfo, logger zerolog.Logger) (ok bool)
}
type Window ¶
type Window struct {
// contains filtered or unexported fields
}
A Window contains a fixed number of request slots (say N). Rate limiting is performed by informing it about all received requests using the AllowRequest method. The window records the last N requests, even the ones that have not been accepted. See the body of the AllowRequest method for details about the algorithm.
func NewWindow ¶
func NewWindow(params WindowParameters) *Window
func (*Window) AllowRequest ¶
func (window *Window) AllowRequest(rInfo WindowRequestInfo, logger zerolog.Logger) (ok bool)
TODO: treat many HTTP/1.1 connections from same IP as suspicious AllowRequest returns false if the request should be rate limited.
func (*Window) SetIpLevelWindow ¶
type WindowParameters ¶
type WindowRequestInfo ¶
type WindowRequestInfo struct { Id string Method string CreationTime time.Time RemoteAddrAndPort netaddr.RemoteAddrWithPort RemoteIpAddr netaddr.RemoteIpAddr SentBytes int }
Click to show internal directories.
Click to hide internal directories.