2018-10-19 11:41:36 +00:00
|
|
|
#ifndef LLARP_RPC_HPP
|
|
|
|
#define LLARP_RPC_HPP
|
2018-12-12 02:52:51 +00:00
|
|
|
|
|
|
|
#include <crypto.hpp>
|
|
|
|
#include <ev.h>
|
|
|
|
#include <time.hpp>
|
|
|
|
|
2018-10-19 11:41:36 +00:00
|
|
|
#include <string>
|
2018-11-01 12:47:14 +00:00
|
|
|
#include <functional>
|
2018-10-19 11:41:36 +00:00
|
|
|
|
|
|
|
namespace llarp
|
|
|
|
{
|
2018-12-10 16:26:46 +00:00
|
|
|
struct Router;
|
|
|
|
|
2018-10-19 11:41:36 +00:00
|
|
|
namespace rpc
|
|
|
|
{
|
|
|
|
struct ServerImpl;
|
|
|
|
|
2018-11-01 12:47:14 +00:00
|
|
|
/// jsonrpc server
|
2018-10-19 11:41:36 +00:00
|
|
|
struct Server
|
|
|
|
{
|
2018-12-10 16:26:46 +00:00
|
|
|
Server(llarp::Router* r);
|
2018-10-19 11:41:36 +00:00
|
|
|
~Server();
|
|
|
|
|
|
|
|
bool
|
|
|
|
Start(const std::string& bindaddr);
|
|
|
|
|
|
|
|
private:
|
|
|
|
ServerImpl* m_Impl;
|
|
|
|
};
|
|
|
|
|
2018-11-01 12:47:14 +00:00
|
|
|
struct CallerImpl;
|
|
|
|
|
|
|
|
/// jsonrpc caller
|
|
|
|
struct Caller
|
|
|
|
{
|
2018-12-10 16:26:46 +00:00
|
|
|
Caller(llarp::Router* r);
|
2018-11-01 12:47:14 +00:00
|
|
|
~Caller();
|
|
|
|
|
|
|
|
/// start with jsonrpc endpoint address
|
|
|
|
bool
|
|
|
|
Start(const std::string& remote);
|
|
|
|
|
2018-11-20 15:22:59 +00:00
|
|
|
/// test if a router is valid
|
2018-11-21 17:46:33 +00:00
|
|
|
bool
|
|
|
|
VerifyRouter(const llarp::PubKey& pk);
|
|
|
|
|
|
|
|
/// do per second tick
|
2018-11-01 12:47:14 +00:00
|
|
|
void
|
2018-11-21 17:46:33 +00:00
|
|
|
Tick(llarp_time_t now);
|
2018-11-01 12:47:14 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
CallerImpl* m_Impl;
|
|
|
|
};
|
|
|
|
|
2018-10-19 11:41:36 +00:00
|
|
|
} // namespace rpc
|
|
|
|
} // namespace llarp
|
|
|
|
|
|
|
|
#endif
|