Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add P2P security options #1764

Merged
merged 87 commits into from
Sep 12, 2022
Merged
Changes from 1 commit
Commits
Show all changes
87 commits
Select commit Hold shift + click to select a range
d5cf0ef
Add p2p security options
jmjatlanta May 16, 2019
16c70f6
Add tests
jmjatlanta May 17, 2019
28d08f7
Allow changes to be accessed from the command line
jmjatlanta May 20, 2019
3ed2b89
Fix typos
jmjatlanta May 20, 2019
a38a1ff
Do not add to db if !accept_incoming_connections
jmjatlanta May 20, 2019
6e879c3
Fix spacing, add node_util to tests
jmjatlanta Jul 5, 2019
a125384
rename advertise_list for clarity
jmjatlanta Jul 8, 2019
e0f7a1f
clarify / fix comments
jmjatlanta Jul 8, 2019
6bc930c
Advertise actual connected nodes, not fake ones
jmjatlanta Jul 8, 2019
40bd1bd
Add separate parameter for connect to new peers
jmjatlanta Jul 8, 2019
8e22331
disable filewall check when !connect_to_new_peers
jmjatlanta Jul 8, 2019
ffa871b
adjust set_ method names, code cleanup
jmjatlanta Jul 8, 2019
6ec8161
Remove duplicates from advertise-peer-list
jmjatlanta Jul 8, 2019
a0d659c
Added log msg for bad endpoint, add add_seed_node
jmjatlanta Jul 26, 2019
510e3f0
Switch message from error to warning
jmjatlanta Jul 29, 2019
a76c20b
advertise lists and firewall checking
jmjatlanta Aug 2, 2019
833c60d
refactor advertise_list, return unable_to_check
jmjatlanta Aug 5, 2019
3f6408b
search set by endpoint
jmjatlanta Aug 5, 2019
19ac1da
Improve readability
jmjatlanta Aug 5, 2019
59cb73f
Prevent connections when unwanted
jmjatlanta Aug 7, 2019
1299102
do not continue once unable_to_check is sent
jmjatlanta Aug 9, 2019
5c03d20
Add test for firwall check changes
jmjatlanta Aug 12, 2019
1d67a96
Move info firewall msgs from warning to info
jmjatlanta Aug 19, 2019
f7bc153
remove unnecessary validity check
jmjatlanta Aug 19, 2019
b09e222
add missing include
jmjatlanta Aug 26, 2019
4dcb4b2
fix poor merge from rebase
jmjatlanta Aug 26, 2019
b900a77
Remove firewall checks and get_current_connections
jmjatlanta Aug 30, 2019
48223b2
rebase to fix conflict
jmjatlanta Oct 10, 2019
d5e19be
Merge develop branch into jmj_659c and fix build
abitmore Aug 12, 2022
94053f9
Do not listen to network if not accept connections
abitmore Aug 12, 2022
ad71e5c
Remove unnecessary code
abitmore Aug 12, 2022
7d63ebc
Remove trailing whitespaces
abitmore Aug 12, 2022
baf0468
Update docs
abitmore Aug 12, 2022
d484ce8
Add virtual destructor to address_builder class
abitmore Aug 12, 2022
0db53ad
Remove trailing whitespaces
abitmore Aug 12, 2022
73fb7a0
Fix network_mapper
abitmore Aug 13, 2022
896049d
Deal with nodes that have changed ID
abitmore Aug 13, 2022
9fa8e97
Fix code smells
abitmore Aug 13, 2022
50bfefc
Fix code smells
abitmore Aug 14, 2022
a08ddd7
Replace non-public addresses with public addresses
abitmore Aug 14, 2022
52c6649
Add comments
abitmore Aug 14, 2022
812b935
Fix a code smell
abitmore Aug 14, 2022
b4f6329
Update address records when building by list
abitmore Aug 14, 2022
a0a7410
Listen to default but not random port by default
abitmore Aug 14, 2022
53ab60a
Simplify code
abitmore Aug 14, 2022
c56ed06
Only save new or updated address to peer database
abitmore Aug 14, 2022
c2c21cd
Fix code smells
abitmore Aug 14, 2022
17bb77a
Fix code smells
abitmore Aug 15, 2022
dfd33c6
Re-add peer_connection::is_firewalled and ...
abitmore Aug 17, 2022
f027741
Add "p2p-inbound-endpoint" node startup option
abitmore Aug 26, 2022
33a62e3
Add some gatekeeping code
abitmore Aug 28, 2022
e9d1e16
Handle node_id in user_data in hello message
abitmore Aug 29, 2022
efe8690
Refactor on_hello_message, verify inbound endpoint
abitmore Aug 29, 2022
8381eb3
Update logging
abitmore Aug 29, 2022
a6a1b7e
Update inbound endpoint verification ...
abitmore Sep 2, 2022
c94cbc7
Add colors to log messages in app_test
abitmore Sep 2, 2022
3d56e96
Fix and improve P2P node tests
abitmore Sep 2, 2022
8db58de
Update tests to get around race conditions in code
abitmore Sep 2, 2022
e498589
Add a comment
abitmore Sep 2, 2022
7458c24
Fix threading issues in p2p_node_tests
abitmore Sep 3, 2022
e758340
Update member functions to const, update logging
abitmore Sep 5, 2022
649bcbc
Create dir for saving node config if not exist
abitmore Sep 5, 2022
cfbdba9
Update two_node_network test to three_node_network
abitmore Sep 5, 2022
2e535c1
Avoid using get_socket() in on_hello_message()
abitmore Sep 5, 2022
171bdd9
Add try-catch in on_hello when checking signature
abitmore Sep 5, 2022
da8ea0d
Add more P2P node tests
abitmore Sep 6, 2022
bbea3c9
Fix threading issues in p2p_node_tests
abitmore Sep 6, 2022
01a4e27
Fix code smells
abitmore Sep 6, 2022
68c452b
Remove redundant "disable-peer-advertising" option
abitmore Sep 6, 2022
09d6ca7
Skip processing addresses if !connect_to_new_peers
abitmore Sep 6, 2022
9ce161a
Reconnect from OS-selected port if fail to connect
abitmore Sep 6, 2022
dc72295
Save successfully connected endpoint to peer db
abitmore Sep 7, 2022
6169691
Fix code smells
abitmore Sep 7, 2022
e3ddde5
Fix typo
abitmore Sep 7, 2022
9edf789
Do not expose local address if not listening
abitmore Sep 7, 2022
be70a6f
Rename some startup options related to p2p network
abitmore Sep 7, 2022
9b175ea
Do not try to bind if not listening
abitmore Sep 7, 2022
b9f64d6
Prefer peer's socket address if it's not listening
abitmore Sep 7, 2022
1ae2bca
Update three_node_network to test not listening
abitmore Sep 7, 2022
53e9c38
Rename and update some P2P-related startup options
abitmore Sep 7, 2022
b231426
Update logging
abitmore Sep 8, 2022
b211dce
Update logging
abitmore Sep 8, 2022
67bbdea
Save remote endpoint of inbound peer to peer db
abitmore Sep 8, 2022
9a7f723
Update logging
abitmore Sep 8, 2022
e0721f9
Update logging
abitmore Sep 9, 2022
75686ef
Update logging
abitmore Sep 9, 2022
984b1b6
Update logging
abitmore Sep 12, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Update logging
  • Loading branch information
