mirror of
https://github.com/oxen-io/lokinet.git
synced 2024-10-31 09:20:21 +00:00
36792d4337
Lots and lots of places in the code had broken < operators because they are returning something like: foo < other.foo or bar < other.bar; but this breaks both the strict weak ordering requirements that are required for the "Compare" requirement for things like std::map/set/priority_queue. For example: a = {.foo=1, .bar=3} b = {.foo=3, .bar=1} does not have an ordering over a and b (both `a < b` and `b < a` are satisfied at the same time). This needs to be instead something like: foo < other.foo or (foo == other.foo and bar < other.bar) but that's a bit clunkier, and it is easier to use std::tie for tuple's built-in < comparison which does the right thing: std::tie(foo, bar) < std::tie(other.foo, other.bar) (Initially I noticed this in SockAddr/sockaddr_in6, but upon further investigation this extends to the major of multi-field `operator<`'s.) This fixes it by using std::tie (or something similar) everywhere we are doing multi-field inequalities.
64 lines
1.4 KiB
C++
64 lines
1.4 KiB
C++
#pragma once
|
|
|
|
#include <llarp/constants/link_layer.hpp>
|
|
#include <llarp/crypto/crypto.hpp>
|
|
#include <llarp/crypto/encrypted.hpp>
|
|
#include <llarp/crypto/types.hpp>
|
|
#include <llarp/link/server.hpp>
|
|
#include <llarp/config/key_manager.hpp>
|
|
|
|
#include <memory>
|
|
|
|
#include <llarp/ev/ev.hpp>
|
|
|
|
namespace llarp::iwp
|
|
{
|
|
struct Session;
|
|
|
|
struct LinkLayer final : public ILinkLayer
|
|
{
|
|
LinkLayer(
|
|
std::shared_ptr<KeyManager> keyManager,
|
|
std::shared_ptr<EventLoop> ev,
|
|
GetRCFunc getrc,
|
|
LinkMessageHandler h,
|
|
SignBufferFunc sign,
|
|
BeforeConnectFunc_t before,
|
|
SessionEstablishedHandler est,
|
|
SessionRenegotiateHandler reneg,
|
|
TimeoutHandler timeout,
|
|
SessionClosedHandler closed,
|
|
PumpDoneHandler pumpDone,
|
|
WorkerFunc_t dowork,
|
|
bool permitInbound);
|
|
|
|
std::shared_ptr<ILinkSession>
|
|
NewOutboundSession(const RouterContact& rc, const AddressInfo& ai) override;
|
|
|
|
std::string_view
|
|
Name() const override;
|
|
|
|
uint16_t
|
|
Rank() const override;
|
|
|
|
void
|
|
RecvFrom(const SockAddr& from, ILinkSession::Packet_t pkt) override;
|
|
|
|
void
|
|
WakeupPlaintext();
|
|
|
|
std::string
|
|
PrintableName() const;
|
|
|
|
private:
|
|
void
|
|
HandleWakeupPlaintext();
|
|
|
|
const std::shared_ptr<EventLoopWakeup> m_Wakeup;
|
|
std::vector<ILinkSession*> m_WakingUp;
|
|
const bool m_Inbound;
|
|
};
|
|
|
|
using LinkLayer_ptr = std::shared_ptr<LinkLayer>;
|
|
} // namespace llarp::iwp
|