mirror of
https://github.com/oxen-io/lokinet.git
synced 2024-11-11 07:10:36 +00:00
4ef25ef679
Wires up systemd support to configure DNS on startup and when enabling/disabling exit mode. On startup (and when turning off an exit) we tell systemd-resolved to direct .loki and .snode lookups to lokinet (leaving other DNS traffic alone). On exit enabling, we reconfigure it to resolve "." (i.e. the root DNS domain) so that all lookups come into it.
78 lines
1.3 KiB
C++
78 lines
1.3 KiB
C++
#pragma once
|
|
|
|
#include <unordered_map>
|
|
#include <string>
|
|
#include <memory>
|
|
#include <optional>
|
|
#include <llarp/net/net_int.hpp>
|
|
#include "systemd_resolved.hpp"
|
|
|
|
namespace llarp
|
|
{
|
|
struct AbstractRouter;
|
|
|
|
struct RoutePoker
|
|
{
|
|
void
|
|
AddRoute(huint32_t ip);
|
|
|
|
void
|
|
DelRoute(huint32_t ip);
|
|
|
|
void
|
|
Init(AbstractRouter* router, bool enable = false);
|
|
|
|
~RoutePoker();
|
|
|
|
void
|
|
Update();
|
|
|
|
// sets stored routes and causes AddRoute to actually
|
|
// set routes rather than just storing them
|
|
void
|
|
Enable();
|
|
|
|
// unsets stored routes, and causes AddRoute to simply
|
|
// remember the desired routes rather than setting them.
|
|
void
|
|
Disable();
|
|
|
|
/// explicitly put routes up
|
|
void
|
|
Up();
|
|
|
|
/// explicitly put routes down
|
|
void
|
|
Down();
|
|
|
|
private:
|
|
void
|
|
DeleteAllRoutes();
|
|
|
|
void
|
|
DisableAllRoutes();
|
|
|
|
void
|
|
EnableAllRoutes();
|
|
|
|
void
|
|
EnableRoute(huint32_t ip, huint32_t gateway);
|
|
|
|
void
|
|
DisableRoute(huint32_t ip, huint32_t gateway);
|
|
|
|
std::optional<huint32_t>
|
|
GetDefaultGateway() const;
|
|
|
|
std::unordered_map<huint32_t, huint32_t> m_PokedRoutes;
|
|
huint32_t m_CurrentGateway;
|
|
|
|
bool m_Enabled = false;
|
|
bool m_Enabling = false;
|
|
|
|
AbstractRouter* m_Router = nullptr;
|
|
|
|
bool m_HasNetwork = true;
|
|
};
|
|
} // namespace llarp
|