Create wintun interface if not found
This commit is contained in:
@@ -6,7 +6,7 @@ cmake_minimum_required(VERSION 3.16)
|
|||||||
# If MAJOR is 0, and MINOR > 0, Version is BETA
|
# If MAJOR is 0, and MINOR > 0, Version is BETA
|
||||||
|
|
||||||
project(ColumnLynx
|
project(ColumnLynx
|
||||||
VERSION 0.2.0
|
VERSION 0.3.0
|
||||||
LANGUAGES CXX
|
LANGUAGES CXX
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
@@ -49,7 +49,7 @@ namespace ColumnLynx::Utils {
|
|||||||
}
|
}
|
||||||
|
|
||||||
std::string getVersion() {
|
std::string getVersion() {
|
||||||
return "b0.2";
|
return "b0.3";
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned short serverPort() {
|
unsigned short serverPort() {
|
||||||
|
|||||||
@@ -18,6 +18,7 @@ static WINTUN_RECEIVE_PACKET_FUNC* pWintunReceivePacket;
|
|||||||
static WINTUN_RELEASE_RECEIVE_PACKET_FUNC* pWintunReleaseReceivePacket;
|
static WINTUN_RELEASE_RECEIVE_PACKET_FUNC* pWintunReleaseReceivePacket;
|
||||||
static WINTUN_ALLOCATE_SEND_PACKET_FUNC* pWintunAllocateSendPacket;
|
static WINTUN_ALLOCATE_SEND_PACKET_FUNC* pWintunAllocateSendPacket;
|
||||||
static WINTUN_SEND_PACKET_FUNC* pWintunSendPacket;
|
static WINTUN_SEND_PACKET_FUNC* pWintunSendPacket;
|
||||||
|
static WINTUN_CREATE_ADAPTER_FUNC* pWintunCreateAdapter;
|
||||||
|
|
||||||
static void InitializeWintun()
|
static void InitializeWintun()
|
||||||
{
|
{
|
||||||
@@ -47,6 +48,7 @@ static void InitializeWintun()
|
|||||||
RESOLVE(WintunReleaseReceivePacket, WINTUN_RELEASE_RECEIVE_PACKET_FUNC)
|
RESOLVE(WintunReleaseReceivePacket, WINTUN_RELEASE_RECEIVE_PACKET_FUNC)
|
||||||
RESOLVE(WintunAllocateSendPacket, WINTUN_ALLOCATE_SEND_PACKET_FUNC)
|
RESOLVE(WintunAllocateSendPacket, WINTUN_ALLOCATE_SEND_PACKET_FUNC)
|
||||||
RESOLVE(WintunSendPacket, WINTUN_SEND_PACKET_FUNC)
|
RESOLVE(WintunSendPacket, WINTUN_SEND_PACKET_FUNC)
|
||||||
|
RESOLVE(WintunCreateAdapter, WINTUN_CREATE_ADAPTER_FUNC)
|
||||||
|
|
||||||
#undef RESOLVE
|
#undef RESOLVE
|
||||||
}
|
}
|
||||||
@@ -113,12 +115,18 @@ namespace ColumnLynx::Net {
|
|||||||
|
|
||||||
InitializeWintun();
|
InitializeWintun();
|
||||||
|
|
||||||
mAdapter = pWintunOpenAdapter(
|
mAdapter = pWintunOpenAdapter(ifaceName);
|
||||||
std::wstring(ifName.begin(), ifName.end()).c_str()
|
|
||||||
|
if (!mAdapter) {
|
||||||
|
mAdapter = pWintunCreateAdapter(
|
||||||
|
ifaceName,
|
||||||
|
L"ColumnLynx",
|
||||||
|
nullptr
|
||||||
);
|
);
|
||||||
|
}
|
||||||
|
|
||||||
if (!mAdapter)
|
if (!mAdapter)
|
||||||
throw std::runtime_error("Wintun adapter not found");
|
throw std::runtime_error("Failed to open or create Wintun adapter");
|
||||||
|
|
||||||
mSession = pWintunStartSession(mAdapter, 0x200000);
|
mSession = pWintunStartSession(mAdapter, 0x200000);
|
||||||
if (!mSession)
|
if (!mSession)
|
||||||
|
|||||||
Reference in New Issue
Block a user