dnstree

package
v4.12.0 Latest Latest
Warning

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

Go to latest
Published: Jun 18, 2024 License: MIT Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DomainTree

type DomainTree[T any] domainNode[T]

DomainTree is a domain tree.

func Create

func Create[T any]() *DomainTree[T]

Create creates a tree like structure to add arbitrary data to DNS names. The DomainTree splits the domain name based on the dot (.), reverses the resulting list and add all strings the tree in order. It has support for wildcard domain names the tree nodes (`Set`), but not during retrieval (Get and Has). Get always returns the most specific node; it doesn't immediately return the node upon finding a wildcard node.

func (*DomainTree[T]) Get

func (tree *DomainTree[T]) Get(fqdn string) T

Get retrieves the attached data from a given FQDN. The tree will return the data entry for the most specific FQDN entry. If no entry is found Get will return the default value for the specific type.

tree.Set("*.example.com", 1) tree.Set("a.example.com", 2) tree.Get("a.example.com") // 2 tree.Get("a.a.example.com") // 1 tree.Get("other.com") // 0

func (*DomainTree[T]) Has

func (tree *DomainTree[T]) Has(fqdn string) bool

Has returns if the tree contains data for given FQDN.

func (*DomainTree[T]) Set

func (tree *DomainTree[T]) Set(fqdn string, data T)

Set adds given data to the given fqdn. The FQDN can contain a wildcard on the start. example fqdn: *.example.com

Jump to

Keyboard shortcuts

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