Keep hostname as a string
This commit is contained in:
parent
06f165fc36
commit
61763955ba
|
@ -10,7 +10,8 @@ defmodule Chronoscope.NTS.KeyEstablishmentClient do
|
||||||
def key_establishment(%{host: host, port: port}) do
|
def key_establishment(%{host: host, port: port}) do
|
||||||
case ssl_connect(host, port) do
|
case ssl_connect(host, port) do
|
||||||
{:ok, socket} -> perform_key_establishment(socket)
|
{:ok, socket} -> perform_key_establishment(socket)
|
||||||
{:error, {:tls_alert, {:handshake_failure, error}}} -> {:error, to_string(error)}
|
{:error, {:tls_alert, {:handshake_failure, error}}} -> {:error, String.trim("#{error}")}
|
||||||
|
{:error, {:tls_alert, {:no_application_protocol, error}}} -> {:error, String.trim("#{error}")}
|
||||||
{:error, :timeout} -> {:error, :timeout}
|
{:error, :timeout} -> {:error, :timeout}
|
||||||
{:error, error} -> {:error, inspect(error)}
|
{:error, error} -> {:error, inspect(error)}
|
||||||
error -> {:error, inspect(error)}
|
error -> {:error, inspect(error)}
|
||||||
|
@ -18,7 +19,9 @@ defmodule Chronoscope.NTS.KeyEstablishmentClient do
|
||||||
end
|
end
|
||||||
|
|
||||||
defp ssl_connect(host, port) do
|
defp ssl_connect(host, port) do
|
||||||
:ssl.connect(host, port, tls_options(host), @timeout_in_milliseconds)
|
host
|
||||||
|
|> String.to_charlist()
|
||||||
|
|> :ssl.connect(port, tls_options(host), @timeout_in_milliseconds)
|
||||||
end
|
end
|
||||||
|
|
||||||
defp tls_options(host) do
|
defp tls_options(host) do
|
||||||
|
|
|
@ -8,7 +8,7 @@ defmodule ChronoscopeWeb.API.V1.NTS.KeyEstablishmentController do
|
||||||
@default_port "4460"
|
@default_port "4460"
|
||||||
|
|
||||||
def get(conn, params) do
|
def get(conn, params) do
|
||||||
host = to_charlist(params["host"])
|
host = params["host"]
|
||||||
port = String.to_integer(params["port"] || @default_port)
|
port = String.to_integer(params["port"] || @default_port)
|
||||||
|
|
||||||
case NTS.key_establishment(host, port) do
|
case NTS.key_establishment(host, port) do
|
||||||
|
|
Loading…
Reference in New Issue