1
1
Fork 0
mirror of https://github.com/oxen-io/lokinet synced 2023-12-14 06:53:00 +01:00
lokinet/include/llarp/exit/endpoint.hpp

101 lines
2.1 KiB
C++
Raw Normal View History

#ifndef LLARP_EXIT_ENDPOINT_HPP
#define LLARP_EXIT_ENDPOINT_HPP
2018-11-19 23:45:37 +01:00
#include <llarp/time.hpp>
#include <llarp/crypto.hpp>
#include <llarp/router.h>
#include <llarp/path.hpp>
namespace llarp
{
namespace handlers
{
// forward declare
struct ExitEndpoint;
} // namespace handlers
namespace exit
{
/// persistant exit state for 1 identity on the exit node
struct Endpoint
{
Endpoint(const llarp::PubKey& remoteIdent,
const llarp::PathID_t& beginPath, bool rewriteDst, huint32_t ip,
llarp::handlers::ExitEndpoint* parent);
~Endpoint();
2018-11-14 19:02:27 +01:00
/// close ourselves
void
Close();
/// return true if we are expired right now
bool
IsExpired(llarp_time_t now) const;
2018-11-14 19:02:27 +01:00
bool
ExpiresSoon(llarp_time_t now, llarp_time_t dlt = 5000) const;
/// tick ourself, reset tx/rx rates
void
Tick(llarp_time_t now);
/// handle traffic from service node / internet
bool
SendInboundTraffic(llarp_buffer_t buff);
/// send traffic to service node / internet
2018-11-14 13:23:08 +01:00
/// does ip rewrite here
bool
SendOutboundTraffic(llarp_buffer_t buf);
2018-11-14 13:23:08 +01:00
/// update local path id and cascade information to parent
/// return true if success
bool
UpdateLocalPath(const llarp::PathID_t& nextPath);
llarp::path::IHopHandler*
GetCurrentPath() const;
2018-11-14 13:23:08 +01:00
const llarp::PubKey&
PubKey() const
{
return m_remoteSignKey;
}
const llarp::PathID_t&
LocalPath() const
{
return m_CurrentPath;
}
2018-11-14 19:02:27 +01:00
uint64_t
TxRate() const
{
return m_TxRate;
}
uint64_t
RxRate() const
{
return m_RxRate;
}
2018-11-15 22:47:05 +01:00
huint32_t
LocalIP() const
{
return m_IP;
}
private:
llarp::handlers::ExitEndpoint* m_Parent;
llarp::PubKey m_remoteSignKey;
llarp::PathID_t m_CurrentPath;
2018-11-14 13:23:08 +01:00
llarp::huint32_t m_IP;
2018-11-14 19:02:27 +01:00
uint64_t m_TxRate, m_RxRate;
2018-11-14 13:23:08 +01:00
bool m_RewriteSource;
};
} // namespace exit
} // namespace llarp
2018-11-19 23:45:37 +01:00
#endif