2018-06-23 00:00:44 +00:00
|
|
|
#ifndef LLARP_API_MESSAGES_HPP
|
|
|
|
#define LLARP_API_MESSAGES_HPP
|
|
|
|
|
|
|
|
#include <list>
|
|
|
|
#include <llarp/aligned.hpp>
|
|
|
|
#include <llarp/bencode.hpp>
|
|
|
|
#include <llarp/crypto.hpp>
|
2018-07-13 19:26:28 +00:00
|
|
|
#include <llarp/service/Info.hpp>
|
2018-06-23 00:00:44 +00:00
|
|
|
|
|
|
|
namespace llarp
|
|
|
|
{
|
|
|
|
namespace api
|
|
|
|
{
|
|
|
|
// forward declare
|
|
|
|
struct Client;
|
|
|
|
struct Server;
|
|
|
|
|
|
|
|
/// base message
|
|
|
|
struct IMessage : public IBEncodeMessage
|
|
|
|
{
|
2018-07-13 19:26:28 +00:00
|
|
|
uint64_t seqno = 0;
|
2018-06-23 00:00:44 +00:00
|
|
|
llarp::ShortHash hash;
|
|
|
|
|
2018-07-13 19:26:28 +00:00
|
|
|
virtual ~IMessage(){};
|
|
|
|
|
2018-06-23 00:00:44 +00:00
|
|
|
// the function name this message belongs to
|
|
|
|
virtual std::string
|
|
|
|
FunctionName() const = 0;
|
|
|
|
|
|
|
|
bool
|
|
|
|
BEncode(llarp_buffer_t* buf) const;
|
|
|
|
|
2018-07-13 19:26:28 +00:00
|
|
|
virtual bool
|
2018-06-23 00:00:44 +00:00
|
|
|
DecodeKey(llarp_buffer_t key, llarp_buffer_t* buf);
|
|
|
|
|
2018-07-13 19:26:28 +00:00
|
|
|
/// encode the dictionary members after the A value and before the Y value
|
2018-06-23 00:00:44 +00:00
|
|
|
virtual bool
|
2018-07-13 19:26:28 +00:00
|
|
|
EncodeParams(llarp_buffer_t* buf) const = 0;
|
2018-06-23 00:00:44 +00:00
|
|
|
|
|
|
|
bool
|
|
|
|
IsWellFormed(llarp_crypto* c, const std::string& password);
|
|
|
|
|
|
|
|
void
|
|
|
|
CalculateHash(llarp_crypto* c, const std::string& password);
|
|
|
|
};
|
|
|
|
|
|
|
|
/// a "yes we got your command" type message
|
2018-07-13 19:26:28 +00:00
|
|
|
struct AckMessage : public IMessage
|
2018-06-23 00:00:44 +00:00
|
|
|
{
|
2018-07-13 19:26:28 +00:00
|
|
|
~AckMessage();
|
2018-06-23 00:00:44 +00:00
|
|
|
|
2018-07-13 19:26:28 +00:00
|
|
|
bool
|
|
|
|
EncodeParams(llarp_buffer_t* buf) const;
|
|
|
|
|
|
|
|
std::string
|
|
|
|
FunctionName() const
|
2018-06-23 00:00:44 +00:00
|
|
|
{
|
2018-07-13 19:26:28 +00:00
|
|
|
return "ack";
|
2018-06-23 00:00:44 +00:00
|
|
|
}
|
2018-07-13 19:26:28 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
// spawn hidden service message
|
|
|
|
struct SpawnMessage : public IMessage
|
|
|
|
{
|
|
|
|
~SpawnMessage();
|
|
|
|
|
|
|
|
std::string SessionName;
|
|
|
|
llarp::service::ServiceInfo Info;
|
|
|
|
|
|
|
|
bool
|
|
|
|
DecodeKey(llarp_buffer_t key, llarp_buffer_t* buf);
|
2018-06-23 00:00:44 +00:00
|
|
|
|
|
|
|
bool
|
2018-07-13 19:26:28 +00:00
|
|
|
EncodeParams(llarp_buffer_t* buf) const;
|
2018-06-23 00:00:44 +00:00
|
|
|
|
|
|
|
std::string
|
|
|
|
FunctionName() const
|
|
|
|
{
|
2018-07-13 19:26:28 +00:00
|
|
|
return "spawn";
|
2018-06-23 00:00:44 +00:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
/// a keepalive ping
|
2018-07-13 19:26:28 +00:00
|
|
|
struct KeepAliveMessage : public IMessage
|
2018-06-23 00:00:44 +00:00
|
|
|
{
|
2018-07-13 19:26:28 +00:00
|
|
|
~KeepAliveMessage();
|
|
|
|
|
|
|
|
bool
|
|
|
|
EncodeParams(llarp_buffer_t* buf) const;
|
|
|
|
|
|
|
|
std::string
|
|
|
|
FunctionName() const
|
|
|
|
{
|
|
|
|
return "keepalive";
|
|
|
|
}
|
2018-06-23 00:00:44 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/// end a session with the router
|
|
|
|
struct DestroySessionMessage : public IMessage
|
|
|
|
{
|
|
|
|
};
|
|
|
|
|
|
|
|
/// base messgae type for hidden service control and transmission
|
|
|
|
struct HSMessage : public IMessage
|
|
|
|
{
|
|
|
|
llarp::PubKey pubkey;
|
|
|
|
llarp::Signature sig;
|
|
|
|
|
|
|
|
/// validate signature on message (server side)
|
|
|
|
bool
|
|
|
|
SignatureIsValid(llarp_crypto* crypto) const;
|
|
|
|
|
|
|
|
/// sign message using secret key (client side)
|
|
|
|
bool
|
|
|
|
SignMessge(llarp_crypto* crypto, byte_t* seckey);
|
|
|
|
};
|
|
|
|
|
|
|
|
/// create a new hidden service
|
|
|
|
struct CreateServiceMessgae : public HSMessage
|
|
|
|
{
|
|
|
|
};
|
|
|
|
|
|
|
|
/// end an already created hidden service we created
|
|
|
|
struct DestroyServiceMessage : public HSMessage
|
|
|
|
{
|
|
|
|
};
|
|
|
|
|
|
|
|
/// start lookup of another service's descriptor
|
|
|
|
struct LookupServiceMessage : public IMessage
|
|
|
|
{
|
|
|
|
};
|
|
|
|
|
|
|
|
/// publish our hidden service's descriptor
|
|
|
|
struct PublishServiceMessage : public IMessage
|
|
|
|
{
|
|
|
|
};
|
|
|
|
|
|
|
|
/// send pre encrypted data down a path we own
|
|
|
|
struct SendPathDataMessage : public IMessage
|
|
|
|
{
|
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace api
|
|
|
|
} // namespace llarp
|
|
|
|
|
|
|
|
#endif
|