Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master' into update-endpoint-ip
Browse files Browse the repository at this point in the history
  • Loading branch information
tripplet committed Jan 10, 2022
2 parents 9957796 + 6ed37f3 commit 0ec183c
Show file tree
Hide file tree
Showing 152 changed files with 224 additions and 759 deletions.
2 changes: 1 addition & 1 deletion COPYING
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Copyright (C) 2018-2021 WireGuard LLC. All Rights Reserved.
Copyright (C) 2018-2022 WireGuard LLC. All Rights Reserved.

Permission is hereby granted, free of charge, to any person obtaining a
copy of this software and associated documentation files (the "Software"),
Expand Down
9 changes: 4 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
GOFLAGS := -tags load_wgnt_from_rsrc -ldflags="-H windowsgui -s -w" -v -trimpath
GOFLAGS := -tags load_wgnt_from_rsrc -ldflags="-H windowsgui -s -w" -trimpath -buildinfo=false -buildvcs=false -v
export GOOS := windows
export PATH := $(CURDIR)/.deps/go/bin:$(PATH)

Expand All @@ -25,15 +25,14 @@ define download =
if ! mv $$@.unverified $$@; then rm -f $$@.unverified; exit 1; fi
endef

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

.deps/go/prepared: .distfiles/go.tar.gz $(wildcard go-patches/*.patch)
.deps/go/prepared: .distfiles/go.tar.gz
mkdir -p .deps
rm -rf .deps/go
bsdtar -C .deps -xf .distfiles/go.tar.gz
chmod -R +w .deps/go
cat $(filter %.patch,$^) | patch -f -N -r- -p1 -d .deps/go
touch $@

.deps/wireguard-nt/prepared: .distfiles/wireguard-nt.zip
Expand Down Expand Up @@ -72,7 +71,7 @@ remaster: .deps/go/prepared
rm -f go.sum go.mod
cp go.mod.master go.mod
go get -d
sed -i $(shell curl -L https://go.dev/dl/?mode=json | 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
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

fmt: export GOARCH := amd64
fmt: .deps/go/prepared
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ In addition to this [`README.md`](README.md), the following documents are also a
This repository is MIT-licensed.

```text
Copyright (C) 2018-2021 WireGuard LLC. All Rights Reserved.
Copyright (C) 2018-2022 WireGuard LLC. All Rights Reserved.
Permission is hereby granted, free of charge, to any person obtaining a
copy of this software and associated documentation files (the "Software"),
Expand Down
10 changes: 3 additions & 7 deletions build.bat
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
@echo off
rem SPDX-License-Identifier: MIT
rem Copyright (C) 2019-2021 WireGuard LLC. All Rights Reserved.
rem Copyright (C) 2019-2022 WireGuard LLC. All Rights Reserved.

setlocal enabledelayedexpansion
set BUILDDIR=%~dp0
Expand All @@ -13,19 +13,15 @@ if exist .deps\prepared goto :render
rmdir /s /q .deps 2> NUL
mkdir .deps || goto :error
cd .deps || goto :error
call :download go.zip https://go.dev/dl/go1.17.4.windows-amd64.zip 903cffeb7c6ab7490b9101086a2b978076bd9356e56369404b9c45dff866da77 || goto :error
call :download go.zip https://go.dev/dl/go1.18beta1.windows-amd64.zip 3a43ab4ec28eee6b10fd412a055724d962227f1c27a78960d6d229d741f8353d || goto :error
rem Mirror of https://github.com/mstorsjo/llvm-mingw/releases/download/20201020/llvm-mingw-20201020-msvcrt-x86_64.zip
call :download llvm-mingw-msvcrt.zip https://download.wireguard.com/windows-toolchain/distfiles/llvm-mingw-20201020-msvcrt-x86_64.zip 2e46593245090df96d15e360e092f0b62b97e93866e0162dca7f93b16722b844 || goto :error
rem Mirror of https://imagemagick.org/download/binaries/ImageMagick-7.0.8-42-portable-Q16-x64.zip
call :download imagemagick.zip https://download.wireguard.com/windows-toolchain/distfiles/ImageMagick-7.0.8-42-portable-Q16-x64.zip 584e069f56456ce7dde40220948ff9568ac810688c892c5dfb7f6db902aa05aa "convert.exe colors.xml delegates.xml" || goto :error
rem Mirror of https://sourceforge.net/projects/ezwinports/files/make-4.2.1-without-guile-w32-bin.zip
call :download make.zip https://download.wireguard.com/windows-toolchain/distfiles/make-4.2.1-without-guile-w32-bin.zip 30641be9602712be76212b99df7209f4f8f518ba764cf564262bc9d6e4047cc7 "--strip-components 1 bin" || goto :error
call :download wireguard-tools.zip https://git.zx2c4.com/wireguard-tools/snapshot/wireguard-tools-1ee37b8e4833a25efe6f1fc0d5bdcb476148f4ba.zip ed0739bc3e5a7021a59d4cc4fc63e5fb60a0cb8628d30515a747bfbdcf1fdb0a "--exclude wg-quick --strip-components 1" || goto :error
rem Mirror of https://sourceforge.net/projects/gnuwin32/files/patch/2.5.9-7/patch-2.5.9-7-bin.zip with fixed manifest
call :download patch.zip https://download.wireguard.com/windows-toolchain/distfiles/patch-2.5.9-7-bin-fixed-manifest.zip 25977006ca9713f2662a5d0a2ed3a5a138225b8be3757035bd7da9dcf985d0a1 "--strip-components 1 bin" || goto :error
call :download wireguard-nt.zip https://download.wireguard.com/wireguard-nt/wireguard-nt-0.10.1.zip 772c0b1463d8d2212716f43f06f4594d880dea4f735165bd68e388fc41b81605 || goto :error
echo [+] Patching go
for %%a in ("..\go-patches\*.patch") do .\patch.exe -f -N -r- -d go -p1 --binary < "%%a" || goto :error
copy /y NUL prepared > NUL || goto :error
cd .. || goto :error

Expand Down Expand Up @@ -77,7 +73,7 @@ if exist .deps\prepared goto :render
echo [+] Assembling resources %1
%~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%
echo [+] Building program %1
go build -tags load_wgnt_from_rsrc -ldflags="-H windowsgui -s -w" -trimpath -v -o "%~1\wireguard.exe" || exit /b 1
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
if not exist "%~1\wg.exe" (
echo [+] Building command line tools %1
del .deps\src\*.exe .deps\src\*.o .deps\src\wincompat\*.o .deps\src\wincompat\*.lib 2> NUL
Expand Down
2 changes: 1 addition & 1 deletion conf/admin_windows.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* SPDX-License-Identifier: MIT
*
* Copyright (C) 2019-2021 WireGuard LLC. All Rights Reserved.
* Copyright (C) 2019-2022 WireGuard LLC. All Rights Reserved.
*/

package conf
Expand Down
5 changes: 2 additions & 3 deletions conf/config.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* SPDX-License-Identifier: MIT
*
* Copyright (C) 2019-2021 WireGuard LLC. All Rights Reserved.
* Copyright (C) 2019-2022 WireGuard LLC. All Rights Reserved.
*/

package conf
Expand All @@ -10,11 +10,10 @@ import (
"crypto/subtle"
"encoding/base64"
"fmt"
"net/netip"
"strings"
"time"

"golang.zx2c4.com/go118/netip"

"golang.org/x/crypto/curve25519"

"golang.zx2c4.com/wireguard/windows/l18n"
Expand Down
4 changes: 2 additions & 2 deletions conf/dnsresolver_windows.go
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
/* SPDX-License-Identifier: MIT
*
* Copyright (C) 2019-2021 WireGuard LLC. All Rights Reserved.
* Copyright (C) 2019-2022 WireGuard LLC. All Rights Reserved.
*/

package conf

import (
"log"
"net/netip"
"time"
"unsafe"

"golang.zx2c4.com/go118/netip"
"golang.zx2c4.com/wireguard/windows/tunnel/winipcfg"

"golang.org/x/sys/windows"
Expand Down
2 changes: 1 addition & 1 deletion conf/dpapi/dpapi_windows.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* SPDX-License-Identifier: MIT
*
* Copyright (C) 2019-2021 WireGuard LLC. All Rights Reserved.
* Copyright (C) 2019-2022 WireGuard LLC. All Rights Reserved.
*/

package dpapi
Expand Down
2 changes: 1 addition & 1 deletion conf/dpapi/dpapi_windows_test.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* SPDX-License-Identifier: MIT
*
* Copyright (C) 2019-2021 WireGuard LLC. All Rights Reserved.
* Copyright (C) 2019-2022 WireGuard LLC. All Rights Reserved.
*/

package dpapi
Expand Down
2 changes: 1 addition & 1 deletion conf/filewriter_windows.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* SPDX-License-Identifier: MIT
*
* Copyright (C) 2019-2021 WireGuard LLC. All Rights Reserved.
* Copyright (C) 2019-2022 WireGuard LLC. All Rights Reserved.
*/

package conf
Expand Down
2 changes: 1 addition & 1 deletion conf/migration_windows.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* SPDX-License-Identifier: MIT
*
* Copyright (C) 2019-2021 WireGuard LLC. All Rights Reserved.
* Copyright (C) 2019-2022 WireGuard LLC. All Rights Reserved.
*/

package conf
Expand Down
2 changes: 1 addition & 1 deletion conf/mksyscall.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* SPDX-License-Identifier: MIT
*
* Copyright (C) 2019-2021 WireGuard LLC. All Rights Reserved.
* Copyright (C) 2019-2022 WireGuard LLC. All Rights Reserved.
*/

package conf
Expand Down
2 changes: 1 addition & 1 deletion conf/name.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* SPDX-License-Identifier: MIT
*
* Copyright (C) 2019-2021 WireGuard LLC. All Rights Reserved.
* Copyright (C) 2019-2022 WireGuard LLC. All Rights Reserved.
*/

package conf
Expand Down
10 changes: 3 additions & 7 deletions conf/parser.go
Original file line number Diff line number Diff line change
@@ -1,17 +1,16 @@
/* SPDX-License-Identifier: MIT
*
* Copyright (C) 2019-2021 WireGuard LLC. All Rights Reserved.
* Copyright (C) 2019-2022 WireGuard LLC. All Rights Reserved.
*/

package conf

import (
"encoding/base64"
"net/netip"
"strconv"
"strings"

"golang.zx2c4.com/go118/netip"

"golang.org/x/sys/windows"
"golang.org/x/text/encoding/unicode"

Expand Down Expand Up @@ -182,10 +181,7 @@ func FromWgQuick(s, name string) (*Config, error) {
sawPrivateKey := false
var peer *Peer
for _, line := range lines {
pound := strings.IndexByte(line, '#')
if pound >= 0 {
line = line[:pound]
}
line, _, _ = strings.Cut(line, "#")
line = strings.TrimSpace(line)
lineLower := strings.ToLower(line)
if len(line) == 0 {
Expand Down
11 changes: 5 additions & 6 deletions conf/parser_test.go
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
/* SPDX-License-Identifier: MIT
*
* Copyright (C) 2019-2021 WireGuard LLC. All Rights Reserved.
* Copyright (C) 2019-2022 WireGuard LLC. All Rights Reserved.
*/

package conf

import (
"net/netip"
"reflect"
"runtime"
"testing"

"golang.zx2c4.com/go118/netip"
)

const testInput = `
Expand Down Expand Up @@ -46,7 +45,7 @@ func noError(t *testing.T, err error) bool {
return false
}

func equal(t *testing.T, expected, actual interface{}) bool {
func equal(t *testing.T, expected, actual any) bool {
if reflect.DeepEqual(expected, actual) {
return true
}
Expand All @@ -55,7 +54,7 @@ func equal(t *testing.T, expected, actual interface{}) bool {
return false
}

func lenTest(t *testing.T, actualO interface{}, expected int) bool {
func lenTest(t *testing.T, actualO any, expected int) bool {
actual := reflect.ValueOf(actualO).Len()
if reflect.DeepEqual(expected, actual) {
return true
Expand All @@ -65,7 +64,7 @@ func lenTest(t *testing.T, actualO interface{}, expected int) bool {
return false
}

func contains(t *testing.T, list, element interface{}) bool {
func contains(t *testing.T, list, element any) bool {
listValue := reflect.ValueOf(list)
for i := 0; i < listValue.Len(); i++ {
if reflect.DeepEqual(listValue.Index(i).Interface(), element) {
Expand Down
2 changes: 1 addition & 1 deletion conf/path_windows.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* SPDX-License-Identifier: MIT
*
* Copyright (C) 2019-2021 WireGuard LLC. All Rights Reserved.
* Copyright (C) 2019-2022 WireGuard LLC. All Rights Reserved.
*/

package conf
Expand Down
2 changes: 1 addition & 1 deletion conf/store.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* SPDX-License-Identifier: MIT
*
* Copyright (C) 2019-2021 WireGuard LLC. All Rights Reserved.
* Copyright (C) 2019-2022 WireGuard LLC. All Rights Reserved.
*/

package conf
Expand Down
2 changes: 1 addition & 1 deletion conf/store_test.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* SPDX-License-Identifier: MIT
*
* Copyright (C) 2019-2021 WireGuard LLC. All Rights Reserved.
* Copyright (C) 2019-2022 WireGuard LLC. All Rights Reserved.
*/

package conf
Expand Down
2 changes: 1 addition & 1 deletion conf/storewatcher.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* SPDX-License-Identifier: MIT
*
* Copyright (C) 2019-2021 WireGuard LLC. All Rights Reserved.
* Copyright (C) 2019-2022 WireGuard LLC. All Rights Reserved.
*/

package conf
Expand Down
2 changes: 1 addition & 1 deletion conf/storewatcher_windows.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* SPDX-License-Identifier: MIT
*
* Copyright (C) 2019-2021 WireGuard LLC. All Rights Reserved.
* Copyright (C) 2019-2022 WireGuard LLC. All Rights Reserved.
*/

package conf
Expand Down
5 changes: 2 additions & 3 deletions conf/writer.go
Original file line number Diff line number Diff line change
@@ -1,17 +1,16 @@
/* SPDX-License-Identifier: MIT
*
* Copyright (C) 2019-2021 WireGuard LLC. All Rights Reserved.
* Copyright (C) 2019-2022 WireGuard LLC. All Rights Reserved.
*/

package conf

import (
"fmt"
"net/netip"
"strings"
"unsafe"

"golang.zx2c4.com/go118/netip"

"golang.org/x/sys/windows"
"golang.zx2c4.com/wireguard/windows/driver"
"golang.zx2c4.com/wireguard/windows/tunnel/winipcfg"
Expand Down
4 changes: 2 additions & 2 deletions docs/buildrun.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,8 @@ C:\Projects\wireguard-windows\installer> build
Add a file called `sign.bat` in the root of this repository with these contents, or similar:

```text
set SigningCertificate=DF98E075A012ED8C86FBCF14854B8F9555CB3D45
set TimestampServer=http://timestamp.digicert.com
set SigningCertificate=8BC932FDFF15B892E8364C49B383210810E4709D
set TimestampServer=http://timestamp.entrust.net/rfc3161ts2
```

After, run the above `build` commands as usual, from a shell that has [`signtool.exe`](https://docs.microsoft.com/en-us/windows/desktop/SecCrypto/signtool) in its `PATH`, such as the Visual Studio 2017 command prompt.
Expand Down
10 changes: 5 additions & 5 deletions driver/configuration_windows.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* SPDX-License-Identifier: MIT
*
* Copyright (C) 2017-2021 WireGuard LLC. All Rights Reserved.
* Copyright (C) 2017-2022 WireGuard LLC. All Rights Reserved.
*/

package driver
Expand Down Expand Up @@ -81,7 +81,7 @@ var (

// SetAdapterState sets the adapter either Up or Down.
func (wireguard *Adapter) SetAdapterState(adapterState AdapterState) (err error) {
r0, _, e1 := syscall.Syscall(procWireGuardSetAdapterState.Addr(), 2, wireguard.handle, uintptr(adapterState), 0)
r0, _, e1 := syscall.SyscallN(procWireGuardSetAdapterState.Addr(), wireguard.handle, uintptr(adapterState))
if r0 == 0 {
err = e1
}
Expand All @@ -90,7 +90,7 @@ func (wireguard *Adapter) SetAdapterState(adapterState AdapterState) (err error)

// AdapterState returns the current state of the adapter.
func (wireguard *Adapter) AdapterState() (adapterState AdapterState, err error) {
r0, _, e1 := syscall.Syscall(procWireGuardGetAdapterState.Addr(), 2, wireguard.handle, uintptr(unsafe.Pointer(&adapterState)), 0)
r0, _, e1 := syscall.SyscallN(procWireGuardGetAdapterState.Addr(), wireguard.handle, uintptr(unsafe.Pointer(&adapterState)))
if r0 == 0 {
err = e1
}
Expand All @@ -99,7 +99,7 @@ func (wireguard *Adapter) AdapterState() (adapterState AdapterState, err error)

// SetConfiguration sets the adapter configuration.
func (wireguard *Adapter) SetConfiguration(interfaze *Interface, size uint32) (err error) {
r0, _, e1 := syscall.Syscall(procWireGuardSetConfiguration.Addr(), 3, wireguard.handle, uintptr(unsafe.Pointer(interfaze)), uintptr(size))
r0, _, e1 := syscall.SyscallN(procWireGuardSetConfiguration.Addr(), wireguard.handle, uintptr(unsafe.Pointer(interfaze)), uintptr(size))
if r0 == 0 {
err = e1
}
Expand All @@ -114,7 +114,7 @@ func (wireguard *Adapter) Configuration() (interfaze *Interface, err error) {
}
for {
buf := make([]byte, size)
r0, _, e1 := syscall.Syscall(procWireGuardGetConfiguration.Addr(), 3, wireguard.handle, uintptr(unsafe.Pointer(&buf[0])), uintptr(unsafe.Pointer(&size)))
r0, _, e1 := syscall.SyscallN(procWireGuardGetConfiguration.Addr(), wireguard.handle, uintptr(unsafe.Pointer(&buf[0])), uintptr(unsafe.Pointer(&size)))
if r0 != 0 {
wireguard.lastGetGuessSize = size
return (*Interface)(unsafe.Pointer(&buf[0])), nil
Expand Down
2 changes: 1 addition & 1 deletion driver/dll_windows.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* SPDX-License-Identifier: MIT
*
* Copyright (C) 2017-2021 WireGuard LLC. All Rights Reserved.
* Copyright (C) 2017-2022 WireGuard LLC. All Rights Reserved.
*/

package driver
Expand Down
Loading

0 comments on commit 0ec183c

Please sign in to comment.