acl

package
v0.34.10 Latest Latest
Warning

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

Go to latest
Published: Oct 20, 2026 License: GPL-3.0 Imports: 5 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package acl compiles and evaluates the access lists of nps on top of geomatch: the source lists (who may connect) of the global, client and tunnel or host levels, and the destination list of a proxy tunnel.

Index

Constants

View Source
const (
	// DenyFirst denies an address on the blacklist even if the whitelist has
	// it, and denies addresses on neither list.
	DenyFirst = int(geomatch.DenyFirst)
	// AllowFirst allows an address on the whitelist even if the blacklist has
	// it, and allows addresses on neither list.
	AllowFirst = int(geomatch.AllowFirst)
)

Priorities of a source level that has both lists.

View Source
const DefaultMaxRules = 1000

DefaultMaxRules is the default limit on the rules of a list users may write.

Variables

This section is empty.

Functions

func Allows

func Allows(addr net.Addr, global, client, tunnel *Source) bool

Allows reports whether every level allows addr. Levels are the global, client and tunnel or host policies; nil levels allow everything.

func AllowsString

func AllowsString(addr string, global, client, tunnel *Source) bool

AllowsString is Allows for an address given as text, such as host:port.

func Decide

func Decide(addr net.Addr, names []string, global, client, tunnel *Source) geomatch.Decision

Decide is Allows with the level and rule that decided. names name the global, client and tunnel levels for the decision's text.

func DecideString

func DecideString(addr string, names []string, global, client, tunnel *Source) geomatch.Decision

DecideString is Decide for an address given as text, such as host:port.

func GeoFiles

func GeoFiles() (ipFile, siteFile string)

GeoFiles returns the geoip and geosite files.

func GeoGeneration

func GeoGeneration() uint64

GeoGeneration checks the geodata files and returns a number that grows whenever one of them changed, so that callers refresh their lists only then.

func NormalizeDest

func NormalizeDest(raw string) (string, error)

NormalizeDest returns the canonical form of destination rules, one per line. The error names the rules that were rejected; they are left out.

func NormalizePriority

func NormalizePriority(p int) int

NormalizePriority maps unknown priorities to DenyFirst.

func NormalizeSource

func NormalizeSource(scope Scope, rules []string) ([]string, error)

NormalizeSource returns the canonical form of the source rules, without duplicates. The error names the rules that were rejected; they are left out of the result.

func SetGeoData

func SetGeoData(ipFile, siteFile string)

SetGeoData sets the geoip and geosite files. Lists compiled from other files report stale and are refreshed by Refresh. ext-ip: rules of the global lists resolve relative names next to the geoip file.

func SetMaxRules

func SetMaxRules(n int)

SetMaxRules sets the limit on the rules of each list users may write, the client, tunnel, host and destination lists; 0 means no limit. It must be called before any list is compiled.

Types

type Dest

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

Dest is the compiled destination access policy of a tunnel. A nil Dest allows every destination.

func CompileDest

func CompileDest(mode int, rules string) (*Dest, error)

CompileDest compiles a destination list in mode AclOff, AclWhitelist or AclBlacklist (0, 1, 2). An empty whitelist allows nothing.

func (*Dest) Allows

func (d *Dest) Allows(addr string) bool

Allows reports whether the destination addr, a host or host:port, may be reached.

func (*Dest) Refresh

func (d *Dest) Refresh() error

Refresh recompiles the list when its geodata files changed.

type RuleError

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

RuleError reports the rules of a list that were rejected, by line.

func (*RuleError) Error

func (e *RuleError) Error() string

func (*RuleError) Unwrap

func (e *RuleError) Unwrap() error

type Scope

type Scope uint8

Scope tells who may write a list, which bounds what it may contain.

const (
	// ScopeGlobal lists are written by the administrator only.
	ScopeGlobal Scope = iota
	// ScopeUser lists may be written by users.
	ScopeUser
)

type Source

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

Source is the compiled source access policy of one level. A nil Source allows every address.

func CompileSource

func CompileSource(scope Scope, priority int, black, white []string) (*Source, error)

CompileSource compiles the source lists of a level. Rules that cannot be used, for example geoip: rules without geodata, are skipped and named by the error; the returned Source applies the others.

func (*Source) Policy

func (s *Source) Policy() geomatch.Policy

Policy returns the geomatch policy of the level.

func (*Source) Refresh

func (s *Source) Refresh() error

Refresh recompiles the lists whose geodata files changed. It returns the rules the new data cannot serve; the lists then keep their previous rules.

Jump to

Keyboard shortcuts

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