mdns_lite icon indicating copy to clipboard operation
mdns_lite copied to clipboard

Add a way to get state and status

Open fhunleth opened this issue 5 years ago • 3 comments

It would be nice to be able to query mdns_lite to see what the host has been set to and what services are being advertised.

The situation that I'm running into is that mDNS isn't working. In theory, it should have been set at runtime by nerves_pack, but I can't check.

fhunleth avatar Dec 18 '19 17:12 fhunleth

Here's how I'm getting state (Thanks to @jjcarstens for this):

iex(4)> Supervisor.which_children(MdnsLite.ResponderSupervisor) |> Enum.map(&elem(&1, 1)) |> Enum.map(&:sys.get_state/1)
[
  %MdnsLite.Responder.State{
    dot_alias_name: 'nerves.local',
    dot_local_name: 'nerves-b53c.local',
    instance_name: "nerves-b53c",
    ip: {192, 168, 9, 247},
    services: [
      %{
        name: "Erlang Port Mapper Daemon",
        port: 4369,
        priority: 0,
        protocol: "epmd",
        transport: "tcp",
        type: "_epmd._tcp",
        weight: 0
      },
      %{
        name: "SSH Remote Login Protocol",
        port: 22,
        priority: 0,
        protocol: "ssh",
        transport: "tcp",
        type: "_ssh._tcp",
        weight: 0
      },
      %{
        name: "Secure File Transfer Protocol over SSH",
        port: 22,
        priority: 0,
        protocol: "sftp-ssh",
        transport: "tcp",
        type: "_sftp-ssh._tcp",
        weight: 0
      }
    ],
    skip_udp: nil,
    ttl: 120,
    udp: #Port<0.61>
  }
]

It turns out that neither mdns_lite nor nerves_pack were at fault, but I still think it would be nice to have functions for getting state in the main API.

fhunleth avatar Dec 18 '19 17:12 fhunleth

This should be pretty easy. I should be able to get to it later today, if that's OK time-wise. I'm glad that mdns_lite was not at fault.

pcmarks avatar Dec 18 '19 17:12 pcmarks

Thanks! I’m in no rush.

fhunleth avatar Dec 18 '19 17:12 fhunleth