lokinet/llarp/service/session.cpp
2019-06-18 08:58:22 -04:00

29 lines
802 B
C++

#include <service/session.hpp>
namespace llarp
{
namespace service
{
util::StatusObject
Session::ExtractStatus() const
{
util::StatusObject obj{{"lastUsed", lastUsed},
{"replyIntro", replyIntro.ExtractStatus()},
{"remote", remote.Addr().ToString()},
{"seqno", seqno},
{"intro", intro.ExtractStatus()}};
return obj;
}
bool
Session::IsExpired(llarp_time_t now, llarp_time_t lifetime) const
{
if(now <= lastUsed)
return intro.IsExpired(now) || replyIntro.IsExpired(now);
return now - lastUsed > lifetime || intro.IsExpired(now)
|| replyIntro.IsExpired(now);
}
} // namespace service
} // namespace llarp