lokinet/llarp/service/types.cpp
dr7ana ac6255c736 Squashed commits for merge errors afer fixing client-refactor:
- Deprecate pathset, smashed into PathBuilder (renamed to PathHandler)
- Re-abstraction of sessions and PathHandlers
  - Renamed PathBuilder -> PathHandler to more accurately reflect purpose
  - {Service,Exit}Handler will remain as PathHandlers, though currently no path-sharing amongst sessions being managed is to be implemented. Handlers will maintain their own paths for both lookups and initiating sessions, while sessions will manage their paths independantly.
  - Session object handling necessitates the differentiation between outbound and inbound sessions. Initiators of sessions are entirely responsible for dictating the chosen path on which the session communicates, and must therefore continually build and manage paths for the negotiated session.
  - Outbound sessions are now {Service,Exit}Sessions
  - Inbound sessions are implemented with InboundSession, which is agnostic to the type of service being operated locally (service vs exit, client vs relay, etc). When the Session initiator signals a switch to a different path, it will be assigned to the InboundSession object by {Service,Exit}Endpoint, which manages local services and exits
2024-02-05 05:19:05 -08:00

146 lines
3.7 KiB
C++

#include "types.hpp"
#include <llarp/util/logging.hpp>
namespace llarp::service::util
{
// void ExpireSNodeSessions(llarp_time_t now, SNodeConnectionMap& sessions)
// {
// auto itr = sessions.begin();
// while (itr != sessions.end())
// {
// if (itr->second->ShouldRemove() && itr->second->IsStopped())
// {
// itr = sessions.erase(itr);
// continue;
// }
// // expunge next tick
// if (itr->second->IsExpired(now))
// {
// itr->second->Stop();
// }
// else
// {
// itr->second->Tick(now);
// }
// ++itr;
// }
// }
// void DeregisterDeadSessions(llarp_time_t now, ConnectionMap& sessions)
// {
// auto itr = sessions.begin();
// while (itr != sessions.end())
// {
// if (itr->second->IsDone(now))
// {
// itr = sessions.erase(itr);
// }
// else
// {
// ++itr;
// }
// }
// }
// void TickRemoteSessions(
// llarp_time_t now,
// ConnectionMap& remoteSessions,
// ConnectionMap& deadSessions,
// std::unordered_map<SessionTag, Session>& sessions)
// {
// auto itr = remoteSessions.begin();
// while (itr != remoteSessions.end())
// {
// itr->second->Tick(now);
// if (itr->second->Pump(now))
// {
// LogInfo(
// "marking session as dead T=",
// itr->second->get_current_tag(),
// " to ",
// itr->second->Addr());
// itr->second->Stop();
// sessions.erase(itr->second->get_current_tag());
// deadSessions.emplace(std::move(*itr));
// itr = remoteSessions.erase(itr);
// }
// else
// {
// ++itr;
// }
// }
// for (auto& item : deadSessions)
// {
// item.second->Tick(now);
// }
// }
// void ExpireConvoSessions(
// llarp_time_t now, std::unordered_map<SessionTag, Session>& sessions)
// {
// auto itr = sessions.begin();
// while (itr != sessions.end())
// {
// if (itr->second.IsExpired(now))
// {
// LogInfo("Expire session T=", itr->first, " to ", itr->second.Addr());
// itr = sessions.erase(itr);
// }
// else
// ++itr;
// }
// }
// void StopRemoteSessions(ConnectionMap& remoteSessions)
// {
// for (auto& item : remoteSessions)
// {
// item.second->Stop();
// }
// }
// void StopSnodeSessions(SNodeConnectionMap& sessions)
// {
// for (auto& item : sessions)
// {
// item.second->Stop();
// }
// }
// bool HasPathToService(const Address& addr, const ConnectionMap& remoteSessions)
// {
// auto range = remoteSessions.equal_range(addr);
// auto itr = range.first;
// while (itr != range.second)
// {
// if (itr->second->ReadyToSend())
// return true;
// ++itr;
// }
// return false;
// }
// bool GetConvoTagsForService(
// const std::unordered_map<SessionTag, Session>& sessions,
// const Address& info,
// std::set<SessionTag>& tags)
// {
// bool inserted = false;
// auto itr = sessions.begin();
// while (itr != sessions.end())
// {
// if (itr->second.remote.Addr() == info)
// {
// if (tags.emplace(itr->first).second)
// {
// inserted = true;
// }
// }
// ++itr;
// }
// return inserted;
// }
} // namespace llarp::service::util