2018-07-17 07:30:03 +00:00
|
|
|
#ifndef LLARP_SERVICE_TAG_HPP
|
|
|
|
#define LLARP_SERVICE_TAG_HPP
|
|
|
|
|
2018-12-12 00:48:54 +00:00
|
|
|
#include <dht/key.hpp>
|
2019-01-10 19:41:51 +00:00
|
|
|
#include <util/aligned.hpp>
|
2018-07-17 07:30:03 +00:00
|
|
|
|
2018-12-12 02:52:51 +00:00
|
|
|
#include <sodium/crypto_generichash.h>
|
|
|
|
|
2018-10-23 00:56:53 +00:00
|
|
|
#ifndef WIN32_LEAN_AND_MEAN
|
|
|
|
#define WIN32_LEAN_AND_MEAN
|
|
|
|
#endif
|
|
|
|
|
2018-07-17 07:30:03 +00:00
|
|
|
namespace llarp
|
|
|
|
{
|
|
|
|
namespace service
|
|
|
|
{
|
|
|
|
struct Tag : public llarp::AlignedBuffer< 16 >
|
|
|
|
{
|
2019-01-02 01:03:53 +00:00
|
|
|
Tag() : llarp::AlignedBuffer< SIZE >()
|
2018-07-17 07:30:03 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2019-01-02 01:03:53 +00:00
|
|
|
Tag(const byte_t* d) : llarp::AlignedBuffer< SIZE >(d)
|
2018-07-17 07:30:03 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
Tag(const std::string& str) : Tag()
|
|
|
|
{
|
2018-10-23 00:56:53 +00:00
|
|
|
// evidently, does nothing on LP64 systems (where size_t is *already*
|
|
|
|
// unsigned long but zero-extends this on LLP64 systems
|
2019-01-02 17:41:13 +00:00
|
|
|
// 2Jan19: reeee someone undid the patch
|
2019-01-19 01:04:47 +00:00
|
|
|
std::copy(
|
|
|
|
str.begin(),
|
|
|
|
str.begin() + std::min(std::string::size_type(16), str.size()),
|
|
|
|
begin());
|
2018-07-17 07:30:03 +00:00
|
|
|
}
|
|
|
|
|
2018-08-10 03:51:38 +00:00
|
|
|
Tag&
|
|
|
|
operator=(const Tag& other)
|
|
|
|
{
|
2019-01-02 01:03:53 +00:00
|
|
|
as_array() = other.as_array();
|
2018-08-10 03:51:38 +00:00
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
2018-08-10 21:34:11 +00:00
|
|
|
Tag&
|
|
|
|
operator=(const std::string& str)
|
2018-07-18 03:10:21 +00:00
|
|
|
{
|
2019-01-19 01:04:47 +00:00
|
|
|
std::copy(
|
|
|
|
str.begin(),
|
|
|
|
str.begin() + std::min(std::string::size_type(16), str.size()),
|
|
|
|
begin());
|
2018-08-10 21:34:11 +00:00
|
|
|
return *this;
|
2018-07-18 03:10:21 +00:00
|
|
|
}
|
|
|
|
|
2018-07-17 07:30:03 +00:00
|
|
|
std::string
|
|
|
|
ToString() const;
|
2018-07-18 03:10:21 +00:00
|
|
|
|
2018-08-10 21:34:11 +00:00
|
|
|
bool
|
|
|
|
Empty() const
|
|
|
|
{
|
|
|
|
return ToString().empty();
|
|
|
|
}
|
|
|
|
|
2018-12-20 14:18:03 +00:00
|
|
|
using Hash = AlignedBuffer< SIZE >::Hash;
|
2018-07-17 07:30:03 +00:00
|
|
|
};
|
|
|
|
} // namespace service
|
|
|
|
} // namespace llarp
|
|
|
|
|
2018-10-21 14:19:49 +00:00
|
|
|
#endif
|