acl

package
v0.0.0-20240423 Latest Latest
Warning

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

Go to latest
Published: Apr 23, 2024 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	OPTION_ACL = "acl"
)

Variables

View Source
var (
	ANY_SYM = "*"
	ANY     = NewEntity(ANY_SYM, ANY_SYM, ANY_SYM, ANY_SYM)
)
View Source
var (
	ErrInvalidRule, ErrInvalidRuleFn     = errors.NewErrorAndErrorFunc[string]("invalid rule")
	ErrInvalidEntity, ErrInvalidEntityFn = errors.NewErrorAndErrorFunc[string]("invalid entity")
	ErrNotPermitted                      = fmt.Errorf("not permitted")
)
View Source
var WithAcl, GetAcl = option.New[Acl](OPTION_ACL)

Functions

This section is empty.

Types

type Acl

type Acl interface {
	Permit(Entity) error
}

func FromRules

func FromRules(rs []Rule) (Acl, error)

func FromString

func FromString(s string) (Acl, error)

type Entity

type Entity interface {
	ID() string
	Network() string
	Host() string
	Port() string
	Contains(Entity) bool
	String() string
}

func NewEntity

func NewEntity(id, network, host, port string) Entity

func Parse

func Parse(s string) (Entity, error)

* <id>,<network>,<host>:<port> * examples: * "a,tcp,192.168.1.1:8080" => id=a, network=tcp, host=192.168.1.1, port=8080 * "a,tcp,*:8080" => id=a, network=tcp, host=*, port=8080 * "*,*,127.0.0.1:8080" => id=a, network=*, host=127.0.0.1 port=8080 * "a,tcp,*" => id=a, network=tcp, host=*, port=* * "a,*,*" => id=a, network=*, host=*, port=*

* "a,*" => id=a, network=*, host=*, port=* * "a,tcp" => id=a, network=tcp, host=*, port=*

* "a" => id=a, network=*, host=*, port=* * "*" => id=*, network=*, host=*, port=*

type Rule

type Rule struct {
	Allow  string   `yaml:"allow,omitempty"`
	Block  string   `yaml:"block,omitempty"`
	Allows []string `yaml:"allows,omitempty"`
	Blocks []string `yaml:"blocks,omitempty"`
}

func ParseRules

func ParseRules(s string) (rs []Rule, err error)

Jump to

Keyboard shortcuts

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