restore

package
v1.16.3 Latest Latest
Warning

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

Go to latest
Published: Oct 10, 2024 License: Apache-2.0 Imports: 3 Imported by: 8

Documentation

Overview

The restore package provides data structures important to restoring DNS proxy rules. This package serves as a central source for these structures. Note that these are marshaled as JSON and any changes need to be compatible across an upgrade!

Index

Constants

View Source
const PortProtoV2 = 1 << 24

PortProtoV2 is 1 value at bit position 24.

Variables

This section is empty.

Functions

This section is empty.

Types

type DNSRules

type DNSRules map[PortProto]IPRules

DNSRules contains IP-based DNS rules for a set of port-protocols (e.g., UDP/53)

func (DNSRules) Sort

func (r DNSRules) Sort(_ *testing.T) DNSRules

Sort is only used for testing Sorts in place, but returns DNSRules for convenience

type IPRule

type IPRule struct {
	Re  RuleRegex
	IPs map[string]struct{} // IPs, nil set is wildcard and allows all IPs!
}

IPRule stores the allowed destination IPs for a DNS names matching a regex

type IPRules

type IPRules []IPRule

IPRules is an unsorted collection of IPrules

func (IPRules) Sort

func (r IPRules) Sort(_ *testing.T) IPRules

Sort is only used for testing Sorts in place, but returns IPRules for convenience

type PortProto added in v1.13.15

type PortProto uint32

PortProto is uint32 that encodes two different versions of port protocol keys. Version 1 is protocol agnostic and (naturally) encodes no values at bit positions 16-31. Version 2 encodes protocol at bit positions 16-23, and bit position 24 encodes a 1 value to indicate that it is Version 2. Both versions encode the port at the bit positions 0-15.

This works because Version 1 will naturally encode no values at postions 16-31 as the original Version 1 was a uint16. Version 2 enforces a 1 value at the 24th bit position, so it will alway be legible.

func MakeV2PortProto added in v1.13.15

func MakeV2PortProto(port uint16, proto uint8) PortProto

MakeV2PortProto returns a Version 2 port protocol.

func (PortProto) IsPortV2 added in v1.13.15

func (pp PortProto) IsPortV2() bool

IsPortV2 returns true if the PortProto is Version 2.

func (PortProto) Port added in v1.13.15

func (pp PortProto) Port() uint16

Port returns the port of the PortProto

func (PortProto) Protocol added in v1.13.15

func (pp PortProto) Protocol() uint8

Protocol returns the protocol of the PortProto. It returns "0" for Version 1.

func (PortProto) String added in v1.13.15

func (pp PortProto) String() string

String returns the decimal representation of PortProtocol in string form.

func (PortProto) ToV1 added in v1.13.15

func (pp PortProto) ToV1() PortProto

ToV1 returns the Version 1 (that is, "port") version of the PortProto.

type RuleRegex

type RuleRegex struct {
	Pattern *string
}

RuleRegex is a wrapper for a pointer to a string so that we can define marshalers for it.

func (RuleRegex) MarshalText

func (r RuleRegex) MarshalText() ([]byte, error)

MarshalText marshals RuleRegex as string

func (*RuleRegex) UnmarshalText

func (r *RuleRegex) UnmarshalText(b []byte) error

UnmarshalText unmarshals json into a RuleRegex This must have a pointer receiver, otherwise the RuleRegex remains empty.

Jump to

Keyboard shortcuts

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