mirror of https://github.com/oxen-io/lokinet
broken
parent
dfa567e816
commit
6ad79b97dc
@ -1,6 +1,8 @@
|
||||
#ifndef LLARP_PATHFINDER_HPP_
|
||||
#define LLARP_PATHFINDER_HPP_
|
||||
#ifndef LLARP_PATHBUILDER_HPP_
|
||||
#define LLARP_PATHBUILDER_HPP_
|
||||
#include <llarp/pathbuilder.h>
|
||||
#include <llarp/router.h>
|
||||
#include <llarp/pathset.hpp>
|
||||
|
||||
struct llarp_pathbuilder_context : public llarp::path::PathSet
|
||||
{
|
@ -0,0 +1,49 @@
|
||||
#ifndef LLARP_SERVICE_IDENTITY_HPP
|
||||
#define LLARP_SERVICE_IDENTITY_HPP
|
||||
#include <llarp/bencode.hpp>
|
||||
#include <llarp/crypto.hpp>
|
||||
#include <llarp/service/Info.hpp>
|
||||
#include <llarp/service/IntroSet.hpp>
|
||||
#include <llarp/service/types.hpp>
|
||||
|
||||
namespace llarp
|
||||
{
|
||||
namespace service
|
||||
{
|
||||
// private keys
|
||||
struct Identity : public llarp::IBEncodeMessage
|
||||
{
|
||||
llarp::SecretKey enckey;
|
||||
llarp::SecretKey signkey;
|
||||
uint64_t version = 0;
|
||||
VanityNonce vanity;
|
||||
|
||||
// public service info
|
||||
ServiceInfo pub;
|
||||
|
||||
~Identity();
|
||||
|
||||
// regenerate secret keys
|
||||
void
|
||||
RegenerateKeys(llarp_crypto* c);
|
||||
|
||||
// load from file
|
||||
bool
|
||||
LoadFromFile(const std::string& fpath);
|
||||
|
||||
bool
|
||||
BEncode(llarp_buffer_t* buf) const;
|
||||
|
||||
bool
|
||||
EnsureKeys(const std::string& fpath, llarp_crypto* c);
|
||||
|
||||
bool
|
||||
DecodeKey(llarp_buffer_t key, llarp_buffer_t* buf);
|
||||
|
||||
bool
|
||||
SignIntroSet(IntroSet& i, llarp_crypto* c) const;
|
||||
};
|
||||
} // namespace service
|
||||
} // namespace llarp
|
||||
|
||||
#endif
|
@ -0,0 +1,52 @@
|
||||
#ifndef LLARP_SERVICE_INFO_HPP
|
||||
#define LLARP_SERVICE_INFO_HPP
|
||||
#include <llarp/bencode.hpp>
|
||||
#include <llarp/crypto.hpp>
|
||||
#include <llarp/service/types.hpp>
|
||||
|
||||
namespace llarp
|
||||
{
|
||||
namespace service
|
||||
{
|
||||
struct ServiceInfo : public llarp::IBEncodeMessage
|
||||
{
|
||||
llarp::PubKey enckey;
|
||||
llarp::PubKey signkey;
|
||||
uint64_t version = 0;
|
||||
VanityNonce vanity;
|
||||
|
||||
ServiceInfo();
|
||||
|
||||
~ServiceInfo();
|
||||
|
||||
ServiceInfo&
|
||||
operator=(const ServiceInfo& other)
|
||||
{
|
||||
enckey = other.enckey;
|
||||
signkey = other.signkey;
|
||||
version = other.version;
|
||||
vanity = other.vanity;
|
||||
return *this;
|
||||
};
|
||||
|
||||
friend std::ostream&
|
||||
operator<<(std::ostream& out, const ServiceInfo& i)
|
||||
{
|
||||
return out << "[e=" << i.enckey << " s=" << i.signkey
|
||||
<< " v=" << i.version << " x=" << i.vanity << "]";
|
||||
}
|
||||
|
||||
/// calculate our address
|
||||
bool
|
||||
CalculateAddress(Address& addr) const;
|
||||
|
||||
bool
|
||||
BEncode(llarp_buffer_t* buf) const;
|
||||
|
||||
bool
|
||||
DecodeKey(llarp_buffer_t key, llarp_buffer_t* buf);
|
||||
};
|
||||
} // namespace service
|
||||
} // namespace llarp
|
||||
|
||||
#endif
|
@ -0,0 +1,45 @@
|
||||
#ifndef LLARP_SERVICE_INTRO_HPP
|
||||
#define LLARP_SERVICE_INTRO_HPP
|
||||
#include <llarp/bencode.hpp>
|
||||
#include <llarp/crypto.hpp>
|
||||
#include <llarp/path_types.hpp>
|
||||
|
||||
#include <iostream>
|
||||
|
||||
namespace llarp
|
||||
{
|
||||
namespace service
|
||||
{
|
||||
struct Introduction : public llarp::IBEncodeMessage
|
||||
{
|
||||
llarp::PubKey router;
|
||||
llarp::PathID_t pathID;
|
||||
uint64_t latency = 0;
|
||||
uint64_t version = 0;
|
||||
uint64_t expiresAt;
|
||||
|
||||
~Introduction();
|
||||
|
||||
friend std::ostream&
|
||||
operator<<(std::ostream& out, const Introduction& i)
|
||||
{
|
||||
return out << "k=" << i.router << " p=" << i.pathID
|
||||
<< " v=" << i.version << " x=" << i.expiresAt;
|
||||
}
|
||||
|
||||
bool
|
||||
BEncode(llarp_buffer_t* buf) const;
|
||||
|
||||
bool
|
||||
DecodeKey(llarp_buffer_t key, llarp_buffer_t* buf);
|
||||
|
||||
bool
|
||||
operator<(const Introduction& other) const
|
||||
{
|
||||
return expiresAt < other.expiresAt || pathID < other.pathID;
|
||||
}
|
||||
};
|
||||
} // namespace service
|
||||
} // namespace llarp
|
||||
|
||||
#endif
|
@ -0,0 +1,63 @@
|
||||
#ifndef LLARP_SERVICE_INTROSET_HPP
|
||||
#define LLARP_SERVICE_INTROSET_HPP
|
||||
#include <iostream>
|
||||
#include <llarp/bencode.hpp>
|
||||
#include <llarp/crypto.hpp>
|
||||
#include <llarp/pow.hpp>
|
||||
#include <llarp/service/Info.hpp>
|
||||
#include <llarp/service/Intro.hpp>
|
||||
|
||||
#include <list>
|
||||
|
||||
namespace llarp
|
||||
{
|
||||
namespace service
|
||||
{
|
||||
constexpr std::size_t MAX_INTROSET_SIZE = 1024;
|
||||
|
||||
struct IntroSet : public llarp::IBEncodeMessage
|
||||
{
|
||||
ServiceInfo A;
|
||||
std::list< Introduction > I;
|
||||
llarp::PoW* W = nullptr;
|
||||
llarp::Signature Z;
|
||||
|
||||
~IntroSet();
|
||||
|
||||
IntroSet&
|
||||
operator=(const IntroSet& other)
|
||||
{
|
||||
A = other.A;
|
||||
I = other.I;
|
||||
version = other.version;
|
||||
if(W)
|
||||
delete W;
|
||||
W = other.W;
|
||||
Z = other.Z;
|
||||
return *this;
|
||||
}
|
||||
|
||||
friend std::ostream&
|
||||
operator<<(std::ostream& out, const IntroSet& i)
|
||||
{
|
||||
out << "A=[" << i.A << "] I=[";
|
||||
for(const auto& intro : i.I)
|
||||
{
|
||||
out << intro << ",";
|
||||
}
|
||||
return out << "] V=" << i.version << " Z=" << i.Z;
|
||||
}
|
||||
|
||||
bool
|
||||
BEncode(llarp_buffer_t* buf) const;
|
||||
|
||||
bool
|
||||
DecodeKey(llarp_buffer_t key, llarp_buffer_t* buf);
|
||||
|
||||
bool
|
||||
VerifySignature(llarp_crypto* crypto) const;
|
||||
};
|
||||
} // namespace service
|
||||
} // namespace llarp
|
||||
|
||||
#endif
|
@ -0,0 +1,30 @@
|
||||
#ifndef LLARP_SERVICE_ENDPOINT_HPP
|
||||
#define LLARP_SERVICE_ENDPOINT_HPP
|
||||
#include <llarp/pathbuilder.hpp>
|
||||
#include <llarp/service/Identity.hpp>
|
||||
|
||||
namespace llarp
|
||||
{
|
||||
namespace service
|
||||
{
|
||||
struct Endpoint
|
||||
{
|
||||
Endpoint(const std::string& nickname, llarp_router* r);
|
||||
~Endpoint();
|
||||
|
||||
bool
|
||||
SetOption(const std::string& k, const std::string& v);
|
||||
|
||||
bool
|
||||
Start();
|
||||
|
||||
private:
|
||||
llarp_router* m_Router;
|
||||
llarp_pathbuilder_context* m_PathSet;
|
||||
std::string m_Keyfile;
|
||||
Identity m_Identity;
|
||||
};
|
||||
} // namespace service
|
||||
} // namespace llarp
|
||||
|
||||
#endif
|
@ -0,0 +1,16 @@
|
||||
#ifndef LLARP_SERVICE_TYPES_HPP
|
||||
#define LLARP_SERVICE_TYPES_HPP
|
||||
#include <llarp/aligned.hpp>
|
||||
|
||||
namespace llarp
|
||||
{
|
||||
namespace service
|
||||
{
|
||||
/// hidden service address
|
||||
typedef llarp::AlignedBuffer< 32 > Address;
|
||||
|
||||
typedef llarp::AlignedBuffer< 16 > VanityNonce;
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
Loading…
Reference in New Issue