minor modifications

This commit is contained in:
Mark Puha
2023-09-19 12:32:21 +02:00
parent 47a0535bc3
commit 4ae96ab4dc
3 changed files with 6 additions and 32 deletions

4
.gitignore vendored Normal file
View File

@@ -0,0 +1,4 @@
.deps
tunnel.dll
tunnel.h
x64/

View File

@@ -1,30 +0,0 @@
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
## Download and extract wintun.dll and friends.
file(DOWNLOAD https://www.wintun.net/builds/wintun-0.12.zip
${CMAKE_CURRENT_BINARY_DIR}/.deps/wintun.zip
EXPECTED_HASH SHA256=eba90e26686ed86595ae0a6d4d3f4f022924b1758f5148a32a91c60cc6e604df)
file(ARCHIVE_EXTRACT INPUT ${CMAKE_CURRENT_BINARY_DIR}/.deps/wintun.zip DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/.deps)
## Build the tunnel DLL
add_custom_target(tunneldll ALL
BYPRODUCTS ${CMAKE_CURRENT_BINARY_DIR}/tunnel.dll ${CMAKE_CURRENT_BINARY_DIR}/tunnel.h
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
COMMAND ${CMAKE_COMMAND} -E env
GOCACHE=${CMAKE_BINARY_DIR}/go-cache
GOOS=windows CGO_ENABLED=1
CC=gcc
CGO_CFLAGS="-O3 -Wall -Wno-unused-function -Wno-switch -std=gnu11 -DWINVER=0x0601"
CGO_LDFLAGS="-Wl,--dynamicbase -Wl,--nxcompat -Wl,--export-all-symbols -Wl,--high-entropy-va"
go build -buildmode c-shared -ldflags="-w -s" -trimpath -v -o "${CMAKE_CURRENT_BINARY_DIR}/tunnel.dll"
)
set_directory_properties(PROPERTIES ADDITIONAL_MAKE_CLEAN_FILES ${CMAKE_BINARY_DIR}/go-cache)
install(FILES
${CMAKE_CURRENT_BINARY_DIR}/tunnel.dll
${CMAKE_CURRENT_BINARY_DIR}/.deps/wintun/bin/${CMAKE_SYSTEM_PROCESSOR}/wintun.dll
DESTINATION .
)

View File

@@ -37,11 +37,11 @@ if exist .deps\prepared goto :build
:download
echo [+] Downloading %1
powershell -command "Invoke-WebRequest" -Uri %2 -OutFile %1 || exit /b 1
curl -#fLo %1 %2 || exit /b 1
echo [+] Verifying %1
for /f %%a in ('CertUtil -hashfile %1 SHA256 ^| findstr /r "^[0-9a-f]*$"') do if not "%%a"=="%~3" exit /b 1
echo [+] Extracting %1
powershell -command "Expand-Archive" -Path %1 -DestinationPath %cd% || exit /b 1
tar -xf %1 %~4 || exit /b 1
echo [+] Cleaning up %1
del %1 || exit /b 1
goto :eof