Fix ExamplePrivateHandle (#1354)
Signed-off-by: Miek Gieben <miek@miek.nl>
This commit is contained in:
parent
49c1b2e20f
commit
dedee46bd4
|
@ -121,21 +121,23 @@ func (rd *APAIR) Len() int {
|
|||
func ExamplePrivateHandle() {
|
||||
dns.PrivateHandle("APAIR", TypeAPAIR, NewAPAIR)
|
||||
defer dns.PrivateHandleRemove(TypeAPAIR)
|
||||
var oldId = dns.Id
|
||||
dns.Id = func() uint16 { return 3 }
|
||||
defer func() { dns.Id = oldId }()
|
||||
|
||||
rr, err := dns.NewRR("miek.nl. APAIR (1.2.3.4 1.2.3.5)")
|
||||
if err != nil {
|
||||
log.Fatal("could not parse APAIR record: ", err)
|
||||
}
|
||||
fmt.Println(rr)
|
||||
// Output: miek.nl. 3600 IN APAIR 1.2.3.4 1.2.3.5
|
||||
fmt.Println(rr) // see first line of Output below
|
||||
|
||||
m := new(dns.Msg)
|
||||
m.Id = 12345
|
||||
m.SetQuestion("miek.nl.", TypeAPAIR)
|
||||
m.Answer = append(m.Answer, rr)
|
||||
|
||||
fmt.Println(m)
|
||||
// ;; opcode: QUERY, status: NOERROR, id: 12345
|
||||
// Output: miek.nl. 3600 IN APAIR 1.2.3.4 1.2.3.5
|
||||
// ;; opcode: QUERY, status: NOERROR, id: 3
|
||||
// ;; flags: rd; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 0
|
||||
//
|
||||
// ;; QUESTION SECTION:
|
||||
|
|
Loading…
Reference in New Issue