Documentation ¶
Index ¶
- Constants
- Variables
- func SendMulticastResponse(in *InboundPacket, m *dns.Msg) (bool, error)
- func SendResponse(in *InboundPacket, to *net.UDPAddr, m *dns.Msg) (bool, error)
- func SendUnicastResponse(in *InboundPacket, m *dns.Msg) (bool, error)
- type Endpoint
- type IPv4Transport
- type IPv6Transport
- type InboundPacket
- type OutboundPacket
- type Transport
Constants ¶
const Port = 5353
Port is the mDNS port number.
Variables ¶
var ( // IPv4Group is the multicast group used for mDNS over IPv4. // // See https://tools.ietf.org/html/rfc6762#section-3. IPv4Group = net.ParseIP("224.0.0.251") // IPv4GroupAddress is the address to which mDNS queries are sent when using IPv4. // // See https://tools.ietf.org/html/rfc6762#section-3. IPv4GroupAddress = &net.UDPAddr{IP: IPv4Group, Port: Port} // IPv4ListenAddress is the address to which the mDNS server binds when using // IPv4. Note that the multicast group address is NOT used in order to control // more precisely which network interfaces join the multicast group. IPv4ListenAddress = &net.UDPAddr{IP: net.ParseIP("224.0.0.0"), Port: Port} )
var ( // IPv6Group is the multicast group used for mDNS over IPv6. // // See https://tools.ietf.org/html/rfc6762#section-3. IPv6Group = net.ParseIP("ff02::fb") // IPv6GroupAddress is the address to which mDNS queries are sent when using IPv6. // // See https://tools.ietf.org/html/rfc6762#section-3. IPv6GroupAddress = &net.UDPAddr{IP: IPv6Group, Port: Port} // IPv6ListenAddress is the address to which the mDNS server binds when using // IPv6. Note that the multicast group address is NOT used in order to control // more precisely which network interfaces join the multicast group. IPv6ListenAddress = &net.UDPAddr{IP: net.ParseIP("ff02::"), Port: Port} )
Functions ¶
func SendMulticastResponse ¶
func SendMulticastResponse(in *InboundPacket, m *dns.Msg) (bool, error)
SendMulticastResponse sends a DNS message as a multicast response to an inbound packet.
func SendResponse ¶
SendResponse sends a DNS message as a response to an inbound packet.
func SendUnicastResponse ¶
func SendUnicastResponse(in *InboundPacket, m *dns.Msg) (bool, error)
SendUnicastResponse sends a DNS message as a unicast response to an inbound packet.
Types ¶
type Endpoint ¶
Endpoint is the origin or destination of a packet.
type IPv4Transport ¶
IPv4Transport is an IPv4-based UDP transport.
func (*IPv4Transport) Close ¶
func (t *IPv4Transport) Close() error
Close closes the transport, preventing further reads and writes.
func (*IPv4Transport) Group ¶
func (t *IPv4Transport) Group() *net.UDPAddr
Group returns the multicast group address for this transport.
func (*IPv4Transport) Listen ¶
func (t *IPv4Transport) Listen(iface *net.Interface) error
Listen starts listening for UDP packets on the given interfaces.
func (*IPv4Transport) Read ¶
func (t *IPv4Transport) Read() (*InboundPacket, error)
Read reads the next packet from the transport.
func (*IPv4Transport) Write ¶
func (t *IPv4Transport) Write(p *OutboundPacket) error
Write sends a packet via the transport.
type IPv6Transport ¶
IPv6Transport is an IPv6-based UDP transport.
func (*IPv6Transport) Close ¶
func (t *IPv6Transport) Close() error
Close closes the transport, preventing further reads and writes.
func (*IPv6Transport) Group ¶
func (t *IPv6Transport) Group() *net.UDPAddr
Group returns the multicast group address for this transport.
func (*IPv6Transport) Listen ¶
func (t *IPv6Transport) Listen(iface *net.Interface) error
Listen starts listening for UDP packets on the given interfaces.
func (*IPv6Transport) Read ¶
func (t *IPv6Transport) Read() (*InboundPacket, error)
Read reads the next packet from the transport.
func (*IPv6Transport) Write ¶
func (t *IPv6Transport) Write(p *OutboundPacket) error
Write sends a packet via the transport.
type InboundPacket ¶
InboundPacket is a UDP packet received from a transport.
func (*InboundPacket) Close ¶
func (p *InboundPacket) Close()
Close returns the packet's data buffer to the pool.
type OutboundPacket ¶
OutboundPacket is a UDP packet to be sent by a transport.
func NewOutboundPacket ¶
func NewOutboundPacket(dest Endpoint, m *dns.Msg) (*OutboundPacket, error)
NewOutboundPacket marshals the message m into p.Data.
func (*OutboundPacket) Close ¶
func (p *OutboundPacket) Close()
Close returns the packet's data buffer to the pool.
type Transport ¶
type Transport interface { // Listen starts listening for UDP packets on the given interface. Listen(iface *net.Interface) error // Read reads the next packet from the transport. Read() (*InboundPacket, error) // Write sends a packet via the transport. Write(*OutboundPacket) error // Group returns the multicast group address for this transport. Group() *net.UDPAddr // Close closes the transport, preventing further reads and writes. Close() error }
Transport is an interface for communicating via UDP.