Exemple #1
0
func Servers(p *pa.Packet, zone *Domain, d *Domain, c Cursor) *ZoneServers {
	redirects := p.SelectRedirects(zone, d)
	if len(redirects) == 0 {
		return nil
	}

	next := redirects[0].Domain

	ret := NewZoneServers(next)
	ret.records = redirects

	for _, rr := range redirects {
		if !rr.Domain.Equal(next) {
			c.Printf("// warning: ignore different subzone: %v", rr.Domain)
			continue
		}

		ns := rdata.ToDomain(rr.Rdata)

		rrs := p.SelectIPs(ns) // glued IPs
		ret.records = append(ret.records, rrs...)

		ips := make([]net.IP, 0, len(rrs))
		for _, rr := range rrs {
			ips = append(ips, rdata.ToIPv4(rr.Rdata))
		}
		ret.Add(ns, ips...)
	}

	return ret
}
Exemple #2
0
Fichier : info.go Projet : h8liu/d8
func (self *Info) PrintTo(p printer.Interface) {
	if len(self.Cnames) > 0 {
		p.Print("cnames {")
		p.ShiftIn()
		for _, r := range self.Cnames {
			p.Printf("%v -> %v", r.Domain, rdata.ToDomain(r.Rdata))
		}
		p.ShiftOut("}")
	}

	if len(self.Results) == 0 {
		p.Print("(unresolvable)")
	} else {
		p.Print("ips {")
		p.ShiftIn()

		for _, r := range self.Results {
			d := r.Domain
			ip := rdata.ToIPv4(r.Rdata)
			if d.Equal(self.Domain) {
				p.Printf("%v", ip)
			} else {
				p.Printf("%v(%v)", ip, d)
			}
		}

		p.ShiftOut("}")
	}

	if len(self.NameServers) > 0 {
		p.Print("servers {")
		p.ShiftIn()

		for _, ns := range self.NameServers {
			p.Printf("%v", ns)
		}

		p.ShiftOut("}")
	}

	if len(self.Records) > 0 {
		p.Print("records {")
		p.ShiftIn()

		for _, rr := range self.Records {
			p.Printf("%v", rr.Digest())
		}

		p.ShiftOut("}")
	}
}
Exemple #3
0
Fichier : info.go Projet : h8liu/d8
func (self *Info) Result() string {
	ret := newInfoResult(self.Domain.String())

	for _, r := range self.Cnames {
		s := fmt.Sprintf("%v -> %v", r.Domain, rdata.ToDomain(r.Rdata))
		ret.cnames = append(ret.cnames, s)
	}

	for _, r := range self.Results {
		d := r.Domain
		ip := rdata.ToIPv4(r.Rdata)
		var s string
		if d.Equal(self.Domain) {
			s = fmt.Sprintf("%v", ip)
		} else {
			s = fmt.Sprintf("%v(%v)", ip, d)
		}

		ret.ips = append(ret.ips, s)
	}

	for _, ns := range self.NameServers {
		s := fmt.Sprintf("%v", ns)
		ret.servers = append(ret.servers, s)
	}
	for _, rr := range self.Records {
		s := fmt.Sprintf("%v", rr.Digest())
		ret.records = append(ret.records, s)
	}

	out := new(bytes.Buffer)

	wr := func(obj interface{}, post string) {
		out.Write(jmarsh(obj))
		out.WriteString(post)
	}

	wr(ret.domain, "\t")
	wr(ret.ips, "\t")
	wr(ret.cnames, "\t")
	wr(ret.servers, "\t")
	wr(ret.records, "\n")

	return out.String()
}