|
|
|
|
@ -19,7 +19,7 @@
|
|
|
|
|
|
|
|
|
|
#include <opendht.h>
|
|
|
|
|
|
|
|
|
|
//#define USE_MREFD_VALUES
|
|
|
|
|
#define USE_MREFD_VALUES
|
|
|
|
|
#define USE_URFD_VALUES
|
|
|
|
|
|
|
|
|
|
/* HELPERS */
|
|
|
|
|
@ -28,14 +28,6 @@ template<typename E> constexpr auto toUType(E enumerator) noexcept
|
|
|
|
|
return static_cast<std::underlying_type_t<E>>(enumerator);
|
|
|
|
|
} // Item #10 in "Effective Modern C++", by Scott Meyers, O'REILLY
|
|
|
|
|
|
|
|
|
|
// every value type needs a const user_type and a timestamp
|
|
|
|
|
struct SDhtValueBase
|
|
|
|
|
{
|
|
|
|
|
SDhtValueBase(const std::string &s) : user_type(s) {}
|
|
|
|
|
std::string user_type;
|
|
|
|
|
std::time_t timestamp;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
#ifdef USE_MREFD_VALUES
|
|
|
|
|
|
|
|
|
|
// user_type for mrefd values
|
|
|
|
|
@ -50,9 +42,9 @@ enum class EMrefdValueID : uint64_t { Config=1, Peers=2, Clients=3, Users=4 };
|
|
|
|
|
|
|
|
|
|
using MrefdPeerTuple = std::tuple<std::string, std::string, std::time_t>;
|
|
|
|
|
enum class EMrefdPeerFields { Callsign, Modules, ConnectTime };
|
|
|
|
|
struct SMrefdPeers1 : public SDhtValueBase
|
|
|
|
|
struct SMrefdPeers1
|
|
|
|
|
{
|
|
|
|
|
SMrefdPeers1() : SDhtValueBase(MREFD_PEERS_1) {}
|
|
|
|
|
std::time_t timestamp;
|
|
|
|
|
unsigned int sequence;
|
|
|
|
|
std::list<MrefdPeerTuple> list;
|
|
|
|
|
|
|
|
|
|
@ -61,9 +53,9 @@ struct SMrefdPeers1 : public SDhtValueBase
|
|
|
|
|
|
|
|
|
|
using MrefdClientTuple = std::tuple<std::string, std::string, char, std::time_t, std::time_t>;
|
|
|
|
|
enum class EMrefdClientFields { Callsign, Ip, Module, ConnectTime, LastHeardTime };
|
|
|
|
|
struct SMrefdClients1 : public SDhtValueBase
|
|
|
|
|
struct SMrefdClients1
|
|
|
|
|
{
|
|
|
|
|
SMrefdClients1() : SDhtValueBase(MREFD_CLIENTS_1) {}
|
|
|
|
|
std::time_t timestamp;
|
|
|
|
|
unsigned int sequence;
|
|
|
|
|
std::list<MrefdClientTuple> list;
|
|
|
|
|
|
|
|
|
|
@ -72,18 +64,18 @@ struct SMrefdClients1 : public SDhtValueBase
|
|
|
|
|
|
|
|
|
|
using MrefdUserTuple = std::tuple<std::string, std::string, std::string, std::time_t>;
|
|
|
|
|
enum class EMrefdUserFields { Source, Destination, Reflector, LastHeardTime };
|
|
|
|
|
struct SMrefdUsers1 : public SDhtValueBase
|
|
|
|
|
struct SMrefdUsers1
|
|
|
|
|
{
|
|
|
|
|
SMrefdUsers1() : SDhtValueBase(MREFD_USERS_1) {}
|
|
|
|
|
std::time_t timestamp;
|
|
|
|
|
unsigned int sequence;
|
|
|
|
|
std::list<MrefdUserTuple> list;
|
|
|
|
|
|
|
|
|
|
MSGPACK_DEFINE(timestamp, sequence, list)
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
struct SMrefdConfig1 : public SDhtValueBase
|
|
|
|
|
struct SMrefdConfig1
|
|
|
|
|
{
|
|
|
|
|
SMrefdConfig1() : SDhtValueBase(MREFD_CONFIG_1) {}
|
|
|
|
|
std::time_t timestamp;
|
|
|
|
|
std::string callsign, ipv4addr, ipv6addr, modules, encryptedmods, url, email, sponsor, country, version;
|
|
|
|
|
uint16_t port;
|
|
|
|
|
|
|
|
|
|
@ -103,9 +95,9 @@ enum class EUrfdValueID : uint64_t { Config=1, Peers=2, Clients=3, Users=4 };
|
|
|
|
|
|
|
|
|
|
using UrfdPeerTuple = std::tuple<std::string, std::string, std::time_t>;
|
|
|
|
|
enum class EUrfdPeerFields { Callsign, Modules, ConnectTime };
|
|
|
|
|
struct SUrfdPeers1 : public SDhtValueBase
|
|
|
|
|
struct SUrfdPeers1
|
|
|
|
|
{
|
|
|
|
|
SUrfdPeers1() : SDhtValueBase(URFD_PEERS_1) {}
|
|
|
|
|
std::time_t timestamp;
|
|
|
|
|
unsigned int sequence;
|
|
|
|
|
std::list<UrfdPeerTuple> list;
|
|
|
|
|
|
|
|
|
|
@ -114,9 +106,9 @@ struct SUrfdPeers1 : public SDhtValueBase
|
|
|
|
|
|
|
|
|
|
using UrfdClientTuple = std::tuple<std::string, std::string, char, std::time_t, std::time_t>;
|
|
|
|
|
enum class EUrfdClientFields { Callsign, Ip, Module, ConnectTime, LastHeardTime };
|
|
|
|
|
struct SUrfdClients1 : public SDhtValueBase
|
|
|
|
|
struct SUrfdClients1
|
|
|
|
|
{
|
|
|
|
|
SUrfdClients1() : SDhtValueBase(URFD_CLIENTS_1) {}
|
|
|
|
|
std::time_t timestamp;
|
|
|
|
|
unsigned int sequence;
|
|
|
|
|
std::list<UrfdClientTuple> list;
|
|
|
|
|
|
|
|
|
|
@ -125,9 +117,9 @@ struct SUrfdClients1 : public SDhtValueBase
|
|
|
|
|
|
|
|
|
|
using UrfdUserTuple = std::tuple<std::string, std::string, char, std::string, std::time_t>;
|
|
|
|
|
enum class EUrfdUserFields { Callsign, ViaNode, OnModule, ViaPeer, LastHeardTime };
|
|
|
|
|
struct SUrfdUsers1 : public SDhtValueBase
|
|
|
|
|
struct SUrfdUsers1
|
|
|
|
|
{
|
|
|
|
|
SUrfdUsers1() : SDhtValueBase(URFD_USERS_1) {}
|
|
|
|
|
std::time_t timestamp;
|
|
|
|
|
unsigned int sequence;
|
|
|
|
|
std::list<UrfdUserTuple> list;
|
|
|
|
|
|
|
|
|
|
@ -139,9 +131,9 @@ enum class EUrfdPorts : unsigned { dcs, dextra, dmrplus, dplus, m17, mmdvm, nxdn
|
|
|
|
|
enum class EUrfdAlMod : unsigned { nxdn, p25, ysf, SIZE };
|
|
|
|
|
enum class EUrfdTxRx : unsigned { rx, tx, SIZE };
|
|
|
|
|
enum class EUrfdRefId : unsigned { nxdn, p25, SIZE };
|
|
|
|
|
struct SUrfdConfig1 : public SDhtValueBase
|
|
|
|
|
struct SUrfdConfig1
|
|
|
|
|
{
|
|
|
|
|
SUrfdConfig1() : SDhtValueBase(URFD_CONFIG_1) {}
|
|
|
|
|
std::time_t timestamp;
|
|
|
|
|
std::string callsign, ipv4addr, ipv6addr, modules, transcodedmods, url, email, sponsor, country, version;
|
|
|
|
|
std::array<uint16_t, toUType(EUrfdPorts::SIZE)> port;
|
|
|
|
|
std::array<char, toUType(EUrfdAlMod::SIZE)> almod;
|
|
|
|
|
|