Commit Graph

107 Commits

Author SHA1 Message Date
tomFlowee 9025a2e2ea Add DoubleSpendService to listen to all double spend notifications 2021-03-16 19:53:14 +01:00
tomFlowee 4d5e7bfb09 Protect node with user-limits for the API.
This introduces several options for public node operators to limit their
nodes usage by 3rd parties, this is aimed at usage of resource-hungry
areas.

We allow limiting the amount of connections any single IP can keep open
with us.
We limit the amount of reconnects we allow in a short number of seconds.
We allow limiting the number of addresses (or scriptHashes) a peer can
register for the node to scan.
The last one is for both the addressMonitorService as well as for the
getBlock filters.

For node operators these items become available using command line
options or config-file options. By default these limits are unlimited as
we assume default usage to be private.
2021-02-26 15:14:14 +01:00
TomZ 3dbb2672b9 Api Docs 2021-02-22 15:53:32 +01:00
TomZ 046c956230 Avoid sideeffects after a move. 2021-02-22 15:52:34 +01:00
tomFlowee b83fd08789 Add chainReorged msg to BlockNotificationService
When blocks are reverted clients likely want to know. This gives them
the information the moment it becomes clear.
2021-02-19 13:43:56 +01:00
tomFlowee abfc90d99a assert -> if 2021-02-17 22:59:35 +01:00
tomFlowee 0824cabbee Sanitize log
Seems some systems are not happy if we print a string that has zeros in it.
This sanitizes the message to replace zeros with spaces.
2021-02-03 13:13:21 +01:00
tomFlowee 3fe98afce9 Minor cleanup
This removes some unused includes from common headers and dead code
from some C++ files.
2021-01-05 22:05:25 +01:00
tomFlowee 9748d3988f Cleanups and improvements. 2020-12-25 23:51:06 +01:00
tomFlowee e89e3fe8ac Add license text
All sources should have a license text at the top of each file
2020-12-25 23:45:03 +01:00
TomZ 4054b9a7d4 Avoid (re)connecting to incoming peer. 2020-10-26 18:21:52 +01:00
TomZ ff58ae6a36 Implement the first ASync API command
This implements the sendTransaction command using the async framework,
allowing clients to benefit from multi-core systems to process
transactions in parallel when being submitted to the Hub.
2020-10-26 18:21:52 +01:00
TomZ cd6937a672 Set the proper default log section specific libs 2020-10-25 23:43:42 +01:00
TomZ 331f1ec773 Fix regression in NWM that disconnects sometimes
This fixes the logic that finds out it should resume an interrupted
process. The code had false positives in case of a message split over
multiple TCP frames.
2020-10-25 23:42:49 +01:00
TomZ 3b553fd80b Make sure we handle a close() correctly.
When we close() the receiveStream is cleared and we should not be
reading from it after. So detect and handle this.
2020-09-17 21:51:37 +02:00
TomZ 7afefefa41 Improve NWM flow-control
The NetworkManager now has more mature flow-control which means that we
send our buffers more regularly and we delay parsing received data if the
sending takes too long.

The direct effect should be that creating of a large number of messages
in response to incoming messages is no longer a problem in many cases.
2020-09-17 21:04:28 +02:00
TomZ 84ee1bc3fe Minor: comments and whitespace. 2020-09-17 20:53:56 +02:00
TomZ f0375c09a7 Fix bad memory access on sending prio message
Don't ask the size of an unitialized buffer.
2020-09-17 20:51:06 +02:00
TomZ 713697525a A network buffer maximum size of 6MB sounds fine for a server.
This is for the connection to the hub/indexer, so not for the incoming
clients.
Increasing the size allows much larger traffic without delay.
2020-09-02 13:47:32 +02:00
TomZ bd2a06a9ff Add a save to match the load Addr. 2020-05-11 13:24:06 +02:00
TomZ 79a92cf2ce NWM: work better with large concurrency
The asio stuff is quite broken when it comes to, ironically,
concurrency.
Connecting to peers lead to lots of 'canceled' (sic) errors being
generated internally in asio and other such issues.
Even though they were called on separate objects.

Adding a mutex around the async_connect calls made the amount of
failures go down dramatically.

This patch also includes upgrading boost::mutex to the std-lib
versions.
2020-05-11 13:19:10 +02:00
TomZ ed5b100ca5 Delete ununsed connections on shutdown. 2020-05-10 22:03:22 +02:00
TomZ 0b3dc7a8f5 NWM: fix reconnects/reuse of connection 2020-05-10 16:02:14 +02:00
TomZ 00453d52c4 NWM: Reuse connection objects
Avoid deleting and creating connections, which is really a rather rare
event anyway, and simply remember the connection object and reuse it
when a new one is requested.
2020-05-10 16:01:08 +02:00
TomZ d49b1ae5e2 Make NetworkManager connections leaner
The NetworkManager usage was mostly for low connection counts and this
made defaults selection easy.
With more usages it is important to allow the NWM-connection to be more
configurable about memory usage and leaner in general.

