Documentation ¶
Index ¶
- Variables
- func A(srv Service, iface *net.Interface) []*dns.A
- func AAAA(srv Service, iface *net.Interface) []*dns.AAAA
- func DNSSDServicesPTR(srv Service) *dns.PTR
- func LookupType(ctx context.Context, service string, add AddFunc, rmv RmvFunc) (err error)
- func MulticastInterfaces(filters ...string) []*net.Interface
- func NSEC(rr dns.RR, srv Service, iface *net.Interface) *dns.NSEC
- func PTR(srv Service) *dns.PTR
- func SRV(srv Service) *dns.SRV
- func TXT(srv Service) *dns.TXT
- type AddFunc
- type BrowseEntry
- type Cache
- type Config
- type MDNSConn
- type Query
- type ReadFunc
- type Request
- type Responder
- type Response
- type RmvFunc
- type Service
- func (s Service) Copy() *Service
- func (s Service) EscapedName() string
- func (s Service) EscapedServiceInstanceName() string
- func (s *Service) HasIPOnAnyInterface(ip net.IP) bool
- func (s Service) Hostname() string
- func (s *Service) IPsAtInterface(iface *net.Interface) []net.IP
- func (s *Service) Interfaces() []*net.Interface
- func (s *Service) IsVisibleAtInterface(n string) bool
- func (s Service) ServiceInstanceName() string
- func (s Service) ServiceName() string
- func (s Service) ServicesMetaQueryName() string
- func (s *Service) SetHostname(hostname string)
- type ServiceHandle
Constants ¶
This section is empty.
Variables ¶
var ( // IPv4LinkLocalMulticast is the IPv4 link-local multicast address. IPv4LinkLocalMulticast = net.ParseIP("224.0.0.251") // IPv6LinkLocalMulticast is the IPv6 link-local multicast address. IPv6LinkLocalMulticast = net.ParseIP("ff02::fb") // AddrIPv4LinkLocalMulticast is the IPv4 link-local multicast UDP address. AddrIPv4LinkLocalMulticast = &net.UDPAddr{ IP: IPv4LinkLocalMulticast, Port: 5353, } // AddrIPv6LinkLocalMulticast is the IPv5 link-local multicast UDP address. AddrIPv6LinkLocalMulticast = &net.UDPAddr{ IP: IPv6LinkLocalMulticast, Port: 5353, } // TTLDefault is the default time-to-live for mDNS resource records. TTLDefault uint32 = 75 * 6 // TTLHostname is the default time-to-livefor mDNS hostname records. TTLHostname uint32 = 120 )
Functions ¶
func DNSSDServicesPTR ¶
func LookupType ¶
LookupType browses for service instanced with a specified service type.
func MulticastInterfaces ¶ added in v1.2.5
MulticastInterfaces returns a list of all active multicast network interfaces.
Types ¶
type AddFunc ¶ added in v1.2.0
type AddFunc func(BrowseEntry)
AddFunc is called when a service instance was found.
type BrowseEntry ¶ added in v1.2.0
type BrowseEntry struct { IPs []net.IP Host string Port int IfaceName string Name string Type string Domain string Text map[string]string }
BrowseEntry represents a discovered service instance.
func (BrowseEntry) EscapedServiceInstanceName ¶ added in v1.2.12
func (e BrowseEntry) EscapedServiceInstanceName() string
ServiceInstanceName returns the service instance name in the form of <instance name>.<service>.<domain>. (Note the trailing dot.)
func (BrowseEntry) ServiceInstanceName ¶ added in v1.2.0
func (e BrowseEntry) ServiceInstanceName() string
ServiceInstanceName returns the same as `ServiceInstanceName()` but removes any escape characters.
type Cache ¶
type Cache struct {
// contains filtered or unexported fields
}
Cache stores services in memory.
type Config ¶ added in v1.1.0
type Config struct { // Name of the service. Name string // Type is the service type, for example "_hap._tcp". Type string // Domain is the name of the domain, for example "local". // If empty, "local" is used. Domain string // Host is the name of the host (no trailing dot). // If empty the local host name is used. Host string // Txt records Text map[string]string // IP addresses of the service. // This field is deprecated and should not be used. IPs []net.IP // Port is the port of the service. Port int // Interfaces at which the service should be registered Ifaces []string }
type MDNSConn ¶
type MDNSConn interface { // SendQuery sends a mDNS query. SendQuery(q *Query) error // SendResponse sends a mDNS response SendResponse(resp *Response) error // Read returns a channel which receives mDNS messages Read(ctx context.Context) <-chan *Request // Clears the connection buffer Drain(ctx context.Context) // Close closes the connection Close() }
MDNSConn represents a mDNS connection. It encapsulates an IPv4 and IPv6 UDP connection.
type Request ¶
type Request struct {
// contains filtered or unexported fields
}
Request represents an incoming mDNS message
func (Request) IfaceName ¶ added in v1.2.0
IfaceName returns the name of the network interface where the request was received. If the network interface is unknown, the string "?" is returned.
type Responder ¶
type Responder interface { // Add adds a service to the responder. // Use the returned service handle to update service properties. Add(srv Service) (ServiceHandle, error) // Remove removes the service associated with the service handle from the responder. Remove(srv ServiceHandle) // Respond makes the receiver announcing and managing services. Respond(ctx context.Context) error // Debug calls a function for every dns request the responder receives. Debug(ctx context.Context, fn ReadFunc) }
Responder represents a mDNS responder.
func NewResponder ¶
NewResponder returns a new mDNS responder.
type Response ¶
type Response struct {
// contains filtered or unexported fields
}
Response is a mDNS response
type RmvFunc ¶ added in v1.2.0
type RmvFunc func(BrowseEntry)
RmvFunc is called when a service instance disappared.
type Service ¶
type Service struct { Name string Type string Domain string Host string Text map[string]string TTL time.Duration // Original time to live Port int IPs []net.IP Ifaces []string // contains filtered or unexported fields }
Service represents a DNS-SD service instance
func LookupInstance ¶
LookupInstance resolves a service by its service instance name.
func NewService ¶
NewService returns a new service for the given config.
func ProbeService ¶
ProbeService probes for the hostname and service instance name of srv. If err == nil, the returned service is verified to be unique on the local network.
func (Service) EscapedName ¶ added in v1.2.12
func (Service) EscapedServiceInstanceName ¶ added in v1.2.12
EscapedServiceInstanceName returns the same as `ServiceInstanceName()` but escapes any special characters.
func (*Service) HasIPOnAnyInterface ¶ added in v1.2.11
HasIPOnAnyInterface returns true, if the service defines the ip address on any network interface.
func (*Service) IPsAtInterface ¶ added in v1.1.0
IPsAtInterface returns the ip address at a specific interface.
func (*Service) Interfaces ¶ added in v1.2.0
Interfaces returns the network interfaces for which the service is registered, or all multicast network interfaces, if no IP addresses are specified.
func (*Service) IsVisibleAtInterface ¶ added in v1.2.5
IsVisibleAtInterface returns true, if the service is published at the network interface with name n.
func (Service) ServiceInstanceName ¶
ServiceInstanceName returns the service instance name in the form of <instance name>.<service>.<domain>. (Note the trailing dot.)
func (Service) ServiceName ¶
ServiceName returns the service name in the form of "<service>.<domain>." (Note the trailing dot.)
func (Service) ServicesMetaQueryName ¶
ServicesMetaQueryName returns the name of the meta query for the service domain in the form of "_services._dns-sd._udp.<domain.". (Note the trailing dot.)
func (*Service) SetHostname ¶
SetHostname sets the service's host name and domain (if specified as "<hostname>.<domain>."). (Note the trailing dot.)
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
cmd
|
|
browse
Command browse browses for specific dns-sd service types.
|
Command browse browses for specific dns-sd service types. |
debug
Command debug logs dns packets to the console.
|
Command debug logs dns packets to the console. |
dnssd
dnssd is a utilty to register and browser DNS-SD services.
|
dnssd is a utilty to register and browser DNS-SD services. |
register
Command register registers a dns-sd service instance.
|
Command register registers a dns-sd service instance. |
resolve
Command resolve resolves a dns-sd service instance.
|
Command resolve resolves a dns-sd service instance. |