hidden service tags

pull/6/head^2
Jeff Becker 6 years ago
parent ac4faf23b5
commit bb8d566671

@ -242,6 +242,7 @@ set(LIB_SRC
llarp/service/address.cpp
llarp/service/context.cpp
llarp/service/endpoint.cpp
llarp/service/tag.cpp
llarp/service/info.cpp
${LIBTUNTAP_SRC}
)

@ -21,22 +21,32 @@ variant 2: recursively find many IS in a tag
{
A: "F",
E: "<N*32 bytes optional exclude SA list>",
I: 0 or 1 if iterative request,
N: "<16 bytes topic tag>",
T: transaction_id_uint64,
V: 0
}
exclude adding service addresses in E if present
got introduction message (GIM)
sent in reply to FIM and PIM
{
A: "G",
I: [IS],
I: [IS, IS, IS, ...],
T: transaction_id_uint64,
V: 0,
}
The I value MUST NOT contain more than 8 IS.
The I value is either 1 or 0 IS long for PIM and FIM variant 1.
publish introduction message (PIM)
publish one IS to the DHT.

@ -178,7 +178,7 @@ a signed set of introductions for a hidden service
a is the service info
i is the list of introductions that this service is advertising with
n is a 16 byte null padded utf-8 encoded string tagging the hidden service in
a topic searchable via a lookup
a topic searchable via a lookup (optional)
v is the protocol version
w is an optinal proof of work for DoS protection (slot for future)
z is the signature of the entire IS where z is set to zero signed by the hidden
@ -187,7 +187,7 @@ service's signing key.
{
a: SI,
i: [ I, I, I, ... ],
n: "<16 bytes service topic>",
n: "<16 bytes service topic (optional)>",
v: 0,
w: optional proof of work,
z: "<64 bytes signature using service info signing key>"

@ -2,6 +2,7 @@
#define LLARP_DHT_MESSAGES_FIND_INTRO_HPP
#include <llarp/dht/message.hpp>
#include <llarp/service/address.hpp>
#include <llarp/service/tag.hpp>
namespace llarp
{
@ -12,6 +13,7 @@ namespace llarp
uint64_t R = 0;
bool iterative = false;
llarp::service::Address S;
llarp::service::Tag N;
uint64_t T = 0;
FindIntroMessage(const Key_t& from) : IMessage(from)

@ -6,6 +6,7 @@
#include <llarp/pow.hpp>
#include <llarp/service/Info.hpp>
#include <llarp/service/Intro.hpp>
#include <llarp/service/tag.hpp>
#include <list>
@ -19,6 +20,7 @@ namespace llarp
{
ServiceInfo A;
std::list< Introduction > I;
Tag topic;
llarp::PoW* W = nullptr;
llarp::Signature Z;
@ -45,7 +47,13 @@ namespace llarp
{
out << intro << ",";
}
return out << "] V=" << i.version << " Z=" << i.Z;
out << "]";
auto topic = i.topic.ToString();
if(topic.size())
{
out << " topic=" << topic;
}
return out << " V=" << i.version << " Z=" << i.Z;
}
bool

@ -0,0 +1,32 @@
#ifndef LLARP_SERVICE_TAG_HPP
#define LLARP_SERVICE_TAG_HPP
#include <llarp/aligned.hpp>
namespace llarp
{
namespace service
{
struct Tag : public llarp::AlignedBuffer< 16 >
{
Tag() : llarp::AlignedBuffer< 16 >()
{
Zero();
}
Tag(const byte_t* d) : llarp::AlignedBuffer< 16 >(d)
{
}
Tag(const std::string& str) : Tag()
{
memcpy(data(), str.c_str(), std::min(16UL, str.size()));
}
std::string
ToString() const;
};
} // namespace service
} // namespace llarp
#endif

@ -25,6 +25,9 @@ namespace llarp
return BEncodeReadList(I, buf);
}
if(!BEncodeMaybeReadDictEntry("n", topic, read, key, buf))
return false;
if(!BEncodeMaybeReadDictInt("v", version, read, key, buf))
return false;
@ -48,6 +51,12 @@ namespace llarp
return false;
// end introduction list
// topic tag
if(topic.ToString().size())
{
if(!BEncodeWriteDictEntry("n", topic, buf))
return false;
}
// write version
if(!BEncodeWriteDictInt(buf, "v", version))
return false;

@ -0,0 +1,13 @@
#include <llarp/service/tag.hpp>
namespace llarp
{
namespace service
{
std::string
Tag::ToString() const
{
return std::string((const char *)data());
}
} // namespace service
} // namespace llarp
Loading…
Cancel
Save