CLI: mix format
This commit is contained in:
parent
226a7603e8
commit
9d69a4b325
|
|
@ -74,8 +74,10 @@ defmodule RabbitMQ.CLI.Diagnostics.Commands.CheckPortConnectivityCommand do
|
|||
|> Enum.sort()
|
||||
|> Enum.join(", ")
|
||||
|
||||
{:ok, "Successfully connected to ports #{ports} on node #{node_name} (using node hostname resolution)"}
|
||||
{:ok,
|
||||
"Successfully connected to ports #{ports} on node #{node_name} (using node hostname resolution)"}
|
||||
end
|
||||
|
||||
def output({true, listeners}, %{node: node_name, address: target_ip}) do
|
||||
ports =
|
||||
listeners
|
||||
|
|
@ -84,7 +86,8 @@ defmodule RabbitMQ.CLI.Diagnostics.Commands.CheckPortConnectivityCommand do
|
|||
|> Enum.sort()
|
||||
|> Enum.join(", ")
|
||||
|
||||
{:ok, "Successfully connected to ports #{ports} on node #{node_name} (using #{target_ip} for target IP address)"}
|
||||
{:ok,
|
||||
"Successfully connected to ports #{ports} on node #{node_name} (using #{target_ip} for target IP address)"}
|
||||
end
|
||||
|
||||
def output({false, failures}, %{formatter: "json", node: node_name}) do
|
||||
|
|
@ -110,6 +113,7 @@ defmodule RabbitMQ.CLI.Diagnostics.Commands.CheckPortConnectivityCommand do
|
|||
def banner([], %{node: node_name, address: nil}) do
|
||||
"Testing TCP connections to all active listeners on node #{node_name} using hostname resolution ..."
|
||||
end
|
||||
|
||||
def banner([], %{node: node_name, address: target_ip}) do
|
||||
"Testing TCP connections to all active listeners on node #{node_name} using #{target_ip} for node IP address ..."
|
||||
end
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@
|
|||
defmodule RabbitMQ.CLI.Diagnostics.Helpers do
|
||||
def test_connection(hostname_or_ip, port, timeout) do
|
||||
hostname_as_list = :rabbit_data_coercion.to_list(hostname_or_ip)
|
||||
|
||||
case :gen_tcp.connect(hostname_as_list, port, [], timeout) do
|
||||
{:error, _} -> :gen_tcp.connect(hostname_as_list, port, [:inet6], timeout)
|
||||
r -> r
|
||||
|
|
@ -17,16 +18,17 @@ defmodule RabbitMQ.CLI.Diagnostics.Helpers do
|
|||
check_port_connectivity(port, node_name, nil, timeout)
|
||||
end
|
||||
|
||||
|
||||
def check_port_connectivity(port, node_name, nil, timeout) do
|
||||
regex = Regex.recompile!(~r/^(.+)@/)
|
||||
hostname = Regex.replace(regex, to_string(node_name), "") |> to_charlist
|
||||
|
||||
check_port_connectivity(port, node_name, hostname, timeout)
|
||||
end
|
||||
|
||||
def check_port_connectivity(port, node_name, hostname_or_ip, timeout) do
|
||||
try do
|
||||
IO.puts("Will connect to #{hostname_or_ip}:#{port}")
|
||||
|
||||
case test_connection(hostname_or_ip, port, timeout) do
|
||||
{:error, err} ->
|
||||
IO.puts("Error connecting to #{hostname_or_ip}:#{port}: #{err}")
|
||||
|
|
|
|||
Loading…
Reference in New Issue