#pragma once #include #include #include #include #include #include #include "platform.hpp" namespace llarp::win32 { using namespace llarp::vpn; class VPNPlatform : public Platform, public AbstractRouteManager { llarp::Context* const _ctx; const int m_Metric{2}; const auto& Net() const { return _ctx->router->net(); } void make_route(std::string ip, std::string gw, std::string cmd); void default_route_via_interface(NetworkInterface& vpn, std::string cmd); void route_via_interface(NetworkInterface& vpn, std::string addr, std::string mask, std::string cmd); public: VPNPlatform(const VPNPlatform&) = delete; VPNPlatform(VPNPlatform&&) = delete; VPNPlatform(llarp::Context* ctx) : Platform{}, _ctx{ctx} {} ~VPNPlatform() override = default; void add_route(oxen::quic::Address ip, oxen::quic::Address gateway) override; void delete_route(oxen::quic::Address ip, oxen::quic::Address gateway) override; void add_route_via_interface(NetworkInterface& vpn, IPRange range) override; void delete_route_via_interface(NetworkInterface& vpn, IPRange range) override; std::vector get_non_interface_gateways(NetworkInterface& vpn) override; void add_default_route_via_interface(NetworkInterface& vpn) override; void delete_default_route_via_interface(NetworkInterface& vpn) override; std::shared_ptr ObtainInterface(InterfaceInfo info, Router* router) override; std::shared_ptr create_packet_io( unsigned int ifindex, const std::optional& dns_upstream_src) override; AbstractRouteManager& RouteManager() override { return *this; } }; } // namespace llarp::win32