config

package
v0.1.16 Latest Latest
Warning

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

Go to latest
Published: Jan 9, 2025 License: AGPL-3.0 Imports: 5 Imported by: 0

Documentation

Overview

Package config contains the schema and helper functions to work with the configuration file.

Index

Constants

View Source
const (
	PolicyAllow = "allow"
	PolicyDeny  = "deny"
)

Accepted policy values.

Variables

This section is empty.

Functions

This section is empty.

Types

type AccessControl

type AccessControl struct {
	DefaultPolicy string              `yaml:"default_policy" validate:"required,oneof=allow deny"`
	Rules         []AccessControlRule `yaml:"rules"          validate:"dive"`
}

AccessControl represents the access control configuration.

type AccessControlRule

type AccessControlRule struct {
	Policy            string   `yaml:"policy"                       validate:"required,oneof=allow deny"`
	Networks          []CIDR   `yaml:"networks,omitempty"           validate:"dive,cidr"`
	Domains           []string `yaml:"domains,omitempty"            validate:"dive,domain"`
	Methods           []string `yaml:"methods,omitempty"            validate:"dive,oneof=GET HEAD POST PUT DELETE PATCH"`
	Countries         []string `yaml:"countries,omitempty"          validate:"dive,iso3166_1_alpha2"`
	AutonomousSystems []uint32 `yaml:"autonomous_systems,omitempty" validate:"dive,numeric"`
}

AccessControlRule represents an access control rule.

type CIDR

type CIDR struct {
	netip.Prefix
}

CIDR represents a CIDR network. It's used to support unmarshaling from YAML.

func (*CIDR) UnmarshalYAML

func (n *CIDR) UnmarshalYAML(unmarshal func(interface{}) error) error

UnmarshalYAML unmarshals a CIDR network from YAML.

type Configuration

type Configuration struct {
	AccessControl AccessControl `yaml:"access_control"`
}

Configuration represents the configuration of the application.

func ReadConfig

func ReadConfig(reader io.Reader) (*Configuration, error)

ReadConfig reads the configuration from the given reader and returns it.

Jump to

Keyboard shortcuts

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