// rdnsSOA returns the nameserver from the SOA (start of authority) reverse-DNS
// record for ip.
rdnsSOA returns the nameserver from the SOA (start of authority) reverse-DNS
record for ip.
// rdnsSOA returns the nameserver from the SOA ( start of authority ) reverse - DNS // record for ip .
func rdnsSOA(ip string) (server string, err error) {
	octets := strings.Split(ip, ".")
	if len(octets) != 4 {
		return "", errors.New("invalid IPv4 address")
	}
	octets[0], octets[1], octets[2], octets[3] = octets[3], octets[2], octets[1], octets[0]
	m := new(dns.Msg)
	for i := 0; i < 4; i++ {
		m.SetQuestion(strings.Join(octets[i:], ".")+".in-addr.arpa.", dns.TypeSOA)
		soa, err := dns.Exchange(m, dnsServer)
		if err != nil {
			return "", err
		}
		if soa.Rcode != dns.RcodeSuccess || len(soa.Answer) == 0 {
			continue
		}
		trsoa, ok := soa.Answer[0].(*dns.SOA)
		if !ok {
			continue
		}
		return trsoa.Ns, nil
	}
	return "", errors.New("SOA not found")
}
func rdnsSOA ( ip string ) ( server string , err error ) { octets := strings . Split ( ip , " " ) if len ( octets ) != 4 { return " " , errors . New ( " " ) } octets [ 0 ] , octets [ 1 ] , octets [ 2 ] , octets [ 3 ] = octets [ 3 ] , octets [ 2 ] , octets [ 1 ] , octets [ 0 ] m := new ( dns . Msg ) for i := 0 ; i < 4 ; i ++ { m . SetQuestion ( strings . Join ( octets [ i : ] , " " ) + " " , dns . TypeSOA ) soa , err := dns . Exchange ( m , dnsServer ) if err != nil { return " " , err } if soa . Rcode != dns . RcodeSuccess || len ( soa . Answer ) == 0 { continue } trsoa , ok := soa . Answer [ 0 ] . ( * dns . SOA ) if ! ok { continue } return trsoa . Ns , nil } return " " , errors . New ( " " ) }
rdnsSOA returns the nameserver from the SOA (start of authority) reverse-DNS
record for ip.
rdnsSOA returns the nameserver from the SOA ( start of authority ) reverse - DNS record for ip .