diff options
author | Alex Auvolat <alex@adnab.me> | 2018-10-12 22:43:24 +0200 |
---|---|---|
committer | Alex Auvolat <alex@adnab.me> | 2018-10-12 22:43:24 +0200 |
commit | dbcfeb69013cb380ca6615ddbcde79c583e3dfd5 (patch) | |
tree | 4614a04ef74d15a7125283813e9da94c8355d4e1 | |
parent | 0ed802601812acd6ad764e6ffd5aacfd7e674553 (diff) | |
download | shard-dbcfeb69013cb380ca6615ddbcde79c583e3dfd5.tar.gz shard-dbcfeb69013cb380ca6615ddbcde79c583e3dfd5.zip |
silence connection errors
-rw-r--r-- | shard/lib/net/tcpconn.ex | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/shard/lib/net/tcpconn.ex b/shard/lib/net/tcpconn.ex index 7025ffe..21d25df 100644 --- a/shard/lib/net/tcpconn.ex +++ b/shard/lib/net/tcpconn.ex @@ -47,7 +47,10 @@ defmodule SNet.TCPConn do def handle_cast(:client_handshake, state) do {:inet, ip, port} = state.connect_to - {:ok, socket} = :gen_tcp.connect(ip, port, [:binary, packet: 2, active: false]) + socket = case :gen_tcp.connect(ip, port, [:binary, packet: 2, active: false]) do + {:ok, socket} -> socket + _ -> exit(:normal) # ignore connection errors + end net_key = Application.get_env(:shard, :network_key) %{public: cli_eph_pk, secret: cli_eph_sk} = :enacl.box_keypair @@ -152,7 +155,7 @@ defmodule SNet.TCPConn do Logger.info "New peer: #{print_id state} at #{inspect addr}:#{port}" {:noreply, state} :redundant -> - exit :redundant + exit(:normal) end end @@ -280,7 +283,7 @@ defmodule SNet.TCPConn do Logger.info "New peer: #{print_id state} at #{inspect state.peer_info} (#{port})" {:noreply, state} :redundant -> - exit(:redundant) + exit(:normal) end end |