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.
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.
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.
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.
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.
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.
A connection that is 'shutdown' now ensures one more time we'll call
onDisconnected() (is it was..) allowing the application level logic to
get notified and avoid memory leaks.
When the user-layer triggers a re-connect instead of waiting for the
layer to re-connect then we should avoid doing work twice.
This also avoids a reconnect in some cases.
As we moved most of the creation of a BufferPool to be via the
Streaming::pool() method, which uses a thread-local, it makes sense
to start cleaning up the design and make it more modern C++.
The above mentioned method would return a reference and you'd see
loads of places use `auto &pool =` which is less than ideal.
As the number of places where we actually instantiate a BufferPool
goes down, the usage of some sort of smart pointer makes more sense.
This now makes all APIs use BufferPool be wrapped in a shared_ptr.
Avoid massive connect storm.
Using the network manager based logger we got into a fun situation where
logging to a remote host caused us to connect and fail, which caused us
to log this failed which made us try to connect and .. etc.