From 2d6410ea3e714c930a762f61b84893a1f67879ff Mon Sep 17 00:00:00 2001 From: mawdegroot Date: Wed, 20 Apr 2022 21:57:54 +0200 Subject: [PATCH] Try to prevent stungunning relayed peers --- src/libp2p_transport_tcp.erl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libp2p_transport_tcp.erl b/src/libp2p_transport_tcp.erl index 2ee8a85a..ca83bf33 100644 --- a/src/libp2p_transport_tcp.erl +++ b/src/libp2p_transport_tcp.erl @@ -492,7 +492,7 @@ handle_info(stungun_retry, State=#state{observed_addrs=Addrs, tid=TID, stun_txns {PeerPath, TxnID} = libp2p_stream_stungun:mk_stun_txn(), %% choose a random connected peer to do stungun with {ok, MyPeer} = libp2p_peerbook:get(libp2p_swarm:peerbook(TID), libp2p_swarm:pubkey_bin(TID)), - case [libp2p_crypto:pubkey_bin_to_p2p(P) || P <- libp2p_peer:connected_peers(MyPeer)] of + case [libp2p_crypto:pubkey_bin_to_p2p(P) || P <- libp2p_peer:connected_peers(MyPeer), libp2p_peer:has_public_ip(P)] of [] -> %% no connected peers Ref = erlang:send_after(30000, self(), stungun_retry),