---
title: llarp/exit/endpoint.hpp

---

# llarp/exit/endpoint.hpp



## Namespaces

| Name           |
| -------------- |
| **[llarp](Namespaces/namespacellarp.md)** <br>[crypto.hpp] |
| **[llarp::exit](Namespaces/namespacellarp_1_1exit.md)**  |

## Classes

|                | Name           |
| -------------- | -------------- |
| struct | **[llarp::exit::Endpoint](Classes/structllarp_1_1exit_1_1Endpoint.md)** <br>persistant exit state for 1 identity on the exit node  |




## Source code

```cpp
#pragma once

#include <llarp/crypto/types.hpp>
#include <llarp/net/ip_packet.hpp>
#include <llarp/path/ihophandler.hpp>
#include <llarp/routing/transfer_traffic_message.hpp>
#include <llarp/service/protocol_type.hpp>
#include <llarp/util/time.hpp>

#include <queue>

namespace llarp
{
  struct AbstractRouter;
}

namespace llarp::exit
{
  struct Endpoint
  {
    static constexpr size_t MaxUpstreamQueueSize = 256;

    Endpoint(
        AbstractRouter& router,
        const llarp::PubKey& remoteIdent,
        const llarp::path::HopHandler_ptr& path,
        bool rewriteIP,
        huint128_t ip);

    void
    Close();

    util::StatusObject
    ExtractStatus() const;

    bool
    IsExpired(llarp_time_t now) const;

    bool
    ExpiresSoon(llarp_time_t now, llarp_time_t dlt = 5s) const;

    bool
    LooksDead(llarp_time_t now, llarp_time_t timeout = 10s) const;

    void
    Tick(llarp_time_t now);

    // bool
    // QueueInboundTraffic(std::vector<byte_t> data, service::ProtocolType t);

    // bool
    //  Flush();

    // bool
    // QueueOutboundTraffic(
    //     PathID_t txid, std::vector<byte_t> data, uint64_t counter, service::ProtocolType t);

    bool
    UpdateLocalPath(const llarp::PathID_t& nextPath);

    llarp::path::HopHandler_ptr
    GetCurrentPath() const
    {
      return m_CurrentPath;
    }

    const llarp::PubKey&
    PubKey() const
    {
      return m_remoteSignKey;
    }

    uint64_t
    TxRate() const
    {
      return m_TxRate;
    }

    uint64_t
    RxRate() const
    {
      return m_RxRate;
    }

    huint128_t
    LocalIP() const
    {
      return m_IP;
    }

    const llarp_time_t createdAt;

   private:
    AbstractRouter& _router;
    llarp::PubKey m_remoteSignKey;
    llarp::path::HopHandler_ptr m_CurrentPath;
    llarp::huint128_t m_IP;
    uint64_t m_TxRate, m_RxRate;
    llarp_time_t m_LastActive;
    bool m_RewriteSource;
    using InboundTrafficQueue_t = std::deque<llarp::routing::TransferTrafficMessage>;
    using TieredQueue = std::map<uint8_t, InboundTrafficQueue_t>;
    // maps number of fragments the message will fit in to the queue for it
    TieredQueue m_DownstreamQueues;

    struct UpstreamBuffer
    {
      UpstreamBuffer(llarp::net::IPPacket p, uint64_t c) : pkt{std::move(p)}, counter(c)
      {}

      llarp::net::IPPacket pkt;
      uint64_t counter;

      bool
      operator<(const UpstreamBuffer& other) const
      {
        return counter < other.counter;
      }
    };

    using UpstreamQueue_t = std::priority_queue<UpstreamBuffer>;
    UpstreamQueue_t m_UpstreamQueue;
    uint64_t m_Counter;
  };

}  // namespace llarp::exit
```


-------------------------------

Updated on 2023-03-06 at 20:36:34 +0000
