Documentation
¶
Index ¶
- func AAAAtoIP(rr *dns.RR_AAAA) net.IP
- func AtoIP(rr *dns.RR_A) net.IP
- func NewAddressRR(name string, class uint16, ttl uint32, ip net.IP) dns.RR
- func NewPtrRR(name string, class uint16, ttl uint32, ptr string) dns.RR
- func NewSrvRR(name string, class uint16, ttl uint32, target string, ...) dns.RR
- func NewTxtRR(name string, class uint16, ttl uint32, txt []string) dns.RR
- func SetMulticastLoopback(conn *net.UDPConn, ipversion int, v bool) (*net.UDPConn, error)
- func SetMulticastTTL(conn *net.UDPConn, ipversion int, v int) (*net.UDPConn, error)
- type MDNS
- func (s *MDNS) AddService(service, host string, port uint16, txt ...string) error
- func (s *MDNS) Hostname() string
- func (s *MDNS) RemoveService(service, host string, port uint16, txt ...string) error
- func (s *MDNS) ResolveAddress(dn string) ([]net.IP, uint32)
- func (s *MDNS) ResolveInstance(instance, service string) ServiceInstance
- func (s *MDNS) ResolveRR(dn string, rrtype uint16) []dns.RR
- func (s *MDNS) ScanInterfaces() (string, error)
- func (s *MDNS) ServiceDiscovery(service string) []ServiceInstance
- func (s *MDNS) ServiceMemberDiscovery(service string) []string
- func (s *MDNS) ServiceMemberWatch(service string) (<-chan ServiceInstance, func())
- func (s *MDNS) SetOutgoingTTL(ttl uint32)
- func (s *MDNS) Stop()
- func (s *MDNS) SubscribeToService(service string)
- func (s *MDNS) UnsubscribeFromService(service string)
- type ServiceInstance
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewAddressRR ¶
Returns an A or AAAA RR, whichever is appropriate for the passed in address.
func NewSrvRR ¶
func NewSrvRR(name string, class uint16, ttl uint32, target string, port, priority, weight uint16) dns.RR
Returns a SRV RR.
func SetMulticastLoopback ¶
SetMulticastLoopback turns on or off multicast loopbacks on the interface the connection is on.
Types ¶
type MDNS ¶
type MDNS struct {
// contains filtered or unexported fields
}
func (*MDNS) AddService ¶
Announce a service. If the host name is empty, we just use the host name from NewMDNS. If the host name ends in .local. we strip it off. If the port is zero, we do not announce the host addresses.
func (*MDNS) RemoveService ¶
Remove a service. If the host name is empty, we just use the host name from NewMDNS. If the host name ends in .local. we strip it off.
func (*MDNS) ResolveAddress ¶
ResolveToAddress return all IP addresses for a domain name (from all interfaces). These come from A and AAAA RR's for the name <host>.local. We use a map to dedup replies and then make a slice out of the map values. It also returns the lowest TTL of all the address records.
func (*MDNS) ResolveInstance ¶
func (s *MDNS) ResolveInstance(instance, service string) ServiceInstance
ResolveInstance returns the address records, the port, and the min ttl for a single service instance.
func (*MDNS) ScanInterfaces ¶
ScanInterfaces looks for changes in the interface list and makes sure we are using them for mdns.
func (*MDNS) ServiceDiscovery ¶
func (s *MDNS) ServiceDiscovery(service string) []ServiceInstance
ServiceDiscovery returns all current instances of a service (i.e. with a SRV record). We assume the user has already subscribed to the service to get systems on the network to multicast their entries.
func (*MDNS) ServiceMemberDiscovery ¶
ServiceMemberDiscovery returns all the members of a service (i.e. with a PTR record).
func (*MDNS) ServiceMemberWatch ¶
func (s *MDNS) ServiceMemberWatch(service string) (<-chan ServiceInstance, func())
ServiceMemberWatch returns a reply channel over which membership changes are announced. The returned function stops watching and closes the reply channel. A zero SRV and TXT record means that the instance is no longer a member.
func (*MDNS) SetOutgoingTTL ¶
Change the ttl for outgoing records to something other than the default.
func (*MDNS) SubscribeToService ¶
SubscriberToService declares our interest in a service. This should elicit responses from everyone implementing that service. This is orthogonal to offering the service ourselves.
func (*MDNS) UnsubscribeFromService ¶
UnsubscribeFromService withholds our interest in a service.