deny traffic to non whitelisted routers. (#1444)

* deny message delivery from non registered nodes when whitelist is enabled and applicable

* use DoCallback and return true so that the event gets fired right
pull/1442/head
Jeff 4 years ago committed by GitHub
parent 87c76a6769
commit ff02e62a79
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -6,6 +6,7 @@
#include <constants/link_layer.hpp>
#include <util/meta/memfn.hpp>
#include <util/status.hpp>
#include <router/i_rc_lookup_handler.hpp>
#include <algorithm>
#include <cstdlib>
@ -22,6 +23,12 @@ namespace llarp
OutboundMessageHandler::QueueMessage(
const RouterID& remote, const ILinkMessage* msg, SendStatusHandler callback)
{
if (not _lookupHandler->RemoteIsAllowed(remote))
{
DoCallback(callback, SendStatus::InvalidRouter);
return true;
}
const uint16_t priority = msg->Priority();
std::array<byte_t, MAX_LINK_MSG_SIZE> linkmsg_buffer;
llarp_buffer_t buf(linkmsg_buffer);
@ -105,9 +112,11 @@ namespace llarp
}
void
OutboundMessageHandler::Init(ILinkManager* linkManager, std::shared_ptr<Logic> logic)
OutboundMessageHandler::Init(
ILinkManager* linkManager, I_RCLookupHandler* lookupHandler, std::shared_ptr<Logic> logic)
{
_linkManager = linkManager;
_lookupHandler = lookupHandler;
_logic = logic;
outboundMessageQueues.emplace(zeroID, MessageQueue());

@ -17,6 +17,7 @@ struct llarp_buffer_t;
namespace llarp
{
struct I_RCLookupHandler;
struct ILinkManager;
class Logic;
enum class SessionResult;
@ -42,7 +43,7 @@ namespace llarp
ExtractStatus() const override;
void
Init(ILinkManager* linkManager, std::shared_ptr<Logic> logic);
Init(ILinkManager* linkManager, I_RCLookupHandler* lookupHandler, std::shared_ptr<Logic> logic);
private:
using Message = std::pair<std::vector<byte_t>, SendStatusHandler>;
@ -137,6 +138,7 @@ namespace llarp
std::queue<PathID_t> roundRobinOrder;
ILinkManager* _linkManager;
I_RCLookupHandler* _lookupHandler;
std::shared_ptr<Logic> _logic;
util::ContentionKiller m_Killer;

@ -551,7 +551,7 @@ namespace llarp
LogInfo("Loaded ", bootstrapRCList.size(), " bootstrap routers");
// Init components after relevant config settings loaded
_outboundMessageHandler.Init(&_linkManager, _logic);
_outboundMessageHandler.Init(&_linkManager, &_rcLookupHandler, _logic);
_outboundSessionMaker.Init(
this,
&_linkManager,

Loading…
Cancel
Save