lokinet/llarp/service/session.hpp

57 lines
1.2 KiB
C++
Raw Normal View History

#pragma once
#include "info.hpp"
#include "intro.hpp"
#include <llarp/crypto/types.hpp>
#include <llarp/path/path.hpp>
#include <llarp/util/status.hpp>
#include <llarp/util/types.hpp>
2023-10-03 20:00:23 +00:00
namespace llarp::service
{
2023-10-03 20:00:23 +00:00
static constexpr auto SessionLifetime = path::DEFAULT_LIFETIME * 2;
2023-10-03 20:00:23 +00:00
struct Session
{
/// the intro we have
Introduction replyIntro;
SharedSecret sharedKey;
ServiceInfo remote;
/// the intro they have
Introduction intro;
2023-10-03 20:00:23 +00:00
/// the sequence number we are to use for the next message
uint64_t seqno = 0;
2023-10-03 20:00:23 +00:00
/// number of remote messages we sent to them
uint64_t messagesSend = 0;
/// number of remote messages we got from them
uint64_t messagesRecv = 0;
2023-10-03 20:00:23 +00:00
bool inbound = false;
bool forever = false;
2023-10-03 20:00:23 +00:00
Duration_t lastSend{};
Duration_t lastRecv{};
2023-10-03 20:00:23 +00:00
util::StatusObject
ExtractStatus() const;
2023-10-03 20:00:23 +00:00
/// called to indicate we recieved on this session
void
RX();
2023-10-03 20:00:23 +00:00
/// called to indicate we transimitted on this session
void
TX();
2023-10-03 20:00:23 +00:00
bool
IsExpired(llarp_time_t now, llarp_time_t lifetime = SessionLifetime) const;
2023-10-03 20:00:23 +00:00
Address
Addr() const;
};
2023-10-03 20:00:23 +00:00
} // namespace llarp::service