webrtc_mdns_responder (webrtc v0.1.0)

View Source

Sans-IO multicast DNS responder for the <uuid>.local names of our own host candidates (draft-ietf-mmusic-mdns-ice-candidates §3.1).

Each registered address gets a random version 4 UUID name (draft-ietf-mmusic-mdns-ice-candidates-03 §3.1.1). As the draft recommends, a new name is announced (announcement/2, RFC 6762 §8.3) without probing. Queries are answered (RFC 6762 §6):

  • a query from a port other than the mDNS port is a legacy one-shot query: unicast reply to its source, ID and question repeated, TTL at most 10 seconds and no cache-flush bit (§6.7);
  • a QU question gets a unicast reply to its source (§5.4);
  • otherwise the reply is multicast to the group, at most once per second per name (§6);
  • a question whose answer the querier already lists with at least half its TTL left is not answered (known-answer suppression, §7.1).

A and AAAA (or ANY) questions for a name of the right family are answered with the address; a question for the other family gets an NSEC record saying the name has only the address it has (§6.1), so the querier does not wait for an answer that will not come.

Summary

Functions

Unsolicited response announcing a registered name, cache-flush bit set (RFC 6762 §8.3, §10.2).

Goodbye packets withdrawing every name (TTL 0, RFC 6762 §10.1).

A query received from Src on the group socket (mDNS port MdnsPort). Returns the replies to send.

Registered names and their addresses.

Options: max_names (default 16).

The name of IP, created on first use.

Types

dest/0

-type dest() :: group | {inet:ip_address(), inet:port_number()}.

responder/0

-opaque responder()

Functions

announcement(Name, Rs)

-spec announcement(binary(), responder()) -> binary().

Unsolicited response announcing a registered name, cache-flush bit set (RFC 6762 §8.3, §10.2).

goodbye(Rs)

-spec goodbye(responder()) -> [binary()].

Goodbye packets withdrawing every name (TTL 0, RFC 6762 §10.1).

handle_query(Src, MdnsPort, Bin, Now, Rs)

-spec handle_query({inet:ip_address(), inet:port_number()},
                   inet:port_number(),
                   binary(),
                   integer(),
                   responder()) ->
                      {responder(), [{dest(), binary()}]}.

A query received from Src on the group socket (mDNS port MdnsPort). Returns the replies to send.

names(Rs)

-spec names(responder()) -> #{binary() => inet:ip_address()}.

Registered names and their addresses.

new(Opts)

-spec new(map()) -> responder().

Options: max_names (default 16).

register(IP, Rs)

-spec register(inet:ip_address(), responder()) -> {ok, binary(), responder()} | {error, too_many_names}.

The name of IP, created on first use.