configvalues

package
v0.1.4 Latest Latest
Warning

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

Go to latest
Published: May 15, 2024 License: MIT Imports: 16 Imported by: 2

Documentation

Overview

Package configvalues contains types to help with configuring point-c.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CaddyfileUnmarshaler

func CaddyfileUnmarshaler[T any, TP caddyfileUnmarshaler[T]](name string) func(d *caddyfile.Dispenser, resume any) (any, error)

CaddyfileUnmarshaler returns a function that unmarshals Caddyfile configuration into a specific type. It works with types T whose pointer implements the caddyfile.Unmarshaler interface. The function handles both the initialization of a new configuration object and the resumption of a partially-unmarshaled configuration. This is useful if the caddyfile.App manages a list of submodules and whose caddyfile.Unmarshaler will mainly just append to that list.

Types

type CaddyTextUnmarshaler

type CaddyTextUnmarshaler[V, T any, TP valueConstraint[V, T]] struct {
	// contains filtered or unexported fields
}

CaddyTextUnmarshaler is a generic struct for unmarshaling text into a value. It stores the unmarshaled value and the original text representation.

func (CaddyTextUnmarshaler[V, T, TP]) MarshalJSON

func (c CaddyTextUnmarshaler[V, T, TP]) MarshalJSON() (text []byte, err error)

MarshalJSON marshals the CaddyTextUnmarshaler into JSON. It quotes the text if it's not valid JSON.

func (CaddyTextUnmarshaler[V, T, TP]) MarshalText

func (c CaddyTextUnmarshaler[V, T, TP]) MarshalText() (text []byte, err error)

MarshalText marshals the CaddyTextUnmarshaler back to text. It returns the original text representation.

func (*CaddyTextUnmarshaler[V, T, TP]) UnmarshalCaddyfile

func (c *CaddyTextUnmarshaler[V, T, TP]) UnmarshalCaddyfile(d *caddyfile.Dispenser) error

UnmarshalCaddyfile reads the next arg as a string and unmarshalls it

func (*CaddyTextUnmarshaler[V, T, TP]) UnmarshalJSON

func (c *CaddyTextUnmarshaler[V, T, TP]) UnmarshalJSON(text []byte) error

UnmarshalJSON unmarshals JSON into the CaddyTextUnmarshaler's value. It handles JSON strings and unmarshals them as text.

func (*CaddyTextUnmarshaler[V, T, TP]) UnmarshalText

func (c *CaddyTextUnmarshaler[V, T, TP]) UnmarshalText(text []byte) error

UnmarshalText unmarshals text into the CaddyTextUnmarshaler's value. It uses Caddy's replacer for variable expansion in the text before unmarshaling. The value and the stored text are reset when this is called, even if unmarshalling fails.

func (*CaddyTextUnmarshaler[V, T, TP]) Value

func (c *CaddyTextUnmarshaler[V, T, TP]) Value() V

Value returns the underlying value of the CaddyTextUnmarshaler.

type Hostname

type Hostname = String

Hostname represents a unique hostname string.

type HostnamePair added in v0.0.14

type HostnamePair = CaddyTextUnmarshaler[*PairValue[string], ValuePair[string, ValueString, *ValueString], *ValuePair[string, ValueString, *ValueString]]

HostnamePair represents a structured combination of hostnames formatted as <hostname>:<hostname>.

type IP

type IP = CaddyTextUnmarshaler[net.IP, ValueIP, *ValueIP]

IP is a type alias for handling IP addresses. It wraps the net.IP type and uses CaddyTextUnmarshaler for converting text-based IPv4 or IPv6 address representations into net.IP.

type PairValue added in v0.0.14

type PairValue[T any] struct {
	Left, Right T
}

PairValue is used to store the base values of a parsed pair value.

type Port

type Port = CaddyTextUnmarshaler[uint16, ValueUnsigned[uint16], *ValueUnsigned[uint16]]

Port defines a network port value, which is an unsigned 16-bit integer. The validity of 0 as a port number depends on the specific use case or context.

type PortPair

PortPair represents a structured combination of ports formatted as <src>:<dst>.

type PresharedKey added in v0.0.15

type PresharedKey = CaddyTextUnmarshaler[wgapi.PresharedKey, valueKey[wgapi.PresharedKey], *valueKey[wgapi.PresharedKey]]

PresharedKey is a wireguard preshared key in base64 format.

type PrivateKey added in v0.0.15

type PrivateKey = CaddyTextUnmarshaler[wgapi.PrivateKey, valueKey[wgapi.PrivateKey], *valueKey[wgapi.PrivateKey]]

PrivateKey is a wireguard private key in base64 format.

type PublicKey added in v0.0.15

type PublicKey = CaddyTextUnmarshaler[wgapi.PublicKey, valueKey[wgapi.PublicKey], *valueKey[wgapi.PublicKey]]

PublicKey is a wireguard public key in base64 format.

type ResolvedIP added in v0.1.2

type ResolvedIP = CaddyTextUnmarshaler[net.IP, ValueResolvedIP, *ValueResolvedIP]

ResolvedIP is a type alias for handling hostnames that can be resolved into IP addresses. If wraps the net.IP type and resolves the IP address when CaddyTextUnmarshaler is unmarshalling.

type String

