mirror of
https://github.com/oxen-io/lokinet.git
synced 2024-11-15 12:13:24 +00:00
871c3e3281
* wintun vpn platform for windows * bundle config snippets into nsis installer for exit node, keyfile persisting, reduced hops mode. * use wintun for vpn platform * isolate all windows platform specific code into their own compilation units and libraries * split up internal libraries into more specific components * rename liblokinet.a target to liblokinet-amalgum.a to elimiate ambiguity with liblokinet.so * DNS platform for win32 * rename llarp/ev/ev_libuv.{c,h}pp to llarp/ev/libuv.{c,h}pp as the old name was idiotic * split up net platform into win32 and posix specific compilation units * rename lokinet_init.c to easter_eggs.cpp as that is what they are for and it does not need to be a c compilation target * add cmake option STRIP_SYMBOLS for seperating out debug symbols for windows builds * intercept dns traffic on all interfaces on windows using windivert and feed it into lokinet
50 lines
1.3 KiB
C++
50 lines
1.3 KiB
C++
#pragma once
|
|
#include <llarp/net/net_int.hpp>
|
|
#include <llarp/net/ip_packet.hpp>
|
|
#include <functional>
|
|
#include <unordered_map>
|
|
|
|
namespace llarp::vpn
|
|
{
|
|
using PacketHandlerFunc_t = std::function<void(llarp::net::IPPacket)>;
|
|
|
|
struct Layer4Handler;
|
|
|
|
class PacketRouter
|
|
{
|
|
PacketHandlerFunc_t m_BaseHandler;
|
|
std::unordered_map<uint8_t, std::unique_ptr<Layer4Handler>> m_IPProtoHandler;
|
|
|
|
public:
|
|
/// baseHandler will be called if no other handlers matches a packet
|
|
explicit PacketRouter(PacketHandlerFunc_t baseHandler);
|
|
|
|
/// feed in an ip packet for handling
|
|
void
|
|
HandleIPPacket(llarp::net::IPPacket pkt);
|
|
|
|
/// add a non udp packet handler using ip protocol proto
|
|
void
|
|
AddIProtoHandler(uint8_t proto, PacketHandlerFunc_t func);
|
|
|
|
/// helper that adds a udp packet handler for UDP destinted for localport
|
|
void
|
|
AddUDPHandler(huint16_t localport, PacketHandlerFunc_t func);
|
|
|
|
/// remove a udp handler that is already set up by bound port
|
|
void
|
|
RemoveUDPHandler(huint16_t localport);
|
|
};
|
|
|
|
struct Layer4Handler
|
|
{
|
|
virtual ~Layer4Handler() = default;
|
|
|
|
virtual void
|
|
HandleIPPacket(llarp::net::IPPacket pkt) = 0;
|
|
|
|
virtual void AddSubHandler(nuint16_t, PacketHandlerFunc_t){};
|
|
};
|
|
|
|
} // namespace llarp::vpn
|