MdnsLite.Options (mdns_lite v0.8.0) View Source

MdnsLite options

MdnsLite is usually configured in a project's application environment (config.exs) as follows:

config :mdns_lite,
  hosts: [:hostname, "nerves"],
  ttl: 120,

  services: [
    %{
      id: :web_server,
      protocol: "http",
      transport: "tcp",
      port: 80,
      txt_payload: ["key=value"]
    },
    %{
      id: :ssh_daemon,
      protocol: "ssh",
      transport: "tcp",
      port: 22
    }
  ]

The configurable keys are:

  • :hosts - A list of hostnames to respond to. Normally this would be set to :hostname and mdns_lite will advertise the actual hostname with .local appended.
  • :ttl - The default mDNS record time-to-live. The default of 120 seconds is probably fine for most use. See RFC 6762 - Multicast DNS for considerations.
  • :excluded_ifnames - A list of network interfaces names to ignore. By default, mdns_lite will ignore loopback and cellular network interfaces.
  • :ipv4_only - Set to true to only respond on IPv4 interfaces. Since IPv6 isn't fully supported yet, this is the default. Note that it's still possible to get AAAA records when using IPv4.
  • :if_monitor - Set to MdnsLite.VintageNetMonitor when using Nerves or MdnsLite.InetMonitor elsewhere. The default is MdnsLite.VintageNetMonitor.
  • :dns_bridge_enabled - Set to true to start a DNS server running that will bridge DNS to mDNS.
  • :dns_bridge_ip - The IP address for the DNS server. Defaults to 127.0.0.53.
  • :dns_bridge_port - The UDP port for the DNS server. Defaults to 53.
  • :dns_bridge_recursive - If a regular DNS request comes on the DNS bridge, forward it to a DNS server rather than returning an error. This is the default since there's an issue on Linux and Nerves that prevents Erlang's DNS resolver from checking the next one.
  • :services - A list of services to advertise. See MdnsLite.service for details.

Some options are modifiable at runtime. Functions for modifying these are in the MdnsLite module.

Link to this section Summary

Functions

Normalize a service description

Link to this section Functions

Link to this function

normalize_service(service)

View Source

Specs

normalize_service(MdnsLite.service()) ::
  {:ok, MdnsLite.service()} | {:error, String.t()}

Normalize a service description

All service descriptions are normalized before use. Call this function if you're unsure how the service description will be transformed for use.