Commit Graph

4409 Commits

Author SHA1 Message Date
draoi
65e669f1a1 hosts: delete darklist entries older than one day
We introduce a new method called refresh() which deletes hosts older
than a specified period. This is applied to the darklist when we load it
on start(), and when we store hosts onto our darklist that are received by
other peers.

We do this to avoid the risk of passing faulty nodes around the network,
and assume that one day is sufficient for valid hosts to propagate to
hosts that support that transport.
2024-07-24 12:17:08 +02:00
draoi
7e1b792dc2 chore: make clippy 2024-07-24 12:17:08 +02:00
draoi
b56193acb8 Revert "refine_session: clear the darklist once a day"
This reverts commit 38aa8be3b3.
2024-07-24 12:17:08 +02:00
draoi
36204d3685 channel: deserialize vector, not individual bytes on read_command() 2024-07-23 18:05:21 +02:00
draoi
c699d326a9 doc: update hosts.rs HostColor documentation 2024-07-23 14:56:35 +02:00
draoi
38aa8be3b3 refine_session: clear the darklist once a day
This helps reduce the tradeoff space between a) ensuring all transports
are propagated, even those we do not support b) ensuring hosts shared
around the network are valid.

We assume that a one day period is sufficient for valid hosts to
propagate and enter into non-dark hostlists of a peer that does support
this transport.
2024-07-23 14:54:17 +02:00
draoi
3b0e012126 src: Use peers() instead of channels() method where applicable
The following messages are now only broadcast to peers (inbound/ manual/
outbound session) and not seed or refinery connections:

* EventGraph DAG sync
* OutboundSession `GetAddrs`

The following changes have been made to the p2p API:

* p2p.broadcast() now only sends to peers, not seeds or refine connections.
* p2p.is_connected() only reports peer connections, not all (seed, refinery) connections.
2024-07-23 11:54:05 +02:00
draoi
5e5bca6340 rpc: add SESSION_REFINE to channel matching in p2p_method() 2024-07-23 11:54:05 +02:00
skoupidi
fa6a4be257 net/hosts: use reference in block_all_ports() 2024-07-22 19:34:51 +03:00
skoupidi
151aa186c4 net/channel: introduced Message pre-serialization for minor optimization of p2p.broadcast() 2024-07-22 19:29:09 +03:00
draoi
d63f675fba net: match on host() instead of host_str() in block_all_ports
This fixes a bug where IPv6 addresses could be truncated in different
ways during the comparison due to the `host_str()` conversion and potentially be treated as different addresses.
2024-07-22 18:21:02 +02:00
draoi
5be7a372e8 hosts: use host() not host_str() method in filter_addresses()
Also add an additional check and print a warning if an external address
enters the hostlist.
2024-07-22 18:21:02 +02:00
draoi
a316bcc84e hosts: make peers() reject both seed and refine session channels 2024-07-22 18:21:02 +02:00
draoi
3b8a685d9c hosts: add peers() method to return channels minus seed connections 2024-07-22 12:04:39 +02:00
draoi
3b5535a90d inbound_session: explicitly handle failures in setup_channel() 2024-07-18 13:49:04 +02:00
draoi
1b24bfa340 channel: actually stop the channel on main_receive_loop() error
Previously we would return Error::ChannelStopped which triggers
handle_error but doesn't actually explicitly stop the channel. This was
leading inbound session to hang forever on `stop_sub.receive().await`.

Also add some useful debug info to inbound_session.rs.
2024-07-18 13:13:00 +02:00
draoi
1d8ab03f80 refine_session: actually delete greylist entries that fail the handshake 2024-07-18 13:13:00 +02:00
draoi
3359893c30 doc: fix copy paste misprint on seedsync_session 2024-07-18 13:13:00 +02:00
draoi
4e952746ad chore: make clippy 2024-07-17 16:01:11 +02:00
draoi
4070f482e4 settings: implement Default for BanPolicy 2024-07-17 15:52:39 +02:00
draoi
9dd240f13e net+lilith: introduce BanPolicy
We create a new net Setting called BanPolicy that can be Strict or
Relaxed. If it's set to Strict, we ban peers that send messages without
us having a corresponding Dispatcher. If it's set to Relaxed we simply
close the connection.

