diff options
author | Alex Auvolat <alex@adnab.me> | 2018-09-01 16:01:48 +0200 |
---|---|---|
committer | Alex Auvolat <alex@adnab.me> | 2018-09-01 16:01:48 +0200 |
commit | 1a0ef154a421af60f6d57dfe861dacb844a7d142 (patch) | |
tree | ac4ce4ef99991c9826d69114489acaaeb7638e51 /lib/net/tcpconn.ex | |
parent | dd078cfecbe07f1e4d4e002467707ed53aeff180 (diff) | |
download | shard-1a0ef154a421af60f6d57dfe861dacb844a7d142.tar.gz shard-1a0ef154a421af60f6d57dfe861dacb844a7d142.zip |
Add peer id suffix to make sub networks
Diffstat (limited to 'lib/net/tcpconn.ex')
-rw-r--r-- | lib/net/tcpconn.ex | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/lib/net/tcpconn.ex b/lib/net/tcpconn.ex index 6fc4b1a..44669bb 100644 --- a/lib/net/tcpconn.ex +++ b/lib/net/tcpconn.ex @@ -39,6 +39,10 @@ defmodule SNet.TCPConn do challenge_sign = decode_pkt(pkt, cli_sess_pkey, sess_skey) :ok = Sign.verify_detached(challenge_sign, challenge, cli_pkey) + expected_suffix = Application.get_env(:shard, :peer_id_suffix) + len = byte_size(expected_suffix) + ^len = :binary.longest_common_suffix([cli_pkey, expected_suffix]) + # Connected :inet.setopts(socket, [active: true]) |