abitmore committed Sep 9, 2022
commit 9a7f723a5d7b22835d1245c14b0ac52759bb0046
31 changes: 22 additions & 9 deletions libraries/net/node.cpp
Original file line number Diff line number Diff line change
@@ -1802,7 +1802,8 @@ namespace graphene { namespace net { namespace detail {
}
else if( 0 == originating_peer->inbound_port )
{
dlog( "peer did not give an inbound port so I'm treating them as if they are firewalled." );
ilog( "peer ${peer} did not give an inbound port so I'm treating them as if they are firewalled.",
("peer", originating_peer->get_remote_endpoint()) );
originating_peer->is_firewalled = firewalled_state::firewalled;
}
else
@@ -1823,6 +1824,9 @@ namespace graphene { namespace net { namespace detail {
endpoints_to_save.insert( fc::ip::endpoint( peers_actual_outbound_endpoint.get_address(),
originating_peer->inbound_port ) );

ilog( "Saving potential endpoints to the peer database for peer ${peer}: ${endpoints}",
("peer", originating_peer->get_remote_endpoint()) ("endpoints", endpoints_to_save) );

for( const auto& ep : endpoints_to_save )
{
// add to the peer database
@@ -4590,29 +4594,38 @@ namespace graphene { namespace net { namespace detail {
{
VERIFY_CORRECT_THREAD();
ilog( "----------------- PEER STATUS UPDATE --------------------" );
ilog( " number of peers: ${active} active, ${handshaking}, ${closing} closing. attempting to maintain ${desired} - ${maximum} peers",
( "active", _active_connections.size() )("handshaking", _handshaking_connections.size() )("closing",_closing_connections.size() )
ilog( " number of peers: ${active} active, ${handshaking} handshaking, ${closing} closing. "
" attempting to maintain ${desired} - ${maximum} peers",
( "active", _active_connections.size() )("handshaking", _handshaking_connections.size() )
( "closing", _closing_connections.size() )
( "desired", _desired_number_of_connections )("maximum", _maximum_number_of_connections ) );
{
fc::scoped_lock<fc::mutex> lock(_active_connections.get_mutex());
for( const peer_connection_ptr& peer : _active_connections )
{
ilog( " active peer ${endpoint} peer_is_in_sync_with_us:${in_sync_with_us} we_are_in_sync_with_peer:${in_sync_with_them}",
ilog( " active peer ${endpoint} [${direction}] peer_is_in_sync_with_us:${in_sync_with_us} "
"we_are_in_sync_with_peer:${in_sync_with_them}",
( "endpoint", peer->get_remote_endpoint() )
( "in_sync_with_us", !peer->peer_needs_sync_items_from_us )("in_sync_with_them", !peer->we_need_sync_items_from_peer ) );
( "direction", peer->direction )
( "in_sync_with_us", !peer->peer_needs_sync_items_from_us )
( "in_sync_with_them", !peer->we_need_sync_items_from_peer ) );
if( peer->we_need_sync_items_from_peer )
ilog( " above peer has ${count} sync items we might need", ("count", peer->ids_of_items_to_get.size() ) );
ilog( " above peer has ${count} sync items we might need",
("count", peer->ids_of_items_to_get.size() ) );
if (peer->inhibit_fetching_sync_blocks)
ilog( " we are not fetching sync blocks from the above peer (inhibit_fetching_sync_blocks == true)" );
ilog( " we are not fetching sync blocks from the above peer "
"(inhibit_fetching_sync_blocks == true)" );

}
}
{
fc::scoped_lock<fc::mutex> lock(_handshaking_connections.get_mutex());
for( const peer_connection_ptr& peer : _handshaking_connections )
{
ilog( " handshaking peer ${endpoint} in state ours(${our_state}) theirs(${their_state})",
( "endpoint", peer->get_remote_endpoint() )("our_state", peer->our_state )("their_state", peer->their_state ) );
ilog( " handshaking peer ${endpoint} [${direction}] in state ours(${our_state}) theirs(${their_state})",
( "endpoint", peer->get_remote_endpoint() )
( "direction", peer->direction )
( "our_state", peer->our_state )( "their_state", peer->their_state ) );
}
}
ilog( "--------- MEMORY USAGE ------------" );