193 Commits

Author SHA1 Message Date
John Galt 0e8d31aafd networkmanager: catch queued send failures 2026-05-19 19:03:35 +02:00
tomFlowee 21a6b1bef4 Cap reassmbled native messages.
Implement old TODO; set the maximum size of a sequenced message to 64MiB
by default.
We use a variable, so it should be easy to make a setter, but without
usecase we'll wait to write code that would be unused.
2026-05-19 18:46:35 +02:00
John Galt 2a07f278b2 networkmanager: validate legacy p2p envelopes 2026-05-19 18:09:19 +02:00
tomFlowee be12bd4b58 Add comments. 2026-05-19 17:44:04 +02:00
John Galt c9e805195a networkmanager: bound native parser to packet 2026-05-19 17:44:04 +02:00
John Galt 1713c8f940 networkmanager: reject short native packets 2026-05-19 10:22:58 +02:00
John Galt 79b389caf6 networkmanager: keep ring buffer full state distinct 2026-05-19 10:22:58 +02:00
tomFlowee aa7f639e79 Fix assert and add comment. 2026-05-04 21:32:08 +02:00
John Galt f1067b0744 NWM: prioritize pong replies under queue pressure
Rationale: pong responses should use the priority queue so they
are not stranded behind normal-backlog traffic.
2026-05-04 19:13:17 +02:00
tomFlowee 5bd01e0752 Fix threading issues
The binds to the executor now use the strand for more callbacks and
avoid race conditions that way.
2026-05-04 17:11:16 +02:00
tomFlowee bb36475f45 Avoid calls to throwing methods. 2026-05-04 15:45:46 +02:00
tomFlowee 69d4c03e48 Use shared from this, instead of 'this' in callbacks.
Defensive programming, really.
2026-05-04 15:29:24 +02:00
tomFlowee 465aa8630d Move away from deprecated deadline_timer. 2026-04-09 19:25:27 +02:00
tomFlowee f2b59b7737 Make logging code compile with more defines
This allows compile with BCH_NO_INFO_OUTPUT define, which removes
from the compiled binary all info level logging.
2026-01-14 18:23:19 +01:00
tomFlowee 0675f272c1 Fix sometimes reconnect not working 2026-01-08 12:05:51 +01:00
tomFlowee 18f0405c30 Fix compile, add include. 2025-10-26 16:12:58 +01:00
tomFlowee ab4a04f176 Replace deprecated deadline_timer
Move to system timer for real world waits for most of them,
since sleeping or being suspended is local and this is networking.
2025-10-21 19:28:16 +02:00
tomFlowee bde4268202 Handle edge cases better in NetworkManager
Prevent a trivial acceptor DoS in the network layer by never shutting down
the listener due to a single bad inbound socket (or banned IP). Instead we
close just that socket and keep accepting.

In NetworkManagerServerBase::acceptConnection(tcp::socket&&), two paths that
previously called shutdown() (which closes the acceptor) now only close the
offending socket:
- When an inbound connection is from a banned IP.
- When an exception occurs while inspecting the just-accepted socket (e.g.,
remote_endpoint throws because the peer vanished).

