pkg

package
v0.0.0-...-587470e Latest Latest
Warning

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

Go to latest
Published: Dec 7, 2024 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	DnsTimeout  = 2
	NetResolver = DefaultResolver()
	Zone        string // Zone is the domain name of the cluster
)

Functions

func ARecord

func ARecord(domain string) (ips []net.IP, err error)

func CheckKubeDNS

func CheckKubeDNS(dns ...*SpiderResolver) bool

https://github.com/kubernetes/dns/blob/master/docs/specification.md CheckKubernetes checks if the current environment is a kubernetes cluster

func CheckKubeDNS_DNSVersion

func CheckKubeDNS_DNSVersion(dns *SpiderResolver) bool

func CheckKubeDNS_DefaultAPIServer

func CheckKubeDNS_DefaultAPIServer(dns *SpiderResolver) bool

func CheckKubeDNS_NS_DNS_DOMAIN

func CheckKubeDNS_NS_DNS_DOMAIN(dns *SpiderResolver) bool

func CheckPodVerified

func CheckPodVerified() bool

CheckPodVerified is utils to check if current Kubernetes has set pod verified

func IPtoPodHostName

func IPtoPodHostName(ip, namespace string) string

func PTRRecord

func PTRRecord(ip net.IP) []string

func ParseIPNetToIPs

func ParseIPNetToIPs(ipv4Net *net.IPNet) (ips []net.IP)

func ParseStringToIPNet

func ParseStringToIPNet(s string) (ipnet *net.IPNet, err error)

func SRVRecord

func SRVRecord(svcDomain string) (string, []*net.SRV, error)

func SubnetInto

func SubnetInto(network *net.IPNet, count int) ([]*net.IPNet, error)

SubnetInto wraps SubnetShift and divides a network into at least count-many, equal-sized subnets, which are as large as allowed.

func SubnetShift

func SubnetShift(network *net.IPNet, bits int) ([]*net.IPNet, error)

SubnetShift divides a network into subnets by shifting the given number of bits.

func TXTRecord

func TXTRecord(domain string) (txts []string, err error)

Types

type DnsQuery

type DnsQuery func(domain string) ([]string, error)
var (
	QueryPTR DnsQuery = func(domain string) ([]string, error) {
		return PTRRecord(net.ParseIP(domain)), nil
	}
	QueryA DnsQuery = func(domain string) ([]string, error) {
		res, err := ARecord(domain)
		var ret []string
		for _, r := range res {
			ret = append(ret, r.String())
		}
		return ret, err
	}
	QueryTXT DnsQuery = TXTRecord
	QuerySRV DnsQuery = func(domain string) ([]string, error) {
		_, res, err := SRVRecord(domain)
		var ret []string
		for _, r := range res {
			ret = append(ret, fmt.Sprintf("%s:%d", r.Target, r.Port))
		}
		return ret, err
	}
)

type SpiderResolver

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

func DefaultResolver

func DefaultResolver() *SpiderResolver

func WarpDnsServer

func WarpDnsServer(dnsServer string) *SpiderResolver

func (*SpiderResolver) ARecord

func (s *SpiderResolver) ARecord(domain string) ([]net.IP, error)

func (*SpiderResolver) CurrentDNS

func (s *SpiderResolver) CurrentDNS() string

func (*SpiderResolver) CustomSRVRecord

func (s *SpiderResolver) CustomSRVRecord(svcDomain string, service, proto string) (string, []*net.SRV, error)

func (*SpiderResolver) PTRRecord

func (s *SpiderResolver) PTRRecord(ip net.IP) []string

func (*SpiderResolver) SRVRecord

func (s *SpiderResolver) SRVRecord(svcDomain string) (string, []*net.SRV, error)

func (*SpiderResolver) SetContainsFilter

func (r *SpiderResolver) SetContainsFilter(name ...string)

func (*SpiderResolver) SetFilter

func (r *SpiderResolver) SetFilter(filters ...string)

func (*SpiderResolver) SetSuffixFilter

func (r *SpiderResolver) SetSuffixFilter(filter string)

func (*SpiderResolver) TXTRecord

func (s *SpiderResolver) TXTRecord(domain string) ([]string, error)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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