mdns

package
v1.0.14 Latest Latest
Warning

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

Go to latest
Published: Sep 28, 2021 License: Apache-2.0 Imports: 23 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ServicesQuery = "_services._dns-sd._udp"
	DefaultTTL    = 60 * 5 // In seconds (5 mins)

)
View Source
const (
	DefaultServiceDatabase = "https://www.iana.org/assignments/service-names-port-numbers/service-names-port-numbers.xml"
)
View Source
const (
	EOF rune = -(iota + 1)
)

Variables

View Source
var (
	MULTICAST_ADDR_IPV4 = &net.UDPAddr{IP: net.ParseIP("224.0.0.251"), Port: 5353}
	MULTICAST_ADDR_IPV6 = &net.UDPAddr{IP: net.ParseIP("ff02::fb"), Port: 5353}
)
View Source
var (
	ErrParseError = errors.New("Parse Error")
)

Functions

func NewDiscovery

func NewDiscovery(c <-chan message, e chan<- event) (*discovery, error)

func NewListener

func NewListener(domain, iface string, c chan<- message) (*listener, error)

func NewService

func NewService(zone string) *service

func NewServiceDatabase added in v1.0.7

func NewServiceDatabase() *servicedb

func NewTokenizer

func NewTokenizer(src string) *tokenizer

func Quote

func Quote(src string) string

func ReadServiceDatabase added in v1.0.7

func ReadServiceDatabase(v string) (*servicedb, error)

func Unquote

func Unquote(src string) (string, error)

Unquote returns a bare string without quoted characters. The following Coversions happen: \\ \n \f \t \r Happen as normal \xFF returns a byte from hex \123 returns a byte from decimal \0123 returns a bype from octal

Types

type Config

type Config struct {
	Interface       string   `yaml:"interface"`
	Domain          string   `yaml:"domain"`
	TTL             int      `yaml:"ttl"`
	ServiceDatabase []string `yaml:"services"`
}

type EventType added in v1.0.7

type EventType int
const (
	EVENT_TYPE_ADDED EventType = (1 << iota)
	EVENT_TYPE_REMOVED
	EVENT_TYPE_EXPIRED
	EVENT_TYPE_CHANGED
	EVENT_TYPE_SERVICE
	EVENT_TYPE_NONE EventType = 0
	EVENT_TYPE_MIN            = EVENT_TYPE_ADDED
	EVENT_TYPE_MAX            = EVENT_TYPE_SERVICE
)

func (EventType) FlagString added in v1.0.7

func (v EventType) FlagString() string

func (EventType) String added in v1.0.7

func (f EventType) String() string

type Server

type Server struct {
	C chan Event // Channel for emitting events
	// contains filtered or unexported fields
}

func New

func New(cfg Config) (*Server, error)

func (Server) Changed

func (this Server) Changed(v *service) bool

Check if service has changed, returns false if service does not yet exist

func (Server) Delete

func (this Server) Delete(v *service)

Delete a service

func (*Server) EnumerateInstances added in v1.0.7

func (this *Server) EnumerateInstances(ctx context.Context, services ...string) ([]Service, error)

func (*Server) EnumerateServices added in v1.0.7

func (this *Server) EnumerateServices(ctx context.Context) ([]string, error)

func (Server) Exists

func (this Server) Exists(v *service) *service

Check if service already exists

func (Server) Get

func (this Server) Get(name string) *service

Get returns a service by name, or nil if service not found

func (Server) Instances

func (this Server) Instances() []*service

Instances returns service instances

func (Server) Lookup added in v1.0.7

func (this Server) Lookup(service string) ServiceDescription

Lookup a record

func (*Server) LookupServiceDescription added in v1.0.7

func (this *Server) LookupServiceDescription(v string) ServiceDescription

Return a service description for the given service name

func (Server) Query

func (this Server) Query(ctx context.Context, msg *dns.Msg, iface int) error

Query by sending multiple messages to interfaces

func (Server) Read added in v1.0.7

func (this Server) Read(v string) error

Read records into database

func (*Server) Run

func (this *Server) Run(ctx context.Context) error

func (Server) Send

func (this Server) Send(msg *dns.Msg, ifIndex int) error

Send a single DNS message to a particular interface or all interfaces if 0

func (Server) Set

func (this Server) Set(v *service)

Set a service and update expiration

func (*Server) String

func (this *Server) String() string

type ServiceDescription added in v1.0.7

type ServiceDescription interface {
	Name() string
	Service() string
	Protocol() string
	Description() string
	Note() string
}

type ServiceEvent added in v1.0.7

type ServiceEvent interface {
	Event
	Type() EventType
	Service() Service
}

Jump to

Keyboard shortcuts

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