Expose rr.Txt as []string instead of joining it with “|”.
Joining the different fields into a single string is problematic when the fields contain the separator character “|” themselves. As an example, I’ve named my chromecast “Hendrix|test”, and this happens when I print a ServiceEntry: ServiceEntry: &{Name:Hendrix|test._googlecast._tcp.local. Host:Hendrix|test.local. AddrV4:10.0.0.184 AddrV6:<nil> Port:8009 Info:id=3fc948dbfebcf5d7ec77d7b043dce81e|ve=04|md=Chromecast Audio|ic=/setup/icon.png|fn=Hendrix|test|ca=4|st=0|bs=FA8FCA928304|rs= Addr:10.0.0.184 hasTXT:true sent:true} When using strings.Split, I would not correctly parse the fn= field. With the new InfoFields member, this problem can be avoided entirely.
This commit is contained in:
parent
2b439d3701
commit
83d7e99a21
@ -21,6 +21,7 @@ type ServiceEntry struct {
|
|||||||
AddrV6 net.IP
|
AddrV6 net.IP
|
||||||
Port int
|
Port int
|
||||||
Info string
|
Info string
|
||||||
|
InfoFields []string
|
||||||
|
|
||||||
Addr net.IP // @Deprecated
|
Addr net.IP // @Deprecated
|
||||||
|
|
||||||
@ -258,6 +259,7 @@ func (c *client) query(params *QueryParam) error {
|
|||||||
// Pull out the txt
|
// Pull out the txt
|
||||||
inp = ensureName(inprogress, rr.Hdr.Name)
|
inp = ensureName(inprogress, rr.Hdr.Name)
|
||||||
inp.Info = strings.Join(rr.Txt, "|")
|
inp.Info = strings.Join(rr.Txt, "|")
|
||||||
|
inp.InfoFields = rr.Txt
|
||||||
inp.hasTXT = true
|
inp.hasTXT = true
|
||||||
|
|
||||||
case *dns.A:
|
case *dns.A:
|
||||||
|
Loading…
Reference in New Issue
Block a user