net

package
v0.3.17 Latest Latest
Warning

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

Go to latest
Published: Aug 22, 2023 License: AGPL-3.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var TCPRateLimitsField = forms.Field{
	Name: "tcp_rate_limits",
	Validators: []forms.Validator{
		forms.IsOptional{},
		forms.IsList{
			Validators: []forms.Validator{
				forms.IsStringMap{
					Form: &forms.Form{
						Fields: []forms.Field{
							{
								Name: "type",
								Validators: []forms.Validator{
									forms.IsIn{Choices: []interface{}{"second", "minute", "hour"}},
								},
							},
							{
								Name: "limit",
								Validators: []forms.Validator{
									forms.IsInteger{HasMin: true, Min: 1},
								},
							},
						},
					},
				},
			},
		},
	},
}

Functions

This section is empty.

Types

type RateLimit

type RateLimit struct {
	TimeWindow *TimeWindow `json:"timeWindow"`
	Type       string      `json:"type"`
	Limit      int64       `json:"limit"`
}

type RateLimitedListener

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

func MakeRateLimitedListener

func MakeRateLimitedListener(listener net.Listener, rateLimits []*RateLimit) *RateLimitedListener

func (*RateLimitedListener) Accept

func (l *RateLimitedListener) Accept() (net.Conn, error)

Accept a connection, ensuring that rate limits are enforced

func (*RateLimitedListener) Addr

func (l *RateLimitedListener) Addr() net.Addr

func (*RateLimitedListener) Close

func (l *RateLimitedListener) Close() error

type TimeWindow

type TimeWindow struct {
	From int64
	To   int64
	Type string
}

func Day

func Day(value int64) TimeWindow

func Hour

func Hour(value int64) TimeWindow

func MakeTimeWindow

func MakeTimeWindow(t int64, twType string) TimeWindow

func Minute

func Minute(value int64) TimeWindow

func Month

func Month(value int64) TimeWindow

func QuarterHour

func QuarterHour(value int64) TimeWindow

func Second

func Second(value int64) TimeWindow

func Week

func Week(value int64) TimeWindow

func (*TimeWindow) Copy

func (t *TimeWindow) Copy() TimeWindow

func (*TimeWindow) EqualTo

func (t *TimeWindow) EqualTo(tw *TimeWindow) bool

type TimeWindowFunc

type TimeWindowFunc func(int64) TimeWindow

Jump to

Keyboard shortcuts

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