Specify override and final in inheritance tree of llarp::IBEncodeMessage

pull/41/head
Michael Thorpe 6 years ago
parent 6f8e6be252
commit a5f99def0b
No known key found for this signature in database
GPG Key ID: 9E72CAE320D5817C

@ -17,7 +17,7 @@
/// address information model
namespace llarp
{
struct AddressInfo : public IBEncodeMessage
struct AddressInfo final : public IBEncodeMessage
{
uint16_t rank;
std::string dialect;
@ -52,10 +52,10 @@ namespace llarp
operator<(const AddressInfo& other) const;
bool
BEncode(llarp_buffer_t* buf) const;
BEncode(llarp_buffer_t* buf) const override;
bool
DecodeKey(llarp_buffer_t k, llarp_buffer_t* buf);
DecodeKey(llarp_buffer_t k, llarp_buffer_t* buf) override;
friend std::ostream&
operator<<(std::ostream& out, const AddressInfo& a)

@ -230,16 +230,10 @@ namespace llarp
}
virtual bool
DecodeKey(llarp_buffer_t key, llarp_buffer_t* val)
{
return false;
}
DecodeKey(llarp_buffer_t key, llarp_buffer_t* val) = 0;
virtual bool
BEncode(llarp_buffer_t* buf) const
{
return false;
}
BEncode(llarp_buffer_t* buf) const = 0;
virtual bool
BDecode(llarp_buffer_t* buf)

@ -1,5 +1,6 @@
#ifndef LLARP_DHT_MESSAGE_HPP
#define LLARP_DHT_MESSAGE_HPP
#include <llarp/dht.h>
#include <llarp/bencode.hpp>
#include <llarp/dht/key.hpp>

@ -8,7 +8,7 @@ namespace llarp
{
namespace dht
{
struct FindIntroMessage : public IMessage
struct FindIntroMessage final : public IMessage
{
uint64_t R = 0;
llarp::service::Address S;
@ -38,14 +38,15 @@ namespace llarp
~FindIntroMessage();
bool
BEncode(llarp_buffer_t* buf) const;
BEncode(llarp_buffer_t* buf) const override;
bool
DecodeKey(llarp_buffer_t key, llarp_buffer_t* val);
DecodeKey(llarp_buffer_t key, llarp_buffer_t* val) override;
bool
HandleMessage(llarp_dht_context* ctx,
std::vector< std::unique_ptr< IMessage > >& replies) const;
HandleMessage(
llarp_dht_context* ctx,
std::vector< std::unique_ptr< IMessage > >& replies) const override;
};
} // namespace dht
} // namespace llarp

@ -27,14 +27,15 @@ namespace llarp
~FindRouterMessage();
bool
BEncode(llarp_buffer_t* buf) const;
BEncode(llarp_buffer_t* buf) const override;
bool
DecodeKey(llarp_buffer_t key, llarp_buffer_t* val);
DecodeKey(llarp_buffer_t key, llarp_buffer_t* val) override;
virtual bool
HandleMessage(llarp_dht_context* ctx,
std::vector< std::unique_ptr< IMessage > >& replies) const;
HandleMessage(
llarp_dht_context* ctx,
std::vector< std::unique_ptr< IMessage > >& replies) const override;
RouterID K;
bool iterative = false;
@ -44,7 +45,7 @@ namespace llarp
};
/// variant of FindRouterMessage relayed via path
struct RelayedFindRouterMessage : public FindRouterMessage
struct RelayedFindRouterMessage final : public FindRouterMessage
{
RelayedFindRouterMessage(const Key_t& from) : FindRouterMessage(from)
{
@ -54,8 +55,9 @@ namespace llarp
/// the path of the result
/// TODO: smart path expiration logic needs to be implemented
virtual bool
HandleMessage(llarp_dht_context* ctx,
std::vector< std::unique_ptr< IMessage > >& replies) const;
HandleMessage(
llarp_dht_context* ctx,
std::vector< std::unique_ptr< IMessage > >& replies) const override;
};
} // namespace dht
} // namespace llarp