Patch is from John Galt.
2025-08-15 13:42:35 +02:00
tomFlowee 51c24cefaf Remove unused include 2025-06-21 17:40:33 +02:00
tomFlowee 51d77f84ad Only call onDisconnect if the connection was open 2025-05-06 12:11:25 +02:00
tomFlowee 553568da32 Delete our connections in destructor.
When we didn't and one was still alive, it might do a callback on the
class after the destructor.
Deleting them makes the callbacks be removed on the server, avoiding
usage after free.
2025-04-14 16:36:27 +02:00
tomFlowee 412adb11ef Detect closed network listener.
This also removes the duplicate call.
2025-02-24 08:25:56 +01:00
tomFlowee c083a56916 Add guards for ssl functionlity of network manager
When Boost is too old, avoid compiling the SLL features into the network
manager.
2025-02-11 20:16:32 +01:00
tomFlowee 25c0ad9650 Redo the callback handling in the proxy
This makes the unit test work, specifically it ensures the callbacks are
done in the strand.
2025-02-11 19:23:14 +01:00
tomFlowee 5cae07500c Port away from deprecated ASIO methods
This makes thehub compile with BOOST_ASIO_NO_DEPRECATED defined.
2025-02-11 16:46:21 +01:00
tomFlowee bb7275466b Stop using deprecated asio io_service
This ports the io-service to the source compatible io-context
class, with the most work going to the WorkerThreads which owns
that one.
2025-02-08 19:05:26 +01:00
tomFlowee da4321e6a6 Minor language update 2024-10-20 12:18:21 +02:00
tomFlowee be89f191e9 Add todo 2024-09-16 23:18:47 +02:00
tomFlowee e5986f6199 remove unused include 2024-09-10 19:14:01 +02:00
tomFlowee 9bb8311a5f Minor clarifications.
Rename variable to talk about message instead of package (which probably
was meant to be packet anyway).
Make log message of exception we caught a little more useful.
2024-09-10 19:06:07 +02:00
tomFlowee b060064d45 Cleanups 2024-08-21 19:45:32 +02:00
tomFlowee 3a25af6f0e Complete the new SSL connections in networkmanager
This completes the API and makes the unit test pass.
2024-08-21 17:58:45 +02:00
tomFlowee 7fcecedd76 Make handshake of ssl connection work. 2024-08-21 16:55:01 +02:00
tomFlowee 69b3d78e19 Making the ssl unit test work. 2024-08-20 22:46:48 +02:00
tomFlowee af5a76f9aa Add server functionality to ssl connections. 2024-08-13 22:56:24 +02:00
tomFlowee 87d771ba8f Merge branch 'master' into sslNetworkManager 2024-08-13 22:55:47 +02:00
tomFlowee 2879587a64 OnDisconnected now shows it is disconnected
The onDisconnected callback is moved to later in the process after the
internal state has been updated so calling 'isConnected()' is what you'd
expect.
2024-08-11 20:32:32 +02:00
tomFlowee 69e275ae4c Add connection-id in debug output
In the networkmanager it may get confusing to see lines without knowing
which connection actually created it. So we add the connection id.
2024-08-11 20:32:32 +02:00
tomFlowee 8c31f8d004 Revert "Make simpler"
This reverts commit e28b5e1823.

The port number is again passed through the dns lookup, which is
weird as fuck but needed to get the actual resulting iterator still
have the port numebr we wanted to connect to.
2024-08-11 19:37:21 +02:00
tomFlowee b84a934977 comments 2024-08-11 18:49:35 +02:00
tomFlowee 93c413a004 Make simple (plain) stuff work again. 2024-08-11 18:49:35 +02:00
tomFlowee f0d426dc90 make compile 2024-08-11 18:49:35 +02:00
tomFlowee d2ce7e61d2 Refactor socket to live in a wrapping class. 2024-08-11 18:49:35 +02:00
tomFlowee 712dcdb3a6 Start to implement the ssl server. 2024-08-11 18:49:35 +02:00
tomFlowee b4e90cf945 Add ssl lib to networkmanager 2024-08-11 18:49:35 +02:00
tomFlowee 210fef16cc Start making space for an ssl backend. 2024-08-11 18:49:35 +02:00
tomFlowee e28b5e1823 Make simpler 2024-05-01 21:54:22 +02:00
tomFlowee ee354b62d1 Avoid repeating myself. 2024-02-12 21:29:33 +01:00
tomFlowee eace700859 Add EndPoint::isOutgoing() -> bool & isIncomimg() 2024-01-24 21:06:25 +01:00
tomFlowee 4fe9d69e7b Use more specific define-guards 2024-01-24 21:03:58 +01:00