mdns

package
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: Aug 26, 2021 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ServicesQuery = "_services._dns-sd._udp"
	DefaultTTL    = 60 * 5 // In seconds (5 mins)
)
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) (*discovery, error)

func NewListener

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

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 Config

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

type Server

type Server struct {
	// 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) 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(ctx context.Context, services ...string) []Service

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) 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 Service

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

func NewService

func NewService(zone string) *Service

func (*Service) Addrs

func (this *Service) Addrs() []net.IP

func (*Service) Equals

func (this *Service) Equals(other *Service) bool

func (*Service) Host

func (this *Service) Host() string

func (*Service) Instance

func (this *Service) Instance() string

func (*Service) Name

func (this *Service) Name() string

func (*Service) Port

func (this *Service) Port() uint16

func (*Service) Service

func (this *Service) Service() string

func (*Service) SetA

func (this *Service) SetA(ip net.IP)

func (*Service) SetAAAA

func (this *Service) SetAAAA(ip net.IP)

func (*Service) SetPTR

func (this *Service) SetPTR(ptr *dns.PTR)

func (*Service) SetSRV

func (this *Service) SetSRV(host string, port uint16, priority uint16)

func (*Service) SetTXT

func (this *Service) SetTXT(txt []string)

func (*Service) String

func (this *Service) String() string

func (*Service) Txt

func (this *Service) Txt() []string

func (*Service) Zone

func (this *Service) Zone() string

Jump to

Keyboard shortcuts

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