netshare

package
v1.3.1 Latest Latest
Warning

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

Go to latest
Published: Dec 21, 2023 License: AGPL-3.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MaxLengthAuthorAll = 100 // Max length or paste author name, email and URL.
)

Variables

View Source
var (
	ErrBadRequest       = errors.New("Bad Request")        // 400
	ErrUnauthorized     = errors.New("Unauthorized")       // 401
	ErrNotFound         = errors.New("Not Found")          // 404
	ErrMethodNotAllowed = errors.New("Method Not Allowed") // 405
	ErrPayloadTooLarge  = errors.New("Payload Too Large")  // 413
	//	ErrTooManyRequests  = errors.New("Too Many Requests")     // 429
	ErrInternal = errors.New("Internal Server Error") // 500
)

Functions

func GetClientAddr

func GetClientAddr(req *http.Request) net.IP

func GetHost

func GetHost(req *http.Request) string

func GetProtocol

func GetProtocol(req *http.Request) string

func PasteAddFromForm

func PasteAddFromForm(req *http.Request, db storage.DB, rateSys *RateLimitSystem, titleMaxLen int, bodyMaxLen int, maxLifeTime int64, lexerNames []string) (string, int64, int64, error)

Types

type ErrTooManyRequests

type ErrTooManyRequests struct {
	RetryAfter int64
	// contains filtered or unexported fields
}

func ErrTooManyRequestsNew

func ErrTooManyRequestsNew(retryAfter int64) *ErrTooManyRequests

func (*ErrTooManyRequests) Error

func (e *ErrTooManyRequests) Error() string

type RateLimit

type RateLimit struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

func NewRateLimit

func NewRateLimit(rateLimitPeriod int, limitCount uint) *RateLimit

func (*RateLimit) CheckAndUse

func (rateLimit *RateLimit) CheckAndUse(ip net.IP) int64

type RateLimitSystem

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

func NewRateLimitSystem

func NewRateLimitSystem(per5Min, per15Min, per1Hour uint) *RateLimitSystem

func (*RateLimitSystem) CheckAndUse

func (rateSys *RateLimitSystem) CheckAndUse(ip net.IP) error

Jump to

Keyboard shortcuts

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