Documentation
¶
Index ¶
Constants ¶
View Source
const ( // A is the DNS Type for ipv4 A = 1 // AAAA is the DNS Type for ipv6 AAAA = 28 // PTR is the DNS Type for domain name pointers PTR = 12 // SRV is the DNS Type for services SRV = 33 // IN is the Internet DNS Class IN = 1 )
View Source
const DefaultPort int = 5353
DefaultPort is the mDNS port required of the spec, though this library is port-agnostic.
Variables ¶
This section is empty.
Functions ¶
func IpToDnsRecordType ¶
IpToDnsRecordType returns either A or AAAA based on the type of ip.
Types ¶
type MDNS ¶
type MDNS interface { // EnableIPv4 enables listening on IPv4 network interfaces. EnableIPv4() // EnableIPv6 enables listening on IPv6 network interfaces. EnableIPv6() // SetAddress sets a non-default listen address. SetAddress(address string) error // SetMCastTTL sets the multicast time to live. If this is set to less // than zero it stays at the default. If it is set to zero this will mean // no packets can escape the host. // // Must be no greater than 255. SetMCastTTL(ttl int) error // AddHandler calls f on every Packet received. AddHandler(f func(net.Interface, net.Addr, Packet)) // AddWarningHandler calls f on every non-fatal error. AddWarningHandler(f func(net.Addr, error)) // AddErrorHandler calls f on every fatal error. After // all active handlers are called, m will stop listening and // close it's connection so this function will not be called twice. AddErrorHandler(f func(error)) // Start causes m to start listening for mDNS packets on all interfaces on // the specified port. Listening will stop if ctx is done. Start(ctx context.Context, port int) error // Send serializes and sends packet out as a multicast to all interfaces // using the port that m is listening on. Note that Start must be // called prior to making this call. Send(ctx context.Context, packet Packet) error // SendTo serializes and sends packet to dst. If dst is a multicast // address then packet is multicast to the corresponding group on // all interfaces. Note that start must be called prior to making this // call. SendTo(ctx context.Context, packet Packet, dst *net.UDPAddr) error // Close closes all connections. Close() }
MDNS is the central interface through which requests are sent and received. This implementation is agnostic to use case and asynchronous. To handle various responses add Handlers. To send a packet you may use either SendTo (generally used for unicast) or Send (generally used for multicast).
type Packet ¶
type Packet struct { Header Header Questions []Question Answers []Record Authority []Record Additional []Record }
func AnswerPacket ¶
AnswerPacket constructs and returns a packet that gives a response to the
func QuestionPacket ¶
QuestionPacket constructs and returns a packet that requests the ip address associated with domain.
Click to show internal directories.
Click to hide internal directories.