lokinet/llarp/messages/exit.hpp

227 lines
4.7 KiB
C++
Raw Normal View History

#ifndef LLARP_MESSAGES_EXIT_HPP
#define LLARP_MESSAGES_EXIT_HPP
2018-12-12 01:06:46 +00:00
#include <crypto.hpp>
#include <exit/policy.hpp>
2018-12-12 02:04:32 +00:00
#include <routing/message.hpp>
2018-12-12 01:06:46 +00:00
#include <vector>
namespace llarp
{
namespace routing
{
struct ObtainExitMessage final : public IMessage
{
std::vector< llarp::exit::Policy > B;
uint64_t E;
llarp::PubKey I;
uint64_t T;
std::vector< llarp::exit::Policy > W;
llarp_time_t X;
llarp::Signature Z;
ObtainExitMessage() : IMessage()
{
}
~ObtainExitMessage()
{
}
ObtainExitMessage&
operator=(const ObtainExitMessage& other);
/// populates I and signs
bool
Sign(llarp::Crypto* c, const llarp::SecretKey& sk);
bool
Verify(llarp::Crypto* c) const;
bool
BEncode(llarp_buffer_t* buf) const override;
bool
DecodeKey(llarp_buffer_t key, llarp_buffer_t* buf) override;
bool
HandleMessage(IMessageHandler* h, llarp::Router* r) const override;
};
struct GrantExitMessage final : public IMessage
{
2018-11-14 18:02:27 +00:00
using Nonce_t = llarp::AlignedBuffer< 16 >;
2018-11-14 12:23:08 +00:00
uint64_t T;
2018-11-14 18:02:27 +00:00
Nonce_t Y;
llarp::Signature Z;
GrantExitMessage() : IMessage()
{
}
~GrantExitMessage()
{
}
2018-11-14 18:02:27 +00:00
GrantExitMessage&
operator=(const GrantExitMessage& other);
bool
BEncode(llarp_buffer_t* buf) const override;
2018-11-14 18:02:27 +00:00
bool
Sign(llarp::Crypto* c, const llarp::SecretKey& sk);
2018-11-14 18:02:27 +00:00
bool
Verify(llarp::Crypto* c, const llarp::PubKey& pk) const;
2018-11-14 18:02:27 +00:00
bool
DecodeKey(llarp_buffer_t key, llarp_buffer_t* buf) override;
bool
HandleMessage(IMessageHandler* h, llarp::Router* r) const override;
};
struct RejectExitMessage final : public IMessage
{
2018-11-14 18:02:27 +00:00
using Nonce_t = llarp::AlignedBuffer< 16 >;
2018-11-14 12:23:08 +00:00
uint64_t B;
std::vector< llarp::exit::Policy > R;
uint64_t T;
2018-11-14 18:02:27 +00:00
Nonce_t Y;
llarp::Signature Z;
2018-11-14 12:23:08 +00:00
RejectExitMessage() : IMessage()
{
}
~RejectExitMessage()
{
}
2018-11-14 18:02:27 +00:00
RejectExitMessage&
operator=(const RejectExitMessage& other);
bool
Sign(llarp::Crypto* c, const llarp::SecretKey& sk);
2018-11-14 18:02:27 +00:00
bool
Verify(llarp::Crypto* c, const llarp::PubKey& pk) const;
2018-11-14 18:02:27 +00:00
bool
BEncode(llarp_buffer_t* buf) const override;
bool
DecodeKey(llarp_buffer_t key, llarp_buffer_t* buf) override;
bool
HandleMessage(IMessageHandler* h, llarp::Router* r) const override;
};
2018-11-14 12:23:08 +00:00
struct UpdateExitVerifyMessage final : public IMessage
{
2018-11-14 18:02:27 +00:00
using Nonce_t = llarp::AlignedBuffer< 16 >;
2018-11-14 12:23:08 +00:00
uint64_t T;
2018-11-14 18:02:27 +00:00
Nonce_t Y;
llarp::Signature Z;
2018-11-14 12:23:08 +00:00
UpdateExitVerifyMessage() : IMessage()
{
}
~UpdateExitVerifyMessage()
{
}
2018-11-14 18:02:27 +00:00
UpdateExitVerifyMessage&
operator=(const UpdateExitVerifyMessage& other);
bool
Sign(llarp::Crypto* c, const llarp::SecretKey& sk);
2018-11-14 18:02:27 +00:00
bool
Verify(llarp::Crypto* c, const llarp::PubKey& pk) const;
2018-11-14 18:02:27 +00:00
2018-11-14 12:23:08 +00:00
bool
BEncode(llarp_buffer_t* buf) const override;
bool
DecodeKey(llarp_buffer_t key, llarp_buffer_t* buf) override;
bool
HandleMessage(IMessageHandler* h, llarp::Router* r) const override;
2018-11-14 12:23:08 +00:00
};
struct UpdateExitMessage final : public IMessage
{
2018-11-14 18:02:27 +00:00
using Nonce_t = llarp::AlignedBuffer< 16 >;
2018-11-14 12:23:08 +00:00
llarp::PathID_t P;
uint64_t T;
2018-11-14 18:02:27 +00:00
Nonce_t Y;
2018-11-14 12:23:08 +00:00
llarp::Signature Z;
UpdateExitMessage() : IMessage()
{
}
~UpdateExitMessage()
{
}
2018-11-14 12:23:08 +00:00
UpdateExitMessage&
operator=(const UpdateExitMessage& other);
bool
Sign(llarp::Crypto* c, const llarp::SecretKey& sk);
2018-11-14 12:23:08 +00:00
bool
Verify(llarp::Crypto* c, const llarp::PubKey& pk) const;
2018-11-14 12:23:08 +00:00
bool
BEncode(llarp_buffer_t* buf) const override;
bool
DecodeKey(llarp_buffer_t key, llarp_buffer_t* buf) override;
bool
HandleMessage(IMessageHandler* h, llarp::Router* r) const override;
};
struct CloseExitMessage final : public IMessage
{
2018-11-14 18:02:27 +00:00
using Nonce_t = llarp::AlignedBuffer< 16 >;
Nonce_t Y;
llarp::Signature Z;
CloseExitMessage() : IMessage()
{
}
~CloseExitMessage()
{
}
2018-11-14 18:02:27 +00:00
CloseExitMessage&
operator=(const CloseExitMessage& other);
bool
BEncode(llarp_buffer_t* buf) const override;
bool
DecodeKey(llarp_buffer_t key, llarp_buffer_t* buf) override;
bool
HandleMessage(IMessageHandler* h, llarp::Router* r) const override;
2018-11-14 18:02:27 +00:00
bool
Sign(llarp::Crypto* c, const llarp::SecretKey& sk);
2018-11-14 18:02:27 +00:00
bool
Verify(llarp::Crypto* c, const llarp::PubKey& pk) const;
};
} // namespace routing
} // namespace llarp
#endif