aboutsummaryrefslogtreecommitdiff
path: root/shard
diff options
context:
space:
mode:
authorAlex Auvolat <alex@adnab.me>2018-10-12 22:43:24 +0200
committerAlex Auvolat <alex@adnab.me>2018-10-12 22:43:24 +0200
commitdbcfeb69013cb380ca6615ddbcde79c583e3dfd5 (patch)
tree4614a04ef74d15a7125283813e9da94c8355d4e1 /shard
parent0ed802601812acd6ad764e6ffd5aacfd7e674553 (diff)
downloadshard-dbcfeb69013cb380ca6615ddbcde79c583e3dfd5.tar.gz
shard-dbcfeb69013cb380ca6615ddbcde79c583e3dfd5.zip
silence connection errors
Diffstat (limited to 'shard')
-rw-r--r--shard/lib/net/tcpconn.ex9
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