mdns

package
v0.0.0-...-c3ad350 Latest Latest
Warning

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

Go to latest
Published: Jul 13, 2024 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const ClassCacheFlush = 0x8001

ClassCacheFlush https://datatracker.ietf.org/doc/html/rfc6762#section-10.2

View Source
const ServiceHAP = "_hap._tcp.local." // HomeKit Accessory Protocol

Variables

View Source
var MulticastAddr = &net.UDPAddr{
	IP:   net.IP{224, 0, 0, 251},
	Port: 5353,
}

Functions

func BasicDiscovery

func BasicDiscovery(service string, onentry func(*ServiceEntry) bool) error

BasicDiscovery - default golang Multicast UDP listener. Does not work well with multiple interfaces.

func Discovery

func Discovery(service string, onentry func(*ServiceEntry) bool) error

Discovery - better discovery version. Works well with multiple interfaces.

func GetPTR

func GetPTR(msg *dns.Msg, service string) string

func HasQuestionPTP

func HasQuestionPTP(msg *dns.Msg, name string) bool

func InterfacesIP4

func InterfacesIP4() ([]net.IP, error)

func MatchLocalIP

func MatchLocalIP(remote net.IP) net.IP

func NewDNSAnswer

func NewDNSAnswer(entries []*ServiceEntry, service string, ip net.IP) *dns.Msg

func QueryOrDiscovery

func QueryOrDiscovery(host, service string, onentry func(*ServiceEntry) bool) error

QueryOrDiscovery - useful if we know previous device host and want to update port or any other information. Will work even over VPN.

func Serve

func Serve(service string, entries []*ServiceEntry) error

func SetsockoptIPMreq

func SetsockoptIPMreq(fd uintptr, level, opt int, mreq *syscall.IPMreq) (err error)

func SetsockoptInt

func SetsockoptInt(fd uintptr, level, opt int, value int) (err error)

Types

type Browser

type Browser struct {
	Service string

	Addr  net.Addr
	Recv  net.PacketConn
	Sends []net.PacketConn

	RecvTimeout time.Duration
	SendTimeout time.Duration
}

func (*Browser) Browse

func (b *Browser) Browse(onentry func(*ServiceEntry) bool) error

func (*Browser) Close

func (b *Browser) Close() error

func (*Browser) ListenMulticastUDP

func (b *Browser) ListenMulticastUDP() error

ListenMulticastUDP - creates multiple senders socket (each for IP4 interface). And one receiver with multicast membership for each sender. Receiver will get multicast responses on senders requests.

func (*Browser) Serve

func (b *Browser) Serve(entries []*ServiceEntry) error

type ServiceEntry

type ServiceEntry struct {
	Name string            `json:"name,omitempty"`
	IP   net.IP            `json:"ip,omitempty"`
	Port uint16            `json:"port,omitempty"`
	Info map[string]string `json:"info,omitempty"`
}

func NewServiceEntries

func NewServiceEntries(msg *dns.Msg, ip net.IP) (entries []*ServiceEntry)

func Query

func Query(host, service string) (entry *ServiceEntry, err error)

Query - direct Discovery request on device IP-address. Works even over VPN.

func (*ServiceEntry) Addr

func (e *ServiceEntry) Addr() string

func (*ServiceEntry) Complete

func (e *ServiceEntry) Complete() bool

func (*ServiceEntry) Host

func (e *ServiceEntry) Host(service string) string

func (*ServiceEntry) String

func (e *ServiceEntry) String() string

func (*ServiceEntry) TXT

func (e *ServiceEntry) TXT() []string

Jump to

Keyboard shortcuts

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