Commit Graph

7750 Commits

Author SHA1 Message Date
lunar-mining
27d1b3aa03 hosts: fix logic on anchorlist_fetch_with_schemes
if we don't have any hosts on the anchorlist, chose from the whitelist.
if we don't have any on the whitelist, chose from the greylist.

same principle for whitelist_fetch_with_schemes (each method has a
different selection priority)
2024-01-01 01:09:47 +01:00
lunar-mining
426efdf90b chore: cargo fmt 2023-12-31 11:49:55 +01:00
lunar-mining
18479be298 test: add seed node to net/test.rs 2023-12-31 11:48:48 +01:00
lunar-mining
1578138e8f outbound_session: move fetch_address logic into new function 2023-12-31 11:47:42 +01:00
lunar-mining
2696290aad store: fix logic on is_empty_hostlist()
anchorlist, greylist AND whitelist must be empty for this to return
true (previously OR)
2023-12-30 15:31:36 +01:00
lunar-mining
ca885a43ee store: improve error naming
Error::InvalidIndex -> Error::HostDoesNotExist
2023-12-30 12:05:47 +01:00
lunar-mining
07c2d667e1 session: remove redundant anchorlist write
We are already storing anchorlist entries in perform_handshake_protocols of session/mod.rs.
2023-12-30 11:58:26 +01:00
lunar-mining
4d4392f9e8 net: add test module to mod.rs 2023-12-30 11:45:27 +01:00
lunar-mining
873cd35e0e net: add hostlist documentation 2023-12-29 17:31:21 +01:00
lunar-mining
51b4263a93 net: remove connection from anchorlist when it disconnects and cleanup.
also remove perform_local_handshake function as it's made redudant by
the anchorlist removal change.
2023-12-29 17:31:03 +01:00
lunar-mining
a555f2e744 net: add anchor_connection_count and white_connect_percent to Settings and cleanup 2023-12-29 17:30:51 +01:00
lunar-mining
ca4d523dd3 net: remove unwrap()'s and cleanup 2023-12-29 17:30:38 +01:00
lunar-mining
6e8671d5b0 net: create greylist_refinery_interval in net::Settings and update TODOs 2023-12-29 17:30:29 +01:00
lunar-mining
995ff6f6c2 lilith: add hostlist path to NetInfo and default config 2023-12-29 17:29:26 +01:00
lunar-mining
d15cc3b2bd net: read hostlist path from Settings. Define a default setting and allow overriding in config 2023-12-29 17:28:39 +01:00
lunar-mining
b456d8f5ec lilith: remove load and save host functionality (made redundant by greylist upgrade) 2023-12-29 17:28:15 +01:00
lunar-mining
5be6a07c61 net: add save_hosts() and load_hosts() methods and invoke on greylist refinery start and stop 2023-12-29 17:28:04 +01:00
lunar-mining
03e6e99e90 net: move host selection logic back into hosts/store to avoid insane nesting in outbound session loop 2023-12-29 17:27:47 +01:00
lunar-mining
0096f778c6 net: improve outbound_session connection loop logic. 2023-12-29 17:27:34 +01:00
lunar-mining
6a39e926f1 net: prevent inbound session channels from being stored in the anchorlist 2023-12-29 17:26:54 +01:00
lunar-mining
c850f629b8 net: cleanup connect loop code reuse by implement connect_slot() method. also prevent infinite loop by doing peer discovery when the hostlist is empty.
also fix tests.
2023-12-29 17:26:44 +01:00
lunar-mining
b5bf749fe9 net: replace outbound connection loop with monero grey/white/anchor connection_maker()
see: ac02af9286/src/p2p/net_node.inl (L1807)

we have made connection_maker()mless nested and adapted it to the existing structure.

