Commit Graph

4393 Commits

Author SHA1 Message Date
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
skoupidi
85670eb1f6 src/rpc: server handle requests in the background 2024-07-02 17:17:34 +03:00
draoi
9033567f00 net: stabilize HostState.unregister() calls
We previously deleted the call to `unregister()` after the refinery is
successful on a16dd562d9.

It was considered redundant since the `unregister()` call happens in
`subscribe_on_stop()`, which for refine session is called directly after
the refinery process finishes (after `channel.stop()`).

However, in a highly async environment the `unregister()` call in
`subscribe_on_stop()` can be called before the call to `move_host()`, meaning
that the host would then be stuck in the `Moving` state.

We have fixed this by specifying that `unregister` should only be called
in `subscribe_on_stop()` to peers that are not part of a refine session.
We seperately call `unregister` after `move_host` in the refinery.

This commit also fixes some documentation.

Note: the call to `unregister()` is highly fragile and can lead to race
conditions. We are working to replace this with something more robust
(like `tombstone()`).
2024-07-02 13:57:02 +02:00
parazyd
e09f0b192d net/tor: Add a way to retrieve the running onion address 2024-07-02 13:05:43 +02:00
parazyd
ccc5d9cf30 net/tor: Use P2P datastore for Tor's state and cache dirs 2024-07-02 12:13:22 +02:00
parazyd
c6aa5c1544 net: Define a datastore path 2024-07-02 11:51:42 +02:00
parazyd
ba62cdf6e5 net/settings: Convert hostlist into an Option<String> 2024-07-02 11:45:06 +02:00
skoupidi
cb029adc4d contract/dao/lib: typo lol 2024-07-01 18:37:57 +03:00
skoupidi
7b92070c7c contract/dao/lib: fixed blockwindow 2024-07-01 18:33:31 +03:00
skoupidi
97f7a91879 drk: rpc cleanup and minor fix
- All rpc use same fn to perform requests towards darkfid\n- Moved all rpc related Drk fns to rpc.rs\n- Fixed subscribe where if darkfid went off, drk subscription errored and drk hanged
2024-07-01 16:36:29 +03:00
draoi
a16dd562d9 refine_session: remove redundant call to unregister()
unregister() will get called when the refine session channel disconnects
in session::remove_sub_on_stop(). Calling it here is actually dangerous
and creates rare race conditions.
2024-06-28 15:47:36 +02:00
draoi
39ce78632a hosts: create resize() and sort_by_last_seen() methods
We organize this functionality into distinct methods which get called
higher up, for example rather than manually resizing inside of store(),
we call resize() after we call store().

This is about reducing the "critical section" where locks are held and
using function scopes to ensure locks are released as quickly as possible.
2024-06-28 10:41:59 +02:00
draoi
2cd8b4dff7 net: use sync Mutex for HostContainer
Rationale: using a sync Mutex wherever possible is the recommended
method.

Additionally, using a sync Mutex here fixes some really weird fairness
behaviors we observed in the smol::lock::RwLock where writers in the
priority queue were occassionally ignored.
2024-06-27 15:03:22 +02:00
draoi
e7d8ba1864 refine_session: use remove_if_exists() method to delete entry when refinery fails
There's no need to acquire the write lock in the refinery when we can
just use one of the hosts methods.
2024-06-27 13:56:25 +02:00
draoi
958361c953 net: simplfy fetch_last() method and fix lilith's usage 2024-06-26 10:24:06 +02:00
draoi
6a0d4cfe7d net: simplify update_last_seen() method
Also fix its usage by Lilith
2024-06-26 10:01:42 +02:00
draoi
e2ba275cb9 session/mod: use !p2p.connected() instead of channels().is_empty() 2024-06-26 09:21:23 +02:00