mirror of https://github.com/oxen-io/lokinet
Remove dead/redundant code
- win32_platform.cpp is dead - win32_platform.hpp is useless Style changes from clang-tidy warnings: - remove `virtual` from some definitions that already have `override` - remove virtual destructor from NetworkInterface because it already has a virtual destructor via the base type (and clang-tiny warns about it)
This commit is contained in:
parent
4103908a8d
commit
879e678771
|
@ -373,9 +373,8 @@ lokinet_main(int argc, char** argv)
|
|||
if (startWinsock())
|
||||
return -1;
|
||||
SetConsoleCtrlHandler(handle_signal_win32, TRUE);
|
||||
|
||||
// SetUnhandledExceptionFilter(win32_signal_handler);
|
||||
#endif
|
||||
|
||||
cxxopts::Options options(
|
||||
"lokinet",
|
||||
"LokiNET is a free, open source, private, "
|
||||
|
|
|
@ -16,7 +16,6 @@
|
|||
#include "oxen/log.hpp"
|
||||
#include "sd_platform.hpp"
|
||||
#include "nm_platform.hpp"
|
||||
#include "win32_platform.hpp"
|
||||
|
||||
namespace llarp::dns
|
||||
{
|
||||
|
@ -570,10 +569,6 @@ namespace llarp::dns
|
|||
plat->add_impl(std::make_unique<SD_Platform_t>());
|
||||
plat->add_impl(std::make_unique<NM_Platform_t>());
|
||||
}
|
||||
if constexpr (llarp::platform::is_windows)
|
||||
{
|
||||
plat->add_impl(std::make_unique<Win32_Platform_t>());
|
||||
}
|
||||
return plat;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,51 +0,0 @@
|
|||
#include "win32_platform.hpp"
|
||||
#include <llarp/net/net.hpp>
|
||||
|
||||
namespace llarp::dns::win32
|
||||
{
|
||||
void
|
||||
Platform::set_resolver(unsigned int index, llarp::SockAddr dns, bool)
|
||||
{
|
||||
#ifdef _WIN32
|
||||
|
||||
// clear any previous dns settings
|
||||
m_UndoDNS.clear();
|
||||
|
||||
auto interfaces = m_Loop->Net_ptr()->AllNetworkInterfaces();
|
||||
// remove dns
|
||||
{
|
||||
std::vector<llarp::win32::OneShotExec> jobs;
|
||||
for (const auto& ent : interfaces)
|
||||
{
|
||||
if (ent.index == index)
|
||||
continue;
|
||||
jobs.emplace_back(
|
||||
"netsh.exe", fmt::format("interface ipv4 delete dns \"{}\" all", ent.name));
|
||||
jobs.emplace_back(
|
||||
"netsh.exe", fmt::format("interface ipv6 delete dns \"{}\" all", ent.name));
|
||||
}
|
||||
}
|
||||
// add new dns
|
||||
{
|
||||
std::vector<llarp::win32::OneShotExec> jobs;
|
||||
for (const auto& ent : interfaces)
|
||||
{
|
||||
if (ent.index == index)
|
||||
continue;
|
||||
jobs.emplace_back(
|
||||
"netsh.exe",
|
||||
fmt::format("interface ipv4 add dns \"{}\" {} validate=no", ent.name, dns.asIPv4()));
|
||||
jobs.emplace_back(
|
||||
"netsh.exe",
|
||||
fmt::format("interface ipv6 add dns \"{}\" {} validate=no", ent.name, dns.asIPv6()));
|
||||
m_UndoDNS.emplace_back("netsh.exe", fmt::format("", index));
|
||||
}
|
||||
m_UndoDNS.emplace_back("netsh.exe", "winsock reset");
|
||||
}
|
||||
// flush dns
|
||||
llarp::win32::Exec("ipconfig.exe", "/flushdns");
|
||||
|
||||
#endif
|
||||
}
|
||||
|
||||
} // namespace llarp::dns::win32
|
|
@ -1,8 +0,0 @@
|
|||
#pragma once
|
||||
#include "platform.hpp"
|
||||
|
||||
namespace llarp::dns
|
||||
{
|
||||
// TODO: implement me
|
||||
using Win32_Platform_t = Null_Platform;
|
||||
} // namespace llarp::dns
|
|
@ -59,8 +59,6 @@ namespace llarp::vpn
|
|||
NetworkInterface(const NetworkInterface&) = delete;
|
||||
NetworkInterface(NetworkInterface&&) = delete;
|
||||
|
||||
virtual ~NetworkInterface() = default;
|
||||
|
||||
const InterfaceInfo&
|
||||
Info() const
|
||||
{
|
||||
|
|
|
@ -125,13 +125,13 @@ namespace llarp::win32
|
|||
return -1;
|
||||
}
|
||||
|
||||
virtual bool
|
||||
bool
|
||||
WritePacket(net::IPPacket) override
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
virtual net::IPPacket
|
||||
net::IPPacket
|
||||
ReadNextPacket() override
|
||||
{
|
||||
auto w_pkt = m_RecvQueue.tryPopFront();
|
||||
|
@ -144,7 +144,7 @@ namespace llarp::win32
|
|||
return pkt;
|
||||
}
|
||||
|
||||
virtual void
|
||||
void
|
||||
Start() override
|
||||
{
|
||||
L::info(cat, "starting windivert");
|
||||
|
@ -172,7 +172,7 @@ namespace llarp::win32
|
|||
m_Runner = std::thread{std::move(read_loop)};
|
||||
}
|
||||
|
||||
virtual void
|
||||
void
|
||||
Stop() override
|
||||
{
|
||||
L::info(cat, "stopping windivert");
|
||||
|
|
|
@ -233,11 +233,9 @@ namespace llarp::win32
|
|||
[[nodiscard]] std::pair<std::unique_ptr<PacketWrapper>, bool>
|
||||
ReadPacket() const
|
||||
{
|
||||
// typedef so the return statement fits on 1 line :^D
|
||||
using Pkt_ptr = std::unique_ptr<PacketWrapper>;
|
||||
DWORD sz;
|
||||
if (auto* ptr = read_packet(_impl, &sz))
|
||||
return {Pkt_ptr{new PacketWrapper{ptr, sz, _impl}}, false};
|
||||
return {std::unique_ptr<PacketWrapper>{new PacketWrapper{ptr, sz, _impl}}, false};
|
||||
const auto err = GetLastError();
|
||||
if (err == ERROR_NO_MORE_ITEMS or err == ERROR_HANDLE_EOF)
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue