2019-01-22 01:14:02 +00:00
|
|
|
#include <dht/publishservicejob.hpp>
|
|
|
|
|
|
|
|
#include <dht/context.hpp>
|
|
|
|
#include <dht/messages/pubintro.hpp>
|
2020-02-29 03:59:24 +00:00
|
|
|
#include <dht/messages/gotintro.hpp>
|
2019-07-30 23:42:13 +00:00
|
|
|
#include <utility>
|
2019-01-22 01:14:02 +00:00
|
|
|
|
|
|
|
namespace llarp
|
|
|
|
{
|
|
|
|
namespace dht
|
|
|
|
{
|
2020-02-20 15:36:29 +00:00
|
|
|
PublishServiceJob::PublishServiceJob(
|
|
|
|
const TXOwner &asker, const service::EncryptedIntroSet &introset_,
|
|
|
|
AbstractContext *ctx, bool relayed_, uint64_t relayOrder_)
|
2020-01-27 21:30:41 +00:00
|
|
|
: TX< Key_t, service::EncryptedIntroSet >(
|
2020-02-20 00:07:46 +00:00
|
|
|
asker, Key_t{introset_.derivedSigningKey}, ctx)
|
|
|
|
, relayed(relayed_)
|
|
|
|
, relayOrder(relayOrder_)
|
|
|
|
, introset(introset_)
|
2019-01-22 01:14:02 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
2020-01-27 21:30:41 +00:00
|
|
|
PublishServiceJob::Validate(const service::EncryptedIntroSet &value) const
|
2019-01-22 01:14:02 +00:00
|
|
|
{
|
2020-01-27 21:30:41 +00:00
|
|
|
if(value.derivedSigningKey != introset.derivedSigningKey)
|
2019-01-22 01:14:02 +00:00
|
|
|
{
|
|
|
|
llarp::LogWarn(
|
|
|
|
"publish introset acknowledgement acked a different service");
|
|
|
|
return false;
|
|
|
|
}
|
2020-01-27 21:30:41 +00:00
|
|
|
const llarp_time_t now = llarp::time_now_ms();
|
|
|
|
return value.Verify(now);
|
2019-01-22 01:14:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
PublishServiceJob::Start(const TXOwner &peer)
|
|
|
|
{
|
2020-01-27 21:30:41 +00:00
|
|
|
parent->DHTSendTo(
|
|
|
|
peer.node.as_array(),
|
2020-02-20 00:07:46 +00:00
|
|
|
new PublishIntroMessage(introset, peer.txid, relayed, relayOrder));
|
2019-01-22 01:14:02 +00:00
|
|
|
}
|
2020-02-29 03:59:24 +00:00
|
|
|
|
|
|
|
void
|
2020-03-01 15:48:43 +00:00
|
|
|
PublishServiceJob::SendReply()
|
2020-02-29 03:59:24 +00:00
|
|
|
{
|
|
|
|
parent->DHTSendTo(whoasked.node.as_array(),
|
|
|
|
new GotIntroMessage({introset}, whoasked.txid));
|
|
|
|
}
|
|
|
|
|
2019-01-22 01:14:02 +00:00
|
|
|
} // namespace dht
|
|
|
|
} // namespace llarp
|