access

package
v0.15.0 Latest Latest
Warning

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

Go to latest
Published: Mar 23, 2020 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (

	// ErrNoDevice is returned when device is empty or not found in procfs.
	ErrNoDevice = errors.New("no device found")
)

Functions

func GetMonitoring added in v0.15.0

func GetMonitoring(ctx context.Context) bool

GetMonitoring attempts to extract the monitoring value from the given context.

func SetMonitoring added in v0.15.0

func SetMonitoring(ctx context.Context, value bool) context.Context

SetMonitoring returns a derived context with the given value.

Types

type Controller added in v0.15.0

type Controller interface {
	Limit(next http.Handler) http.Handler
}

Controller is the interface that all access control types should implement.

type TokenController added in v0.15.0

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

TokenController manages access control for clients providing access_token parameters.

func NewTokenController added in v0.15.0

func NewTokenController(name string, verifier Verifier) *TokenController

NewTokenController creates a new token controller.

func (*TokenController) Limit added in v0.15.0

func (t *TokenController) Limit(next http.Handler) http.Handler

Limit checks client-provided access_tokens. Limit implements the Controller interface.

type TxController

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

TxController calculates the bytes transmitted every period from the named device.

func NewTxController

func NewTxController(rate uint64) (*TxController, error)

NewTxController creates a new instance initialized to run every second. Caller should run Watch in a goroutine to regularly update the current rate.

func (*TxController) Accept added in v0.14.2

func (tx *TxController) Accept(l net.Listener) (net.Conn, error)

Accept wraps the call to listener's Accept. If the TxController is limited, then Accept immediately closes the connection and returns an error.

func (*TxController) Current added in v0.14.2

func (tx *TxController) Current() uint64

Current exports the current rate. Useful for diagnostics.

func (*TxController) Limit

func (tx *TxController) Limit(next http.Handler) http.Handler

Limit enforces that the TxController rate limit is respected before running the next handler. If the rate is unspecified (zero), all requests are accepted.

func (*TxController) Watch

func (tx *TxController) Watch(ctx context.Context) error

Watch updates the current rate every period. If the context is cancelled, the context error is returned. If the TxController rate is zero, Watch returns immediately. Callers should typically run Watch in a goroutine.

type Verifier added in v0.15.0

type Verifier interface {
	Verify(token string, exp jwt.Expected) (*jwt.Claims, error)
}

Verifier is used by the TokenController to verify JWT claims in access tokens.

Jump to

Keyboard shortcuts

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