mdns

package
v0.0.0-...-c2017eb Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 12, 2024 License: Apache-2.0 Imports: 7 Imported by: 4

Documentation

Index

Constants

View Source
const (
	// A list of domains recommended for browsing.
	RecommendedBrowsingService = "b._dns-sd._udp"
	// A single recommended default domain for browsing.
	DefaultBrowsingService = "db._dns-sd._udp"
	// A list of domains recommended for registering services using Dynamic Update.
	RecommendedRegisteringService = "r._dns-sd._udp"
	// A single recommended default domain for registering services.
	DefaultRegisteringService = "dr._dns-sd._udp"
	// The "legacy browsing" or "automatic browsing" domain(s).
	AutomaticBrowsingService = "lb._dns-sd._udp"
)

RFC 6765: 11. Discovery of Browsing and Registration Domains (Domain Enumeration).

View Source
const (
	DefaultDomain = "local"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	sync.Mutex
	*transport.MessageManager
	// contains filtered or unexported fields
}

Client represents a client node instance.

func NewClient

func NewClient() *Client

NewClient returns a new client instance.

func (Client) AddService

func (services Client) AddService(service *Service) bool

AddService adds the specified service into th service array.

func (Client) HasService

func (services Client) HasService(targetService *Service) bool

func (*Client) MessageReceived

func (client *Client) MessageReceived(msg *dns.Message) (*dns.Message, error)

func (*Client) Query

func (client *Client) Query(q []*Query) error

Query sends a question message to the multicast address.

func (*Client) Restart

func (client *Client) Restart() error

Restart restarts the client instance.

func (Client) Services

func (services Client) Services() []*Service

Services returns the sercice array.

func (*Client) SetListener

func (client *Client) SetListener(l MessageListener)

Set sets a message listner to listen raw protocol messages.

func (*Client) Start

func (client *Client) Start() error

Start starts the client instance.

func (*Client) Stop

func (client *Client) Stop() error

Stop stops the client instance.

type Message

type Message = dns.Message

Message represents a protocol message.

func NewRequestWithQueries

func NewRequestWithQueries(queries []*Query) *Message

NewRequestWithQueries returns a new request message with the specified queries.

func NewRequestWithQuery

func NewRequestWithQuery(query *Query) *Message

NewMessage returns a nil message instance.

type MessageListener

type MessageListener interface {
	MessageReceived(*Message)
}

MessageListener represents a protocol message listiner interface.

type Query

type Query struct {
	Service string
	Domain  string
}

Query represents a question query.

func NewQueryWithService

func NewQueryWithService(service string) *Query

NewQueryWithService returns a new query instance with the specified service name.

func NewQueryWithServices

func NewQueryWithServices(services []string) []*Query

NewQueryWithServices returns a new query instance array with the specified service names.

func (*Query) String

func (q *Query) String() string

String returns the string representation.

type Server

type Server struct {
	*transport.MessageManager
	// contains filtered or unexported fields
}

Server represents a server node instance.

func NewServer

func NewServer() *Server

NewServer returns a new server instance.

func (Server) AddService

func (services Server) AddService(service *Service) bool

AddService adds the specified service into th service array.

func (Server) HasService

func (services Server) HasService(targetService *Service) bool

func (*Server) MessageReceived

func (server *Server) MessageReceived(msg *dns.Message) (*dns.Message, error)

func (*Server) Restart

func (server *Server) Restart() error

Restart restarts the server instance.

func (Server) Services

func (services Server) Services() []*Service

Services returns the sercice array.

func (*Server) SetListener

func (server *Server) SetListener(l MessageListener)

Set sets a message listner to listen raw protocol messages.

func (*Server) Start

func (server *Server) Start() error

Start starts the server instance.

func (*Server) Stop

func (server *Server) Stop() error

Stop stops the server instance.

type Service

type Service struct {
	*Message

	dns.Attributes
	// contains filtered or unexported fields
}

Service represents a SRV record.

func NewService

func NewService(name, domain string, port uint) *Service

NewService returns a new service instance.

func NewServiceWithMessage

func NewServiceWithMessage(msg *Message) (*Service, error)

NewServiceWithMessage returns a new service instance.

func (*Service) Addresses

func (srv *Service) Addresses() []net.IP

Addresses returns the service addresses.

func (*Service) Domain

func (srv *Service) Domain() string

Domain returns the service domain.

func (*Service) Equal

func (srv *Service) Equal(other *Service) bool

Equal returns true if the header is same as the specified header, otherwise false.

func (*Service) Host

func (srv *Service) Host() string

Host returns the service host.

func (*Service) Name

func (srv *Service) Name() string

Name returns the service name.

func (*Service) Port

func (srv *Service) Port() int

Port returns the service port.

func (*Service) String

func (srv *Service) String() string

String returns the string representation.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL