func (self *Exchange) printRecv(p printer.Interface) { switch self.PrintFlag { case PrintAll: if self.Recv != nil { p.Print("recv {") p.ShiftIn() self.Recv.PrintTo(p) p.ShiftOut("}") } if self.Error != nil { p.Printf("error %v", self.Error) } case PrintReply: if self.Recv != nil { self.Recv.Packet.PrintTo(p) self.printTimeTaken(p) } if self.Error != nil { p.Printf("error %v", self.Error) } default: panic("unknown print flag") } p.ShiftOut("}") }
func (self *Exchange) printSend(p printer.Interface) { p.Printf("%s {", self.Query.String()) p.ShiftIn() switch self.PrintFlag { case PrintAll: p.Print("send {") p.ShiftIn() self.Send.PrintTo(p) p.ShiftOut("}") case PrintReply: // do nothing default: panic("unknown print flag") } }
func (self Section) PrintNameTo(p printer.Interface, name string) { if self == nil { return } if len(self) == 0 { return } if len(self) == 1 { p.Printf("%s %v", name, self[0]) } else { p.Printf("%s {", name) p.ShiftIn() self.PrintTo(p) p.ShiftOut("}") } }
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("}") } }