access

package
v0.0.0-...-b6e3791 Latest Latest
Warning

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

Go to latest
Published: Mar 11, 2024 License: AGPL-3.0 Imports: 14 Imported by: 0

Documentation

Overview

Package access contains structures for access control management.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DefaultProfile

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

DefaultProfile controls profile specific IP and client blocking that take place before all other processing. DefaultProfile is safe for concurrent use.

func NewDefaultProfile

func NewDefaultProfile(conf *ProfileConfig) (p *DefaultProfile)

NewDefaultProfile creates a new *DefaultProfile. conf is assumed to be valid.

func (*DefaultProfile) Config

func (p *DefaultProfile) Config() (conf *ProfileConfig)

Config implements the Profile interface for *DefaultProfile.

func (*DefaultProfile) IsBlocked

func (p *DefaultProfile) IsBlocked(req *dns.Msg, rAddr netip.AddrPort, l *geoip.Location) (blocked bool)

IsBlocked implements the Profile interface for *DefaultProfile.

type EmptyProfile

type EmptyProfile struct{}

EmptyProfile is an empty profile implementation that does nothing.

func (EmptyProfile) Config

func (EmptyProfile) Config() (conf *ProfileConfig)

Config implements the Profile interface for EmptyProfile. It always returns nil.

func (EmptyProfile) IsBlocked

func (EmptyProfile) IsBlocked(_ *dns.Msg, _ netip.AddrPort, _ *geoip.Location) (blocked bool)

IsBlocked implements the Profile interface for EmptyProfile. It always returns false.

type Global

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

Global controls IP and client blocking that takes place before all other processing. Global is safe for concurrent use.

func NewGlobal

func NewGlobal(blockedDomains []string, blockedSubnets []netip.Prefix) (g *Global, err error)

NewGlobal create a new Global from provided parameters.

func (*Global) IsBlockedHost

func (g *Global) IsBlockedHost(host string, qt uint16) (blocked bool)

IsBlockedHost implements the Interface interface for *Global.

func (*Global) IsBlockedIP

func (g *Global) IsBlockedIP(ip netip.Addr) (blocked bool)

IsBlockedIP implements the Interface interface for *Global.

type Interface

type Interface interface {
	// IsBlockedHost returns true if host should be blocked.
	IsBlockedHost(host string, qt uint16) (blocked bool)

	// IsBlockedIP returns the status of the IP address blocking as well as the
	// rule that blocked it.
	IsBlockedIP(ip netip.Addr) (blocked bool)
}

Interface is the access manager interface.

type Profile

type Profile interface {
	// Config returns profile access configuration.
	Config() (conf *ProfileConfig)

	// IsBlocked returns true if the req should be blocked.  req must not be
	// nil, and req.Question must have one item.
	IsBlocked(req *dns.Msg, rAddr netip.AddrPort, l *geoip.Location) (blocked bool)
}

Profile is the profile access manager interface.

type ProfileConfig

type ProfileConfig struct {
	// AllowedNets is slice of CIDRs to be allowed.
	AllowedNets []netip.Prefix

	// BlockedNets is slice of CIDRs to be blocked.
	BlockedNets []netip.Prefix

	// AllowedNets is slice of location ASNs to be allowed.
	AllowedASN []geoip.ASN

	// BlockedASN is slice of location ASNs to be blocked.
	BlockedASN []geoip.ASN

	// BlocklistDomainRules is slice of rules to match requests.
	BlocklistDomainRules []string
}

ProfileConfig is a profile specific access configuration.

NOTE: Do not change fields of this structure without incrementing internal/profiledb/internal.FileCacheVersion.

Jump to

Keyboard shortcuts

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