func reverseByDot(ip []byte) (rev []byte) {
	addrs := bytes.Split(ip, []byte{'.'})
	for x := len(addrs) - 1; x >= 0; x-- {
		if len(rev) > 0 {
			rev = append(rev, '.')
		}
		rev = append(rev, addrs[x]...)
	}
	return
}
reverseByDot reverse the IP address by dot.
For example, IPv4 with address "127.0.0.1" it will return "1.0.0.127".
For IPv6 with address "2001:db8::cb01" it will return
"1.0.b.c.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.1.0.0.2".
package dns
import (
	"bytes"
	"fmt"
	"net"
	libnet "github.com/shuLhan/share/lib/net"
)
func GetSystemNameServers(path string) []string {
	if len(path) == 0 {
		path = "/etc/resolv.conf"
	}
	rc, err := libnet.NewResolvConf(path)
	if err != nil {
		return nil
	}
	return rc.NameServers
}
func ParseNameServers(nameservers []string) ([]*net.UDPAddr, error) {
	udpAddrs := make([]*net.UDPAddr, 0)
	for _, ns := range nameservers {
		addr, err := libnet.ParseUDPAddr(ns, DefaultPort)
		if err != nil {
			return udpAddrs, err
		}
		udpAddrs = append(udpAddrs, addr)
	}
	return udpAddrs, nil
}
func LookupPTR(client Client, ip net.IP) (answer string, err error) {
	if ip == nil {
		return "", fmt.Errorf("empty IP address")
	}
	revIP, isIPv4 := reverseIP(ip)
	if len(revIP) == 0 {
		return "", fmt.Errorf("invalid IP address %q", ip)
	}
	if isIPv4 {
		revIP = append(revIP, []byte(".in-addr.arpa")...)
	} else {
		revIP = append(revIP, []byte(".ip6.arpa")...)
	}
	msg, err := client.Lookup(true, QueryTypePTR, QueryClassIN,
		string(revIP))
	if err != nil {
		return "", err
	}
	rranswers := msg.FilterAnswers(QueryTypePTR)
	if len(rranswers) == 0 {
		return "", nil
	}
	banswer, ok := rranswers[0].Value.(string)
	if !ok {
		return "", fmt.Errorf("invalid PTR record data")
	}
	answer = string(banswer)
	return answer, nil
}
func reverseIP(ip net.IP) (revIP []byte, isIPv4 bool) {
	isIPv4 = libnet.IsIPv4(ip)
	if isIPv4 {
		revIP = reverseByDot([]byte(ip.String()))
		return
	}
	if libnet.IsIPv6(ip) {
		revIP = reverseByDot(libnet.ToDotIPv6(ip))
		return
	}
	return nil, false
}