2021-03-09 22:24:35 +00:00
|
|
|
#pragma once
|
2019-04-21 18:38:30 +00:00
|
|
|
|
2023-10-24 13:18:03 +00:00
|
|
|
#include "info.hpp"
|
|
|
|
#include "intro.hpp"
|
|
|
|
|
2021-03-09 22:24:35 +00:00
|
|
|
#include <llarp/crypto/types.hpp>
|
|
|
|
#include <llarp/path/path.hpp>
|
|
|
|
#include <llarp/util/status.hpp>
|
|
|
|
#include <llarp/util/types.hpp>
|
2019-04-21 18:38:30 +00:00
|
|
|
|
2023-10-03 20:00:23 +00:00
|
|
|
namespace llarp::service
|
2019-04-21 18:38:30 +00:00
|
|
|
{
|
2023-10-03 20:00:23 +00:00
|
|
|
static constexpr auto SessionLifetime = path::DEFAULT_LIFETIME * 2;
|
2021-04-02 15:10:37 +00:00
|
|
|
|
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;
|
2021-04-02 15:10:37 +00:00
|
|
|
|
2023-10-03 20:00:23 +00:00
|
|
|
/// the sequence number we are to use for the next message
|
|
|
|
uint64_t seqno = 0;
|
2021-04-02 15:10:37 +00:00
|
|
|
|
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;
|
2019-04-21 18:38:30 +00:00
|
|
|
|
2023-10-03 20:00:23 +00:00
|
|
|
bool inbound = false;
|
|
|
|
bool forever = false;
|
2021-04-02 15:10:37 +00:00
|
|
|
|
2023-10-03 20:00:23 +00:00
|
|
|
Duration_t lastSend{};
|
|
|
|
Duration_t lastRecv{};
|
2021-04-02 15:10:37 +00:00
|
|
|
|
2023-10-03 20:00:23 +00:00
|
|
|
util::StatusObject
|
|
|
|
ExtractStatus() const;
|
2021-04-02 15:10:37 +00:00
|
|
|
|
2023-10-03 20:00:23 +00:00
|
|
|
/// called to indicate we recieved on this session
|
|
|
|
void
|
|
|
|
RX();
|
2021-04-02 15:10:37 +00:00
|
|
|
|
2023-10-03 20:00:23 +00:00
|
|
|
/// called to indicate we transimitted on this session
|
|
|
|
void
|
|
|
|
TX();
|
2021-06-03 12:21:15 +00:00
|
|
|
|
2023-10-03 20:00:23 +00:00
|
|
|
bool
|
|
|
|
IsExpired(llarp_time_t now, llarp_time_t lifetime = SessionLifetime) const;
|
2019-04-21 18:38:30 +00:00
|
|
|
|
2023-10-03 20:00:23 +00:00
|
|
|
Address
|
|
|
|
Addr() const;
|
|
|
|
};
|
2019-04-21 18:38:30 +00:00
|
|
|
|
2023-10-03 20:00:23 +00:00
|
|
|
} // namespace llarp::service
|