@ -8,7 +8,7 @@ namespace llarp
{
namespace dht
{
/// acknologement to PublishIntroMessage or reply to FinIntroMessage
/// acknowledgement to PublishIntroMessage or reply to FinIntroMessage
struct GotIntroMessage : public IMessage
{
std::vector< llarp::service::IntroSet > I;
@ -24,25 +24,27 @@ namespace llarp
~GotIntroMessage();
bool
BEncode(llarp_buffer_t* buf) const;
BEncode(llarp_buffer_t* buf) const override;
bool
DecodeKey(llarp_buffer_t key, llarp_buffer_t* val);
DecodeKey(llarp_buffer_t key, llarp_buffer_t* val) override;
virtual bool
HandleMessage(llarp_dht_context* ctx,
std::vector< std::unique_ptr< IMessage > >& replies) const;
HandleMessage(
llarp_dht_context* ctx,
std::vector< std::unique_ptr< IMessage > >& replies) const override;
};
struct RelayedGotIntroMessage : public GotIntroMessage
struct RelayedGotIntroMessage final : public GotIntroMessage
{
RelayedGotIntroMessage() : GotIntroMessage({})
{
}
bool
HandleMessage(llarp_dht_context* ctx,
std::vector< std::unique_ptr< IMessage > >& replies) const;
HandleMessage(
llarp_dht_context* ctx,
std::vector< std::unique_ptr< IMessage > >& replies) const override;
};
} // namespace dht
} // namespace llarp

