network

package
v1.10.0 Latest Latest
Warning

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

Go to latest
Published: Mar 31, 2023 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrMaxNamesReached = errors.New("dns reverse max names reached")

ErrMaxNamesReached is thrown when the capacity of the names map is reached

Functions

This section is empty.

Types

type Address

type Address [16]byte

Address is the comparable type-alias for the IP v4/v6 addresses

func AddressFromIP

func AddressFromIP(ip net.IP) Address

AddressFromIP constructs the address from the IP address.

func (Address) ToIP

func (addr Address) ToIP() net.IP

ToIP converts the address to net.IP type.

func (Address) ToIPString

func (addr Address) ToIPString() string

ToIPString converts the address to IP string representation.

type L4Proto

type L4Proto uint8

L4Proto is the type alias for the Layer 4 protocol.

const (
	// TCP identifies TCP Layer 4 protocol.
	TCP L4Proto = iota + 1
	// UDP identifies UDP Layer 4 protocol.
	UDP
)

func (L4Proto) String

func (proto L4Proto) String() string

String returns the string representation of the Layer 4 protocol.

type ReverseDNS

type ReverseDNS struct {
	// contains filtered or unexported fields
}

ReverseDNS performs reverse DNS resolutions and keeps the cache of resolved IP to domain mappings.

func NewReverseDNS

func NewReverseDNS(size int, ttl, exp time.Duration) *ReverseDNS

NewReverseDNS creates a new DNS reverser with the specified size and TTL period.

func (*ReverseDNS) Add

func (r *ReverseDNS) Add(addr Address) ([]string, error)

Add performs a reverse lookup for the given address, returning a list of names mapping to that address. It assigns a ttl to the names value and puts it in the map. If the names map capacity is reached this method returns an error and gives up on adding new entries.

func (*ReverseDNS) Close

func (r *ReverseDNS) Close()

Close closes the expiration ticker.

func (*ReverseDNS) Expire

func (r *ReverseDNS) Expire()

Expire evicts name values that are eligible for expiration.

func (*ReverseDNS) Get

func (r *ReverseDNS) Get(addr Address) []string

Get returns all the name mappings for the specified address.

func (*ReverseDNS) Len

func (r *ReverseDNS) Len() int

Len returns the size of the names map.

Jump to

Keyboard shortcuts

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