From dbcfeb69013cb380ca6615ddbcde79c583e3dfd5 Mon Sep 17 00:00:00 2001 From: Alex Auvolat Date: Fri, 12 Oct 2018 22:43:24 +0200 Subject: silence connection errors --- shard/lib/net/tcpconn.ex | 9 ++++++--- 1 file 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 -- cgit v1.2.3