dnsgraph

package
v5.4.0 Latest Latest
Warning

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

Go to latest
Published: Oct 9, 2026 License: MIT Imports: 1 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

View Source
const (
	// IncomingEdge is an edge inbound.
	IncomingEdge edgeDirection = iota
	// OutgoingEdge is an edge outbound.
	OutgoingEdge
)

Variables

This section is empty.

Functions

func GetRecordsNamesForGraphables

func GetRecordsNamesForGraphables[T Graphable](graphables []T) []string

GetRecordsNamesForGraphables returns names in a graph.

Types

type Dependency

type Dependency struct {
	NameFQDN string
	Type     DependencyType
	// CNAME would generate Dependency{NameFQDN: target, OnlyType: ""}
	// because the dependency is on the target.
	//
	// However a DS's dependency is on its own label, not the target.
	// A DS needs to specify that the dependency is on the NS record at the same label.
	// Therefore a DS record returns Dependency{NameFQDN: label, OnlyType: "NS"}
	// to indicate that the dependency is only for NS records.
	// If OnlyType were "", a DS would also depend on the *other* DS records at its
	// label; with two or more DS there, they'd depend on each other and dnsgraph
	// reports a cycle.
	OnlyType string
}

Dependency is a dependency.

type DependencyType

type DependencyType uint8

DependencyType enumerates the dependency types.

const (
	// ForwardDependency is a forward dependency.
	ForwardDependency DependencyType = iota
	// BackwardDependency is a backwards dependency.
	BackwardDependency
)

type Edge

type Edge[T Graphable] struct {
	Dependency Dependency
	Node       *Node[T]
	Direction  edgeDirection
}

Edge an edge on the graph.

type Edges

type Edges[T Graphable] []Edge[T]

Edges a list of edges.

func (Edges[T]) Contains

func (edges Edges[T]) Contains(toFind *Node[T], direction edgeDirection) bool

Contains returns true if a node is in the graph AND is in that direction.

func (Edges[T]) RemoveNode

func (edges Edges[T]) RemoveNode(toRemove *Node[T]) Edges[T]

RemoveNode removes a node edges.

type Graph

type Graph[T Graphable] struct {
	All  dnsGraphNodes[T]
	Tree *dnstree.DomainTree[dnsGraphNodes[T]]
}

Graph a graph.

func CreateGraph

func CreateGraph[T Graphable](entries []T) *Graph[T]

CreateGraph returns a graph.

func (*Graph[T]) AddEdge

func (graph *Graph[T]) AddEdge(sourceNode *Node[T], dependency Dependency)

AddEdge adds an edge to a graph.

func (*Graph[T]) AddNode

func (graph *Graph[T]) AddNode(data T)

AddNode adds a node to a graph.

func (*Graph[T]) RemoveNode

func (graph *Graph[T]) RemoveNode(toRemove *Node[T])

RemoveNode removes a node from a graph.

type Graphable

type Graphable interface {
	GetType() NodeType
	GetName() string
	// GetRecordType returns the DNS record type (e.g. "NS", "DS") of the node.
	// It is used to satisfy Dependency.OnlyType filters.
	GetRecordType() string
	GetDependencies() []Dependency
}

Graphable is an interface for things that can be in a graph.

type Node

type Node[T Graphable] struct {
	Data  T
	Edges Edges[T]
}

Node a node in the graph.

type NodeType

type NodeType uint8

NodeType enumerates the node types.

const (
	// Change is the type of change.
	Change NodeType = iota
	// Report is a Report.
	Report
)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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