WARNING: UNTESTED
2023-12-29 17:26:33 +01:00
lunar-mining
03ae65956a net: add peer to the anchorlist with an updated last_seen when we call p2p.store() on a connected channel 2023-12-29 17:26:20 +01:00
lunar-mining
ebe8eb1626 net: check whether host is in the peerlist before adding to greylist. also make additional anchorlist utils.
we do this because otherwise a whitelisted or anchor node could be added
to the greylist as a new peer, resulting in duplicates across the
peerlist.
2023-12-29 17:26:10 +01:00
lunar-mining
3725de07ec net: and anchorlist and minimal utilities. also clarify hosts specific TODOs. 2023-12-29 17:25:58 +01:00
lunar-mining
065f254661 lilith: comment out broken load_hosts code and add FIXME note 2023-12-29 17:25:44 +01:00
lunar-mining
560b332e37 net: create perform_local_handshake which does a version exchange without adding channel to the p2p store, and use in ping_node 2023-12-29 17:25:34 +01:00
lunar-mining
d591fac8dc net: remove whitelist_downgrade() from outbound_session (monero doesn't do this) 2023-12-29 17:25:08 +01:00
lunar-mining
1a282a951d net: call channel.stop() when we get a handshake error on ping_node 2023-12-29 17:24:55 +01:00
lunar-mining
845b9ded6b net: fix tests on store.rs 2023-12-29 17:24:44 +01:00
lunar-mining
e693b48cb5 net: clean up reference/ pass by value usage in store.rs 2023-12-29 17:24:30 +01:00
lunar-mining
ef3b95ffdf net: avoid adding our own address to the greylist when on localnet
also standardize the whitelist_store_or_update function call
2023-12-29 17:24:19 +01:00
parazyd
80df5b68b5 net/hosts: Add missing mod.rs 2023-12-29 17:24:10 +01:00
lunar-mining
a61a08c020 net: remove whitelist_store_or_update call from OutboundSession
this should be redundant due to the GreylistRefinery task which is
responsible for filtering host lists. OutboundSession is just focused on
reading from the whitelist, not writing to it.
2023-12-29 17:23:58 +01:00
lunar-mining
4adc0585c0 net: change try_read() and try_write() to read() and write() and cleanup warnings
also experiment with a longer greylist refinery period
2023-12-29 17:22:16 +01:00
lunar-mining
c4ebcb3d45 net: reimplement address filtering on greylist_store().
we don't need to implement this for whitelist as it would be redundant
(whitelist gets data from greylist)
2023-12-29 17:22:03 +01:00
lunar-mining
ae5b4d0a69 net/store: reimplement test_greylist_store() 2023-12-29 17:21:53 +01:00
lunar-mining
2a2d516ac4 net: if a greylist peer is non responsive, remove it from the greylist 2023-12-29 17:21:42 +01:00
lunar-mining
0639e9bdf7 net: working greylist protocol
Working on this commit:

* Nodes connect to a seed node, do ProtocolAddr, ping themselves and send over their ADDR if the address is reachable.
* Seed nodes add addresses into greylist, probe them to make sure they're reachable, then promote to whitelist and send to other peers.
* On receiving whitelisted addresses, nodes add to greylist and after performing refinery process, promote to whitelist.

Still TODO:

* reimplement address filtering
* test: unstable_sort_by_key
* implement "anchor" connections when we've already established a connection to a node
* keep track of how many times we ping ourselves to avoid redundant self ping
* idle handshake protocol
2023-12-29 17:21:17 +01:00
lunar-mining
de2fb840bf net: invoke GreylistRefinery in p2p.rs and cleanup 2023-12-29 17:20:48 +01:00
lunar-mining
748c659f93 lilith: fix warnings 2023-12-29 17:20:38 +01:00
lunar-mining
066d3dc9c5 net: fix warnings and cargo fmt 2023-12-29 17:20:28 +01:00
lunar-mining
7cf5a1e081 net: delete hosts.rs 2023-12-29 17:20:18 +01:00
lunar-mining
c2ba96dc6f net: move GreylistRefinery and ping_node() to new hosts submodule. rename hosts.rs to hosts/store.rs. update host imports and ping_node usage 2023-12-29 17:20:07 +01:00
lunar-mining
d4541d4315 net: fix typo in protocol/mod.rs documentation 2023-12-29 17:19:40 +01:00
lunar-mining
de743a03b6 lilith: remove all peerlist filtering logic 2023-12-29 17:19:22 +01:00
lunar-mining
c0a47457f8 net: BUGFIX: stop duplicate entries in greylist
check if we have the peer and update it's last seen if we do.
this commit also standardizes the format of send_my_addrs across
ProtocolSeed and ProtocolAddr, so we can perhaps extract the
functionality to protocol/mod.rs at some point.
2023-12-29 17:19:11 +01:00
lunar-mining
175f6e78a1 net: commit working test 2023-12-29 17:18:40 +01:00
lunar-mining
cc602048d6 net: standardize format + fix logic error on protocol_seed, protocol_address self_my_addrs() 2023-12-29 17:15:38 +01:00
lunar-mining
519353ae42 hosts: fix minor typo 2023-12-29 17:15:18 +01:00