From eaa4856972a6d9a4ae83f0887bc50d118b9e34f5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Valim?= Date: Tue, 31 Jan 2023 09:33:29 +0100 Subject: [PATCH] Support finding epmd wit ipv6 --- lib/livebook/application.ex | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/lib/livebook/application.ex b/lib/livebook/application.ex index 08fb13049..bea534bd7 100644 --- a/lib/livebook/application.ex +++ b/lib/livebook/application.ex @@ -124,7 +124,15 @@ defmodule Livebook.Application do unless Livebook.Config.longname() do [nodename, hostname] = node() |> Atom.to_charlist() |> :string.split(~c"@") - with {:ok, nodenames} <- :erl_epmd.names(hostname), + # erl_epmd names do not support ipv6 resolution by default, + # unless inet6 is configured, so we attempt both. + gethostbyname = + with {:error, _} <- :inet.gethostbyname(hostname, :inet, :infinity), + {:error, _} <- :inet.gethostbyname(hostname, :inet6, :infinity), + do: :error + + with {:ok, hostent(h_addr_list: [epmd_addr | _])} <- gethostbyname, + {:ok, nodenames} <- :erl_epmd.names(epmd_addr), true <- List.keymember?(nodenames, nodename, 0) do :ok else