Commit Graph

4421 Commits

Author SHA1 Message Date
draoi
8962f43407 outbound_session: only attempt a seedsync if we have seeds configured 2024-08-09 09:37:11 +02:00
darkfi
ac03e32622 event_graph: replace foo(event_graph: &EventGraphPtr) with foo(event_graph: &EventGraph) 2024-08-09 09:29:34 +02:00
draoi
497fe1d06f channel: remove redundant calls to self.stop()
self.stop() stops the main_receive_loop(), so we can just exit function with Error::ChannelStopped.
2024-08-08 11:33:26 +02:00
draoi
42e8bc84ca settings: fix bug that was making nodes run a Relaxed ban policy 2024-08-08 08:32:59 +02:00
draoi
a5eb9cc5bf seedsync_session: fix deceptive logic on failed()
We should return an error when ALL seed slots have failed, not ANY.

Otherwise this would print a deceptive error message ("Network reseed failed") if
we have e.g. 2 seed slots and one seeds successfully and the other fails.
2024-08-07 10:45:20 +02:00
darkfi
e7eb633916 wallet: UI working with darkirc 🔥🔥🔥 2024-08-06 11:55:03 +02:00
dasman
3aeec3d861 specify timestamp unit in Event::timestamp 2024-08-05 16:32:41 +03:00
draoi
9cc8fa56b5 hosts: fix overflow bug on refresh() 2024-08-04 13:45:36 +02:00
dasman
3bbadabaee event_graph: complete docstring of EventGraph::new() 2024-08-03 18:05:12 +03:00
dasman
953049a36c event_graph: complete doc of EventGraph fields 2024-08-03 17:33:43 +03:00
dasman
19f70bd58f event_graph: gracefully stop pruning task 2024-07-30 19:00:26 +03:00
draoi
687a1a54ad acceptor: don't shutdown the accept process on broken pipe (EPIPE) 2024-07-30 11:18:54 +02:00
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