* allow to receive multicast on the same host
via multicast loopback flag
* export SendMulticast function, needed for async
notification on registry updates
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
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.
- 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.