Introduce context.Context to enable cancellation in addition to the
existing timeout functionality. To retain compatability, Timeout is
still available but will only be used if Context is not set.
We use x/net/context.Context for the moment instead of context.Context
in order to avoid creating a requirement on Go 1.7
When the timeout it reached, the query can still fail to complete if the
caller isn't consuming the results from the channel. This change allows
the query to exit in any case.
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.
- dns.Msg construction is now explicit, with comments pointing to the RFC about
the values of each field.
- dns.Msg responses no longer contain a Question section, which is not allowed
according to the spec.
- handleQuestion's interface returns both unicast and multicast answer records.
(Note: These are not yet treated differently by the sendResponse method.)
- removed unused error return value of handleQuestion
- Change API for constructing an MDNSService: use NewMDNSService func instead of
creating an MDNSService struct and calling its Init method.
- Allow full specification of the host name and IP addresses of an MDNSService
instead of relying on the net package to infer them from the OS.
- Remove deprecated Addr member of MDNSService.
- Modify tests to comply with new API.
- Add WantUnicastResponse to allow sending mDNS queries that desire unicast
responses (see section 5.4 in RFC6762).
- Listen for UDP packets sent to the mDNS multicast addresses ("ipv4:
224.0.0.251", ipv6: "ff02::fb")
- Fix bug on line 177 of client.go: Ignored error during sendQuery.
- Add TODO comments regarding unimplemented features of mDNS protocol.
- Add error logging statement when DNS packet parsing failed.