mdns

package
v2.0.30 Latest Latest
Warning

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

Go to latest
Published: Apr 27, 2020 License: BSD-2-Clause Imports: 21 Imported by: 9

Documentation

Index

Constants

View Source
const (
	DISCOVERY_SERVICE_QUERY = "_services._dns-sd._udp"
	MDNS_DEFAULT_DOMAIN     = "local."
	MDNS_DEFAULT_TTL        = 120
	DISCOVERY_LOOKUP_DELTA  = 5 * time.Second

	QUERY_REPEAT   = 2   // Number of times to repeat a message
	DELTA_QUERY_MS = 500 // Maximum time to wait between repeats

	// Pulisher queue numbers
	QUEUE_MESSAGES = 0
	QUEUE_ERRORS   = 1
	QUEUE_NAME     = 2
	QUEUE_RECORD   = 3
)
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 NewEvent

func NewEvent(source gopi.Unit, type_ gopi.RPCEventType, service gopi.RPCServiceRecord, ttl time.Duration) gopi.RPCEvent

func NewService

func NewService(zone string) *service

func NewTokenizer

func NewTokenizer(src string) *tokenizer

func Quote

func Quote(src string) string

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 Database added in v2.0.19

type Database struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

Database represents the current state of mDNS, service names and records

func (*Database) Close added in v2.0.19

func (this *Database) Close()

func (*Database) DeleteName added in v2.0.19

func (this *Database) DeleteName(name string) bool

DeleteName and return true if the name previously existed

func (*Database) DeleteRecord added in v2.0.19

func (this *Database) DeleteRecord(key string) bool

DeleteRecord and return true if the name previously existed

func (*Database) ExistsName added in v2.0.19

func (this *Database) ExistsName(name string) bool

ExistsName returns true if name exists and isn't expired

func (*Database) Init added in v2.0.19

func (this *Database) Init()

func (*Database) Names added in v2.0.19

func (this *Database) Names() []string

Return all unexpired names

func (*Database) Records added in v2.0.19

func (this *Database) Records(srv string) []gopi.RPCServiceRecord

Return all unexpired records that match a service

func (*Database) RegisterName added in v2.0.19

func (this *Database) RegisterName(r *event) gopi.RPCEvent

func (*Database) RegisterRecord added in v2.0.19

func (this *Database) RegisterRecord(r *event) gopi.RPCEvent

func (*Database) SetName added in v2.0.19

func (this *Database) SetName(name string, expires time.Time) bool

SetName and return true if the name previously existed

func (*Database) SetRecord added in v2.0.19

func (this *Database) SetRecord(key string, srv gopi.RPCServiceRecord, expires time.Time) (bool, bool)

SetRecord and return true if the record previously existed

type Discovery

type Discovery struct {
	Listener ListenerIface
}

func (Discovery) Name

func (Discovery) Name() string

func (Discovery) New

func (config Discovery) New(log gopi.Logger) (gopi.Unit, error)

type Listener

type Listener struct {
	Domain    string
	Interface net.Interface
	Flags     gopi.RPCFlag
}

func (Listener) FQDomain

func (config Listener) FQDomain() string

func (Listener) Name

func (Listener) Name() string

func (Listener) New

func (config Listener) New(log gopi.Logger) (gopi.Unit, error)

type ListenerIface

type ListenerIface interface {
	// Return properties
	Zone() string

	// Perform queries
	QueryAll(ctx context.Context, msg *dns.Msg, count uint) error

	// Send responses
	SendAll(msg *dns.Msg) error

	// Implements pub/sub interface
	gopi.Publisher
}

type Record added in v2.0.19

type Record struct {
	// contains filtered or unexported fields
}

type Register

type Register struct {
	Listener ListenerIface
}

func (Register) Name

func (Register) Name() string

func (Register) New

func (config Register) New(log gopi.Logger) (gopi.Unit, error)

type ServiceDB added in v2.0.16

type ServiceDB struct {
	Listener ListenerIface
	Bus      gopi.Bus
}

func (ServiceDB) Name added in v2.0.16

func (ServiceDB) Name() string

func (ServiceDB) New added in v2.0.16

func (config ServiceDB) New(log gopi.Logger) (gopi.Unit, error)

Jump to

Keyboard shortcuts

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