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
- func EligibleInterfacesToBind() []*net.Interface
- func InterfaceToBind() *net.Interface
- func IsInterfaceEligible(bIntf *net.Interface) bool
- func Register(instance, service, domain string, port int, text []string, ...) (chan<- bool, error)
- func RegisterProxy(instance, service, domain string, port int, host, ip string, text []string, ...) (chan<- bool, error)
- type Bonjour
- type BonjourNotify
- type LookupParams
- type Resolver
- type ServiceEntry
- type ServiceRecord
Constants ¶
const ( ECHO_REPLY = iota NO_REPLY ERROR )
Variables ¶
This section is empty.
Functions ¶
func EligibleInterfacesToBind ¶ added in v0.1.2
func InterfaceToBind ¶ added in v0.1.2
func IsInterfaceEligible ¶ added in v0.1.2
Types ¶
type Bonjour ¶ added in v0.1.2
type BonjourNotify ¶ added in v0.1.2
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 ¶
func NewResolver(iface *net.Interface, serviceChan chan<- *ServiceEntry) (*Resolver, error)
Resolver structure constructor
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.
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
Godeps
|
|
_workspace/src/github.com/miekg/dns
Package dns implements a full featured interface to the Domain Name System.
|
Package dns implements a full featured interface to the Domain Name System. |
_workspace/src/github.com/miekg/dns/idn
Package idn implements encoding from and to punycode as speficied by RFC 3492.
|
Package idn implements encoding from and to punycode as speficied by RFC 3492. |
_workspace/src/github.com/socketplane/go-fastping
Package fastping is an ICMP ping library inspired by AnyEvent::FastPing Perl module to send ICMP ECHO REQUEST packets quickly.
|
Package fastping is an ICMP ping library inspired by AnyEvent::FastPing Perl module to send ICMP ECHO REQUEST packets quickly. |
_workspace/src/golang.org/x/net/internal/iana
Package iana provides protocol number resources managed by the Internet Assigned Numbers Authority (IANA).
|
Package iana provides protocol number resources managed by the Internet Assigned Numbers Authority (IANA). |
_workspace/src/golang.org/x/net/ipv4
Package ipv4 implements IP-level socket options for the Internet Protocol version 4.
|
Package ipv4 implements IP-level socket options for the Internet Protocol version 4. |
_workspace/src/golang.org/x/net/ipv6
Package ipv6 implements IP-level socket options for the Internet Protocol version 6.
|
Package ipv6 implements IP-level socket options for the Internet Protocol version 6. |