@ -7,7 +7,7 @@ namespace llarp
{
namespace dht
{
struct GotRouterMessage : public IMessage
struct GotRouterMessage final : public IMessage
{
GotRouterMessage(const Key_t& from, bool tunneled)
: IMessage(from), relayed(tunneled)
@ -29,14 +29,15 @@ namespace llarp
~GotRouterMessage();
bool
BEncode(llarp_buffer_t* buf) const;
BEncode(llarp_buffer_t* buf) const override;
bool
DecodeKey(llarp_buffer_t key, llarp_buffer_t* val);
DecodeKey(llarp_buffer_t key, llarp_buffer_t* val) override;
virtual bool
HandleMessage(llarp_dht_context* ctx,
std::vector< std::unique_ptr< IMessage > >& replies) const;
HandleMessage(
llarp_dht_context* ctx,
std::vector< std::unique_ptr< IMessage > >& replies) const override;
std::vector< RouterContact > R;
std::vector< RouterID > N;

@ -8,7 +8,7 @@ namespace llarp
{
namespace dht
{
struct PublishIntroMessage : public IMessage
struct PublishIntroMessage final : public IMessage
{
llarp::service::IntroSet I;
std::vector< Key_t > E;
@ -31,14 +31,15 @@ namespace llarp
~PublishIntroMessage();
bool
BEncode(llarp_buffer_t* buf) const;
BEncode(llarp_buffer_t* buf) const override;
bool
DecodeKey(llarp_buffer_t key, llarp_buffer_t* val);
DecodeKey(llarp_buffer_t key, llarp_buffer_t* val) override;
virtual bool
HandleMessage(llarp_dht_context* ctx,
std::vector< std::unique_ptr< IMessage > >& replies) const;
HandleMessage(
llarp_dht_context* ctx,
std::vector< std::unique_ptr< IMessage > >& replies) const override;
};
} // namespace dht
} // namespace llarp

@ -15,7 +15,7 @@
/// Exit info model
namespace llarp
{
struct ExitInfo : public IBEncodeMessage
struct ExitInfo final : public IBEncodeMessage
{
struct in6_addr address;
struct in6_addr netmask;
@ -36,10 +36,10 @@ namespace llarp
~ExitInfo();
bool
BEncode(llarp_buffer_t *buf) const;
BEncode(llarp_buffer_t *buf) const override;
bool
DecodeKey(llarp_buffer_t k, llarp_buffer_t *buf);
DecodeKey(llarp_buffer_t k, llarp_buffer_t *buf) override;
ExitInfo &
operator=(const ExitInfo &other);

@ -9,7 +9,7 @@ namespace llarp
{
namespace routing
{
struct DHTMessage : public IMessage
struct DHTMessage final : public IMessage
{
std::vector< std::unique_ptr< llarp::dht::IMessage > > M;
uint64_t V = 0;
@ -17,13 +17,13 @@ namespace llarp
~DHTMessage();
bool
DecodeKey(llarp_buffer_t key, llarp_buffer_t* val);
DecodeKey(llarp_buffer_t key, llarp_buffer_t* val) override;
bool
BEncode(llarp_buffer_t* buf) const;
BEncode(llarp_buffer_t* buf) const override;
bool
HandleMessage(IMessageHandler* h, llarp_router* r) const;
HandleMessage(IMessageHandler* h, llarp_router* r) const override;
};
} // namespace routing
} // namespace llarp

@ -7,7 +7,7 @@
namespace llarp
{
struct DiscardMessage : public ILinkMessage
struct DiscardMessage final : public ILinkMessage
{
/// who did this message come from or is going to
@ -24,7 +24,7 @@ namespace llarp
}
bool
BEncode(llarp_buffer_t* buf) const
BEncode(llarp_buffer_t* buf) const override
{
if(!bencode_start_dict(buf))
return false;
@ -36,13 +36,13 @@ namespace llarp
}
bool
DecodeKey(llarp_buffer_t key, llarp_buffer_t* buf)
DecodeKey(llarp_buffer_t key, llarp_buffer_t* buf) override
{
return false;
}
bool
HandleMessage(llarp_router* router) const
HandleMessage(llarp_router* router) const override
{
return true;
}
@ -50,7 +50,7 @@ namespace llarp
namespace routing
{
struct DataDiscardMessage : public IMessage
struct DataDiscardMessage final : public IMessage
{
PathID_t P;
@ -65,13 +65,13 @@ namespace llarp
}
bool
HandleMessage(IMessageHandler* h, llarp_router* r) const
HandleMessage(IMessageHandler* h, llarp_router* r) const override
{
return h->HandleDataDiscardMessage(this, r);
}
bool
DecodeKey(llarp_buffer_t k, llarp_buffer_t* buf)
DecodeKey(llarp_buffer_t k, llarp_buffer_t* buf) override
{
bool read = false;
if(!BEncodeMaybeReadDictEntry("P", P, read, k, buf))
@ -84,7 +84,7 @@ namespace llarp
}
bool
BEncode(llarp_buffer_t* buf) const
BEncode(llarp_buffer_t* buf) const override
{
if(!bencode_start_dict(buf))
return false;

@ -7,7 +7,7 @@ namespace llarp
{
namespace routing
{
struct PathConfirmMessage : public IMessage
struct PathConfirmMessage final : public IMessage
{
uint64_t pathLifetime;
uint64_t pathCreated;
@ -16,15 +16,15 @@ namespace llarp
~PathConfirmMessage(){};
bool
BEncode(llarp_buffer_t* buf) const;
BEncode(llarp_buffer_t* buf) const override;
bool
DecodeKey(llarp_buffer_t key, llarp_buffer_t* val);
DecodeKey(llarp_buffer_t key, llarp_buffer_t* val) override;
bool
HandleMessage(IMessageHandler* h, llarp_router* r) const;
HandleMessage(IMessageHandler* h, llarp_router* r) const override;
};
} // namespace routing
} // namespace llarp
#endif
#endif

@ -7,22 +7,22 @@ namespace llarp
{
namespace routing
{
struct PathLatencyMessage : public IMessage
struct PathLatencyMessage final : public IMessage
{
uint64_t T = 0;
uint64_t L = 0;
PathLatencyMessage();
bool
BEncode(llarp_buffer_t* buf) const;
BEncode(llarp_buffer_t* buf) const override;
bool
DecodeKey(llarp_buffer_t key, llarp_buffer_t* val);
DecodeKey(llarp_buffer_t key, llarp_buffer_t* val) override;
bool
HandleMessage(IMessageHandler* h, llarp_router* r) const;
HandleMessage(IMessageHandler* h, llarp_router* r) const override;
};
} // namespace routing
} // namespace llarp
#endif
#endif

@ -10,7 +10,7 @@ namespace llarp
{
namespace routing
{
struct PathTransferMessage : public IMessage
struct PathTransferMessage final : public IMessage
{
PathID_t P;
service::ProtocolFrame T;
@ -25,13 +25,13 @@ namespace llarp
~PathTransferMessage();
bool
DecodeKey(llarp_buffer_t key, llarp_buffer_t* val);
DecodeKey(llarp_buffer_t key, llarp_buffer_t* val) override;
bool
BEncode(llarp_buffer_t* buf) const;
BEncode(llarp_buffer_t* buf) const override;
bool
HandleMessage(IMessageHandler*, llarp_router* r) const;
HandleMessage(IMessageHandler*, llarp_router* r) const override;
};
} // namespace routing

@ -7,7 +7,7 @@
namespace llarp
{
/// proof of work
struct PoW : public IBEncodeMessage
struct PoW final : public IBEncodeMessage
{
static constexpr size_t MaxSize = 128;
uint64_t timestamp = 0;
@ -20,10 +20,10 @@ namespace llarp
IsValid(llarp_shorthash_func hashfunc, llarp_time_t now) const;
bool
DecodeKey(llarp_buffer_t k, llarp_buffer_t* val);
DecodeKey(llarp_buffer_t k, llarp_buffer_t* val) override;
bool
BEncode(llarp_buffer_t* buf) const;
BEncode(llarp_buffer_t* buf) const override;
bool
operator==(const PoW& other) const
@ -48,4 +48,4 @@ namespace llarp
};
} // namespace llarp
#endif
#endif

@ -9,7 +9,7 @@
namespace llarp
{
struct RouterProfile : public IBEncodeMessage
struct RouterProfile final : public IBEncodeMessage
{
static constexpr size_t MaxSize = 256;
uint64_t connectTimeoutCount = 0;
@ -18,21 +18,25 @@ namespace llarp
uint64_t pathFailCount = 0;
RouterProfile() : IBEncodeMessage(){};
~RouterProfile(){};
bool
BEncode(llarp_buffer_t* buf) const;
BEncode(llarp_buffer_t* buf) const override;
bool
DecodeKey(llarp_buffer_t k, llarp_buffer_t* buf);
DecodeKey(llarp_buffer_t k, llarp_buffer_t* buf) override;
bool
IsGood(uint64_t chances) const;
};
struct Profiling : public IBEncodeMessage
struct Profiling final : public IBEncodeMessage
{
Profiling() : IBEncodeMessage(){};
Profiling() : IBEncodeMessage()
{
}
~Profiling()
{
}
@ -47,10 +51,10 @@ namespace llarp
MarkTimeout(const RouterID& r);
bool
BEncode(llarp_buffer_t* buf) const;
BEncode(llarp_buffer_t* buf) const override;
bool
DecodeKey(llarp_buffer_t k, llarp_buffer_t* buf);
DecodeKey(llarp_buffer_t k, llarp_buffer_t* buf) override;
bool
Load(const char* fname);

@ -12,7 +12,7 @@
namespace llarp
{
struct RouterContact : public IBEncodeMessage
struct RouterContact final : public IBEncodeMessage
{
RouterContact() : IBEncodeMessage()
{
@ -48,20 +48,20 @@ namespace llarp
uint64_t last_updated;
bool
BEncode(llarp_buffer_t *buf) const;
BEncode(llarp_buffer_t *buf) const override;
void
Clear();
bool
BDecode(llarp_buffer_t *buf)
BDecode(llarp_buffer_t *buf) override
{
Clear();
return IBEncodeMessage::BDecode(buf);
}
bool
DecodeKey(llarp_buffer_t k, llarp_buffer_t *buf);
DecodeKey(llarp_buffer_t k, llarp_buffer_t *buf) override;
RouterContact &
operator=(const RouterContact &other);

@ -11,7 +11,7 @@ namespace llarp
namespace service
{
// private keys
struct Identity : public llarp::IBEncodeMessage
struct Identity final : public llarp::IBEncodeMessage
{
llarp::SecretKey enckey;
llarp::SecretKey signkey;
@ -33,7 +33,7 @@ namespace llarp
LoadFromFile(const std::string& fpath);
bool
BEncode(llarp_buffer_t* buf) const;
BEncode(llarp_buffer_t* buf) const override;
bool
EnsureKeys(const std::string& fpath, llarp_crypto* c);
@ -43,7 +43,7 @@ namespace llarp
const ServiceInfo& other, const byte_t* N) const;
bool
DecodeKey(llarp_buffer_t key, llarp_buffer_t* buf);
DecodeKey(llarp_buffer_t key, llarp_buffer_t* buf) override;
bool
SignIntroSet(IntroSet& i, llarp_crypto* c, llarp_time_t now) const;
@ -54,4 +54,4 @@ namespace llarp
} // namespace service
} // namespace llarp
#endif
#endif

@ -8,7 +8,7 @@ namespace llarp
{
namespace service
{
struct ServiceInfo : public llarp::IBEncodeMessage
struct ServiceInfo final : public llarp::IBEncodeMessage
{
private:
llarp::PubKey enckey;
@ -121,7 +121,7 @@ namespace llarp
CalculateAddress(byte_t* buf) const;
bool
BDecode(llarp_buffer_t* buf)
BDecode(llarp_buffer_t* buf) override
{
if(IBEncodeMessage::BDecode(buf))
return CalculateAddress(m_CachedAddr.data());
@ -129,10 +129,10 @@ namespace llarp
}
bool
BEncode(llarp_buffer_t* buf) const;
BEncode(llarp_buffer_t* buf) const override;
bool
DecodeKey(llarp_buffer_t key, llarp_buffer_t* buf);
DecodeKey(llarp_buffer_t key, llarp_buffer_t* buf) override;
private:
Address m_CachedAddr;

@ -10,7 +10,7 @@ namespace llarp
{
namespace service
{
struct Introduction : public llarp::IBEncodeMessage
struct Introduction final : public llarp::IBEncodeMessage
{
llarp::PubKey router;
llarp::PathID_t pathID;
@ -52,10 +52,10 @@ namespace llarp
}
bool
BEncode(llarp_buffer_t* buf) const;
BEncode(llarp_buffer_t* buf) const override;
bool
DecodeKey(llarp_buffer_t key, llarp_buffer_t* buf);
DecodeKey(llarp_buffer_t key, llarp_buffer_t* buf) override;
void
Clear();

@ -19,7 +19,7 @@ namespace llarp
constexpr std::size_t MAX_INTROSET_SIZE = 4096;
// 10 seconds clock skew permitted for introset expiration
constexpr llarp_time_t MAX_INTROSET_TIME_DELTA = (10 * 1000);
struct IntroSet : public llarp::IBEncodeMessage
struct IntroSet final : public llarp::IBEncodeMessage
{
ServiceInfo A;
std::vector< Introduction > I;
@ -142,10 +142,10 @@ namespace llarp
IsExpired(llarp_time_t now) const;
bool
BEncode(llarp_buffer_t* buf) const;
BEncode(llarp_buffer_t* buf) const override;
bool
DecodeKey(llarp_buffer_t key, llarp_buffer_t* buf);
DecodeKey(llarp_buffer_t key, llarp_buffer_t* buf) override;
bool
Verify(llarp_crypto* crypto, llarp_time_t now) const;

@ -23,7 +23,7 @@ namespace llarp
constexpr ProtocolType eProtocolTraffic = 1UL;
/// inner message
struct ProtocolMessage : public IBEncodeMessage
struct ProtocolMessage final : public IBEncodeMessage
{
ProtocolMessage(const ConvoTag& tag);
ProtocolMessage();
@ -39,10 +39,10 @@ namespace llarp
ConvoTag tag;
bool
DecodeKey(llarp_buffer_t key, llarp_buffer_t* val);
DecodeKey(llarp_buffer_t key, llarp_buffer_t* val) override;
bool
BEncode(llarp_buffer_t* buf) const;
BEncode(llarp_buffer_t* buf) const override;
void
PutBuffer(llarp_buffer_t payload);
@ -52,7 +52,7 @@ namespace llarp
};
/// outer message
struct ProtocolFrame : public llarp::routing::IMessage
struct ProtocolFrame final : public llarp::routing::IMessage
{
llarp::PQCipherBlock C;
llarp::Encrypted D;
@ -105,16 +105,17 @@ namespace llarp
ProtocolMessage& into) const;
bool
DecodeKey(llarp_buffer_t key, llarp_buffer_t* val);
DecodeKey(llarp_buffer_t key, llarp_buffer_t* val) override;
bool
BEncode(llarp_buffer_t* buf) const;
BEncode(llarp_buffer_t* buf) const override;
bool
Verify(llarp_crypto* c, const ServiceInfo& from) const;
bool
HandleMessage(llarp::routing::IMessageHandler* h, llarp_router* r) const;
HandleMessage(llarp::routing::IMessageHandler* h,
llarp_router* r) const override;
};
} // namespace service
} // namespace llarp

Loading…
Cancel
Save