type String = CaddyTextUnmarshaler[string, ValueString, *ValueString]

String is a custom type leveraging CaddyTextUnmarshaler to handle text-based data. It allows caddy's replacer to replace the string before it is used.

type UDPAddr

type UDPAddr = CaddyTextUnmarshaler[*net.UDPAddr, ValueUDPAddr, *ValueUDPAddr]

UDPAddr is a type alias for handling UDP network addresses. It wraps the net.UDPAddr type and utilizes CaddyTextUnmarshaler for parsing and handling UDP addresses in text form. Hosts are resolved to the IP they represent if possible.

type Value

type Value[V any] interface {
	encoding.TextUnmarshaler
	Value() V
	Reset()
}

Value is an interface for types that can unmarshal text and return a value.

type ValueBool

type ValueBool bool

ValueBool handles unmarshalling bool values.

func (*ValueBool) Reset

func (b *ValueBool) Reset()

Reset sets the value to false.

func (*ValueBool) UnmarshalText

func (b *ValueBool) UnmarshalText(text []byte) error

UnmarshalText parses the bool with strconv.ParseBool internally.

func (*ValueBool) Value

func (b *ValueBool) Value() bool

Value returns the underlying bool value of ValueBool.

type ValueIP

type ValueIP net.IP

ValueIP handles unmarshalling net.IP.

func (*ValueIP) Reset

func (ip *ValueIP) Reset()

Reset sets this value to nil.

func (*ValueIP) UnmarshalText

func (ip *ValueIP) UnmarshalText(text []byte) error

UnmarshalText implements the unmarshaling of text data into an IP address. It delegates to the encoding.TextUnmarshaler implementation of net.IP.

func (*ValueIP) Value

func (ip *ValueIP) Value() net.IP

Value returns the underlying net.IP of ValueIP.

type ValuePair added in v0.0.14

type ValuePair[V any, T any, TP valueConstraint[V, T]] struct {
	// contains filtered or unexported fields
}

ValuePair represents a structured combination of `<value>:<value>` pairs.

func (*ValuePair[V, T, TP]) Reset added in v0.0.14

func (pp *ValuePair[V, T, TP]) Reset()

Reset resets the pair values to their zero values.

func (*ValuePair[V, T, TP]) UnmarshalText added in v0.0.14

func (pp *ValuePair[V, T, TP]) UnmarshalText(b []byte) error

UnmarshalText unmarshals a `<value>:<value>` pair.

func (*ValuePair[V, T, TP]) Value added in v0.0.14

func (pp *ValuePair[V, T, TP]) Value() *PairValue[V]

Value returns the pair's base values.

type ValueResolvedIP added in v0.1.2

type ValueResolvedIP net.IP

ValueResolvedIP handles resolving and unmarshalling net.IP.

func (*ValueResolvedIP) Reset added in v0.1.2

func (ip *ValueResolvedIP) Reset()

Reset sets this value to nil.

func (*ValueResolvedIP) UnmarshalText added in v0.1.2

func (ip *ValueResolvedIP) UnmarshalText(text []byte) error

UnmarshalText implements the resolving of a hostname into an IP address. It delegates to the encoding.TextUnmarshaler implementation of net.IP. If the host has multiple IP addresses, the first one is used.

func (*ValueResolvedIP) Value added in v0.1.2

func (ip *ValueResolvedIP) Value() net.IP

Value returns the underlying net.IP that was resolved.

type ValueString

type ValueString string

ValueString handles unmarshalling string values.

func (*ValueString) Reset

func (s *ValueString) Reset()

Reset sets the value to the empty string

func (*ValueString) UnmarshalText

func (s *ValueString) UnmarshalText(b []byte) error

UnmarshalText just sets the value to string(b).

func (*ValueString) Value

func (s *ValueString) Value() string

Value returns the underlying string value of ValueString.

type ValueUDPAddr

type ValueUDPAddr net.UDPAddr

ValueUDPAddr handles unmarshalling a net.UDPAddr.

func (*ValueUDPAddr) Reset

func (addr *ValueUDPAddr) Reset()

Reset sets this value to an empty UDPAddr.

func (*ValueUDPAddr) UnmarshalText

func (addr *ValueUDPAddr) UnmarshalText(text []byte) error

UnmarshalText implements the unmarshaling of text data into a UDP address. It resolves the text using net.ResolveUDPAddr.

func (*ValueUDPAddr) Value

func (addr *ValueUDPAddr) Value() *net.UDPAddr

Value returns the underlying net.UDPAddr of ValueUDPAddr.

type ValueUnsigned

type ValueUnsigned[N constraints.Unsigned] struct{ V N }

ValueUnsigned is a generic type for unmarshalling an unsigned number. N must be an unsigned type (e.g., uint, uint32).

func (*ValueUnsigned[N]) Reset

func (n *ValueUnsigned[N]) Reset()

Reset sets this value to 0.

func (*ValueUnsigned[N]) UnmarshalText

func (n *ValueUnsigned[N]) UnmarshalText(b []byte) error

UnmarshalText parses the uint with strconv.ParseUint internally.

func (*ValueUnsigned[N]) Value

func (n *ValueUnsigned[N]) Value() N

Value returns the underlying unsigned number of ValueUnsigned.

Jump to

Keyboard shortcuts

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