Move router_contact.hpp to llarp/

pull/137/head
Michael 6 years ago
parent 8877f60462
commit b92ea0521b
No known key found for this signature in database
GPG Key ID: 2D51757B47E2434C

@ -1,20 +1,18 @@
#include <getopt.h>
#include <buffer.hpp>
#include <crypto.hpp>
#include <fs.hpp>
#include <fstream>
#include <llarp.h>
#include <signal.h>
#include "logger.hpp"
#include <llarp/messages/dht.hpp>
#include <llarp/net.hpp>
#include <llarp/nodedb.hpp>
#include <llarp/router_contact.hpp>
#include <llarp/time.hpp>
#include <logger.hpp>
#include <router.hpp>
#include <router_contact.hpp>
#include <fstream>
#include "buffer.hpp"
#include "crypto.hpp"
#include "fs.hpp"
#include "llarp/net.hpp"
#include <llarp/messages/dht.hpp>
#include <getopt.h>
#include <signal.h>
struct llarp_main *ctx = 0;

@ -1,7 +1,9 @@
#ifndef LLARP_MESSAGES_LINK_INTRO_HPP
#define LLARP_MESSAGES_LINK_INTRO_HPP
#include <link_message.hpp>
#include <llarp/router_contact.hpp>
#include <router_contact.hpp>
namespace llarp
{
struct ILinkSession;

@ -1,11 +1,11 @@
#ifndef LLARP_NODEDB_HPP
#define LLARP_NODEDB_HPP
#include <fs.hpp>
#include <llarp/common.hpp>
#include <llarp/crypto.h>
#include <llarp/router_contact.hpp>
#include <llarp/router_id.hpp>
#include <fs.hpp>
#include <router_contact.hpp>
/**
* nodedb.hpp

@ -1,112 +0,0 @@
#ifndef LLARP_RC_HPP
#define LLARP_RC_HPP
#include <address_info.hpp>
#include <llarp/bencode.hpp>
#include <llarp/crypto.h>
#include <llarp/exit_info.hpp>
#include <vector>
#define MAX_RC_SIZE (1024)
#define NICKLEN (32)
namespace llarp
{
struct RouterContact final : public IBEncodeMessage
{
RouterContact() : IBEncodeMessage()
{
Clear();
}
RouterContact(const RouterContact &other)
: IBEncodeMessage()
, addrs(other.addrs)
, enckey(other.enckey)
, pubkey(other.pubkey)
, exits(other.exits)
, signature(other.signature)
, nickname(other.nickname)
, last_updated(other.last_updated)
{
version = other.version;
}
// advertised addresses
std::vector< AddressInfo > addrs;
// public encryption public key
llarp::PubKey enckey;
// public signing public key
llarp::PubKey pubkey;
// advertised exits
std::vector< ExitInfo > exits;
// signature
llarp::Signature signature;
/// node nickname, yw kee
llarp::AlignedBuffer< NICKLEN > nickname;
uint64_t last_updated;
bool
BEncode(llarp_buffer_t *buf) const override;
void
Clear();
bool
IsExit() const
{
return exits.size() > 0;
}
bool
BDecode(llarp_buffer_t *buf) override
{
Clear();
return IBEncodeMessage::BDecode(buf);
}
bool
DecodeKey(llarp_buffer_t k, llarp_buffer_t *buf) override;
RouterContact &
operator=(const RouterContact &other);
bool
HasNick() const;
std::string
Nick() const;
bool
IsPublicRouter() const;
void
SetNick(const std::string &nick);
bool
Verify(llarp::Crypto *crypto) const;
bool
Sign(llarp::Crypto *crypto, const llarp::SecretKey &secret);
bool
OtherIsNewer(const RouterContact &other) const
{
return last_updated < other.last_updated;
}
bool
Read(const char *fname);
bool
Write(const char *fname) const;
private:
bool
VerifySignature(llarp::Crypto *crypto) const;
};
} // namespace llarp
#endif

@ -1,9 +1,9 @@
#ifndef LLARP_DHT_H_
#define LLARP_DHT_H_
#include <llarp/buffer.h>
#include <crypto.hpp>
#include <llarp/router_contact.hpp>
#include <llarp/buffer.h>
#include <router_contact.hpp>
/**
* dht.h

@ -1,7 +1,7 @@
#ifndef LLARP_DHT_MESSAGES_GOT_ROUTER_HPP
#define LLARP_DHT_MESSAGES_GOT_ROUTER_HPP
#include <dht/message.hpp>
#include <llarp/router_contact.hpp>
#include <router_contact.hpp>
namespace llarp
{

@ -2,8 +2,8 @@
#define LLARP_DHT_NODE_HPP
#include <dht/key.hpp>
#include <llarp/router_contact.hpp>
#include <llarp/service/IntroSet.hpp>
#include <router_contact.hpp>
namespace llarp
{

@ -3,7 +3,7 @@
#include <llarp/bencode.h>
#include <llarp/buffer.h>
#include <llarp/router_contact.hpp>
#include <router_contact.hpp>
namespace llarp
{

@ -5,8 +5,8 @@
#include <llarp/ev.h>
#include <llarp/logic.hpp>
#include <llarp/net.hpp>
#include <llarp/router_contact.hpp>
#include <llarp/threading.hpp>
#include <router_contact.hpp>
#include <list>
#include <unordered_map>

@ -3,8 +3,9 @@
#include <crypto.hpp>
#include <llarp/net.hpp>
#include <llarp/router_contact.hpp>
#include <llarp/types.hpp>
#include <router_contact.hpp>
#include <functional>
namespace llarp

@ -1,8 +1,8 @@
#include <llarp/bencode.h>
#include <llarp/router_contact.hpp>
#include <llarp/messages/link_intro.hpp>
#include "logger.hpp"
#include "router.hpp"
#include <logger.hpp>
#include <router.hpp>
#include <router_contact.hpp>
namespace llarp
{

@ -1,7 +1,7 @@
#include <llarp/router_contact.hpp>
#include <buffer.hpp>
#include <llarp/messages.hpp>
#include "buffer.hpp"
#include "logger.hpp"
#include <logger.hpp>
#include <router_contact.hpp>
namespace llarp
{

@ -1,15 +1,15 @@
#include <buffer.hpp>
#include <crypto.hpp>
#include <encode.hpp>
#include <fs.hpp>
#include <llarp/logic.hpp>
#include <llarp/nodedb.hpp>
#include <llarp/router_contact.hpp>
#include <logger.hpp>
#include <mem.hpp>
#include <router_contact.hpp>
#include <fstream>
#include <crypto.hpp>
#include <unordered_map>
#include "buffer.hpp"
#include "encode.hpp"
#include "fs.hpp"
#include "logger.hpp"
#include "mem.hpp"
static const char skiplist_subdirs[] = "0123456789abcdef";
static const std::string RC_FILE_EXT = ".signed";

@ -17,11 +17,11 @@
#include <llarp/nodedb.hpp>
#include <llarp/path.hpp>
#include <llarp/profiling.hpp>
#include <llarp/router_contact.hpp>
#include <llarp/routing/handler.hpp>
#include <llarp/rpc.hpp>
#include <llarp/service.hpp>
#include <mem.hpp>
#include <router_contact.hpp>
#include <str.hpp>
#include <threadpool.hpp>

@ -1,12 +1,12 @@
#include <buffer.hpp>
#include <crypto.hpp>
#include <llarp/bencode.hpp>
#include <llarp/net.hpp>
#include <llarp/router_contact.hpp>
#include <llarp/time.hpp>
#include <llarp/version.hpp>
#include "buffer.hpp"
#include "logger.hpp"
#include "mem.hpp"
#include <logger.hpp>
#include <mem.hpp>
#include <router_contact.hpp>
#include <fstream>

@ -0,0 +1,112 @@
#ifndef LLARP_RC_HPP
#define LLARP_RC_HPP
#include <address_info.hpp>
#include <llarp/bencode.hpp>
#include <llarp/crypto.h>
#include <llarp/exit_info.hpp>
#include <vector>
#define MAX_RC_SIZE (1024)
#define NICKLEN (32)
namespace llarp
{
struct RouterContact final : public IBEncodeMessage
{
RouterContact() : IBEncodeMessage()
{
Clear();
}
RouterContact(const RouterContact &other)
: IBEncodeMessage()
, addrs(other.addrs)
, enckey(other.enckey)
, pubkey(other.pubkey)
, exits(other.exits)
, signature(other.signature)
, nickname(other.nickname)
, last_updated(other.last_updated)
{
version = other.version;
}
// advertised addresses
std::vector< AddressInfo > addrs;
// public encryption public key
llarp::PubKey enckey;
// public signing public key
llarp::PubKey pubkey;
// advertised exits
std::vector< ExitInfo > exits;
// signature
llarp::Signature signature;
/// node nickname, yw kee
llarp::AlignedBuffer< NICKLEN > nickname;
uint64_t last_updated;
bool
BEncode(llarp_buffer_t *buf) const override;
void
Clear();
bool
IsExit() const
{
return exits.size() > 0;
}
bool
BDecode(llarp_buffer_t *buf) override
{
Clear();
return IBEncodeMessage::BDecode(buf);
}
bool
DecodeKey(llarp_buffer_t k, llarp_buffer_t *buf) override;
RouterContact &
operator=(const RouterContact &other);
bool
HasNick() const;
std::string
Nick() const;
bool
IsPublicRouter() const;
void
SetNick(const std::string &nick);
bool
Verify(llarp::Crypto *crypto) const;
bool
Sign(llarp::Crypto *crypto, const llarp::SecretKey &secret);
bool
OtherIsNewer(const RouterContact &other) const
{
return last_updated < other.last_updated;
}
bool
Read(const char *fname);
bool
Write(const char *fname) const;
private:
bool
VerifySignature(llarp::Crypto *crypto) const;
};
} // namespace llarp
#endif
Loading…
Cancel
Save