Skip to content

net: LookupTXT fails when TXT record contains multiple strings #10482

Closed
@DenBeke

Description

@DenBeke

What version of Go are you using (go version)?
Go 1.4

What operating system and processor architecture are you using?
OS X 10.10.3

What did you do?
DNS TXT lookup on _spf.facebook.com:

package main

import "fmt"
import "net"

func main() {
    txt, err := net.LookupTXT("_spf.facebook.com")
    fmt.Println(err)
    fmt.Println(txt)
}

What did you expect to see?
"v=spf1 ip4:69.63.179.25 ip4:69.63.178.128/25 ip4:69.63.184.0/25 ip4:66.220.144.128/25 ip4:66.220.155.0/24 ip4:69.171.232.0/25 i" "p4:66.220.157.0/25 ip4:69.171.244.0/24 mx -all"

dig _spf.facebook.com TXT returns this:

;; QUESTION SECTION:
;_spf.facebook.com.     IN  TXT

;; ANSWER SECTION:
_spf.facebook.com.  3599    IN  TXT "v=spf1 ip4:69.63.179.25 ip4:69.63.178.128/25 ip4:69.63.184.0/25 ip4:66.220.144.128/25 ip4:66.220.155.0/24 ip4:69.171.232.0/25 i" "p4:66.220.157.0/25 ip4:69.171.244.0/24 mx -all"

What did you see instead?
lookup _spf.facebook.com on 8.8.8.8:53: no such host

Go fails to lookup TXT records which consist of multiple character strings.
RFC 1035 3.3.14.

3.3.14. TXT RDATA format

    +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
    /                   TXT-DATA                    /
    +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+

where:

TXT-DATA        One or more <character-string>s.

<character-string> is defined in section 3.3. of the same RFC 1035

<character-string> is a single
length octet followed by that number of characters.  <character-string>
is treated as binary information, and can be up to 256 characters in
length (including the length octet).

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions