Documentation ¶
Overview ¶
bonjour
This is a simple Multicast DNS-SD (Apple Bonjour) library written in Golang. You can use it to discover services in the LAN. Pay attention to the infrastructure you are planning to use it (clouds or shared infrastructures usually prevent mDNS from functioning). But it should work in the most office, home and private environments.
**IMPORTANT**: It does NOT pretend to be a full & valid implementation of the RFC 6762 & RFC 6763, but it fulfils the requirements of its authors (we just needed service discovery in the LAN environment for our IoT products). The registration code needs a lot of improvements. This code was not tested for Bonjour conformance but have been manually verified to be working using built-in OSX utility `/usr/bin/dns-sd`.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type LookupParams ¶
type LookupParams struct { ServiceRecord Entries chan<- *ServiceEntry // Entries Channel }
LookupParams contains configurable properties to create a service discovery request
func NewLookupParams ¶
func NewLookupParams(instance, service, domain string, entries chan<- *ServiceEntry) *LookupParams
Constructs a LookupParams structure by given arguments
type Resolver ¶
type Resolver struct { Exit chan<- bool // contains filtered or unexported fields }
Main client data structure to run browse/lookup queries
func NewResolver ¶
Resolver structure constructor
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
Server structure encapsulates both IPv4/IPv6 UDP connections
func Register ¶
func Register(instance, service, domain string, port int, text []string, iface *net.Interface, ttl uint32) (*Server, error)
Register a service by given arguments. This call will take the system's hostname and lookup IP by that hostname. If ttl is 0 the default will be used.
func RegisterProxy ¶
func RegisterProxy(instance, service, domain string, port int, host string, ips []string, text []string, iface *net.Interface, ttl uint32) (*Server, error)
Register a service proxy by given argument. This call will skip the hostname/IP lookup and will use the provided values. If ttl is 0 the default will be used.
type ServiceEntry ¶
type ServiceEntry struct { ServiceRecord HostName string `json:"hostname"` // Host machine DNS name Port int `json:"port"` // Service Port Text []string `json:"text"` // Service info served as a TXT record TTL uint32 `json:"ttl"` // TTL of the service record AddrIPv4 []net.IP `json:"-"` // Host machine IPv4 address AddrIPv6 []net.IP `json:"-"` // Host machine IPv6 address }
ServiceEntry represents a browse/lookup result for client API. It is also used to configure service registration (server API), which is used to answer multicast queries.
func NewServiceEntry ¶
func NewServiceEntry(instance, service, domain string) *ServiceEntry
Constructs a ServiceEntry structure by given arguments
type ServiceRecord ¶
type ServiceRecord struct { Instance string `json:"name"` // Instance name (e.g. "My web page") Service string `json:"type"` // Service name (e.g. _http._tcp.) Domain string `json:"domain"` // If blank, assumes "local" // contains filtered or unexported fields }
ServiceRecord contains the basic description of a service, which contains instance name, service type & domain
func NewServiceRecord ¶
func NewServiceRecord(instance, service, domain string) *ServiceRecord
Constructs a ServiceRecord structure by given arguments
func (*ServiceRecord) ServiceInstanceName ¶
func (s *ServiceRecord) ServiceInstanceName() string
Returns complete service instance name (e.g. MyDemo\ Service._foobar._tcp.local.), which is composed from service instance name, service name and a domain.
func (*ServiceRecord) ServiceName ¶
func (s *ServiceRecord) ServiceName() string
Returns complete service name (e.g. _foobar._tcp.local.), which is composed from a service name (also referred as service type) and a domain.
func (*ServiceRecord) ServiceTypeName ¶
func (s *ServiceRecord) ServiceTypeName() string