-
Notifications
You must be signed in to change notification settings - Fork 7
/
doc.go
57 lines (37 loc) · 1.56 KB
/
doc.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
package mdns
/*
Package MDNS provides an MDNS interface (RFC 6762) that is both a client and a server. It caches all
resource records learned from any network it is listening to. Depending on the loopback flag in NewMDNS,
it will either listen to all non-loopback or to only loopback network interfaces and, in both cases,
only on ones that have ipv4 or ipv6 addresses.
An instance is created by:
s, err := NewMDNS(hostname,
ipv4 address - default "224.0.0.251:5353",
ipv6 address - default "[FF02::FB]:5353",
true if using only loopback (i.e. testing)
true if we want extensive logging)
To register interest in a service (i.e. for service discovery ala RFC 6763):
s.SubscribeToService(service name)
This actually sends a multicast request on all networks asking for anyone providing that service.
It need only be done once, since, as systems join the network they will multicast that information.
To register as a provider of a service:
s.AddService(servicename,
hostname - default, the host name provided with NewMDNS,
port)
To learn all providers of a service:
var instances []mdns.ServiceInstance
instances = s.ServiceDiscovery(service name)
where
type ServiceInstance struct {
Target string
Port uint16
}
To learn the addresses of a host:
var ips []net.IP
ips = s.ResolveAddress(domain name - can be with or without a trailing ".local")
To learn an RR (dns resource record) of a particular type:
var rrs []dns.RR
rrs = s.ResolveRR(domain name - can be with or without a trailing ".local")
To stop the service:
s.Stop()
*/