netc

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Jan 11, 2025 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MinBackoff time.Duration = 10 * time.Millisecond
	MaxBackoff time.Duration = 15 * time.Second
)

Variables

This section is empty.

Functions

func LocalAddrs

func LocalAddrs() ([]netip.Addr, error)

func NextBackoff

func NextBackoff(d time.Duration) time.Duration

func NextBackoffCustom

func NextBackoffCustom(d, jmin, jmax time.Duration) time.Duration

Types

type IPRestriction added in v0.4.0

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

func ParseIPRestriction added in v0.4.0

func ParseIPRestriction(allows []string, denys []string) (IPRestriction, error)

ParseIPRestriction parses a slice of allows/denys restrictions in CIDR format.

func (IPRestriction) Accept added in v0.4.0

func (r IPRestriction) Accept(ip netip.Addr) bool

Accept checks an ip address according to Allow and Deny rules.

If the ip matches any of the Deny rules, Accept returns false. If the ip matches any of the Allow rules (after checking all Deny rules), Accept returns true.

Finally, if the ip matches no Allow or Deny rules, Accept returns true only if no explicit Allow rules were defined.

func (IPRestriction) AcceptAddr added in v0.4.0

func (r IPRestriction) AcceptAddr(addr net.Addr) bool

Jump to

Keyboard shortcuts

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