mirror of https://github.com/oxen-io/lokinet
Convert llarp_router to be a true C++ class
This commit is contained in:
parent
2d833211ba
commit
f0fce5b68a
|
@ -1,5 +1,6 @@
|
|||
#include <unistd.h>
|
||||
#include <llarp.h>
|
||||
#include <llarp/config.h>
|
||||
#include <llarp/dns_iptracker.hpp>
|
||||
#include <llarp/dnsd.hpp>
|
||||
#include <llarp/dns_dotlokilookup.hpp>
|
||||
|
|
|
@ -3,15 +3,16 @@
|
|||
#include <signal.h>
|
||||
#include "logger.hpp"
|
||||
|
||||
#include <llarp/nodedb.hpp>
|
||||
#include <llarp/router_contact.hpp>
|
||||
#include <llarp/time.hpp>
|
||||
#include <router.hpp>
|
||||
|
||||
#include <fstream>
|
||||
#include "buffer.hpp"
|
||||
#include "crypto.hpp"
|
||||
#include "fs.hpp"
|
||||
#include "llarp/net.hpp"
|
||||
#include "router.hpp"
|
||||
|
||||
#include <llarp/messages/dht.hpp>
|
||||
|
||||
|
|
|
@ -8,6 +8,9 @@
|
|||
#include <vector>
|
||||
#include <llarp/crypto.h>
|
||||
|
||||
struct llarp_config;
|
||||
struct llarp_config_iterator;
|
||||
|
||||
namespace llarp
|
||||
{
|
||||
struct Context
|
||||
|
@ -17,7 +20,7 @@ namespace llarp
|
|||
int num_nethreads = 1;
|
||||
bool singleThreaded = false;
|
||||
llarp_crypto crypto;
|
||||
llarp_router *router = nullptr;
|
||||
llarp::Router *router = nullptr;
|
||||
llarp_threadpool *worker = nullptr;
|
||||
llarp::Logic *logic = nullptr;
|
||||
llarp_config *config = nullptr;
|
||||
|
|
|
@ -2,7 +2,6 @@
|
|||
#define LLARP_DHT_H_
|
||||
|
||||
#include <llarp/buffer.h>
|
||||
#include <llarp/router.h>
|
||||
#include <llarp/crypto.hpp>
|
||||
#include <llarp/router_contact.hpp>
|
||||
|
||||
|
@ -14,9 +13,11 @@
|
|||
|
||||
struct llarp_dht_context;
|
||||
|
||||
namespace llarp { struct Router; }
|
||||
|
||||
/// allocator
|
||||
struct llarp_dht_context*
|
||||
llarp_dht_context_new(struct llarp_router* parent);
|
||||
llarp_dht_context_new(llarp::Router* parent);
|
||||
|
||||
/// deallocator
|
||||
void
|
||||
|
@ -37,7 +38,6 @@ struct llarp_router_lookup_job
|
|||
void* user;
|
||||
llarp_router_lookup_handler hook;
|
||||
struct llarp_dht_context* dht;
|
||||
// byte_t target[PUBKEYSIZE];
|
||||
llarp::PubKey target;
|
||||
bool found;
|
||||
// make sure you initialize addr and exits
|
||||
|
|
|
@ -7,7 +7,6 @@
|
|||
#include <llarp/dht/message.hpp>
|
||||
#include <llarp/dht/messages/findintro.hpp>
|
||||
#include <llarp/dht/node.hpp>
|
||||
#include <llarp/router.h>
|
||||
#include <llarp/service/IntroSet.hpp>
|
||||
#include <llarp/time.hpp>
|
||||
|
||||
|
@ -15,6 +14,8 @@
|
|||
|
||||
namespace llarp
|
||||
{
|
||||
struct Router;
|
||||
|
||||
namespace dht
|
||||
{
|
||||
struct TXOwner
|
||||
|
@ -234,7 +235,7 @@ namespace llarp
|
|||
|
||||
/// initialize dht context and explore every exploreInterval milliseconds
|
||||
void
|
||||
Init(const Key_t& us, llarp_router* router, llarp_time_t exploreInterval);
|
||||
Init(const Key_t& us, llarp::Router* router, llarp_time_t exploreInterval);
|
||||
|
||||
/// get localally stored introset by service address
|
||||
const llarp::service::IntroSet*
|
||||
|
@ -250,7 +251,7 @@ namespace llarp
|
|||
void
|
||||
Explore(size_t N = 3);
|
||||
|
||||
llarp_router* router = nullptr;
|
||||
llarp::Router* router = nullptr;
|
||||
// for router contacts
|
||||
Bucket< RCNode >* nodes = nullptr;
|
||||
|
||||
|
@ -427,8 +428,8 @@ namespace llarp
|
|||
struct llarp_dht_context
|
||||
{
|
||||
llarp::dht::Context impl;
|
||||
llarp_router* parent;
|
||||
llarp_dht_context(llarp_router* router);
|
||||
llarp::Router* parent;
|
||||
llarp_dht_context(llarp::Router* router);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -24,7 +24,7 @@ namespace llarp
|
|||
|
||||
virtual bool
|
||||
HandleMessage(
|
||||
llarp_dht_context* dht,
|
||||
struct llarp_dht_context* dht,
|
||||
std::vector< std::unique_ptr< IMessage > >& replies) const = 0;
|
||||
|
||||
Key_t From;
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
#ifndef LLARP_DHT_MESSAGES_FIND_INTRO_HPP
|
||||
#define LLARP_DHT_MESSAGES_FIND_INTRO_HPP
|
||||
#include <llarp/dht/message.hpp>
|
||||
#include <llarp/routing/message.hpp>
|
||||
#include <llarp/service/address.hpp>
|
||||
#include <llarp/service/tag.hpp>
|
||||
|
||||
|
|
|
@ -4,7 +4,6 @@
|
|||
#include <string>
|
||||
#include <unordered_map>
|
||||
#include <llarp/handlers/exit.hpp>
|
||||
#include <llarp/router.h>
|
||||
|
||||
namespace llarp
|
||||
{
|
||||
|
@ -15,7 +14,7 @@ namespace llarp
|
|||
{
|
||||
using Config_t = std::unordered_multimap< std::string, std::string >;
|
||||
|
||||
Context(llarp_router *r);
|
||||
Context(llarp::Router *r);
|
||||
~Context();
|
||||
|
||||
void
|
||||
|
@ -43,7 +42,7 @@ namespace llarp
|
|||
CalculateExitTraffic(TrafficStats &stats);
|
||||
|
||||
private:
|
||||
llarp_router *m_Router;
|
||||
llarp::Router *m_Router;
|
||||
std::unordered_map< std::string,
|
||||
std::unique_ptr< llarp::handlers::ExitEndpoint > >
|
||||
m_Exits;
|
||||
|
@ -51,4 +50,4 @@ namespace llarp
|
|||
} // namespace exit
|
||||
} // namespace llarp
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
|
|
@ -2,7 +2,6 @@
|
|||
#define LLARP_EXIT_ENDPOINT_HPP
|
||||
#include <llarp/time.hpp>
|
||||
#include <llarp/crypto.hpp>
|
||||
#include <llarp/router.h>
|
||||
#include <llarp/path.hpp>
|
||||
#include <llarp/ip.hpp>
|
||||
|
||||
|
|
|
@ -17,7 +17,7 @@ namespace llarp
|
|||
|
||||
BaseSession(const llarp::RouterID& exitRouter,
|
||||
std::function< bool(llarp_buffer_t) > writepkt,
|
||||
llarp_router* r, size_t numpaths, size_t hoplen);
|
||||
llarp::Router* r, size_t numpaths, size_t hoplen);
|
||||
|
||||
virtual ~BaseSession();
|
||||
|
||||
|
@ -76,7 +76,7 @@ namespace llarp
|
|||
{
|
||||
ExitSession(const llarp::RouterID& snodeRouter,
|
||||
std::function< bool(llarp_buffer_t) > writepkt,
|
||||
llarp_router* r, size_t numpaths, size_t hoplen)
|
||||
llarp::Router* r, size_t numpaths, size_t hoplen)
|
||||
: BaseSession(snodeRouter, writepkt, r, numpaths, hoplen){};
|
||||
|
||||
~ExitSession(){};
|
||||
|
@ -95,7 +95,7 @@ namespace llarp
|
|||
{
|
||||
SNodeSession(const llarp::RouterID& snodeRouter,
|
||||
std::function< bool(llarp_buffer_t) > writepkt,
|
||||
llarp_router* r, size_t numpaths, size_t hoplen)
|
||||
llarp::Router* r, size_t numpaths, size_t hoplen)
|
||||
: BaseSession(snodeRouter, writepkt, r, numpaths, hoplen){};
|
||||
|
||||
~SNodeSession(){};
|
||||
|
|
|
@ -11,7 +11,7 @@ namespace llarp
|
|||
{
|
||||
struct ExitEndpoint
|
||||
{
|
||||
ExitEndpoint(const std::string& name, llarp_router* r);
|
||||
ExitEndpoint(const std::string& name, llarp::Router* r);
|
||||
~ExitEndpoint();
|
||||
|
||||
void
|
||||
|
@ -41,7 +41,7 @@ namespace llarp
|
|||
void
|
||||
OnInetPacket(llarp_buffer_t buf);
|
||||
|
||||
llarp_router*
|
||||
llarp::Router*
|
||||
Router();
|
||||
|
||||
llarp_time_t
|
||||
|
@ -100,7 +100,7 @@ namespace llarp
|
|||
void
|
||||
KickIdentOffExit(const llarp::PubKey& pk);
|
||||
|
||||
llarp_router* m_Router;
|
||||
llarp::Router* m_Router;
|
||||
bool m_ShouldInitTun;
|
||||
std::string m_Name;
|
||||
bool m_PermitExit;
|
||||
|
|
|
@ -8,7 +8,7 @@ namespace llarp
|
|||
{
|
||||
struct NullEndpoint final : public llarp::service::Endpoint
|
||||
{
|
||||
NullEndpoint(const std::string &name, llarp_router *r)
|
||||
NullEndpoint(const std::string &name, llarp::Router *r)
|
||||
: llarp::service::Endpoint(name, r){};
|
||||
|
||||
bool HandleWriteIPPacket(llarp_buffer_t,
|
||||
|
@ -32,4 +32,4 @@ namespace llarp
|
|||
} // namespace handlers
|
||||
} // namespace llarp
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
|
|
@ -19,7 +19,7 @@ namespace llarp
|
|||
|
||||
struct TunEndpoint : public service::Endpoint, public dns::IQueryHandler
|
||||
{
|
||||
TunEndpoint(const std::string& nickname, llarp_router* r);
|
||||
TunEndpoint(const std::string& nickname, llarp::Router* r);
|
||||
~TunEndpoint();
|
||||
|
||||
virtual bool
|
||||
|
|
|
@ -3,12 +3,17 @@
|
|||
#include <llarp/crypto.h>
|
||||
#include <string>
|
||||
|
||||
namespace llarp {
|
||||
class Logic;
|
||||
struct Router;
|
||||
}
|
||||
|
||||
struct llarp_iwp_args
|
||||
{
|
||||
struct llarp_crypto* crypto;
|
||||
llarp::Logic* logic;
|
||||
struct llarp_threadpool* cryptoworker;
|
||||
struct llarp_router* router;
|
||||
struct llarp::Router* router;
|
||||
bool permitInbound;
|
||||
};
|
||||
|
||||
|
|
|
@ -8,7 +8,7 @@ namespace llarp
|
|||
namespace curvecp
|
||||
{
|
||||
std::unique_ptr< ILinkLayer >
|
||||
NewServer(llarp_router* r);
|
||||
NewServer(llarp::Router* r);
|
||||
}
|
||||
} // namespace llarp
|
||||
|
||||
|
|
|
@ -10,10 +10,10 @@
|
|||
#include <llarp/logic.hpp>
|
||||
#include <list>
|
||||
|
||||
struct llarp_router;
|
||||
|
||||
namespace llarp
|
||||
{
|
||||
struct Router;
|
||||
|
||||
struct ILinkLayer
|
||||
{
|
||||
virtual ~ILinkLayer();
|
||||
|
|
|
@ -8,7 +8,7 @@ namespace llarp
|
|||
namespace utp
|
||||
{
|
||||
std::unique_ptr< ILinkLayer >
|
||||
NewServer(llarp_router* r);
|
||||
NewServer(llarp::Router* r);
|
||||
}
|
||||
} // namespace llarp
|
||||
|
||||
|
|
|
@ -8,11 +8,10 @@
|
|||
#include <queue>
|
||||
#include <vector>
|
||||
|
||||
struct llarp_router;
|
||||
|
||||
namespace llarp
|
||||
{
|
||||
struct ILinkSession;
|
||||
struct Router;
|
||||
|
||||
using SendQueue = std::queue< ILinkMessage* >;
|
||||
|
||||
|
@ -35,12 +34,12 @@ namespace llarp
|
|||
}
|
||||
|
||||
virtual bool
|
||||
HandleMessage(llarp_router* router) const = 0;
|
||||
HandleMessage(Router* router) const = 0;
|
||||
};
|
||||
|
||||
struct InboundMessageParser
|
||||
{
|
||||
InboundMessageParser(llarp_router* router);
|
||||
InboundMessageParser(Router* router);
|
||||
dict_reader reader;
|
||||
|
||||
static bool
|
||||
|
@ -65,7 +64,7 @@ namespace llarp
|
|||
|
||||
private:
|
||||
bool firstkey;
|
||||
llarp_router* router;
|
||||
Router* router;
|
||||
ILinkSession* from = nullptr;
|
||||
std::unique_ptr< ILinkMessage > msg;
|
||||
};
|
||||
|
|
|
@ -23,7 +23,7 @@ namespace llarp
|
|||
BEncode(llarp_buffer_t* buf) const override;
|
||||
|
||||
bool
|
||||
HandleMessage(IMessageHandler* h, llarp_router* r) const override;
|
||||
HandleMessage(IMessageHandler* h, llarp::Router* r) const override;
|
||||
};
|
||||
} // namespace routing
|
||||
} // namespace llarp
|
||||
|
|
|
@ -27,7 +27,7 @@ namespace llarp
|
|||
BEncode(llarp_buffer_t* buf) const;
|
||||
|
||||
bool
|
||||
HandleMessage(llarp_router* router) const;
|
||||
HandleMessage(llarp::Router* router) const;
|
||||
};
|
||||
} // namespace llarp
|
||||
|
||||
|
|
|
@ -43,7 +43,7 @@ namespace llarp
|
|||
}
|
||||
|
||||
bool
|
||||
HandleMessage(__attribute__((unused)) llarp_router* router) const override
|
||||
HandleMessage(__attribute__((unused)) llarp::Router* router) const override
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
@ -66,7 +66,7 @@ namespace llarp
|
|||
}
|
||||
|
||||
bool
|
||||
HandleMessage(IMessageHandler* h, llarp_router* r) const override
|
||||
HandleMessage(IMessageHandler* h, llarp::Router* r) const override
|
||||
{
|
||||
return h->HandleDataDiscardMessage(this, r);
|
||||
}
|
||||
|
|
|
@ -44,7 +44,7 @@ namespace llarp
|
|||
DecodeKey(llarp_buffer_t key, llarp_buffer_t* buf) override;
|
||||
|
||||
bool
|
||||
HandleMessage(IMessageHandler* h, llarp_router* r) const override;
|
||||
HandleMessage(IMessageHandler* h, llarp::Router* r) const override;
|
||||
};
|
||||
|
||||
struct GrantExitMessage final : public IMessage
|
||||
|
@ -77,7 +77,7 @@ namespace llarp
|
|||
DecodeKey(llarp_buffer_t key, llarp_buffer_t* buf) override;
|
||||
|
||||
bool
|
||||
HandleMessage(IMessageHandler* h, llarp_router* r) const override;
|
||||
HandleMessage(IMessageHandler* h, llarp::Router* r) const override;
|
||||
};
|
||||
|
||||
struct RejectExitMessage final : public IMessage
|
||||
|
@ -113,7 +113,7 @@ namespace llarp
|
|||
DecodeKey(llarp_buffer_t key, llarp_buffer_t* buf) override;
|
||||
|
||||
bool
|
||||
HandleMessage(IMessageHandler* h, llarp_router* r) const override;
|
||||
HandleMessage(IMessageHandler* h, llarp::Router* r) const override;
|
||||
};
|
||||
|
||||
struct UpdateExitVerifyMessage final : public IMessage
|
||||
|
@ -147,7 +147,7 @@ namespace llarp
|
|||
DecodeKey(llarp_buffer_t key, llarp_buffer_t* buf) override;
|
||||
|
||||
bool
|
||||
HandleMessage(IMessageHandler* h, llarp_router* r) const override;
|
||||
HandleMessage(IMessageHandler* h, llarp::Router* r) const override;
|
||||
};
|
||||
|
||||
struct UpdateExitMessage final : public IMessage
|
||||
|
@ -182,7 +182,7 @@ namespace llarp
|
|||
DecodeKey(llarp_buffer_t key, llarp_buffer_t* buf) override;
|
||||
|
||||
bool
|
||||
HandleMessage(IMessageHandler* h, llarp_router* r) const override;
|
||||
HandleMessage(IMessageHandler* h, llarp::Router* r) const override;
|
||||
};
|
||||
|
||||
struct CloseExitMessage final : public IMessage
|
||||
|
@ -210,7 +210,7 @@ namespace llarp
|
|||
DecodeKey(llarp_buffer_t key, llarp_buffer_t* buf) override;
|
||||
|
||||
bool
|
||||
HandleMessage(IMessageHandler* h, llarp_router* r) const override;
|
||||
HandleMessage(IMessageHandler* h, llarp::Router* r) const override;
|
||||
|
||||
bool
|
||||
Sign(llarp_crypto* c, const llarp::SecretKey& sk);
|
||||
|
@ -222,4 +222,4 @@ namespace llarp
|
|||
} // namespace routing
|
||||
} // namespace llarp
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
|
|
@ -35,7 +35,7 @@ namespace llarp
|
|||
BEncode(llarp_buffer_t* buf) const;
|
||||
|
||||
bool
|
||||
HandleMessage(llarp_router* router) const;
|
||||
HandleMessage(llarp::Router* router) const;
|
||||
|
||||
bool
|
||||
Sign(llarp_crypto* c, const SecretKey& signKeySecret);
|
||||
|
|
|
@ -22,7 +22,7 @@ namespace llarp
|
|||
DecodeKey(llarp_buffer_t key, llarp_buffer_t* val) override;
|
||||
|
||||
bool
|
||||
HandleMessage(IMessageHandler* h, llarp_router* r) const override;
|
||||
HandleMessage(IMessageHandler* h, llarp::Router* r) const override;
|
||||
};
|
||||
} // namespace routing
|
||||
} // namespace llarp
|
||||
|
|
|
@ -20,7 +20,7 @@ namespace llarp
|
|||
DecodeKey(llarp_buffer_t key, llarp_buffer_t* val) override;
|
||||
|
||||
bool
|
||||
HandleMessage(IMessageHandler* h, llarp_router* r) const override;
|
||||
HandleMessage(IMessageHandler* h, llarp::Router* r) const override;
|
||||
};
|
||||
} // namespace routing
|
||||
} // namespace llarp
|
||||
|
|
|
@ -31,7 +31,7 @@ namespace llarp
|
|||
BEncode(llarp_buffer_t* buf) const override;
|
||||
|
||||
bool
|
||||
HandleMessage(IMessageHandler*, llarp_router* r) const override;
|
||||
HandleMessage(IMessageHandler*, llarp::Router* r) const override;
|
||||
};
|
||||
|
||||
} // namespace routing
|
||||
|
|
|
@ -26,7 +26,7 @@ namespace llarp
|
|||
BEncode(llarp_buffer_t* buf) const;
|
||||
|
||||
bool
|
||||
HandleMessage(llarp_router* router) const;
|
||||
HandleMessage(llarp::Router* router) const;
|
||||
};
|
||||
|
||||
struct RelayDownstreamMessage : public ILinkMessage
|
||||
|
@ -45,7 +45,7 @@ namespace llarp
|
|||
BEncode(llarp_buffer_t* buf) const;
|
||||
|
||||
bool
|
||||
HandleMessage(llarp_router* router) const;
|
||||
HandleMessage(llarp::Router* router) const;
|
||||
};
|
||||
} // namespace llarp
|
||||
|
||||
|
|
|
@ -67,7 +67,7 @@ namespace llarp
|
|||
BEncode(llarp_buffer_t *buf) const;
|
||||
|
||||
bool
|
||||
HandleMessage(llarp_router *router) const;
|
||||
HandleMessage(llarp::Router *router) const;
|
||||
|
||||
bool
|
||||
AsyncDecrypt(llarp::path::PathContext *context) const;
|
||||
|
|
|
@ -36,9 +36,9 @@ namespace llarp
|
|||
DecodeKey(llarp_buffer_t k, llarp_buffer_t* val) override;
|
||||
|
||||
bool
|
||||
HandleMessage(IMessageHandler* h, llarp_router* r) const override;
|
||||
HandleMessage(IMessageHandler* h, llarp::Router* r) const override;
|
||||
};
|
||||
} // namespace routing
|
||||
} // namespace llarp
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
#ifndef LLARP_PATH_HPP
|
||||
#define LLARP_PATH_HPP
|
||||
#include <llarp/router.h>
|
||||
#include <llarp/time.hpp>
|
||||
#include <llarp/aligned.hpp>
|
||||
#include <llarp/crypto.hpp>
|
||||
|
@ -110,17 +109,17 @@ namespace llarp
|
|||
/// send routing message and increment sequence number
|
||||
virtual bool
|
||||
SendRoutingMessage(const llarp::routing::IMessage* msg,
|
||||
llarp_router* r) = 0;
|
||||
llarp::Router* r) = 0;
|
||||
|
||||
// handle data in upstream direction
|
||||
virtual bool
|
||||
HandleUpstream(llarp_buffer_t X, const TunnelNonce& Y,
|
||||
llarp_router* r) = 0;
|
||||
llarp::Router* r) = 0;
|
||||
|
||||
// handle data in downstream direction
|
||||
virtual bool
|
||||
HandleDownstream(llarp_buffer_t X, const TunnelNonce& Y,
|
||||
llarp_router* r) = 0;
|
||||
llarp::Router* r) = 0;
|
||||
|
||||
uint64_t
|
||||
NextSeqNo()
|
||||
|
@ -176,55 +175,55 @@ namespace llarp
|
|||
// send routing message when end of path
|
||||
bool
|
||||
SendRoutingMessage(const llarp::routing::IMessage* msg,
|
||||
llarp_router* r) override;
|
||||
llarp::Router* r) override;
|
||||
|
||||
// handle routing message when end of path
|
||||
bool
|
||||
HandleRoutingMessage(const llarp::routing::IMessage* msg,
|
||||
llarp_router* r);
|
||||
llarp::Router* r);
|
||||
|
||||
bool
|
||||
HandleDataDiscardMessage(const llarp::routing::DataDiscardMessage* msg,
|
||||
llarp_router* r) override;
|
||||
llarp::Router* r) override;
|
||||
|
||||
bool
|
||||
HandlePathConfirmMessage(const llarp::routing::PathConfirmMessage* msg,
|
||||
llarp_router* r) override;
|
||||
llarp::Router* r) override;
|
||||
bool
|
||||
HandlePathTransferMessage(const llarp::routing::PathTransferMessage* msg,
|
||||
llarp_router* r) override;
|
||||
llarp::Router* r) override;
|
||||
bool
|
||||
HandlePathLatencyMessage(const llarp::routing::PathLatencyMessage* msg,
|
||||
llarp_router* r) override;
|
||||
llarp::Router* r) override;
|
||||
|
||||
bool
|
||||
HandleObtainExitMessage(const llarp::routing::ObtainExitMessage* msg,
|
||||
llarp_router* r) override;
|
||||
llarp::Router* r) override;
|
||||
|
||||
bool
|
||||
HandleUpdateExitVerifyMessage(
|
||||
const llarp::routing::UpdateExitVerifyMessage* msg,
|
||||
llarp_router* r) override;
|
||||
llarp::Router* r) override;
|
||||
|
||||
bool
|
||||
HandleTransferTrafficMessage(
|
||||
const llarp::routing::TransferTrafficMessage* msg,
|
||||
llarp_router* r) override;
|
||||
llarp::Router* r) override;
|
||||
|
||||
bool
|
||||
HandleUpdateExitMessage(const llarp::routing::UpdateExitMessage* msg,
|
||||
llarp_router* r) override;
|
||||
llarp::Router* r) override;
|
||||
|
||||
bool
|
||||
HandleGrantExitMessage(const llarp::routing::GrantExitMessage* msg,
|
||||
llarp_router* r) override;
|
||||
llarp::Router* r) override;
|
||||
bool
|
||||
HandleRejectExitMessage(const llarp::routing::RejectExitMessage* msg,
|
||||
llarp_router* r) override;
|
||||
llarp::Router* r) override;
|
||||
|
||||
bool
|
||||
HandleCloseExitMessage(const llarp::routing::CloseExitMessage* msg,
|
||||
llarp_router* r) override;
|
||||
llarp::Router* r) override;
|
||||
|
||||
bool
|
||||
HandleHiddenServiceFrame(__attribute__((
|
||||
|
@ -240,17 +239,17 @@ namespace llarp
|
|||
|
||||
bool
|
||||
HandleDHTMessage(const llarp::dht::IMessage* msg,
|
||||
llarp_router* r) override;
|
||||
llarp::Router* r) override;
|
||||
|
||||
// handle data in upstream direction
|
||||
bool
|
||||
HandleUpstream(llarp_buffer_t X, const TunnelNonce& Y,
|
||||
llarp_router* r) override;
|
||||
llarp::Router* r) override;
|
||||
|
||||
// handle data in downstream direction
|
||||
bool
|
||||
HandleDownstream(llarp_buffer_t X, const TunnelNonce& Y,
|
||||
llarp_router* r) override;
|
||||
llarp::Router* r) override;
|
||||
};
|
||||
|
||||
/// configuration for a single hop when building a path
|
||||
|
@ -395,55 +394,55 @@ namespace llarp
|
|||
Expired(llarp_time_t now) const override;
|
||||
|
||||
void
|
||||
Tick(llarp_time_t now, llarp_router* r);
|
||||
Tick(llarp_time_t now, llarp::Router* r);
|
||||
|
||||
bool
|
||||
SendRoutingMessage(const llarp::routing::IMessage* msg,
|
||||
llarp_router* r) override;
|
||||
llarp::Router* r) override;
|
||||
|
||||
bool
|
||||
HandleObtainExitMessage(const llarp::routing::ObtainExitMessage* msg,
|
||||
llarp_router* r) override;
|
||||
llarp::Router* r) override;
|
||||
|
||||
bool
|
||||
HandleUpdateExitVerifyMessage(
|
||||
const llarp::routing::UpdateExitVerifyMessage* msg,
|
||||
llarp_router* r) override;
|
||||
llarp::Router* r) override;
|
||||
|
||||
bool
|
||||
HandleTransferTrafficMessage(
|
||||
const llarp::routing::TransferTrafficMessage* msg,
|
||||
llarp_router* r) override;
|
||||
llarp::Router* r) override;
|
||||
|
||||
bool
|
||||
HandleUpdateExitMessage(const llarp::routing::UpdateExitMessage* msg,
|
||||
llarp_router* r) override;
|
||||
llarp::Router* r) override;
|
||||
|
||||
bool
|
||||
HandleCloseExitMessage(const llarp::routing::CloseExitMessage* msg,
|
||||
llarp_router* r) override;
|
||||
llarp::Router* r) override;
|
||||
bool
|
||||
HandleGrantExitMessage(const llarp::routing::GrantExitMessage* msg,
|
||||
llarp_router* r) override;
|
||||
llarp::Router* r) override;
|
||||
bool
|
||||
HandleRejectExitMessage(const llarp::routing::RejectExitMessage* msg,
|
||||
llarp_router* r) override;
|
||||
llarp::Router* r) override;
|
||||
|
||||
bool
|
||||
HandleDataDiscardMessage(const llarp::routing::DataDiscardMessage* msg,
|
||||
llarp_router* r) override;
|
||||
llarp::Router* r) override;
|
||||
|
||||
bool
|
||||
HandlePathConfirmMessage(const llarp::routing::PathConfirmMessage* msg,
|
||||
llarp_router* r) override;
|
||||
llarp::Router* r) override;
|
||||
|
||||
bool
|
||||
HandlePathLatencyMessage(const llarp::routing::PathLatencyMessage* msg,
|
||||
llarp_router* r) override;
|
||||
llarp::Router* r) override;
|
||||
|
||||
bool
|
||||
HandlePathTransferMessage(const llarp::routing::PathTransferMessage* msg,
|
||||
llarp_router* r) override;
|
||||
llarp::Router* r) override;
|
||||
|
||||
bool
|
||||
HandleHiddenServiceFrame(
|
||||
|
@ -454,20 +453,20 @@ namespace llarp
|
|||
|
||||
bool
|
||||
HandleDHTMessage(const llarp::dht::IMessage* msg,
|
||||
llarp_router* r) override;
|
||||
llarp::Router* r) override;
|
||||
|
||||
bool
|
||||
HandleRoutingMessage(llarp_buffer_t buf, llarp_router* r);
|
||||
HandleRoutingMessage(llarp_buffer_t buf, llarp::Router* r);
|
||||
|
||||
// handle data in upstream direction
|
||||
bool
|
||||
HandleUpstream(llarp_buffer_t X, const TunnelNonce& Y,
|
||||
llarp_router* r) override;
|
||||
llarp::Router* r) override;
|
||||
|
||||
// handle data in downstream direction
|
||||
bool
|
||||
HandleDownstream(llarp_buffer_t X, const TunnelNonce& Y,
|
||||
llarp_router* r) override;
|
||||
llarp::Router* r) override;
|
||||
|
||||
bool
|
||||
IsReady() const;
|
||||
|
@ -503,7 +502,7 @@ namespace llarp
|
|||
|
||||
bool
|
||||
SendExitRequest(const llarp::routing::ObtainExitMessage* msg,
|
||||
llarp_router* r);
|
||||
llarp::Router* r);
|
||||
|
||||
protected:
|
||||
llarp::routing::InboundMessageParser m_InboundMessageParser;
|
||||
|
@ -540,7 +539,7 @@ namespace llarp
|
|||
|
||||
struct PathContext
|
||||
{
|
||||
PathContext(llarp_router* router);
|
||||
PathContext(llarp::Router* router);
|
||||
~PathContext();
|
||||
|
||||
/// called from router tick function
|
||||
|
@ -634,7 +633,7 @@ namespace llarp
|
|||
llarp::Logic*
|
||||
Logic();
|
||||
|
||||
llarp_router*
|
||||
llarp::Router*
|
||||
Router();
|
||||
|
||||
byte_t*
|
||||
|
@ -644,7 +643,7 @@ namespace llarp
|
|||
OurRouterID() const;
|
||||
|
||||
private:
|
||||
llarp_router* m_Router;
|
||||
llarp::Router* m_Router;
|
||||
SyncTransitMap_t m_TransitPaths;
|
||||
SyncTransitMap_t m_Paths;
|
||||
SyncOwnedPathsMap_t m_OurPaths;
|
||||
|
|
|
@ -12,14 +12,14 @@ namespace llarp
|
|||
|
||||
struct Builder : public PathSet
|
||||
{
|
||||
struct llarp_router* router;
|
||||
llarp::Router* router;
|
||||
struct llarp_dht_context* dht;
|
||||
llarp::SecretKey enckey;
|
||||
size_t numHops;
|
||||
llarp_time_t lastBuild = 0;
|
||||
llarp_time_t buildIntervalLimit = MIN_PATH_BUILD_INTERVAL;
|
||||
/// construct
|
||||
Builder(llarp_router* p_router, struct llarp_dht_context* p_dht,
|
||||
Builder(llarp::Router* p_router, struct llarp_dht_context* p_dht,
|
||||
size_t numPaths, size_t numHops);
|
||||
|
||||
virtual ~Builder();
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
#ifndef LLARP_PATHSET_HPP
|
||||
#define LLARP_PATHSET_HPP
|
||||
|
||||
#include <llarp/time.hpp>
|
||||
#include <functional>
|
||||
#include <list>
|
||||
|
@ -12,6 +13,8 @@
|
|||
#include <map>
|
||||
#include <tuple>
|
||||
|
||||
struct llarp_nodedb;
|
||||
|
||||
namespace llarp
|
||||
{
|
||||
namespace dht
|
||||
|
@ -58,7 +61,7 @@ namespace llarp
|
|||
|
||||
/// tick owned paths
|
||||
void
|
||||
Tick(llarp_time_t now, llarp_router* r);
|
||||
Tick(llarp_time_t now, llarp::Router* r);
|
||||
|
||||
/// count the number of paths that will exist at this timestamp in future
|
||||
size_t
|
||||
|
@ -167,7 +170,7 @@ namespace llarp
|
|||
std::set< llarp::service::Introduction >& intros) const;
|
||||
|
||||
virtual bool
|
||||
PublishIntroSet(__attribute__((unused)) llarp_router* r)
|
||||
PublishIntroSet(__attribute__((unused)) llarp::Router* r)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -1,30 +0,0 @@
|
|||
#ifndef LLARP_ROUTER_H_
|
||||
#define LLARP_ROUTER_H_
|
||||
#include <llarp/config.h>
|
||||
#include <llarp/ev.h>
|
||||
#include <llarp/logic.hpp>
|
||||
#include <llarp/threadpool.h>
|
||||
#include <llarp/buffer.h>
|
||||
|
||||
struct llarp_nodedb;
|
||||
struct llarp_router;
|
||||
|
||||
bool
|
||||
llarp_findOrCreateIdentity(struct llarp_crypto *crypto, const char *path,
|
||||
byte_t *secretkey);
|
||||
|
||||
struct llarp_router *
|
||||
llarp_init_router(struct llarp_threadpool *worker,
|
||||
struct llarp_ev_loop *netloop, llarp::Logic *logic);
|
||||
void
|
||||
llarp_free_router(struct llarp_router **router);
|
||||
bool
|
||||
llarp_configure_router(struct llarp_router *router, struct llarp_config *conf);
|
||||
|
||||
bool
|
||||
llarp_run_router(struct llarp_router *router, struct llarp_nodedb *nodedb);
|
||||
|
||||
void
|
||||
llarp_stop_router(struct llarp_router *router);
|
||||
|
||||
#endif
|
|
@ -2,7 +2,6 @@
|
|||
#define LLARP_ROUTING_HANDLER_HPP
|
||||
|
||||
#include <llarp/buffer.h>
|
||||
#include <llarp/router.h>
|
||||
#include <llarp/dht.hpp>
|
||||
|
||||
#include <llarp/messages/path_confirm.hpp>
|
||||
|
@ -22,50 +21,50 @@ namespace llarp
|
|||
{
|
||||
virtual bool
|
||||
HandleObtainExitMessage(const ObtainExitMessage *msg,
|
||||
llarp_router *r) = 0;
|
||||
llarp::Router *r) = 0;
|
||||
|
||||
virtual bool
|
||||
HandleGrantExitMessage(const GrantExitMessage *msg, llarp_router *r) = 0;
|
||||
HandleGrantExitMessage(const GrantExitMessage *msg, llarp::Router *r) = 0;
|
||||
|
||||
virtual bool
|
||||
HandleRejectExitMessage(const RejectExitMessage *msg,
|
||||
llarp_router *r) = 0;
|
||||
llarp::Router *r) = 0;
|
||||
|
||||
virtual bool
|
||||
HandleTransferTrafficMessage(const TransferTrafficMessage *msg,
|
||||
llarp_router *r) = 0;
|
||||
llarp::Router *r) = 0;
|
||||
|
||||
virtual bool
|
||||
HandleUpdateExitMessage(const UpdateExitMessage *msg,
|
||||
llarp_router *r) = 0;
|
||||
llarp::Router *r) = 0;
|
||||
|
||||
virtual bool
|
||||
HandleUpdateExitVerifyMessage(const UpdateExitVerifyMessage *msg,
|
||||
llarp_router *r) = 0;
|
||||
llarp::Router *r) = 0;
|
||||
|
||||
virtual bool
|
||||
HandleCloseExitMessage(const CloseExitMessage *msg, llarp_router *r) = 0;
|
||||
HandleCloseExitMessage(const CloseExitMessage *msg, llarp::Router *r) = 0;
|
||||
|
||||
virtual bool
|
||||
HandleDataDiscardMessage(const DataDiscardMessage *msg,
|
||||
llarp_router *r) = 0;
|
||||
llarp::Router *r) = 0;
|
||||
|
||||
virtual bool
|
||||
HandlePathTransferMessage(const PathTransferMessage *msg,
|
||||
llarp_router *r) = 0;
|
||||
llarp::Router *r) = 0;
|
||||
|
||||
virtual bool
|
||||
HandleHiddenServiceFrame(const service::ProtocolFrame *msg) = 0;
|
||||
|
||||
virtual bool
|
||||
HandlePathConfirmMessage(const PathConfirmMessage *msg,
|
||||
llarp_router *r) = 0;
|
||||
llarp::Router *r) = 0;
|
||||
|
||||
virtual bool
|
||||
HandlePathLatencyMessage(const PathLatencyMessage *msg,
|
||||
llarp_router *r) = 0;
|
||||
llarp::Router *r) = 0;
|
||||
virtual bool
|
||||
HandleDHTMessage(const llarp::dht::IMessage *msg, llarp_router *r) = 0;
|
||||
HandleDHTMessage(const llarp::dht::IMessage *msg, llarp::Router *r) = 0;
|
||||
};
|
||||
} // namespace routing
|
||||
} // namespace llarp
|
||||
|
|
|
@ -2,12 +2,12 @@
|
|||
#define LLARP_ROUTING_MESSAGE_HPP
|
||||
|
||||
#include <llarp/buffer.h>
|
||||
#include <llarp/router.h>
|
||||
#include <llarp/bencode.hpp>
|
||||
#include <llarp/path_types.hpp>
|
||||
|
||||
namespace llarp
|
||||
{
|
||||
struct Router;
|
||||
namespace routing
|
||||
{
|
||||
struct IMessageHandler;
|
||||
|
@ -24,7 +24,7 @@ namespace llarp
|
|||
virtual ~IMessage(){};
|
||||
|
||||
virtual bool
|
||||
HandleMessage(IMessageHandler* h, llarp_router* r) const = 0;
|
||||
HandleMessage(IMessageHandler* h, llarp::Router* r) const = 0;
|
||||
};
|
||||
|
||||
struct InboundMessageParser
|
||||
|
@ -32,7 +32,7 @@ namespace llarp
|
|||
InboundMessageParser();
|
||||
bool
|
||||
ParseMessageBuffer(llarp_buffer_t buf, IMessageHandler* handler,
|
||||
const PathID_t& from, llarp_router* r);
|
||||
const PathID_t& from, llarp::Router* r);
|
||||
|
||||
private:
|
||||
static bool
|
||||
|
|
|
@ -6,11 +6,10 @@
|
|||
#include <functional>
|
||||
#include <llarp/crypto.hpp>
|
||||
|
||||
// forward declare
|
||||
struct llarp_router;
|
||||
|
||||
namespace llarp
|
||||
{
|
||||
struct Router;
|
||||
|
||||
namespace rpc
|
||||
{
|
||||
struct ServerImpl;
|
||||
|
@ -18,7 +17,7 @@ namespace llarp
|
|||
/// jsonrpc server
|
||||
struct Server
|
||||
{
|
||||
Server(llarp_router* r);
|
||||
Server(llarp::Router* r);
|
||||
~Server();
|
||||
|
||||
bool
|
||||
|
@ -33,7 +32,7 @@ namespace llarp
|
|||
/// jsonrpc caller
|
||||
struct Caller
|
||||
{
|
||||
Caller(llarp_router* r);
|
||||
Caller(llarp::Router* r);
|
||||
~Caller();
|
||||
|
||||
/// start with jsonrpc endpoint address
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
#ifndef LLARP_SERVICE_CONTEXT_HPP
|
||||
#define LLARP_SERVICE_CONTEXT_HPP
|
||||
#include <llarp/router.h>
|
||||
#include <llarp/net.hpp>
|
||||
#include <llarp/service/config.hpp>
|
||||
#include <llarp/service/endpoint.hpp>
|
||||
|
@ -14,7 +13,7 @@ namespace llarp
|
|||
/// holds all the hidden service endpoints we own
|
||||
struct Context
|
||||
{
|
||||
Context(llarp_router *r);
|
||||
Context(llarp::Router *r);
|
||||
~Context();
|
||||
|
||||
void
|
||||
|
@ -74,7 +73,7 @@ namespace llarp
|
|||
StartAll();
|
||||
|
||||
private:
|
||||
llarp_router *m_Router;
|
||||
llarp::Router *m_Router;
|
||||
std::unordered_map< std::string, std::unique_ptr< Endpoint > >
|
||||
m_Endpoints;
|
||||
};
|
||||
|
|
|
@ -34,7 +34,7 @@ namespace llarp
|
|||
|
||||
static const size_t MAX_OUTBOUND_CONTEXT_COUNT = 4;
|
||||
|
||||
Endpoint(const std::string& nickname, llarp_router* r);
|
||||
Endpoint(const std::string& nickname, llarp::Router* r);
|
||||
~Endpoint();
|
||||
|
||||
void
|
||||
|
@ -64,7 +64,7 @@ namespace llarp
|
|||
llarp_threadpool*
|
||||
Worker();
|
||||
|
||||
llarp_router*
|
||||
llarp::Router*
|
||||
Router()
|
||||
{
|
||||
return m_Router;
|
||||
|
@ -90,10 +90,10 @@ namespace llarp
|
|||
EnsureReplyPath(const ServiceInfo& addr);
|
||||
|
||||
bool
|
||||
PublishIntroSet(llarp_router* r);
|
||||
PublishIntroSet(llarp::Router* r);
|
||||
|
||||
bool
|
||||
PublishIntroSetVia(llarp_router* r, path::Path* p);
|
||||
PublishIntroSetVia(llarp::Router* r, path::Path* p);
|
||||
|
||||
bool
|
||||
HandleGotIntroMessage(const llarp::dht::GotIntroMessage* msg);
|
||||
|
@ -428,7 +428,7 @@ namespace llarp
|
|||
std::unique_ptr< llarp::exit::BaseSession > m_Exit;
|
||||
|
||||
private:
|
||||
llarp_router* m_Router;
|
||||
llarp::Router* m_Router;
|
||||
llarp_threadpool* m_IsolatedWorker = nullptr;
|
||||
llarp::Logic* m_IsolatedLogic = nullptr;
|
||||
llarp_ev_loop* m_IsolatedNetLoop = nullptr;
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
#ifndef LLARP_SERVICE_LOOKUP_HPP
|
||||
#define LLARP_SERVICE_LOOKUP_HPP
|
||||
|
||||
#include <llarp/router.h>
|
||||
#include <llarp/routing/message.hpp>
|
||||
#include <llarp/service/IntroSet.hpp>
|
||||
#include <set>
|
||||
|
@ -46,7 +45,7 @@ namespace llarp
|
|||
|
||||
/// build a new requset message and send it via a path
|
||||
bool
|
||||
SendRequestViaPath(llarp::path::Path* p, llarp_router* r);
|
||||
SendRequestViaPath(llarp::path::Path* p, llarp::Router* r);
|
||||
|
||||
ILookupHolder* parent;
|
||||
uint64_t txid;
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
#include <llarp/bencode.hpp>
|
||||
#include <llarp/crypto.hpp>
|
||||
#include <llarp/encrypted.hpp>
|
||||
#include <llarp/dht/message.hpp>
|
||||
#include <llarp/routing/message.hpp>
|
||||
#include <llarp/service/Identity.hpp>
|
||||
#include <llarp/service/Info.hpp>
|
||||
|
@ -13,6 +14,8 @@
|
|||
|
||||
namespace llarp
|
||||
{
|
||||
class Logic;
|
||||
|
||||
namespace service
|
||||
{
|
||||
constexpr std::size_t MAX_PROTOCOL_MESSAGE_SIZE = 2048 * 2;
|
||||
|
@ -115,7 +118,7 @@ namespace llarp
|
|||
|
||||
bool
|
||||
HandleMessage(llarp::routing::IMessageHandler* h,
|
||||
llarp_router* r) const override;
|
||||
llarp::Router* r) const override;
|
||||
};
|
||||
} // namespace service
|
||||
} // namespace llarp
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
#include <signal.h>
|
||||
#include <sys/param.h> // for MIN
|
||||
#include <llarp.hpp>
|
||||
#include "router.hpp"
|
||||
#include <router.hpp>
|
||||
|
||||
#include <llarp/dnsd.hpp>
|
||||
#include <llarp/dns_dotlokilookup.hpp>
|
||||
|
@ -149,9 +149,9 @@ namespace llarp
|
|||
else
|
||||
logic = new Logic;
|
||||
|
||||
router = llarp_init_router(worker, mainloop, logic);
|
||||
router = new Router(worker, mainloop, logic);
|
||||
|
||||
if(!llarp_configure_router(router, config))
|
||||
if(!router->Configure(config))
|
||||
{
|
||||
llarp::LogError("Failed to configure router");
|
||||
return 1;
|
||||
|
@ -169,7 +169,7 @@ namespace llarp
|
|||
return 1;
|
||||
}
|
||||
// run
|
||||
if(!llarp_run_router(router, nodedb))
|
||||
if(!router->Run(nodedb))
|
||||
return 1;
|
||||
// run net io thread
|
||||
llarp::LogInfo("running mainloop");
|
||||
|
@ -213,7 +213,7 @@ namespace llarp
|
|||
|
||||
llarp::LogDebug("stop router");
|
||||
if(router)
|
||||
llarp_stop_router(router);
|
||||
router->Stop();
|
||||
|
||||
llarp::LogDebug("stop workers");
|
||||
if(worker)
|
||||
|
@ -236,7 +236,7 @@ namespace llarp
|
|||
llarp_ev_loop_stop(mainloop);
|
||||
|
||||
llarp::LogDebug("free router");
|
||||
llarp_free_router(&router);
|
||||
delete router;
|
||||
|
||||
llarp::LogDebug("free logic");
|
||||
delete logic;
|
||||
|
|
|
@ -1,14 +1,14 @@
|
|||
#include <llarp/dht.h>
|
||||
#include "router.hpp"
|
||||
#include <llarp/dht/context.hpp>
|
||||
#include "router_contact.hpp"
|
||||
|
||||
llarp_dht_context::llarp_dht_context(llarp_router *router)
|
||||
llarp_dht_context::llarp_dht_context(llarp::Router *router)
|
||||
{
|
||||
parent = router;
|
||||
}
|
||||
|
||||
struct llarp_dht_context *
|
||||
llarp_dht_context_new(struct llarp_router *router)
|
||||
llarp_dht_context_new(llarp::Router *router)
|
||||
{
|
||||
return new llarp_dht_context(router);
|
||||
}
|
||||
|
|
|
@ -2,8 +2,8 @@
|
|||
#include <llarp/dht/messages/gotrouter.hpp>
|
||||
#include <llarp/messages/dht.hpp>
|
||||
#include <llarp/messages/dht_immediate.hpp>
|
||||
#include <vector>
|
||||
#include "router.hpp"
|
||||
#include <vector>
|
||||
|
||||
namespace llarp
|
||||
{
|
||||
|
@ -79,7 +79,7 @@ namespace llarp
|
|||
// lookup router
|
||||
parent->LookupRouter(
|
||||
pk,
|
||||
std::bind(&llarp_router::HandleDHTLookupForExplore,
|
||||
std::bind(&llarp::Router::HandleDHTLookupForExplore,
|
||||
parent->router, pk, std::placeholders::_1));
|
||||
}
|
||||
}
|
||||
|
@ -258,7 +258,7 @@ namespace llarp
|
|||
}
|
||||
|
||||
void
|
||||
Context::Init(const Key_t &us, llarp_router *r,
|
||||
Context::Init(const Key_t &us, llarp::Router *r,
|
||||
llarp_time_t exploreInterval)
|
||||
{
|
||||
router = r;
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
#include <llarp/messages/dht_immediate.hpp>
|
||||
#include "router.hpp"
|
||||
|
||||
#include <router.hpp>
|
||||
|
||||
namespace llarp
|
||||
{
|
||||
|
@ -57,7 +58,7 @@ namespace llarp
|
|||
}
|
||||
|
||||
bool
|
||||
DHTImmeidateMessage::HandleMessage(llarp_router *router) const
|
||||
DHTImmeidateMessage::HandleMessage(llarp::Router *router) const
|
||||
{
|
||||
DHTImmeidateMessage reply(session);
|
||||
bool result = true;
|
||||
|
|
|
@ -10,7 +10,7 @@ namespace llarp
|
|||
/*
|
||||
struct IntroSetLookupInformer
|
||||
{
|
||||
llarp_router* router;
|
||||
llarp::Router* router;
|
||||
service::Address target;
|
||||
|
||||
void
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
|
||||
#include <llarp/dht/context.hpp>
|
||||
#include <llarp/dht/messages/findrouter.hpp>
|
||||
#include <llarp/dht/messages/gotrouter.hpp>
|
||||
#include <llarp/messages/dht.hpp>
|
||||
#include "router.hpp"
|
||||
|
||||
#include <router.hpp>
|
||||
|
||||
namespace llarp
|
||||
{
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
|
||||
#include <llarp/dht/context.hpp>
|
||||
#include <llarp/dht/messages/gotintro.hpp>
|
||||
#include <llarp/messages/dht.hpp>
|
||||
#include "router.hpp"
|
||||
|
||||
#include <router.hpp>
|
||||
|
||||
namespace llarp
|
||||
{
|
||||
|
|
|
@ -1,7 +1,8 @@
|
|||
|
||||
#include <llarp/dht/context.hpp>
|
||||
#include <llarp/dht/messages/gotrouter.hpp>
|
||||
#include "router.hpp"
|
||||
|
||||
#include <router.hpp>
|
||||
|
||||
namespace llarp
|
||||
{
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
|
||||
#include <llarp/dht/context.hpp>
|
||||
#include <llarp/dht/messages/pubintro.hpp>
|
||||
#include <llarp/messages/dht.hpp>
|
||||
#include <llarp/messages/dht_immediate.hpp>
|
||||
#include "router.hpp"
|
||||
|
||||
#include <router.hpp>
|
||||
|
||||
namespace llarp
|
||||
{
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
#include <llarp/dns_dotlokilookup.hpp>
|
||||
#include <llarp/handlers/tun.hpp>
|
||||
#include <llarp/service/context.hpp>
|
||||
#include <llarp/logic.hpp>
|
||||
|
||||
std::string const default_chars =
|
||||
"abcdefghijklmnaoqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890";
|
||||
|
|
|
@ -76,10 +76,10 @@ namespace llarp
|
|||
}
|
||||
|
||||
bool
|
||||
CloseExitMessage::HandleMessage(IMessageHandler* h, llarp_router* r) const
|
||||
CloseExitMessage::HandleMessage(IMessageHandler* h, llarp::Router* r) const
|
||||
{
|
||||
return h->HandleCloseExitMessage(this, r);
|
||||
}
|
||||
|
||||
} // namespace routing
|
||||
} // namespace llarp
|
||||
} // namespace llarp
|
||||
|
|
|
@ -4,7 +4,7 @@ namespace llarp
|
|||
{
|
||||
namespace exit
|
||||
{
|
||||
Context::Context(llarp_router* r) : m_Router(r)
|
||||
Context::Context(llarp::Router* r) : m_Router(r)
|
||||
{
|
||||
}
|
||||
Context::~Context()
|
||||
|
@ -94,4 +94,4 @@ namespace llarp
|
|||
}
|
||||
|
||||
} // namespace exit
|
||||
} // namespace llarp
|
||||
} // namespace llarp
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
#include <llarp/exit/endpoint.hpp>
|
||||
#include "router.hpp"
|
||||
#include <llarp/handlers/exit.hpp>
|
||||
|
||||
#include <router.hpp>
|
||||
|
||||
namespace llarp
|
||||
{
|
||||
|
@ -173,4 +175,4 @@ namespace llarp
|
|||
return router->paths.GetByUpstream(router->pubkey(), m_CurrentPath);
|
||||
}
|
||||
} // namespace exit
|
||||
} // namespace llarp
|
||||
} // namespace llarp
|
||||
|
|
|
@ -81,10 +81,10 @@ namespace llarp
|
|||
}
|
||||
|
||||
bool
|
||||
GrantExitMessage::HandleMessage(IMessageHandler* h, llarp_router* r) const
|
||||
GrantExitMessage::HandleMessage(IMessageHandler* h, llarp::Router* r) const
|
||||
{
|
||||
return h->HandleGrantExitMessage(this, r);
|
||||
}
|
||||
|
||||
} // namespace routing
|
||||
} // namespace llarp
|
||||
} // namespace llarp
|
||||
|
|
|
@ -103,10 +103,10 @@ namespace llarp
|
|||
}
|
||||
|
||||
bool
|
||||
ObtainExitMessage::HandleMessage(IMessageHandler* h, llarp_router* r) const
|
||||
ObtainExitMessage::HandleMessage(IMessageHandler* h, llarp::Router* r) const
|
||||
{
|
||||
return h->HandleObtainExitMessage(this, r);
|
||||
}
|
||||
|
||||
} // namespace routing
|
||||
} // namespace llarp
|
||||
} // namespace llarp
|
||||
|
|
|
@ -91,10 +91,10 @@ namespace llarp
|
|||
}
|
||||
|
||||
bool
|
||||
RejectExitMessage::HandleMessage(IMessageHandler* h, llarp_router* r) const
|
||||
RejectExitMessage::HandleMessage(IMessageHandler* h, llarp::Router* r) const
|
||||
{
|
||||
return h->HandleRejectExitMessage(this, r);
|
||||
}
|
||||
|
||||
} // namespace routing
|
||||
} // namespace llarp
|
||||
} // namespace llarp
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
#include <llarp/exit/session.hpp>
|
||||
#include "router.hpp"
|
||||
#include <llarp/path.hpp>
|
||||
#include <router.hpp>
|
||||
|
||||
namespace llarp
|
||||
{
|
||||
|
@ -7,7 +8,7 @@ namespace llarp
|
|||
{
|
||||
BaseSession::BaseSession(const llarp::RouterID& router,
|
||||
std::function< bool(llarp_buffer_t) > writepkt,
|
||||
llarp_router* r, size_t numpaths, size_t hoplen)
|
||||
llarp::Router* r, size_t numpaths, size_t hoplen)
|
||||
: llarp::path::Builder(r, r->dht, numpaths, hoplen)
|
||||
, m_ExitRouter(router)
|
||||
, m_WritePacket(writepkt)
|
||||
|
|
|
@ -61,10 +61,10 @@ namespace llarp
|
|||
|
||||
bool
|
||||
TransferTrafficMessage::HandleMessage(IMessageHandler* h,
|
||||
llarp_router* r) const
|
||||
llarp::Router* r) const
|
||||
{
|
||||
return h->HandleTransferTrafficMessage(this, r);
|
||||
}
|
||||
|
||||
} // namespace routing
|
||||
} // namespace llarp
|
||||
} // namespace llarp
|
||||
|
|
|
@ -82,7 +82,7 @@ namespace llarp
|
|||
}
|
||||
|
||||
bool
|
||||
UpdateExitMessage::HandleMessage(IMessageHandler* h, llarp_router* r) const
|
||||
UpdateExitMessage::HandleMessage(IMessageHandler* h, llarp::Router* r) const
|
||||
{
|
||||
return h->HandleUpdateExitMessage(this, r);
|
||||
}
|
||||
|
@ -118,10 +118,10 @@ namespace llarp
|
|||
|
||||
bool
|
||||
UpdateExitVerifyMessage::HandleMessage(IMessageHandler* h,
|
||||
llarp_router* r) const
|
||||
llarp::Router* r) const
|
||||
{
|
||||
return h->HandleUpdateExitVerifyMessage(this, r);
|
||||
}
|
||||
|
||||
} // namespace routing
|
||||
} // namespace llarp
|
||||
} // namespace llarp
|
||||
|
|
|
@ -19,7 +19,7 @@ namespace llarp
|
|||
static_cast< ExitEndpoint * >(tun->user)->Flush();
|
||||
}
|
||||
|
||||
ExitEndpoint::ExitEndpoint(const std::string &name, llarp_router *r)
|
||||
ExitEndpoint::ExitEndpoint(const std::string &name, llarp::Router *r)
|
||||
: m_Router(r)
|
||||
, m_Name(name)
|
||||
, m_Tun{{0}, 0, {0}, 0, 0, 0, 0, 0, 0, 0}
|
||||
|
@ -108,7 +108,7 @@ namespace llarp
|
|||
return true;
|
||||
}
|
||||
|
||||
llarp_router *
|
||||
llarp::Router *
|
||||
ExitEndpoint::Router()
|
||||
{
|
||||
return m_Router;
|
||||
|
|
|
@ -2,7 +2,6 @@
|
|||
// harmless on other platforms
|
||||
#define __USE_MINGW_ANSI_STDIO 1
|
||||
#include <llarp/handlers/tun.hpp>
|
||||
#include "router.hpp"
|
||||
#include <sys/types.h>
|
||||
#ifndef _WIN32
|
||||
#include <sys/socket.h>
|
||||
|
@ -10,6 +9,8 @@
|
|||
#endif
|
||||
#include "ev.hpp"
|
||||
|
||||
#include <router.hpp>
|
||||
|
||||
namespace llarp
|
||||
{
|
||||
namespace handlers
|
||||
|
@ -20,7 +21,7 @@ namespace llarp
|
|||
return static_cast< TunEndpoint * >(tun->user)->Promise.get();
|
||||
}
|
||||
|
||||
TunEndpoint::TunEndpoint(const std::string &nickname, llarp_router *r)
|
||||
TunEndpoint::TunEndpoint(const std::string &nickname, llarp::Router *r)
|
||||
: service::Endpoint(nickname, r)
|
||||
, m_UserToNetworkPktQueue(nickname + "_sendq", r->netloop, r->netloop)
|
||||
, m_NetworkToUserPktQueue(nickname + "_recvq", r->netloop, r->netloop)
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
#include <llarp/link/curvecp.hpp>
|
||||
#include "router.hpp"
|
||||
#include <llarp/messages/link_intro.hpp>
|
||||
|
||||
namespace llarp
|
||||
|
@ -7,7 +6,7 @@ namespace llarp
|
|||
namespace curvecp
|
||||
{
|
||||
std::unique_ptr< ILinkLayer >
|
||||
NewServer(__attribute__((unused)) llarp_router* r)
|
||||
NewServer(__attribute__((unused)) llarp::Router* r)
|
||||
{
|
||||
return nullptr;
|
||||
}
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
#include <llarp/link/utp.hpp>
|
||||
#include "router.hpp"
|
||||
#include <llarp/messages/link_intro.hpp>
|
||||
#include <llarp/messages/discard.hpp>
|
||||
#include <llarp/buffer.hpp>
|
||||
|
@ -9,6 +8,8 @@
|
|||
#include <tuple>
|
||||
#include <deque>
|
||||
|
||||
#include <router.hpp>
|
||||
|
||||
#ifdef __linux__
|
||||
#include <linux/errqueue.h>
|
||||
#include <netinet/ip_icmp.h>
|
||||
|
@ -92,7 +93,7 @@ namespace llarp
|
|||
eClose // utp connection is closed
|
||||
};
|
||||
|
||||
llarp_router*
|
||||
llarp::Router*
|
||||
Router();
|
||||
|
||||
State state;
|
||||
|
@ -323,7 +324,7 @@ namespace llarp
|
|||
struct LinkLayer : public ILinkLayer
|
||||
{
|
||||
utp_context* _utp_ctx = nullptr;
|
||||
llarp_router* router = nullptr;
|
||||
llarp::Router* router = nullptr;
|
||||
static uint64
|
||||
OnRead(utp_callback_arguments* arg);
|
||||
|
||||
|
@ -437,7 +438,7 @@ namespace llarp
|
|||
return 0;
|
||||
}
|
||||
|
||||
LinkLayer(llarp_router* r) : ILinkLayer()
|
||||
LinkLayer(llarp::Router* r) : ILinkLayer()
|
||||
{
|
||||
router = r;
|
||||
_utp_ctx = utp_init(2);
|
||||
|
@ -584,7 +585,7 @@ namespace llarp
|
|||
{
|
||||
}
|
||||
|
||||
llarp_router*
|
||||
llarp::Router*
|
||||
GetRouter();
|
||||
|
||||
bool
|
||||
|
@ -618,7 +619,7 @@ namespace llarp
|
|||
};
|
||||
|
||||
std::unique_ptr< ILinkLayer >
|
||||
NewServer(llarp_router* r)
|
||||
NewServer(llarp::Router* r)
|
||||
{
|
||||
return std::unique_ptr< LinkLayer >(new LinkLayer(r));
|
||||
}
|
||||
|
@ -803,7 +804,7 @@ namespace llarp
|
|||
EnterState(eSessionReady);
|
||||
}
|
||||
|
||||
llarp_router*
|
||||
llarp::Router*
|
||||
BaseSession::Router()
|
||||
{
|
||||
return parent->router;
|
||||
|
|
|
@ -114,7 +114,7 @@ namespace llarp
|
|||
}
|
||||
|
||||
bool
|
||||
LinkIntroMessage::HandleMessage(llarp_router* router) const
|
||||
LinkIntroMessage::HandleMessage(llarp::Router* router) const
|
||||
{
|
||||
if(!Verify(&router->crypto))
|
||||
return false;
|
||||
|
|
|
@ -2,11 +2,10 @@
|
|||
#include <llarp/messages.hpp>
|
||||
#include "buffer.hpp"
|
||||
#include "logger.hpp"
|
||||
#include "router.hpp"
|
||||
|
||||
namespace llarp
|
||||
{
|
||||
InboundMessageParser::InboundMessageParser(llarp_router* _router)
|
||||
InboundMessageParser::InboundMessageParser(Router* _router)
|
||||
: router(_router)
|
||||
{
|
||||
}
|
||||
|
|
|
@ -4,15 +4,15 @@
|
|||
#include <llarp/pathbuilder.hpp>
|
||||
#include <llarp/messages/dht.hpp>
|
||||
#include <llarp/messages/discard.hpp>
|
||||
#include <llarp/endian.hpp>
|
||||
#include "buffer.hpp"
|
||||
#include "router.hpp"
|
||||
#include <llarp/endian.hpp>
|
||||
|
||||
namespace llarp
|
||||
{
|
||||
namespace path
|
||||
{
|
||||
PathContext::PathContext(llarp_router* router)
|
||||
PathContext::PathContext(llarp::Router* router)
|
||||
: m_Router(router), m_AllowTransit(false)
|
||||
{
|
||||
}
|
||||
|
@ -204,7 +204,7 @@ namespace llarp
|
|||
return m_Router->pubkey();
|
||||
}
|
||||
|
||||
llarp_router*
|
||||
llarp::Router*
|
||||
PathContext::Router()
|
||||
{
|
||||
return m_Router;
|
||||
|
@ -418,7 +418,7 @@ namespace llarp
|
|||
}
|
||||
|
||||
void
|
||||
Path::Tick(llarp_time_t now, llarp_router* r)
|
||||
Path::Tick(llarp_time_t now, llarp::Router* r)
|
||||
{
|
||||
if(Expired(now))
|
||||
return;
|
||||
|
@ -488,7 +488,7 @@ namespace llarp
|
|||
|
||||
bool
|
||||
Path::HandleUpstream(llarp_buffer_t buf, const TunnelNonce& Y,
|
||||
llarp_router* r)
|
||||
llarp::Router* r)
|
||||
{
|
||||
TunnelNonce n = Y;
|
||||
for(const auto& hop : hops)
|
||||
|
@ -527,7 +527,7 @@ namespace llarp
|
|||
|
||||
bool
|
||||
Path::HandleDownstream(llarp_buffer_t buf, const TunnelNonce& Y,
|
||||
llarp_router* r)
|
||||
llarp::Router* r)
|
||||
{
|
||||
TunnelNonce n = Y;
|
||||
for(const auto& hop : hops)
|
||||
|
@ -539,7 +539,7 @@ namespace llarp
|
|||
}
|
||||
|
||||
bool
|
||||
Path::HandleRoutingMessage(llarp_buffer_t buf, llarp_router* r)
|
||||
Path::HandleRoutingMessage(llarp_buffer_t buf, llarp::Router* r)
|
||||
{
|
||||
if(!m_InboundMessageParser.ParseMessageBuffer(buf, this, RXID(), r))
|
||||
{
|
||||
|
@ -551,7 +551,7 @@ namespace llarp
|
|||
|
||||
bool
|
||||
Path::HandleUpdateExitVerifyMessage(
|
||||
const llarp::routing::UpdateExitVerifyMessage* msg, llarp_router* r)
|
||||
const llarp::routing::UpdateExitVerifyMessage* msg, llarp::Router* r)
|
||||
{
|
||||
(void)r;
|
||||
if(m_UpdateExitTX && msg->T == m_UpdateExitTX)
|
||||
|
@ -569,7 +569,7 @@ namespace llarp
|
|||
|
||||
bool
|
||||
Path::SendRoutingMessage(const llarp::routing::IMessage* msg,
|
||||
llarp_router* r)
|
||||
llarp::Router* r)
|
||||
{
|
||||
byte_t tmp[MAX_LINK_MSG_SIZE / 2];
|
||||
auto buf = llarp::StackBuffer< decltype(tmp) >(tmp);
|
||||
|
@ -597,7 +597,7 @@ namespace llarp
|
|||
bool
|
||||
Path::HandlePathTransferMessage(
|
||||
__attribute__((unused)) const llarp::routing::PathTransferMessage* msg,
|
||||
__attribute__((unused)) llarp_router* r)
|
||||
__attribute__((unused)) llarp::Router* r)
|
||||
{
|
||||
llarp::LogWarn("unwarranted path transfer message on tx=", TXID(),
|
||||
" rx=", RXID());
|
||||
|
@ -606,7 +606,7 @@ namespace llarp
|
|||
|
||||
bool
|
||||
Path::HandleDataDiscardMessage(
|
||||
const llarp::routing::DataDiscardMessage* msg, llarp_router* r)
|
||||
const llarp::routing::DataDiscardMessage* msg, llarp::Router* r)
|
||||
{
|
||||
MarkActive(r->Now());
|
||||
if(m_DropHandler)
|
||||
|
@ -617,7 +617,7 @@ namespace llarp
|
|||
bool
|
||||
Path::HandlePathConfirmMessage(
|
||||
__attribute__((unused)) const llarp::routing::PathConfirmMessage* msg,
|
||||
llarp_router* r)
|
||||
llarp::Router* r)
|
||||
{
|
||||
auto now = r->Now();
|
||||
if(_status == ePathBuilding)
|
||||
|
@ -658,7 +658,7 @@ namespace llarp
|
|||
|
||||
bool
|
||||
Path::HandlePathLatencyMessage(
|
||||
const llarp::routing::PathLatencyMessage* msg, llarp_router* r)
|
||||
const llarp::routing::PathLatencyMessage* msg, llarp::Router* r)
|
||||
{
|
||||
auto now = r->Now();
|
||||
MarkActive(now);
|
||||
|
@ -680,7 +680,7 @@ namespace llarp
|
|||
}
|
||||
|
||||
bool
|
||||
Path::HandleDHTMessage(const llarp::dht::IMessage* msg, llarp_router* r)
|
||||
Path::HandleDHTMessage(const llarp::dht::IMessage* msg, llarp::Router* r)
|
||||
{
|
||||
llarp::routing::DHTMessage reply;
|
||||
if(!msg->HandleMessage(r->dht, reply.M))
|
||||
|
@ -693,7 +693,7 @@ namespace llarp
|
|||
|
||||
bool
|
||||
Path::HandleCloseExitMessage(const llarp::routing::CloseExitMessage* msg,
|
||||
llarp_router* r)
|
||||
llarp::Router* r)
|
||||
{
|
||||
/// allows exits to close from their end
|
||||
if(SupportsAnyRoles(ePathRoleExit | ePathRoleSVC))
|
||||
|
@ -714,7 +714,7 @@ namespace llarp
|
|||
|
||||
bool
|
||||
Path::SendExitRequest(const llarp::routing::ObtainExitMessage* msg,
|
||||
llarp_router* r)
|
||||
llarp::Router* r)
|
||||
{
|
||||
llarp::LogInfo(Name(), " sending exit request to ", Endpoint());
|
||||
m_ExitObtainTX = msg->T;
|
||||
|
@ -723,7 +723,7 @@ namespace llarp
|
|||
|
||||
bool
|
||||
Path::HandleObtainExitMessage(const llarp::routing::ObtainExitMessage* msg,
|
||||
llarp_router* r)
|
||||
llarp::Router* r)
|
||||
{
|
||||
(void)msg;
|
||||
(void)r;
|
||||
|
@ -733,7 +733,7 @@ namespace llarp
|
|||
|
||||
bool
|
||||
Path::HandleUpdateExitMessage(const llarp::routing::UpdateExitMessage* msg,
|
||||
llarp_router* r)
|
||||
llarp::Router* r)
|
||||
{
|
||||
(void)msg;
|
||||
(void)r;
|
||||
|
@ -743,7 +743,7 @@ namespace llarp
|
|||
|
||||
bool
|
||||
Path::HandleRejectExitMessage(const llarp::routing::RejectExitMessage* msg,
|
||||
llarp_router* r)
|
||||
llarp::Router* r)
|
||||
{
|
||||
if(m_ExitObtainTX && msg->T == m_ExitObtainTX)
|
||||
{
|
||||
|
@ -762,7 +762,7 @@ namespace llarp
|
|||
|
||||
bool
|
||||
Path::HandleGrantExitMessage(const llarp::routing::GrantExitMessage* msg,
|
||||
llarp_router* r)
|
||||
llarp::Router* r)
|
||||
{
|
||||
if(m_ExitObtainTX && msg->T == m_ExitObtainTX)
|
||||
{
|
||||
|
@ -793,7 +793,7 @@ namespace llarp
|
|||
|
||||
bool
|
||||
Path::HandleTransferTrafficMessage(
|
||||
const llarp::routing::TransferTrafficMessage* msg, llarp_router* r)
|
||||
const llarp::routing::TransferTrafficMessage* msg, llarp::Router* r)
|
||||
{
|
||||
// check if we can handle exit data
|
||||
if(!SupportsAnyRoles(ePathRoleExit | ePathRoleSVC))
|
||||
|
|
|
@ -20,7 +20,7 @@ namespace llarp
|
|||
|
||||
Handler result;
|
||||
size_t idx = 0;
|
||||
llarp_router* router = nullptr;
|
||||
llarp::Router* router = nullptr;
|
||||
llarp_threadpool* worker = nullptr;
|
||||
llarp::Logic* logic = nullptr;
|
||||
llarp_crypto* crypto = nullptr;
|
||||
|
@ -153,7 +153,7 @@ namespace llarp
|
|||
|
||||
namespace path
|
||||
{
|
||||
Builder::Builder(llarp_router* p_router, struct llarp_dht_context* p_dht,
|
||||
Builder::Builder(llarp::Router* p_router, struct llarp_dht_context* p_dht,
|
||||
size_t pathNum, size_t hops)
|
||||
: llarp::path::PathSet(pathNum)
|
||||
, router(p_router)
|
||||
|
|
|
@ -57,7 +57,7 @@ namespace llarp
|
|||
}
|
||||
|
||||
void
|
||||
PathSet::Tick(llarp_time_t now, llarp_router* r)
|
||||
PathSet::Tick(llarp_time_t now, llarp::Router* r)
|
||||
{
|
||||
Lock_t l(m_PathsMutex);
|
||||
for(auto& item : m_Paths)
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
#include <llarp/bencode.hpp>
|
||||
#include <llarp/path.hpp>
|
||||
#include <llarp/messages/path_confirm.hpp>
|
||||
#include <llarp/messages/relay_commit.hpp>
|
||||
#include "buffer.hpp"
|
||||
|
@ -45,7 +46,7 @@ namespace llarp
|
|||
}
|
||||
|
||||
bool
|
||||
LR_CommitMessage::HandleMessage(llarp_router* router) const
|
||||
LR_CommitMessage::HandleMessage(llarp::Router* router) const
|
||||
{
|
||||
if(frames.size() != MAXHOPS)
|
||||
{
|
||||
|
|
|
@ -54,7 +54,7 @@ namespace llarp
|
|||
}
|
||||
|
||||
bool
|
||||
RelayUpstreamMessage::HandleMessage(llarp_router *r) const
|
||||
RelayUpstreamMessage::HandleMessage(llarp::Router *r) const
|
||||
{
|
||||
auto path = r->paths.GetByDownstream(session->GetPubKey(), pathid);
|
||||
if(path)
|
||||
|
@ -112,7 +112,7 @@ namespace llarp
|
|||
}
|
||||
|
||||
bool
|
||||
RelayDownstreamMessage::HandleMessage(llarp_router *r) const
|
||||
RelayDownstreamMessage::HandleMessage(llarp::Router *r) const
|
||||
{
|
||||
auto path = r->paths.GetByUpstream(session->GetPubKey(), pathid);
|
||||
if(path)
|
||||
|
|
1973
llarp/router.cpp
1973
llarp/router.cpp
File diff suppressed because it is too large
Load Diff
555
llarp/router.hpp
555
llarp/router.hpp
|
@ -1,11 +1,25 @@
|
|||
#ifndef LLARP_ROUTER_HPP
|
||||
#define LLARP_ROUTER_HPP
|
||||
|
||||
#include <llarp/buffer.h>
|
||||
#include <llarp/config.h>
|
||||
#include <llarp/dht.h>
|
||||
#include <llarp/nodedb.hpp>
|
||||
#include <llarp/router_contact.hpp>
|
||||
#include <llarp/path.hpp>
|
||||
#include <llarp/dht.hpp>
|
||||
#include <llarp/establish_job.hpp>
|
||||
#include <llarp/ev.h>
|
||||
#include <llarp/exit.hpp>
|
||||
#include <llarp/handlers/tun.hpp>
|
||||
#include <llarp/link_layer.hpp>
|
||||
#include <llarp/link_message.hpp>
|
||||
#include <llarp/logic.hpp>
|
||||
#include <llarp/nodedb.hpp>
|
||||
#include <llarp/path.hpp>
|
||||
#include <llarp/profiling.hpp>
|
||||
#include <llarp/router_contact.hpp>
|
||||
#include <llarp/routing/handler.hpp>
|
||||
#include <llarp/rpc.hpp>
|
||||
#include <llarp/service.hpp>
|
||||
#include <threadpool.hpp>
|
||||
|
||||
#include <functional>
|
||||
#include <list>
|
||||
|
@ -13,342 +27,353 @@
|
|||
#include <vector>
|
||||
#include <unordered_map>
|
||||
|
||||
#include <llarp/dht.hpp>
|
||||
#include <llarp/handlers/tun.hpp>
|
||||
#include <llarp/link_message.hpp>
|
||||
#include <llarp/routing/handler.hpp>
|
||||
#include <llarp/service.hpp>
|
||||
#include <llarp/establish_job.hpp>
|
||||
#include <llarp/profiling.hpp>
|
||||
#include <llarp/exit.hpp>
|
||||
|
||||
#include "crypto.hpp"
|
||||
#include "fs.hpp"
|
||||
#include "mem.hpp"
|
||||
#include "str.hpp"
|
||||
#include <crypto.hpp>
|
||||
#include <fs.hpp>
|
||||
#include <mem.hpp>
|
||||
#include <str.hpp>
|
||||
|
||||
bool
|
||||
llarp_findOrCreateEncryption(llarp_crypto *crypto, const char *fpath,
|
||||
llarp::SecretKey &encryption);
|
||||
|
||||
bool
|
||||
llarp_findOrCreateIdentity(struct llarp_crypto *crypto, const char *path,
|
||||
byte_t *secretkey);
|
||||
|
||||
struct TryConnectJob;
|
||||
|
||||
struct llarp_router
|
||||
namespace llarp
|
||||
{
|
||||
bool ready;
|
||||
// transient iwp encryption key
|
||||
fs::path transport_keyfile = "transport.key";
|
||||
|
||||
// nodes to connect to on startup
|
||||
// DEPRECATED
|
||||
// std::map< std::string, fs::path > connect;
|
||||
|
||||
// long term identity key
|
||||
fs::path ident_keyfile = "identity.key";
|
||||
|
||||
fs::path encryption_keyfile = "encryption.key";
|
||||
|
||||
// path to write our self signed rc to
|
||||
fs::path our_rc_file = "rc.signed";
|
||||
|
||||
// our router contact
|
||||
llarp::RouterContact _rc;
|
||||
|
||||
/// should we obey the service node whitelist?
|
||||
bool whitelistRouters = false;
|
||||
|
||||
const llarp::RouterContact &
|
||||
rc() const
|
||||
struct Router
|
||||
{
|
||||
return _rc;
|
||||
}
|
||||
bool ready;
|
||||
// transient iwp encryption key
|
||||
fs::path transport_keyfile = "transport.key";
|
||||
|
||||
// our ipv4 public setting
|
||||
bool publicOverride = false;
|
||||
struct sockaddr_in ip4addr;
|
||||
llarp::AddressInfo addrInfo;
|
||||
// nodes to connect to on startup
|
||||
// DEPRECATED
|
||||
// std::map< std::string, fs::path > connect;
|
||||
|
||||
llarp_ev_loop *netloop;
|
||||
llarp_threadpool *tp;
|
||||
llarp::Logic *logic;
|
||||
llarp_crypto crypto;
|
||||
llarp::path::PathContext paths;
|
||||
llarp::exit::Context exitContext;
|
||||
llarp::SecretKey identity;
|
||||
llarp::SecretKey encryption;
|
||||
llarp_threadpool *disk;
|
||||
llarp_dht_context *dht = nullptr;
|
||||
// long term identity key
|
||||
fs::path ident_keyfile = "identity.key";
|
||||
|
||||
llarp_nodedb *nodedb;
|
||||
fs::path encryption_keyfile = "encryption.key";
|
||||
|
||||
// buffer for serializing link messages
|
||||
byte_t linkmsg_buffer[MAX_LINK_MSG_SIZE];
|
||||
// path to write our self signed rc to
|
||||
fs::path our_rc_file = "rc.signed";
|
||||
|
||||
/// always maintain this many connections to other routers
|
||||
size_t minConnectedRouters = 1;
|
||||
/// hard upperbound limit on the number of router to router connections
|
||||
size_t maxConnectedRouters = 2000;
|
||||
// our router contact
|
||||
llarp::RouterContact _rc;
|
||||
|
||||
size_t minRequiredRouters = 4;
|
||||
/// should we obey the service node whitelist?
|
||||
bool whitelistRouters = false;
|
||||
|
||||
// should we be sending padded messages every interval?
|
||||
bool sendPadding = false;
|
||||
const llarp::RouterContact &
|
||||
rc() const
|
||||
{
|
||||
return _rc;
|
||||
}
|
||||
|
||||
uint32_t ticker_job_id = 0;
|
||||
// our ipv4 public setting
|
||||
bool publicOverride = false;
|
||||
struct sockaddr_in ip4addr;
|
||||
llarp::AddressInfo addrInfo;
|
||||
|
||||
llarp::InboundMessageParser inbound_link_msg_parser;
|
||||
llarp::routing::InboundMessageParser inbound_routing_msg_parser;
|
||||
llarp_ev_loop *netloop;
|
||||
llarp_threadpool *tp;
|
||||
llarp::Logic *logic;
|
||||
llarp_crypto crypto;
|
||||
llarp::path::PathContext paths;
|
||||
llarp::exit::Context exitContext;
|
||||
llarp::SecretKey identity;
|
||||
llarp::SecretKey encryption;
|
||||
llarp_threadpool *disk;
|
||||
llarp_dht_context *dht = nullptr;
|
||||
|
||||
llarp::service::Context hiddenServiceContext;
|
||||
llarp_nodedb *nodedb;
|
||||
|
||||
using NetConfig_t = std::unordered_multimap< std::string, std::string >;
|
||||
// buffer for serializing link messages
|
||||
byte_t linkmsg_buffer[MAX_LINK_MSG_SIZE];
|
||||
|
||||
/// default network config for default network interface
|
||||
NetConfig_t netConfig;
|
||||
/// always maintain this many connections to other routers
|
||||
size_t minConnectedRouters = 1;
|
||||
/// hard upperbound limit on the number of router to router connections
|
||||
size_t maxConnectedRouters = 2000;
|
||||
|
||||
/// identity keys whitelist of routers we will connect to directly (not for
|
||||
/// service nodes)
|
||||
std::set< llarp::RouterID > strictConnectPubkeys;
|
||||
size_t minRequiredRouters = 4;
|
||||
|
||||
/// bootstrap RCs
|
||||
std::list< llarp::RouterContact > bootstrapRCList;
|
||||
// should we be sending padded messages every interval?
|
||||
bool sendPadding = false;
|
||||
|
||||
bool
|
||||
ExitEnabled() const
|
||||
{
|
||||
// TODO: use equal_range ?
|
||||
auto itr = netConfig.find("exit");
|
||||
if(itr == netConfig.end())
|
||||
return false;
|
||||
return llarp::IsTrueValue(itr->second.c_str());
|
||||
}
|
||||
uint32_t ticker_job_id = 0;
|
||||
|
||||
bool
|
||||
CreateDefaultHiddenService();
|
||||
llarp::InboundMessageParser inbound_link_msg_parser;
|
||||
llarp::routing::InboundMessageParser inbound_routing_msg_parser;
|
||||
|
||||
const std::string DefaultRPCBindAddr = "127.0.0.1:1190";
|
||||
bool enableRPCServer = true;
|
||||
std::unique_ptr< llarp::rpc::Server > rpcServer;
|
||||
std::string rpcBindAddr = DefaultRPCBindAddr;
|
||||
llarp::service::Context hiddenServiceContext;
|
||||
|
||||
/// lokid caller
|
||||
const std::string DefaultLokidRPCAddr = "127.0.0.1:22023";
|
||||
std::unique_ptr< llarp::rpc::Caller > rpcCaller;
|
||||
std::string lokidRPCAddr = DefaultLokidRPCAddr;
|
||||
using NetConfig_t = std::unordered_multimap< std::string, std::string >;
|
||||
|
||||
std::unique_ptr< llarp::ILinkLayer > outboundLink;
|
||||
std::vector< std::unique_ptr< llarp::ILinkLayer > > inboundLinks;
|
||||
/// default network config for default network interface
|
||||
NetConfig_t netConfig;
|
||||
|
||||
llarp::Profiling routerProfiling;
|
||||
std::string routerProfilesFile = "profiles.dat";
|
||||
/// identity keys whitelist of routers we will connect to directly (not for
|
||||
/// service nodes)
|
||||
std::set< llarp::RouterID > strictConnectPubkeys;
|
||||
|
||||
using MessageQueue = std::queue< std::vector< byte_t > >;
|
||||
/// bootstrap RCs
|
||||
std::list< llarp::RouterContact > bootstrapRCList;
|
||||
|
||||
/// outbound message queue
|
||||
std::unordered_map< llarp::RouterID, MessageQueue, llarp::RouterID::Hash >
|
||||
outboundMessageQueue;
|
||||
bool
|
||||
ExitEnabled() const
|
||||
{
|
||||
// TODO: use equal_range ?
|
||||
auto itr = netConfig.find("exit");
|
||||
if(itr == netConfig.end())
|
||||
return false;
|
||||
return llarp::IsTrueValue(itr->second.c_str());
|
||||
}
|
||||
|
||||
/// loki verified routers
|
||||
std::unordered_map< llarp::RouterID, llarp::RouterContact,
|
||||
llarp::RouterID::Hash >
|
||||
validRouters;
|
||||
bool
|
||||
CreateDefaultHiddenService();
|
||||
|
||||
// pending establishing session with routers
|
||||
std::unordered_map< llarp::RouterID, std::unique_ptr< TryConnectJob >,
|
||||
llarp::RouterID::Hash >
|
||||
pendingEstablishJobs;
|
||||
const std::string DefaultRPCBindAddr = "127.0.0.1:1190";
|
||||
bool enableRPCServer = true;
|
||||
std::unique_ptr< llarp::rpc::Server > rpcServer;
|
||||
std::string rpcBindAddr = DefaultRPCBindAddr;
|
||||
|
||||
// pending RCs to be verified by pubkey
|
||||
std::unordered_map< llarp::RouterID, llarp_async_verify_rc,
|
||||
llarp::RouterID::Hash >
|
||||
pendingVerifyRC;
|
||||
/// lokid caller
|
||||
const std::string DefaultLokidRPCAddr = "127.0.0.1:22023";
|
||||
std::unique_ptr< llarp::rpc::Caller > rpcCaller;
|
||||
std::string lokidRPCAddr = DefaultLokidRPCAddr;
|
||||
|
||||
// sessions to persist -> timestamp to end persist at
|
||||
std::unordered_map< llarp::RouterID, llarp_time_t, llarp::RouterID::Hash >
|
||||
m_PersistingSessions;
|
||||
std::unique_ptr< llarp::ILinkLayer > outboundLink;
|
||||
std::vector< std::unique_ptr< llarp::ILinkLayer > > inboundLinks;
|
||||
|
||||
// lokinet routers from lokid, maps pubkey to when we think it will expire,
|
||||
// set to max value right now
|
||||
std::unordered_map< llarp::RouterID, llarp_time_t, llarp::RouterID::Hash >
|
||||
lokinetRouters;
|
||||
llarp::Profiling routerProfiling;
|
||||
std::string routerProfilesFile = "profiles.dat";
|
||||
|
||||
llarp_router();
|
||||
~llarp_router();
|
||||
using MessageQueue = std::queue< std::vector< byte_t > >;
|
||||
|
||||
void
|
||||
HandleLinkSessionEstablished(llarp::RouterContact, llarp::ILinkLayer *);
|
||||
/// outbound message queue
|
||||
std::unordered_map< llarp::RouterID, MessageQueue, llarp::RouterID::Hash >
|
||||
outboundMessageQueue;
|
||||
|
||||
bool
|
||||
HandleRecvLinkMessageBuffer(llarp::ILinkSession *from, llarp_buffer_t msg);
|
||||
/// loki verified routers
|
||||
std::unordered_map< llarp::RouterID, llarp::RouterContact,
|
||||
llarp::RouterID::Hash >
|
||||
validRouters;
|
||||
|
||||
void
|
||||
AddInboundLink(std::unique_ptr< llarp::ILinkLayer > &link);
|
||||
// pending establishing session with routers
|
||||
std::unordered_map< llarp::RouterID, std::unique_ptr< TryConnectJob >,
|
||||
llarp::RouterID::Hash >
|
||||
pendingEstablishJobs;
|
||||
|
||||
bool
|
||||
InitOutboundLink();
|
||||
// pending RCs to be verified by pubkey
|
||||
std::unordered_map< llarp::RouterID, llarp_async_verify_rc,
|
||||
llarp::RouterID::Hash >
|
||||
pendingVerifyRC;
|
||||
|
||||
/// initialize us as a service node
|
||||
/// return true on success
|
||||
bool
|
||||
InitServiceNode();
|
||||
// sessions to persist -> timestamp to end persist at
|
||||
std::unordered_map< llarp::RouterID, llarp_time_t, llarp::RouterID::Hash >
|
||||
m_PersistingSessions;
|
||||
|
||||
/// return true if we are running in service node mode
|
||||
bool
|
||||
IsServiceNode() const;
|
||||
// lokinet routers from lokid, maps pubkey to when we think it will expire,
|
||||
// set to max value right now
|
||||
std::unordered_map< llarp::RouterID, llarp_time_t, llarp::PubKey::Hash >
|
||||
lokinetRouters;
|
||||
|
||||
void
|
||||
Close();
|
||||
Router(struct llarp_threadpool *tp, struct llarp_ev_loop *netloop,
|
||||
llarp::Logic *logic);
|
||||
|
||||
bool
|
||||
LoadHiddenServiceConfig(const char *fname);
|
||||
~Router();
|
||||
|
||||
bool
|
||||
AddHiddenService(const llarp::service::Config::section_t &config);
|
||||
void
|
||||
HandleLinkSessionEstablished(llarp::RouterContact, llarp::ILinkLayer *);
|
||||
|
||||
bool
|
||||
Ready();
|
||||
bool
|
||||
HandleRecvLinkMessageBuffer(llarp::ILinkSession *from, llarp_buffer_t msg);
|
||||
|
||||
bool
|
||||
Run();
|
||||
void
|
||||
AddInboundLink(std::unique_ptr< llarp::ILinkLayer > &link);
|
||||
|
||||
void
|
||||
PersistSessionUntil(const llarp::RouterID &remote, llarp_time_t until);
|
||||
bool
|
||||
InitOutboundLink();
|
||||
|
||||
bool
|
||||
EnsureIdentity();
|
||||
/// initialize us as a service node
|
||||
/// return true on success
|
||||
bool
|
||||
InitServiceNode();
|
||||
|
||||
bool
|
||||
EnsureEncryptionKey();
|
||||
/// return true if we are running in service node mode
|
||||
bool
|
||||
IsServiceNode() const;
|
||||
|
||||
bool
|
||||
ConnectionToRouterAllowed(const llarp::RouterID &router) const;
|
||||
void
|
||||
Close();
|
||||
|
||||
bool
|
||||
SaveRC();
|
||||
bool
|
||||
LoadHiddenServiceConfig(const char *fname);
|
||||
|
||||
const byte_t *
|
||||
pubkey() const
|
||||
{
|
||||
return llarp::seckey_topublic(identity);
|
||||
}
|
||||
bool
|
||||
AddHiddenService(const llarp::service::Config::section_t &config);
|
||||
|
||||
void
|
||||
OnConnectTimeout(const llarp::RouterID &remote);
|
||||
bool
|
||||
Configure(struct llarp_config *conf);
|
||||
|
||||
bool
|
||||
HasPendingConnectJob(const llarp::RouterID &remote);
|
||||
bool
|
||||
Ready();
|
||||
|
||||
void
|
||||
try_connect(fs::path rcfile);
|
||||
bool
|
||||
Run(struct llarp_nodedb *nodedb);
|
||||
|
||||
bool
|
||||
ReloadConfig(const llarp_config *conf);
|
||||
void
|
||||
Stop();
|
||||
|
||||
/// send to remote router or queue for sending
|
||||
/// returns false on overflow
|
||||
/// returns true on successful queue
|
||||
/// NOT threadsafe
|
||||
/// MUST be called in the logic thread
|
||||
bool
|
||||
SendToOrQueue(const llarp::RouterID &remote, const llarp::ILinkMessage *msg);
|
||||
void
|
||||
PersistSessionUntil(const llarp::RouterID &remote, llarp_time_t until);
|
||||
|
||||
/// sendto or drop
|
||||
void
|
||||
SendTo(llarp::RouterID remote, const llarp::ILinkMessage *msg,
|
||||
llarp::ILinkLayer *chosen);
|
||||
bool
|
||||
EnsureIdentity();
|
||||
|
||||
/// manually flush outbound message queue for just 1 router
|
||||
void
|
||||
FlushOutboundFor(llarp::RouterID remote, llarp::ILinkLayer *chosen = nullptr);
|
||||
bool
|
||||
EnsureEncryptionKey();
|
||||
|
||||
/// manually discard all pending messages to remote router
|
||||
void
|
||||
DiscardOutboundFor(const llarp::RouterID &remote);
|
||||
bool
|
||||
ConnectionToRouterAllowed(const llarp::RouterID &router) const;
|
||||
|
||||
/// try establishing a session to a remote router
|
||||
void
|
||||
TryEstablishTo(const llarp::RouterID &remote);
|
||||
bool
|
||||
SaveRC();
|
||||
|
||||
void
|
||||
HandleDHTLookupForExplore(llarp::RouterID remote,
|
||||
const std::vector< llarp::RouterContact > &results);
|
||||
const byte_t *
|
||||
pubkey() const
|
||||
{
|
||||
return llarp::seckey_topublic(identity);
|
||||
}
|
||||
|
||||
void
|
||||
ForEachPeer(
|
||||
std::function< void(const llarp::ILinkSession *, bool) > visit) const;
|
||||
void
|
||||
OnConnectTimeout(const llarp::RouterID &remote);
|
||||
|
||||
/// flush outbound message queue
|
||||
void
|
||||
FlushOutbound();
|
||||
bool
|
||||
HasPendingConnectJob(const llarp::RouterID &remote);
|
||||
|
||||
/// called by link when a remote session is expunged
|
||||
void
|
||||
SessionClosed(const llarp::RouterID &remote);
|
||||
void
|
||||
try_connect(fs::path rcfile);
|
||||
|
||||
/// call internal router ticker
|
||||
void
|
||||
Tick();
|
||||
bool
|
||||
ReloadConfig(const llarp_config *conf);
|
||||
|
||||
/// get time from event loop
|
||||
llarp_time_t
|
||||
Now() const
|
||||
{
|
||||
return llarp_ev_loop_time_now_ms(netloop);
|
||||
}
|
||||
/// send to remote router or queue for sending
|
||||
/// returns false on overflow
|
||||
/// returns true on successful queue
|
||||
/// NOT threadsafe
|
||||
/// MUST be called in the logic thread
|
||||
bool
|
||||
SendToOrQueue(const llarp::RouterID &remote,
|
||||
const llarp::ILinkMessage *msg);
|
||||
|
||||
/// schedule ticker to call i ms from now
|
||||
void
|
||||
ScheduleTicker(uint64_t i = 1000);
|
||||
/// sendto or drop
|
||||
void
|
||||
SendTo(llarp::RouterID remote, const llarp::ILinkMessage *msg,
|
||||
llarp::ILinkLayer *chosen);
|
||||
|
||||
llarp::ILinkLayer *
|
||||
GetLinkWithSessionByPubkey(const llarp::RouterID &remote);
|
||||
/// manually flush outbound message queue for just 1 router
|
||||
void
|
||||
FlushOutboundFor(llarp::RouterID remote,
|
||||
llarp::ILinkLayer *chosen = nullptr);
|
||||
|
||||
void
|
||||
ConnectToRandomRouters(int N);
|
||||
/// manually discard all pending messages to remote router
|
||||
void
|
||||
DiscardOutboundFor(const llarp::RouterID &remote);
|
||||
|
||||
size_t
|
||||
NumberOfConnectedRouters() const;
|
||||
/// try establishing a session to a remote router
|
||||
void
|
||||
TryEstablishTo(const llarp::RouterID &remote);
|
||||
|
||||
bool
|
||||
GetRandomConnectedRouter(llarp::RouterContact &result) const;
|
||||
void
|
||||
HandleDHTLookupForExplore(
|
||||
llarp::RouterID remote,
|
||||
const std::vector< llarp::RouterContact > &results);
|
||||
|
||||
void
|
||||
async_verify_RC(const llarp::RouterContact &rc, llarp::ILinkLayer *link);
|
||||
|
||||
void
|
||||
HandleDHTLookupForSendTo(llarp::RouterID remote,
|
||||
const std::vector< llarp::RouterContact > &results);
|
||||
|
||||
bool
|
||||
HasSessionTo(const llarp::RouterID &remote) const;
|
||||
|
||||
void
|
||||
HandleDHTLookupForTryEstablishTo(
|
||||
llarp::RouterID remote,
|
||||
const std::vector< llarp::RouterContact > &results);
|
||||
|
||||
static void
|
||||
on_verify_client_rc(llarp_async_verify_rc *context);
|
||||
|
||||
static void
|
||||
on_verify_server_rc(llarp_async_verify_rc *context);
|
||||
|
||||
static void
|
||||
handle_router_ticker(void *user, uint64_t orig, uint64_t left);
|
||||
|
||||
static void
|
||||
HandleAsyncLoadRCForSendTo(llarp_async_load_rc *async);
|
||||
|
||||
private:
|
||||
template < typename Config >
|
||||
void
|
||||
mergeHiddenServiceConfig(const Config &in, Config &out)
|
||||
{
|
||||
for(const auto &item : netConfig)
|
||||
out.push_back({item.first, item.second});
|
||||
for(const auto &item : in)
|
||||
out.push_back({item.first, item.second});
|
||||
}
|
||||
};
|
||||
void
|
||||
ForEachPeer(
|
||||
std::function< void(const llarp::ILinkSession *, bool) > visit) const;
|
||||
|
||||
/// flush outbound message queue
|
||||
void
|
||||
FlushOutbound();
|
||||
|
||||
/// called by link when a remote session is expunged
|
||||
void
|
||||
SessionClosed(const llarp::RouterID &remote);
|
||||
|
||||
/// call internal router ticker
|
||||
void
|
||||
Tick();
|
||||
|
||||
/// get time from event loop
|
||||
llarp_time_t
|
||||
Now() const
|
||||
{
|
||||
return llarp_ev_loop_time_now_ms(netloop);
|
||||
}
|
||||
|
||||
/// schedule ticker to call i ms from now
|
||||
void
|
||||
ScheduleTicker(uint64_t i = 1000);
|
||||
|
||||
llarp::ILinkLayer *
|
||||
GetLinkWithSessionByPubkey(const llarp::RouterID &remote);
|
||||
|
||||
void
|
||||
ConnectToRandomRouters(int N);
|
||||
|
||||
size_t
|
||||
NumberOfConnectedRouters() const;
|
||||
|
||||
bool
|
||||
GetRandomConnectedRouter(llarp::RouterContact &result) const;
|
||||
|
||||
void
|
||||
async_verify_RC(const llarp::RouterContact &rc, llarp::ILinkLayer *link);
|
||||
|
||||
void
|
||||
HandleDHTLookupForSendTo(
|
||||
llarp::RouterID remote,
|
||||
const std::vector< llarp::RouterContact > &results);
|
||||
|
||||
bool
|
||||
HasSessionTo(const llarp::RouterID &remote) const;
|
||||
|
||||
void
|
||||
HandleDHTLookupForTryEstablishTo(
|
||||
llarp::RouterID remote,
|
||||
const std::vector< llarp::RouterContact > &results);
|
||||
|
||||
static void
|
||||
on_verify_client_rc(llarp_async_verify_rc *context);
|
||||
|
||||
static void
|
||||
on_verify_server_rc(llarp_async_verify_rc *context);
|
||||
|
||||
static void
|
||||
handle_router_ticker(void *user, uint64_t orig, uint64_t left);
|
||||
|
||||
static void
|
||||
HandleAsyncLoadRCForSendTo(llarp_async_load_rc *async);
|
||||
|
||||
private:
|
||||
template < typename Config >
|
||||
void
|
||||
mergeHiddenServiceConfig(const Config &in, Config &out)
|
||||
{
|
||||
for(const auto &item : netConfig)
|
||||
out.push_back({item.first, item.second});
|
||||
for(const auto &item : in)
|
||||
out.push_back({item.first, item.second});
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace llarp
|
||||
|
||||
#endif
|
||||
|
|
|
@ -48,7 +48,7 @@ namespace llarp
|
|||
}
|
||||
|
||||
bool
|
||||
DHTMessage::HandleMessage(IMessageHandler* h, llarp_router* r) const
|
||||
DHTMessage::HandleMessage(IMessageHandler* h, llarp::Router* r) const
|
||||
{
|
||||
// set source as us
|
||||
llarp::dht::Key_t us = r->pubkey();
|
||||
|
|
|
@ -94,7 +94,7 @@ namespace llarp
|
|||
InboundMessageParser::ParseMessageBuffer(llarp_buffer_t buf,
|
||||
IMessageHandler* h,
|
||||
const PathID_t& from,
|
||||
llarp_router* r)
|
||||
llarp::Router* r)
|
||||
{
|
||||
bool result = false;
|
||||
msg = nullptr;
|
||||
|
|
|
@ -51,7 +51,7 @@ namespace llarp
|
|||
}
|
||||
|
||||
bool
|
||||
PathConfirmMessage::HandleMessage(IMessageHandler* h, llarp_router* r) const
|
||||
PathConfirmMessage::HandleMessage(IMessageHandler* h, llarp::Router* r) const
|
||||
{
|
||||
return h && h->HandlePathConfirmMessage(this, r);
|
||||
}
|
||||
|
|
|
@ -45,10 +45,10 @@ namespace llarp
|
|||
}
|
||||
|
||||
bool
|
||||
PathLatencyMessage::HandleMessage(IMessageHandler* h, llarp_router* r) const
|
||||
PathLatencyMessage::HandleMessage(IMessageHandler* h, llarp::Router* r) const
|
||||
{
|
||||
return h && h->HandlePathLatencyMessage(this, r);
|
||||
}
|
||||
|
||||
} // namespace routing
|
||||
} // namespace llarp
|
||||
} // namespace llarp
|
||||
|
|
|
@ -57,7 +57,7 @@ namespace llarp
|
|||
|
||||
bool
|
||||
PathTransferMessage::HandleMessage(IMessageHandler* h,
|
||||
llarp_router* r) const
|
||||
llarp::Router* r) const
|
||||
{
|
||||
return h->HandlePathTransferMessage(this, r);
|
||||
}
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
#include <llarp/rpc.hpp>
|
||||
|
||||
#include "router.hpp"
|
||||
#ifdef USE_ABYSS
|
||||
#include <libabyss.hpp>
|
||||
#endif
|
||||
|
@ -110,12 +109,12 @@ namespace llarp
|
|||
|
||||
struct CallerImpl : public ::abyss::http::JSONRPC
|
||||
{
|
||||
llarp_router* router;
|
||||
llarp::Router* router;
|
||||
llarp_time_t m_NextKeyUpdate;
|
||||
const llarp_time_t KeyUpdateInterval = 1000 * 60 * 2;
|
||||
using PubkeyList_t = GetServiceNodeListHandler::PubkeyList_t;
|
||||
|
||||
CallerImpl(llarp_router* r) : ::abyss::http::JSONRPC(), router(r)
|
||||
CallerImpl(llarp::Router* r) : ::abyss::http::JSONRPC(), router(r)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -179,8 +178,8 @@ namespace llarp
|
|||
|
||||
struct Handler : public ::abyss::httpd::IRPCHandler
|
||||
{
|
||||
llarp_router* router;
|
||||
Handler(::abyss::httpd::ConnImpl* conn, llarp_router* r)
|
||||
llarp::Router* router;
|
||||
Handler(::abyss::httpd::ConnImpl* conn, llarp::Router* r)
|
||||
: ::abyss::httpd::IRPCHandler(conn), router(r)
|
||||
{
|
||||
}
|
||||
|
@ -259,11 +258,11 @@ namespace llarp
|
|||
|
||||
struct ReqHandlerImpl : public ::abyss::httpd::BaseReqHandler
|
||||
{
|
||||
ReqHandlerImpl(llarp_router* r, llarp_time_t reqtimeout)
|
||||
ReqHandlerImpl(llarp::Router* r, llarp_time_t reqtimeout)
|
||||
: ::abyss::httpd::BaseReqHandler(reqtimeout), router(r)
|
||||
{
|
||||
}
|
||||
llarp_router* router;
|
||||
llarp::Router* router;
|
||||
::abyss::httpd::IRPCHandler*
|
||||
CreateHandler(::abyss::httpd::ConnImpl* conn)
|
||||
{
|
||||
|
@ -273,10 +272,10 @@ namespace llarp
|
|||
|
||||
struct ServerImpl
|
||||
{
|
||||
llarp_router* router;
|
||||
llarp::Router* router;
|
||||
ReqHandlerImpl _handler;
|
||||
|
||||
ServerImpl(llarp_router* r) : router(r), _handler(r, 2000)
|
||||
ServerImpl(llarp::Router* r) : router(r), _handler(r, 2000)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -306,7 +305,7 @@ namespace llarp
|
|||
#else
|
||||
struct ServerImpl
|
||||
{
|
||||
ServerImpl(__attribute__((unused)) llarp_router* r){};
|
||||
ServerImpl(__attribute__((unused)) llarp::Router* r){};
|
||||
|
||||
bool
|
||||
Start(__attribute__((unused)) const std::string& addr)
|
||||
|
@ -317,7 +316,7 @@ namespace llarp
|
|||
|
||||
struct CallerImpl
|
||||
{
|
||||
CallerImpl(__attribute__((unused)) llarp_router* r)
|
||||
CallerImpl(__attribute__((unused)) llarp::Router* r)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -340,7 +339,7 @@ namespace llarp
|
|||
|
||||
#endif
|
||||
|
||||
Caller::Caller(llarp_router* r) : m_Impl(new CallerImpl(r))
|
||||
Caller::Caller(llarp::Router* r) : m_Impl(new CallerImpl(r))
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -361,7 +360,7 @@ namespace llarp
|
|||
m_Impl->Tick(now);
|
||||
}
|
||||
|
||||
Server::Server(llarp_router* r) : m_Impl(new ServerImpl(r))
|
||||
Server::Server(llarp::Router* r) : m_Impl(new ServerImpl(r))
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
@ -2,7 +2,6 @@
|
|||
#include "buffer.hpp"
|
||||
#include "fs.hpp"
|
||||
#include "ini.hpp"
|
||||
#include "router.hpp"
|
||||
|
||||
namespace llarp
|
||||
{
|
||||
|
|
|
@ -2,13 +2,12 @@
|
|||
#include <llarp/handlers/null.hpp>
|
||||
#include <llarp/service/context.hpp>
|
||||
#include <llarp/service/endpoint.hpp>
|
||||
#include "router.hpp"
|
||||
|
||||
namespace llarp
|
||||
{
|
||||
namespace service
|
||||
{
|
||||
Context::Context(llarp_router *r) : m_Router(r)
|
||||
Context::Context(llarp::Router *r) : m_Router(r)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -229,16 +228,16 @@ namespace llarp
|
|||
|
||||
static std::map< std::string,
|
||||
std::function< llarp::service::Endpoint *(
|
||||
const std::string &, llarp_router *) > >
|
||||
const std::string &, llarp::Router *) > >
|
||||
endpointConstructors = {
|
||||
{"tun",
|
||||
[](const std::string &nick,
|
||||
llarp_router *r) -> llarp::service::Endpoint * {
|
||||
llarp::Router *r) -> llarp::service::Endpoint * {
|
||||
return new llarp::handlers::TunEndpoint(nick, r);
|
||||
}},
|
||||
{"null",
|
||||
[](const std::string &nick,
|
||||
llarp_router *r) -> llarp::service::Endpoint * {
|
||||
llarp::Router *r) -> llarp::service::Endpoint * {
|
||||
return new llarp::handlers::NullEndpoint(nick, r);
|
||||
}}};
|
||||
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
|
||||
#include <llarp/dht/messages/findintro.hpp>
|
||||
#include <llarp/logic.hpp>
|
||||
#include <llarp/messages/dht.hpp>
|
||||
#include <llarp/service/endpoint.hpp>
|
||||
#include <llarp/service/protocol.hpp>
|
||||
|
@ -10,7 +11,7 @@ namespace llarp
|
|||
{
|
||||
namespace service
|
||||
{
|
||||
Endpoint::Endpoint(const std::string& name, llarp_router* r)
|
||||
Endpoint::Endpoint(const std::string& name, llarp::Router* r)
|
||||
: path::Builder(r, r->dht, 6, 4), m_Router(r), m_Name(name)
|
||||
{
|
||||
m_Tag.Zero();
|
||||
|
@ -513,7 +514,7 @@ namespace llarp
|
|||
}
|
||||
|
||||
bool
|
||||
Endpoint::PublishIntroSet(llarp_router* r)
|
||||
Endpoint::PublishIntroSet(llarp::Router* r)
|
||||
{
|
||||
// publish via near router
|
||||
RouterID location = m_Identity.pub.Addr().data();
|
||||
|
@ -561,7 +562,7 @@ namespace llarp
|
|||
}
|
||||
|
||||
bool
|
||||
Endpoint::PublishIntroSetVia(llarp_router* r, path::Path* path)
|
||||
Endpoint::PublishIntroSetVia(llarp::Router* r, path::Path* path)
|
||||
{
|
||||
auto job = new PublishIntroSetJob(this, GenTXID(), m_IntroSet);
|
||||
if(job->SendRequestViaPath(path, r))
|
||||
|
|
|
@ -16,7 +16,7 @@ namespace llarp
|
|||
}
|
||||
|
||||
bool
|
||||
IServiceLookup::SendRequestViaPath(llarp::path::Path *path, llarp_router *r)
|
||||
IServiceLookup::SendRequestViaPath(llarp::path::Path *path, llarp::Router *r)
|
||||
{
|
||||
auto msg = BuildRequestMessage();
|
||||
if(!msg)
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
#include <llarp/logic.hpp>
|
||||
#include <llarp/routing/handler.hpp>
|
||||
#include <llarp/service/protocol.hpp>
|
||||
#include "buffer.hpp"
|
||||
|
@ -384,7 +385,7 @@ namespace llarp
|
|||
|
||||
bool
|
||||
ProtocolFrame::HandleMessage(llarp::routing::IMessageHandler* h,
|
||||
__attribute__((unused)) llarp_router* r) const
|
||||
__attribute__((unused)) llarp::Router* r) const
|
||||
{
|
||||
return h->HandleHiddenServiceFrame(this);
|
||||
}
|
||||
|
|
|
@ -53,7 +53,7 @@ namespace llarp
|
|||
|
||||
bool
|
||||
TransitHop::SendRoutingMessage(const llarp::routing::IMessage* msg,
|
||||
llarp_router* r)
|
||||
llarp::Router* r)
|
||||
{
|
||||
if(!IsEndpoint(r->pubkey()))
|
||||
return false;
|
||||
|
@ -82,7 +82,7 @@ namespace llarp
|
|||
|
||||
bool
|
||||
TransitHop::HandleDownstream(llarp_buffer_t buf, const TunnelNonce& Y,
|
||||
llarp_router* r)
|
||||
llarp::Router* r)
|
||||
{
|
||||
RelayDownstreamMessage msg;
|
||||
msg.pathid = info.rxID;
|
||||
|
@ -96,7 +96,7 @@ namespace llarp
|
|||
|
||||
bool
|
||||
TransitHop::HandleUpstream(llarp_buffer_t buf, const TunnelNonce& Y,
|
||||
llarp_router* r)
|
||||
llarp::Router* r)
|
||||
{
|
||||
r->crypto.xchacha20(buf, pathKey, Y);
|
||||
if(IsEndpoint(r->pubkey()))
|
||||
|
@ -118,14 +118,14 @@ namespace llarp
|
|||
|
||||
bool
|
||||
TransitHop::HandleDHTMessage(const llarp::dht::IMessage* msg,
|
||||
llarp_router* r)
|
||||
llarp::Router* r)
|
||||
{
|
||||
return r->dht->impl.RelayRequestForPath(info.rxID, msg);
|
||||
}
|
||||
|
||||
bool
|
||||
TransitHop::HandlePathLatencyMessage(
|
||||
const llarp::routing::PathLatencyMessage* msg, llarp_router* r)
|
||||
const llarp::routing::PathLatencyMessage* msg, llarp::Router* r)
|
||||
{
|
||||
llarp::routing::PathLatencyMessage reply;
|
||||
reply.L = msg->T;
|
||||
|
@ -135,7 +135,7 @@ namespace llarp
|
|||
bool
|
||||
TransitHop::HandlePathConfirmMessage(
|
||||
__attribute__((unused)) const llarp::routing::PathConfirmMessage* msg,
|
||||
__attribute__((unused)) llarp_router* r)
|
||||
__attribute__((unused)) llarp::Router* r)
|
||||
{
|
||||
llarp::LogWarn("unwarranted path confirm message on ", info);
|
||||
return false;
|
||||
|
@ -144,7 +144,7 @@ namespace llarp
|
|||
bool
|
||||
TransitHop::HandleDataDiscardMessage(
|
||||
__attribute__((unused)) const llarp::routing::DataDiscardMessage* msg,
|
||||
__attribute__((unused)) llarp_router* r)
|
||||
__attribute__((unused)) llarp::Router* r)
|
||||
{
|
||||
llarp::LogWarn("unwarranted path data discard message on ", info);
|
||||
return false;
|
||||
|
@ -152,7 +152,7 @@ namespace llarp
|
|||
|
||||
bool
|
||||
TransitHop::HandleObtainExitMessage(
|
||||
const llarp::routing::ObtainExitMessage* msg, llarp_router* r)
|
||||
const llarp::routing::ObtainExitMessage* msg, llarp::Router* r)
|
||||
{
|
||||
if(msg->Verify(&r->crypto)
|
||||
&& r->exitContext.ObtainNewExit(msg->I, info.rxID, msg->E != 0))
|
||||
|
@ -182,7 +182,7 @@ namespace llarp
|
|||
|
||||
bool
|
||||
TransitHop::HandleCloseExitMessage(
|
||||
const llarp::routing::CloseExitMessage* msg, llarp_router* r)
|
||||
const llarp::routing::CloseExitMessage* msg, llarp::Router* r)
|
||||
{
|
||||
llarp::routing::DataDiscardMessage discard(info.rxID, msg->S);
|
||||
auto ep = r->exitContext.FindEndpointForPath(info.rxID);
|
||||
|
@ -200,7 +200,7 @@ namespace llarp
|
|||
|
||||
bool
|
||||
TransitHop::HandleUpdateExitVerifyMessage(
|
||||
const llarp::routing::UpdateExitVerifyMessage* msg, llarp_router* r)
|
||||
const llarp::routing::UpdateExitVerifyMessage* msg, llarp::Router* r)
|
||||
{
|
||||
(void)msg;
|
||||
(void)r;
|
||||
|
@ -210,7 +210,7 @@ namespace llarp
|
|||
|
||||
bool
|
||||
TransitHop::HandleUpdateExitMessage(
|
||||
const llarp::routing::UpdateExitMessage* msg, llarp_router* r)
|
||||
const llarp::routing::UpdateExitMessage* msg, llarp::Router* r)
|
||||
{
|
||||
auto ep = r->exitContext.FindEndpointForPath(msg->P);
|
||||
if(ep)
|
||||
|
@ -233,7 +233,7 @@ namespace llarp
|
|||
|
||||
bool
|
||||
TransitHop::HandleRejectExitMessage(
|
||||
const llarp::routing::RejectExitMessage* msg, llarp_router* r)
|
||||
const llarp::routing::RejectExitMessage* msg, llarp::Router* r)
|
||||
{
|
||||
(void)msg;
|
||||
(void)r;
|
||||
|
@ -243,7 +243,7 @@ namespace llarp
|
|||
|
||||
bool
|
||||
TransitHop::HandleGrantExitMessage(
|
||||
const llarp::routing::GrantExitMessage* msg, llarp_router* r)
|
||||
const llarp::routing::GrantExitMessage* msg, llarp::Router* r)
|
||||
{
|
||||
(void)msg;
|
||||
(void)r;
|
||||
|
@ -253,7 +253,7 @@ namespace llarp
|
|||
|
||||
bool
|
||||
TransitHop::HandleTransferTrafficMessage(
|
||||
const llarp::routing::TransferTrafficMessage* msg, llarp_router* r)
|
||||
const llarp::routing::TransferTrafficMessage* msg, llarp::Router* r)
|
||||
{
|
||||
auto endpoint = r->exitContext.FindEndpointForPath(info.rxID);
|
||||
if(endpoint)
|
||||
|
@ -279,7 +279,7 @@ namespace llarp
|
|||
|
||||
bool
|
||||
TransitHop::HandlePathTransferMessage(
|
||||
const llarp::routing::PathTransferMessage* msg, llarp_router* r)
|
||||
const llarp::routing::PathTransferMessage* msg, llarp::Router* r)
|
||||
{
|
||||
auto path = r->paths.GetPathForTransfer(msg->P);
|
||||
llarp::routing::DataDiscardMessage discarded(msg->P, msg->S);
|
||||
|
|
|
@ -1,16 +1,13 @@
|
|||
#include <gtest/gtest.h>
|
||||
#include <llarp/exit.hpp>
|
||||
#include "router.hpp"
|
||||
#include <router.hpp>
|
||||
|
||||
struct ExitTest : public ::testing::Test
|
||||
{
|
||||
ExitTest()
|
||||
ExitTest() : r(nullptr, nullptr, nullptr)
|
||||
{
|
||||
llarp_crypto_init(&r.crypto);
|
||||
r.netloop = nullptr; // only windows uses defined sentinel values in
|
||||
// uninitialised blocks
|
||||
}
|
||||
llarp_router r;
|
||||
llarp::Router r;
|
||||
};
|
||||
|
||||
TEST_F(ExitTest, AddMultipleIP)
|
||||
|
@ -29,4 +26,4 @@ TEST_F(ExitTest, AddMultipleIP)
|
|||
ASSERT_TRUE(r.exitContext.ObtainNewExit(pk, secondPath, true));
|
||||
ASSERT_TRUE(r.exitContext.FindEndpointForPath(firstPath)->LocalIP()
|
||||
== r.exitContext.FindEndpointForPath(secondPath)->LocalIP());
|
||||
};
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue