Documentation ¶
Overview ¶
Package `mdns` implements a multicast DNS client and server to be used to discover and register services over local networks
Index ¶
- Constants
- func NewWithPlugin(p Plugin, label string) (*mdns, error)
- type EventType
- type Message
- func MessageFromPacket(packet []byte, sender net.Addr, iface net.Interface) (Message, error)
- func NewBrowseQuestion(question string, iface net.Interface) (Message, error)
- func NewDiscoverQuestion(question string, iface net.Interface) (Message, error)
- func NewLookupQuestion(question string, iface net.Interface) (Message, error)
- type Plugin
- type Ptr
- type Registration
- type RespInstances
- type RespServices
- type Service
- type Services
- func (srv *Services) AddA(key string, r []net.IP)
- func (srv *Services) AddPTR(key, service string, ptr Ptr, ifindex int) bool
- func (srv *Services) AddSRV(key string, r []Srv)
- func (srv *Services) AddTXT(key string, txt []string)
- func (srv *Services) ExpireInstances() []*Service
- func (srv *Services) Expired(key string) bool
- func (srv *Services) GetInstances(services ...string) []*Service
- func (srv *Services) GetNames() []string
- func (srv *Services) NextBrowseName(ttl time.Duration) string
- func (srv *Services) NextLookupInstance() *Service
- func (srv *Services) Registered(name string, ttl time.Duration) bool
- type Srv
Constants ¶
const ( DefaultName = "mdns" // Name of the plugin DefaultLabel = "local" // Default domain label and zone )
const ( ScopeRead = "github.com/mutablelogic/go-server/mdns:read" ScopeWrite = "github.com/mutablelogic/go-server/mdns:write" )
Variables ¶
This section is empty.
Functions ¶
func NewWithPlugin ¶ added in v1.1.3
Create a new logger task with provider of other tasks
Types ¶
type Message ¶ added in v1.1.3
type Message interface { PTR() []Ptr // Return PTR records A() []net.IP // Return A and AAAA records TXT() (string, []string) // Return TXT records SRV() (string, []Srv) // Return SRV records Bytes() ([]byte, error) // Return the packed message IsAnswer() bool // Return true when the message is an answer IfIndex() int // Interface to send and receive on, or nil }
A sent or received message
func MessageFromPacket ¶ added in v1.1.3
Create a message from a received packet, with a sender and the interface that the message was received on
func NewBrowseQuestion ¶ added in v1.1.5
Create a message from a question, to be sent on a specific interface or on all interfaces if the index is zero
func NewDiscoverQuestion ¶ added in v1.1.5
Create a message from a question, to be sent on a specific interface or on all interfaces if the index is zero
type Plugin ¶ added in v1.1.3
type Registration ¶ added in v1.1.5
type RespInstances ¶ added in v1.1.5
type RespServices ¶ added in v1.1.5
type Service ¶ added in v1.0.46
type Service struct { Name string `json:"name,omitempty"` Service string `json:"service,omitempty"` Added time.Time `json:"added,omitempty"` Expires time.Time `json:"expires,omitempty"` A []net.IP `json:"a,omitempty"` SRV []Srv `json:"srv,omitempty"` TXT map[string]string `json:"txt,omitempty"` IfIndex int `json:"-"` }
type Services ¶ added in v1.1.5
Services stores the service names and registrations
func (*Services) AddPTR ¶ added in v1.1.5
AddPTR from service name to record, with a TTL, and return true if the service was registered rather than updated
func (*Services) ExpireInstances ¶ added in v1.1.5
Expire service instances and return them
func (*Services) Expired ¶ added in v1.1.5
Expire a service instance and return true if the service was deleted
func (*Services) GetInstances ¶ added in v1.1.5
Get the list of service instances which have not expired.
func (*Services) NextBrowseName ¶ added in v1.1.5
Returns a service name which should be browsed for instances. Will return an empty string if no service names are available, or if browsing has occurred within the ttl period.
func (*Services) NextLookupInstance ¶ added in v1.1.5
Returns an instance name which should be looked up. Will return an empty string if no instances are available