Lilith is set to Relaxed by default while other peers are set to Strict.
This helps us avoid Lilith blacklisting peers that send messages for
protocols it is not subscribed to.
2024-07-17 14:36:28 +02:00
dasman
69a26b7fd3 event_graph: return sorted Vec<Events> instead of Vec<blake3::Hash> to reduce dag_get() calls 2024-07-16 04:35:26 +03:00
dasman
501399d388 event_graph: rewrite order_events() to effectivly sort events once 2024-07-16 04:22:16 +03:00
draoi
cedde2e9ec hosts: don't allow manual peers to enter the hostlist via other peers
Storing manual peers on the hostlist creates redundancy since we can
never connect to them in Outbound Session or refine them in Refine
Session, so they just pointlessly sit on our greylist forever.
2024-07-12 10:41:55 +02:00
dasman
d2970c8895 event_graph: iterative dfs_topological_sort() instead of recursion 2024-07-12 03:08:17 +03:00
draoi
216794939d manual_session: sleep when try_register() call fails, then try again
Fixes a bug that would cause a death loop when the call to
try_register() fails.

Also removes a duplicate WARN print.
2024-07-11 23:14:21 +02:00
draoi
aa37b87a3e manual+seedsync_session: unregister() when version exchange fails 2024-07-11 17:26:06 +02:00
draoi
3cdec217d1 seedsync: unregister() seed address after failed connection
This fixes a bug where failed connections would get stuck in the Connect
state, blocking the seedsync from retrying.
2024-07-11 13:44:59 +02:00
parazyd
2f97f384e7 net: Use forked Url crate that supports our transport schemes
Now IP addresses are properly parsed
2024-07-11 10:56:04 +02:00
draoi
0c8b274505 net: replace LazyWeak with Arc::new_cyclic() and delete system::LazyWeak
Also update arch/services.md with the new usage.
2024-07-11 10:25:35 +02:00
draoi
8ae9e42e71 net: allow control of schemes in the blacklist imported from Settings 2024-07-09 18:25:12 +02:00
parazyd
3d60035238 net/acceptor: Add Tor hidden service address to external_addrs if available 2024-07-09 15:09:30 +02:00
parazyd
f94094e732 net/channel: Attempt to properly parse IPs in Channel::ban()
Additionally, skip inbound Tor connections as they're anonymous.
2024-07-09 13:06:25 +02:00
parazyd
3bdae810b3 net/channel: Add helpful debugging error calls 2024-07-09 12:28:36 +02:00
parazyd
27fd3785f8 chore: Update crate dependencies and CI Rust version 2024-07-09 12:20:06 +02:00
parazyd
7945e2eb18 net: Implement mutable Settings which allow dynamic reconfiguration 2024-07-09 11:22:55 +02:00
parazyd
795e2300cb net: Remove SettingsPtr type alias 2024-07-09 11:16:43 +02:00
draoi
f78af159aa chore: improve some hosts.rs code documentation 2024-07-09 10:40:21 +02:00
draoi
b735f9ffd9 channel: block all ports when blacklisting an inbound peer 2024-07-09 10:39:29 +02:00
parazyd
46a74e6b60 net: Use AtomicBool for dnet_enabled mark 2024-07-09 09:42:25 +02:00
draoi
c463537fd2 chore: fix net/ HostRegistry documentation 2024-07-08 10:25:22 +02:00
draoi
3c526d179f hosts: more permissive transitions from HostState::Free
This was a bug regarding the following state transition functions:

Free -> Connected
Free -> Move

Inbound connections go directly to Connected (1) and Move (2) in the
following cases- when an inbound connection connects to us (1), when we
blacklist a peer due to missing dispatchers (2).

If we previously had a connection on the same port that was now marked
as HostState::Free in the hostregistry, this would create a panic.
2024-07-07 14:30:06 +02:00
draoi
ab52d14372 hosts: enable the transition from Refine to Move
We need to be able to move hosts after refining them, whether that's to
send them to the greylist or to the whitelist.
2024-07-07 12:37:38 +02:00
draoi
3b5273c332 hosts: make unregister() call less dangerous
We introduce a new HostState called HostState::Free, which means a host
is freely available for use. This fixes race conditions where multiple threads could try to delete
the entry (using the unregister() call) at the same time.
2024-07-07 12:37:38 +02:00
draoi
3acf49e6a0 net: use standardized methods for net and lilith refinery's 2024-07-06 20:41:29 +02:00
draoi
01f3d5d000 net/tests: more efficiently start nodes 2024-07-06 09:17:35 +02:00
draoi
611f6e0454 session: call subscribe_stop() earlier in channel setup
Fixes a bug on seedsync_session where due to us quickly stopping
channels after they are formed the Subscription would occasionally miss
the channel.stop() event.
2024-07-06 09:08:32 +02:00
parazyd
c6227e38e4 net: Create datastore in P2p::new() 2024-07-05 11:17:58 +02:00
draoi
74eb6f9ba3 seedsync: don't allow duplicate connections to the same seed 2024-07-02 21:43:23 +02:00
skoupidi
97820d7301 darkfid: fixed some sync issues 2024-07-02 22:41:51 +03:00