mirror of
https://github.com/livebook-dev/livebook.git
synced 2025-12-19 22:49:23 +08:00
Allow any address we might be listening on
This commit is contained in:
parent
c751fabf80
commit
8fe8d27d3d
1 changed files with 17 additions and 3 deletions
|
|
@ -88,9 +88,7 @@ defmodule Livebook.Application do
|
||||||
invalid_hostname!("your hostname \"#{hostname}\" does not resolve to an IP address")
|
invalid_hostname!("your hostname \"#{hostname}\" does not resolve to an IP address")
|
||||||
|
|
||||||
{:ok, hostent(h_addrtype: :inet, h_addr_list: addresses)} ->
|
{:ok, hostent(h_addrtype: :inet, h_addr_list: addresses)} ->
|
||||||
any_loopback? = Enum.any?(addresses, &match?({127, _, _, _}, &1))
|
unless any_loopback?(addresses) or any_if?(addresses) do
|
||||||
|
|
||||||
unless any_loopback? do
|
|
||||||
invalid_hostname!(
|
invalid_hostname!(
|
||||||
"your hostname \"#{hostname}\" does not resolve to a loopback address (127.0.0.0/8)"
|
"your hostname \"#{hostname}\" does not resolve to a loopback address (127.0.0.0/8)"
|
||||||
)
|
)
|
||||||
|
|
@ -102,6 +100,22 @@ defmodule Livebook.Application do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
defp any_loopback?(addresses) do
|
||||||
|
Enum.any?(addresses, &match?({127, _, _, _}, &1))
|
||||||
|
end
|
||||||
|
|
||||||
|
defp any_if?(addresses) do
|
||||||
|
case :inet.getifaddrs() do
|
||||||
|
{:ok, addrs} ->
|
||||||
|
Enum.any?(addrs, fn {_name, flags} ->
|
||||||
|
Enum.any?(flags, fn {key, value} -> key == :addr and value in addresses end)
|
||||||
|
end)
|
||||||
|
|
||||||
|
_ ->
|
||||||
|
false
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
defp invalid_hostname!(prelude) do
|
defp invalid_hostname!(prelude) do
|
||||||
Livebook.Config.abort!("""
|
Livebook.Config.abort!("""
|
||||||
#{prelude}, which indicates something wrong in your OS configuration.
|
#{prelude}, which indicates something wrong in your OS configuration.
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue