lokinet/llarp/tooling/dht_event.hpp

135 lines
3.6 KiB
C++
Raw Normal View History

#pragma once
#include "router_event.hpp"
#include "dht/key.hpp"
2020-03-01 08:14:27 +00:00
#include "service/intro_set.hpp"
#include "dht/messages/findrouter.hpp"
namespace tooling
{
struct PubIntroSentEvent : public RouterEvent
{
llarp::dht::Key_t introsetPubkey;
llarp::RouterID relay;
uint64_t relayIndex;
PubIntroSentEvent(
const llarp::RouterID& ourRouter,
const llarp::dht::Key_t& introsetPubkey_,
const llarp::RouterID& relay_,
uint64_t relayIndex_)
: RouterEvent("DHT: PubIntroSentEvent", ourRouter, false)
, introsetPubkey(introsetPubkey_)
, relay(relay_)
, relayIndex(relayIndex_)
{
}
2020-03-07 01:20:11 +00:00
std::string
ToString() const
{
return RouterEvent::ToString() + " ---- introset pubkey: " + introsetPubkey.ShortHex()
+ ", relay: " + relay.ShortString() + ", relayIndex: " + std::to_string(relayIndex);
}
};
struct PubIntroReceivedEvent : public RouterEvent
{
llarp::dht::Key_t from;
llarp::dht::Key_t location;
uint64_t txid;
uint64_t relayOrder;
PubIntroReceivedEvent(
const llarp::RouterID& ourRouter,
const llarp::dht::Key_t& from_,
const llarp::dht::Key_t& location_,
uint64_t txid_,
uint64_t relayOrder_)
: RouterEvent("DHT: PubIntroReceivedEvent", ourRouter, true)
, from(from_)
, location(location_)
, txid(txid_)
, relayOrder(relayOrder_)
{
}
2020-03-07 01:20:11 +00:00
std::string
ToString() const override
{
return RouterEvent::ToString() + "from " + from.ShortHex()
+ " location=" + location.ShortHex() + " order=" + std::to_string(relayOrder)
+ " txid=" + std::to_string(txid);
}
};
2020-03-01 08:14:27 +00:00
struct GotIntroReceivedEvent : public RouterEvent
{
llarp::dht::Key_t From;
llarp::service::EncryptedIntroSet Introset;
uint64_t RelayOrder;
uint64_t TxID;
GotIntroReceivedEvent(
const llarp::RouterID& ourRouter_,
const llarp::dht::Key_t& from_,
const llarp::service::EncryptedIntroSet& introset_,
uint64_t txid_)
: RouterEvent("DHT:: GotIntroReceivedEvent", ourRouter_, true)
, From(from_)
, Introset(introset_)
, TxID(txid_)
{
}
2020-03-07 01:20:11 +00:00
std::string
ToString() const override
{
return RouterEvent::ToString() + "from " + From.ShortHex()
+ " location=" + Introset.derivedSigningKey.ShortHex()
+ " order=" + std::to_string(RelayOrder) + " txid=" + std::to_string(TxID);
}
2020-03-01 08:14:27 +00:00
};
struct FindRouterEvent : public RouterEvent
{
llarp::dht::Key_t from;
llarp::RouterID targetKey;
bool iterative;
bool exploritory;
uint64_t txid;
uint64_t version;
FindRouterEvent(const llarp::RouterID& ourRouter, const llarp::dht::FindRouterMessage& msg)
: RouterEvent("DHT: FindRouterEvent", ourRouter, true)
, from(msg.From)
, targetKey(msg.targetKey)
, iterative(msg.iterative)
, exploritory(msg.exploritory)
, txid(msg.txid)
, version(msg.version)
{
}
std::string
ToString() const override
{
return RouterEvent::ToString() + " from " + from.ShortHex()
+ ", targetKey: " + targetKey.ToString() + ", iterative: " + std::to_string(iterative)
+ ", exploritory " + std::to_string(exploritory) + ", txid " + std::to_string(txid)
+ ", version " + std::to_string(version);
}
};
struct FindRouterReceivedEvent : public FindRouterEvent
{
using FindRouterEvent::FindRouterEvent;
};
struct FindRouterSentEvent : public FindRouterEvent
{
using FindRouterEvent::FindRouterEvent;
};
2020-03-07 01:20:11 +00:00
} // namespace tooling