dns

package
v0.0.0-...-e25560c Latest Latest
Warning

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

Go to latest
Published: Aug 10, 2023 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

copied from https://github.com/coredns/coredns/blob/master/plugin/pkg/dnsutil/reverse.go

Index

Constants

View Source
const (
	// IP4arpa is the reverse tree suffix for v4 IP addresses.
	IP4arpa = ".in-addr.arpa."
	// IP6arpa is the reverse tree suffix for v6 IP addresses.
	IP6arpa = ".ip6.arpa."
)

Variables

This section is empty.

Functions

func ExtractAddressFromReverse

func ExtractAddressFromReverse(reverseName string) string

ExtractAddressFromReverse turns a standard PTR reverse record name into an IP address. This works for ipv4 or ipv6.

54.119.58.176.in-addr.arpa. becomes 176.58.119.54. If the conversion fails the empty string is returned.

func GetDomainByIP

func GetDomainByIP(ip net.IP) (string, bool)

func IsReverse

func IsReverse(name string) int

IsReverse returns 0 is name is not in a reverse zone. Anything > 0 indicates name is in a reverse zone. The returned integer will be 1 for in-addr.arpa. (IPv4) and 2 for ip6.arpa. (IPv6).

func ResolveIP

func ResolveIP(domain string) ([]net.IP, error)

func ResolveIPv4

func ResolveIPv4(domain string) ([]net.IP, error)

func ResolveIPv6

func ResolveIPv6(domain string) ([]net.IP, error)

Types

type DNS

type DNS struct {
	Enable   bool     `yaml:"enable"`
	Listen   string   `yaml:"listen"`
	Upstream []string `yaml:"upstream"`
	FakeIP   FakeIP   `yaml:"fakeip"`
}

func (*DNS) NewServer

func (d *DNS) NewServer(pool *fakeip.FakeIP) *DNSServer

type DNSServer

type DNSServer struct {
	*dns.Server
}

type FakeIP

type FakeIP struct {
	Enable bool   `yaml:"enable"`
	Cidr   string `yaml:"cidr"`
	Ttl    int    `yaml:"ttl"`
}

Jump to

Keyboard shortcuts

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