kill/restore ipv6 with powershell because windows is vile

pull/1899/head
Jeff 2 years ago
parent d05518be57
commit 1a254a4301

@ -169,18 +169,9 @@ namespace llarp::vpn
return ret;
}
class Win32Interface final : public NetworkInterface
namespace
{
std::atomic<bool> m_Run;
HANDLE m_Device, m_IOCP;
std::vector<std::thread> m_Threads;
thread::Queue<net::IPPacket> m_ReadQueue;
InterfaceInfo m_Info;
AbstractRouter* const _router;
static std::wstring
std::wstring
get_win_sys_path()
{
wchar_t win_sys_path[MAX_PATH] = {0};
@ -193,6 +184,18 @@ namespace llarp::vpn
}
return win_sys_path;
}
} // namespace
class Win32Interface final : public NetworkInterface
{
std::atomic<bool> m_Run;
HANDLE m_Device, m_IOCP;
std::vector<std::thread> m_Threads;
thread::Queue<net::IPPacket> m_ReadQueue;
InterfaceInfo m_Info;
AbstractRouter* const _router;
static std::string
NetSHCommand()
@ -514,6 +517,17 @@ namespace llarp::vpn
::system(cmd.c_str());
}
static std::string
PowerShell()
{
std::wstring wcmd =
get_win_sys_path() + L"\\WindowsPowerShell\\v1.0\\powershell.exe -Command ";
using convert_type = std::codecvt_utf8<wchar_t>;
std::wstring_convert<convert_type, wchar_t> converter;
return converter.to_bytes(wcmd);
}
static std::string
RouteCommand()
{
@ -623,12 +637,16 @@ namespace llarp::vpn
void
AddDefaultRouteViaInterface(std::string ifname) override
{
// kill ipv6
Execute(PowerShell() + R"(Disable-NetAdapterBinding -Name "*" -ComponentID ms_tcpip6)");
DefaultRouteViaInterface(ifname, "ADD");
}
void
DelDefaultRouteViaInterface(std::string ifname) override
{
// restore ipv6
Execute(PowerShell() + R"(Enable-NetAdapterBinding -Name "*" -ComponentID ms_tcpip6)");
DefaultRouteViaInterface(ifname, "DELETE");
}
};

Loading…
Cancel
Save