Skip to content

Commit 56c6798

Browse files
committed
Merge branch 'master' into update-endpoint-ip
2 parents 0ec183c + 004c22c commit 56c6798

File tree

12 files changed

+35
-87
lines changed

12 files changed

+35
-87
lines changed

Makefile

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
GOFLAGS := -tags load_wgnt_from_rsrc -ldflags="-H windowsgui -s -w" -trimpath -buildinfo=false -buildvcs=false -v
1+
GOFLAGS := -tags load_wgnt_from_rsrc -ldflags="-H windowsgui -s -w" -trimpath -buildvcs=false -v
22
export GOOS := windows
33
export PATH := $(CURDIR)/.deps/go/bin:$(PATH)
44

@@ -25,7 +25,7 @@ define download =
2525
if ! mv $$@.unverified $$@; then rm -f $$@.unverified; exit 1; fi
2626
endef
2727

28-
$(eval $(call download,go.tar.gz,https://go.dev/dl/go1.18beta1.linux-amd64.tar.gz,128f72c5c22640085e4187cd1b540c587cf8fb280f941519bd2d1ae9fdab4f37))
28+
$(eval $(call download,go.tar.gz,https://go.dev/dl/go1.18.linux-amd64.tar.gz,e85278e98f57cdb150fe8409e6e5df5343ecb13cebf03a5d5ff12bd55a80264f))
2929
$(eval $(call download,wireguard-nt.zip,https://download.wireguard.com/wireguard-nt/wireguard-nt-0.10.1.zip,772c0b1463d8d2212716f43f06f4594d880dea4f735165bd68e388fc41b81605))
3030

3131
.deps/go/prepared: .distfiles/go.tar.gz
@@ -71,7 +71,7 @@ remaster: .deps/go/prepared
7171
rm -f go.sum go.mod
7272
cp go.mod.master go.mod
7373
go get -d
74-
sed -i $(shell curl -L 'https://go.dev/dl/?mode=json&include=all' | jq -r '(".windows-amd64.zip",".linux-amd64.tar.gz") as $$suffix | .[-1].files[] | select(.filename|endswith($$suffix)) | ("-e", "s/go[0-9][^ ]*\\\($$suffix)\\([ ,]\\)[a-f0-9]\\+/\(.filename)\\1\(.sha256)/") | @sh') Makefile build.bat
74+
sed -i $(shell curl -L 'https://go.dev/dl/?mode=json&include=all' | jq -r '(".windows-amd64.zip",".linux-amd64.tar.gz") as $$suffix | .[0].files[] | select(.filename|endswith($$suffix)) | ("-e", "s/go[0-9][^ ]*\\\($$suffix)\\([ ,]\\)[a-f0-9]\\+/\(.filename)\\1\(.sha256)/") | @sh') Makefile build.bat
7575

7676
fmt: export GOARCH := amd64
7777
fmt: .deps/go/prepared

build.bat

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ if exist .deps\prepared goto :render
1313
rmdir /s /q .deps 2> NUL
1414
mkdir .deps || goto :error
1515
cd .deps || goto :error
16-
call :download go.zip https://go.dev/dl/go1.18beta1.windows-amd64.zip 3a43ab4ec28eee6b10fd412a055724d962227f1c27a78960d6d229d741f8353d || goto :error
16+
call :download go.zip https://go.dev/dl/go1.18.windows-amd64.zip 65c5c0c709a7ca1b357091b10b795b439d8b50e579d3893edab4c7e9b384f435 || goto :error
1717
rem Mirror of https://github.com/mstorsjo/llvm-mingw/releases/download/20201020/llvm-mingw-20201020-msvcrt-x86_64.zip
1818
call :download llvm-mingw-msvcrt.zip https://download.wireguard.com/windows-toolchain/distfiles/llvm-mingw-20201020-msvcrt-x86_64.zip 2e46593245090df96d15e360e092f0b62b97e93866e0162dca7f93b16722b844 || goto :error
1919
rem Mirror of https://imagemagick.org/download/binaries/ImageMagick-7.0.8-42-portable-Q16-x64.zip
@@ -73,7 +73,7 @@ if exist .deps\prepared goto :render
7373
echo [+] Assembling resources %1
7474
%~2-w64-mingw32-windres -I ".deps\wireguard-nt\bin\%~1" -DWIREGUARD_VERSION_ARRAY=%WIREGUARD_VERSION_ARRAY% -DWIREGUARD_VERSION_STR=%WIREGUARD_VERSION% -i resources.rc -o "resources_%~3.syso" -O coff -c 65001 || exit /b %errorlevel%
7575
echo [+] Building program %1
76-
go build -tags load_wgnt_from_rsrc -ldflags="-H windowsgui -s -w" -trimpath -buildinfo=false -buildvcs=false -v -o "%~1\wireguard.exe" || exit /b 1
76+
go build -tags load_wgnt_from_rsrc -ldflags="-H windowsgui -s -w" -trimpath -buildvcs=false -v -o "%~1\wireguard.exe" || exit /b 1
7777
if not exist "%~1\wg.exe" (
7878
echo [+] Building command line tools %1
7979
del .deps\src\*.exe .deps\src\*.o .deps\src\wincompat\*.o .deps\src\wincompat\*.lib 2> NUL

conf/dnsresolver_windows.go

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,10 @@ import (
1717
"golang.zx2c4.com/wireguard/windows/services"
1818
)
1919

20-
//sys internetGetConnectedState(flags *uint32, reserved uint32) (connected bool) = wininet.InternetGetConnectedState
21-
2220
func ResolveHostname(name string) (resolvedIPString string, err error) {
2321
maxTries := 10
2422
if services.StartedAtBoot() {
25-
maxTries *= 4
23+
maxTries *= 3
2624
}
2725
for i := 0; i < maxTries; i++ {
2826
if i > 0 {
@@ -33,12 +31,11 @@ func ResolveHostname(name string) (resolvedIPString string, err error) {
3331
return
3432
}
3533
if err == windows.WSATRY_AGAIN {
36-
log.Printf("Temporary DNS error when resolving %s, sleeping for 4 seconds", name)
34+
log.Printf("Temporary DNS error when resolving %s, so sleeping for 4 seconds", name)
3735
continue
3836
}
39-
var state uint32
40-
if err == windows.WSAHOST_NOT_FOUND && services.StartedAtBoot() && !internetGetConnectedState(&state, 0) {
41-
log.Printf("Host not found when resolving %s, but no Internet connection available, sleeping for 4 seconds", name)
37+
if err == windows.WSAHOST_NOT_FOUND && services.StartedAtBoot() {
38+
log.Printf("Host not found when resolving %s at boot time, so sleeping for 4 seconds", name)
4239
continue
4340
}
4441
return

conf/dpapi/test.exe

-3.45 MB
Binary file not shown.

conf/mksyscall.go

Lines changed: 0 additions & 8 deletions
This file was deleted.

conf/zsyscall_windows.go

Lines changed: 0 additions & 50 deletions
This file was deleted.

embeddable-dll-service/.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# Build Output
2+
/x86
3+
/amd64
4+
/arm64

embeddable-dll-service/README.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,12 @@ is absolutely essential; do not forget it.
2424
##### 2. Have your program's main function handle the `/service` switch:
2525

2626
```c
27-
if (!wcscmp(wargv[1], L"/service") && wargc == 3) {
27+
if (wargc == 3 && !wcscmp(wargv[1], L"/service")) {
2828
HMODULE tunnel_lib = LoadLibrary("tunnel.dll");
2929
if (!tunnel_lib)
3030
abort();
31-
tunnel_proc_t tunnel_proc = (tunnel_proc_t)GetProcAddress(tunnel_lib, "WireGuardTunnelService");
31+
BOOL (_cdecl *tunnel_proc)(_In_ LPCWSTR conf_file);
32+
*(FARPROC*)&tunnel_proc = GetProcAddress(tunnel_lib, "WireGuardTunnelService");
3233
if (!tunnel_proc)
3334
abort();
3435
return tunnel_proc(wargv[2]);

embeddable-dll-service/build.bat

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,13 @@ if exist ..\.deps\prepared goto :build
2323
call :build_plat amd64 x86_64 amd64 || goto :error
2424
call :build_plat arm64 aarch64 arm64 || goto :error
2525

26+
:sign
27+
if exist ..\sign.bat call ..\sign.bat
28+
if "%SigningCertificate%"=="" goto :success
29+
if "%TimestampServer%"=="" goto :success
30+
echo [+] Signing
31+
signtool sign /sha1 "%SigningCertificate%" /fd sha256 /tr "%TimestampServer%" /td sha256 /d "WireGuard Tunnel" x86\tunnel.dll amd64\tunnel.dll arm64\tunnel.dll || goto :error
32+
2633
:success
2734
echo [+] Success
2835
exit /b 0

embeddable-dll-service/csharp/TunnelDll/Service.cs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ public static void Add(string configFile, bool ephemeral)
4545
Win32.CloseServiceHandle(service);
4646
Remove(configFile, true);
4747
}
48-
service = Win32.CreateService(scm, shortName, longName, Win32.ServiceAccessRights.AllAccess, Win32.ServiceType.Win32OwnProcess, Win32.ServiceStartType.Demand, Win32.ServiceError.Normal, pathAndArgs, null, IntPtr.Zero, "Nsi\0TcpIp", null, null);
48+
service = Win32.CreateService(scm, shortName, longName, Win32.ServiceAccessRights.AllAccess, Win32.ServiceType.Win32OwnProcess, Win32.ServiceStartType.Demand, Win32.ServiceError.Normal, pathAndArgs, null, IntPtr.Zero, "Nsi\0TcpIp\0", null, null);
4949
if (service == IntPtr.Zero)
5050
throw new Win32Exception(Marshal.GetLastWin32Error());
5151
try
@@ -87,10 +87,7 @@ public static void Remove(string configFile, bool waitForStop)
8787
{
8888
var service = Win32.OpenService(scm, shortName, Win32.ServiceAccessRights.AllAccess);
8989
if (service == IntPtr.Zero)
90-
{
91-
Win32.CloseServiceHandle(service);
9290
return;
93-
}
9491
try
9592
{
9693
var serviceStatus = new Win32.ServiceStatus();

0 commit comments

Comments
 (0)