This changes the headers-buffers (used to create envelopes) to not be per
connection anymore but per thread using the tread_local keyword.

This changes the ring-buffers to become configurable using
NetworkConnections::setMessageQueueSizes().

Also removing some include statements where they were not really needed
in the P2PNet lib.
2020-05-09 20:23:05 +02:00
TomZ 5bb095f8a2 Minor fixes in usage of shared pointers. 2020-05-07 18:26:41 +02:00
TomZ 9a78e770ac P2PNet: handle errors better
This changes handling to also remove peers that fail with:
  "Cannot assign requested address"
An error seen in a Docker container on a system supporting IPv6.

Additionally we now always assign a error level so an unknown error will
still cause the node to be banned after 5 attempts.
2020-05-07 16:07:12 +02:00
TomZ 488e9b4322 Add missing dependency 2020-05-07 14:04:57 +02:00
TomZ fb6f91bf79 Simplify p2pnet ownership
Make the Peer object be owned by a shared pointer.
2020-05-05 22:53:25 +02:00
TomZ bf76c5ab36 Write all bytes after command to zero.
Instead of just a single trailing zero, write all bytes of the
command-section. This is required by the protocol.
2020-05-05 10:54:26 +02:00
TomZ 3f16f6224a Fix the threading model in the P2PNet
This allows deletion of peers also from other threads than their own
assigned ones.
2020-05-03 21:02:45 +02:00
TomZ e5ee37fd87 Fix larger messages in LegacyP2P mode.
Splitting up the bigger message in chunks is not supported on the legacy
p2p network, so don't attempt.
2020-04-16 17:12:57 +02:00
TomZ 436535647f Add several new features to networkmanager
Allow user to shutdown a connection, making it instantly invalid.
Allow user to register a callback for errors.
And fix pinging to be disabled on legacyP2P style connections.
2020-04-01 20:24:04 +02:00
TomZ 24e557f566 Stop double applying of offset.
We already removed the bytes in Message::header()
2020-04-01 20:22:55 +02:00
TomZ 655179e660 Add EndPoint::from() from a byte-array
This is used on the p2p layer and this allows simple
integration.
2020-04-01 20:22:55 +02:00
TomZ 7b1b742036 Remove workaround for old boost version
The API changes in boost between 1.66 and later was the need
for the boost_compat.h header file.
Its been a long time since Flowee started demanding 1.67 minimum
for boost, making this compat obsolete.
2020-03-29 12:55:12 +02:00
TomZ bf24ed042b Add support for legacy p2p network envelope in networkmanager 2020-03-29 12:55:12 +02:00
TomZ e042fb90f5 Cancel timer on shutdown 2020-01-12 18:05:09 +01:00
TomZ aef124e523 Merge branch '2019.10' 2019-12-17 17:58:34 +01:00
TomZ 1143a71a92 Fix assignment typo 2019-12-17 17:57:08 +01:00
TomZ f4d8870001 NWM: tweaks to logs. 2019-12-17 17:36:15 +01:00
TomZ 8c842fa108 Catch exceptions on usage of socket
This should fix the issue where the NWM stopped listening due to us not
calling the proper setupCallback()

Also add some logging.
2019-12-11 23:47:21 +01:00
TomZ 152efb2c5d Print more details on making NWM connection. 2019-11-29 20:09:28 +01:00
TomZ a471d919eb Improve logging of not-acceptable connections
Log IP of remote that tries to talk to us but doesn't know the protocol.
2019-11-29 10:59:58 +01:00
TomZ e7ad998d57 Add -fPIC to installed libs 2019-11-04 14:20:50 +01:00
TomZ 83d455a5d4 Help devops with more info. 2019-08-29 22:33:57 +02:00
TomZ 191bc3758d Add a simpliefied NetworkManager::bind() method
One that doesn't require a callback to be passed in.
2019-08-24 22:25:10 +02:00
TomZ df7de2ecd2 Clean up the hairy ball of util.cpp
Move some globals and all stuff pulling in crypto to the
server/serverutil.cpp file

Remove dead code.

Move several items that were used in only one place to the respective
files using them.

Move the class WaitUntilFinishedHelper into its own file.

Made sure no header includes utils.h
remove a handfull of files including utils.h for nothing.
2019-08-24 22:25:09 +02:00
TomZ 9faf50029e Fix typo 2019-08-24 22:25:09 +02:00
TomZ 2bb06afa9e Cleanup the link-lines 2019-08-24 22:25:09 +02:00