From 69ca16c4fbfa868834fd733f4cb38513d460aad9 Mon Sep 17 00:00:00 2001 From: Mark Puha Date: Wed, 2 Jul 2025 06:26:28 +0200 Subject: [PATCH] Revert "Merge pull request #78 from jmwample/jmwample/upstream" This reverts commit fe75b639fa771c08188cf316479ce9952a1c15f5, reversing changes made to 27e661d68ee34cd9595c07fab0dbe3797d0ff202. --- README.md | 1 - conn/bind_std.go | 2 +- conn/bind_windows.go | 2 +- conn/bindtest/bindtest.go | 2 +- conn/boundif_android.go | 2 +- conn/conn.go | 2 +- conn/conn_test.go | 2 +- conn/controlfns.go | 2 +- conn/controlfns_linux.go | 50 +---------- conn/controlfns_unix.go | 2 +- conn/controlfns_windows.go | 2 +- conn/default.go | 2 +- conn/errors_default.go | 4 +- conn/errors_linux.go | 2 +- conn/features_default.go | 4 +- conn/features_linux.go | 2 +- conn/gso_default.go | 2 +- conn/gso_linux.go | 2 +- conn/mark_default.go | 2 +- conn/mark_unix.go | 2 +- conn/sticky_default.go | 2 +- conn/sticky_linux.go | 2 +- conn/sticky_linux_test.go | 2 +- conn/winrio/rio_windows.go | 2 +- device/allowedips.go | 89 ++++++++----------- device/allowedips_rand_test.go | 12 +-- device/allowedips_test.go | 71 ++-------------- device/bind_test.go | 2 +- device/channels.go | 2 +- device/constants.go | 2 +- device/cookie.go | 2 +- device/cookie_test.go | 2 +- device/device.go | 2 +- device/device_test.go | 2 +- device/endpoint_test.go | 2 +- device/indextable.go | 2 +- device/ip.go | 2 +- device/kdf_test.go | 2 +- device/keypair.go | 2 +- device/logger.go | 2 +- device/mobilequirks.go | 2 +- device/noise-helpers.go | 2 +- device/noise-protocol.go | 2 +- device/noise-types.go | 2 +- device/noise_test.go | 2 +- device/peer.go | 2 +- device/pools.go | 13 ++- device/pools_test.go | 6 +- device/queueconstants_android.go | 2 +- device/queueconstants_default.go | 2 +- device/queueconstants_ios.go | 2 +- device/queueconstants_windows.go | 2 +- device/race_disabled_test.go | 2 +- device/race_enabled_test.go | 2 +- device/receive.go | 2 +- device/send.go | 3 +- device/sticky_default.go | 2 +- device/sticky_linux.go | 6 +- device/timers.go | 2 +- device/tun.go | 2 +- device/uapi.go | 17 +--- format_test.go | 2 +- ipc/uapi_bsd.go | 2 +- ipc/uapi_linux.go | 2 +- ipc/uapi_unix.go | 2 +- ipc/uapi_wasm.go | 2 +- ipc/uapi_windows.go | 2 +- main.go | 2 +- main_windows.go | 2 +- ratelimiter/ratelimiter.go | 2 +- ratelimiter/ratelimiter_test.go | 2 +- replay/replay.go | 2 +- replay/replay_test.go | 2 +- rwcancel/rwcancel.go | 4 +- tai64n/tai64n.go | 2 +- tai64n/tai64n_test.go | 2 +- tun/alignment_windows_test.go | 2 +- tun/checksum.go | 122 +++++++++++++++------------ tun/checksum_test.go | 63 -------------- tun/netstack/examples/http_client.go | 2 +- tun/netstack/examples/http_server.go | 2 +- tun/netstack/examples/ping_client.go | 2 +- tun/netstack/tun.go | 12 ++- tun/offload_linux.go | 2 +- tun/offload_linux_test.go | 2 +- tun/operateonfd.go | 2 +- tun/tun.go | 2 +- tun/tun_darwin.go | 36 +++++--- tun/tun_freebsd.go | 2 +- tun/tun_linux.go | 2 +- tun/tun_openbsd.go | 2 +- tun/tun_windows.go | 2 +- tun/tuntest/tuntest.go | 2 +- version.go | 2 +- 94 files changed, 245 insertions(+), 422 deletions(-) diff --git a/README.md b/README.md index 428b752..853d318 100644 --- a/README.md +++ b/README.md @@ -50,4 +50,3 @@ $ git clone https://github.com/amnezia-vpn/amneziawg-go $ cd amneziawg-go $ make ``` - diff --git a/conn/bind_std.go b/conn/bind_std.go index 6908ba8..312a538 100644 --- a/conn/bind_std.go +++ b/conn/bind_std.go @@ -1,6 +1,6 @@ /* SPDX-License-Identifier: MIT * - * Copyright (C) 2017-2025 WireGuard LLC. All Rights Reserved. + * Copyright (C) 2017-2023 WireGuard LLC. All Rights Reserved. */ package conn diff --git a/conn/bind_windows.go b/conn/bind_windows.go index 1a0e021..6cfa099 100644 --- a/conn/bind_windows.go +++ b/conn/bind_windows.go @@ -1,6 +1,6 @@ /* SPDX-License-Identifier: MIT * - * Copyright (C) 2017-2025 WireGuard LLC. All Rights Reserved. + * Copyright (C) 2017-2023 WireGuard LLC. All Rights Reserved. */ package conn diff --git a/conn/bindtest/bindtest.go b/conn/bindtest/bindtest.go index 25b5eab..42b0bb7 100644 --- a/conn/bindtest/bindtest.go +++ b/conn/bindtest/bindtest.go @@ -1,6 +1,6 @@ /* SPDX-License-Identifier: MIT * - * Copyright (C) 2017-2025 WireGuard LLC. All Rights Reserved. + * Copyright (C) 2017-2023 WireGuard LLC. All Rights Reserved. */ package bindtest diff --git a/conn/boundif_android.go b/conn/boundif_android.go index be69b2a..dd3ca5b 100644 --- a/conn/boundif_android.go +++ b/conn/boundif_android.go @@ -1,6 +1,6 @@ /* SPDX-License-Identifier: MIT * - * Copyright (C) 2017-2025 WireGuard LLC. All Rights Reserved. + * Copyright (C) 2017-2023 WireGuard LLC. All Rights Reserved. */ package conn diff --git a/conn/conn.go b/conn/conn.go index 1304657..a1f57d2 100644 --- a/conn/conn.go +++ b/conn/conn.go @@ -1,6 +1,6 @@ /* SPDX-License-Identifier: MIT * - * Copyright (C) 2017-2025 WireGuard LLC. All Rights Reserved. + * Copyright (C) 2017-2023 WireGuard LLC. All Rights Reserved. */ // Package conn implements WireGuard's network connections. diff --git a/conn/conn_test.go b/conn/conn_test.go index 618d02b..c6194ee 100644 --- a/conn/conn_test.go +++ b/conn/conn_test.go @@ -1,6 +1,6 @@ /* SPDX-License-Identifier: MIT * - * Copyright (C) 2017-2025 WireGuard LLC. All Rights Reserved. + * Copyright (C) 2017-2023 WireGuard LLC. All Rights Reserved. */ package conn diff --git a/conn/controlfns.go b/conn/controlfns.go index 27421bd..4f7d90f 100644 --- a/conn/controlfns.go +++ b/conn/controlfns.go @@ -1,6 +1,6 @@ /* SPDX-License-Identifier: MIT * - * Copyright (C) 2017-2025 WireGuard LLC. All Rights Reserved. + * Copyright (C) 2017-2023 WireGuard LLC. All Rights Reserved. */ package conn diff --git a/conn/controlfns_linux.go b/conn/controlfns_linux.go index f0deefa..a2396fe 100644 --- a/conn/controlfns_linux.go +++ b/conn/controlfns_linux.go @@ -1,6 +1,6 @@ /* SPDX-License-Identifier: MIT * - * Copyright (C) 2017-2025 WireGuard LLC. All Rights Reserved. + * Copyright (C) 2017-2023 WireGuard LLC. All Rights Reserved. */ package conn @@ -13,35 +13,6 @@ import ( "golang.org/x/sys/unix" ) -// Taken from go/src/internal/syscall/unix/kernel_version_linux.go -func kernelVersion() (major, minor int) { - var uname unix.Utsname - if err := unix.Uname(&uname); err != nil { - return - } - - var ( - values [2]int - value, vi int - ) - for _, c := range uname.Release { - if '0' <= c && c <= '9' { - value = (value * 10) + int(c-'0') - } else { - // Note that we're assuming N.N.N here. - // If we see anything else, we are likely to mis-parse it. - values[vi] = value - vi++ - if vi >= len(values) { - break - } - value = 0 - } - } - - return values[0], values[1] -} - func init() { controlFns = append(controlFns, @@ -86,24 +57,5 @@ func init() { } return err }, - - // Attempt to enable UDP_GRO - func(network, address string, c syscall.RawConn) error { - // Kernels below 5.12 are missing 98184612aca0 ("net: - // udp: Add support for getsockopt(..., ..., UDP_GRO, - // ..., ...);"), which means we can't read this back - // later. We could pipe the return value through to - // the rest of the code, but UDP_GRO is kind of buggy - // anyway, so just gate this here. - major, minor := kernelVersion() - if major < 5 || (major == 5 && minor < 12) { - return nil - } - - c.Control(func(fd uintptr) { - _ = unix.SetsockoptInt(int(fd), unix.IPPROTO_UDP, unix.UDP_GRO, 1) - }) - return nil - }, ) } diff --git a/conn/controlfns_unix.go b/conn/controlfns_unix.go index b2e7570..91692c0 100644 --- a/conn/controlfns_unix.go +++ b/conn/controlfns_unix.go @@ -2,7 +2,7 @@ /* SPDX-License-Identifier: MIT * - * Copyright (C) 2017-2025 WireGuard LLC. All Rights Reserved. + * Copyright (C) 2017-2023 WireGuard LLC. All Rights Reserved. */ package conn diff --git a/conn/controlfns_windows.go b/conn/controlfns_windows.go index 5e38305..c3bdf7d 100644 --- a/conn/controlfns_windows.go +++ b/conn/controlfns_windows.go @@ -1,6 +1,6 @@ /* SPDX-License-Identifier: MIT * - * Copyright (C) 2017-2025 WireGuard LLC. All Rights Reserved. + * Copyright (C) 2017-2023 WireGuard LLC. All Rights Reserved. */ package conn diff --git a/conn/default.go b/conn/default.go index 2ce1579..b6f761b 100644 --- a/conn/default.go +++ b/conn/default.go @@ -2,7 +2,7 @@ /* SPDX-License-Identifier: MIT * - * Copyright (C) 2017-2025 WireGuard LLC. All Rights Reserved. + * Copyright (C) 2017-2023 WireGuard LLC. All Rights Reserved. */ package conn diff --git a/conn/errors_default.go b/conn/errors_default.go index 3c9b223..f1e5b90 100644 --- a/conn/errors_default.go +++ b/conn/errors_default.go @@ -2,11 +2,11 @@ /* SPDX-License-Identifier: MIT * - * Copyright (C) 2017-2025 WireGuard LLC. All Rights Reserved. + * Copyright (C) 2017-2023 WireGuard LLC. All Rights Reserved. */ package conn -func errShouldDisableUDPGSO(_ error) bool { +func errShouldDisableUDPGSO(err error) bool { return false } diff --git a/conn/errors_linux.go b/conn/errors_linux.go index 9ed7d76..7548a8a 100644 --- a/conn/errors_linux.go +++ b/conn/errors_linux.go @@ -1,6 +1,6 @@ /* SPDX-License-Identifier: MIT * - * Copyright (C) 2017-2025 WireGuard LLC. All Rights Reserved. + * Copyright (C) 2017-2023 WireGuard LLC. All Rights Reserved. */ package conn diff --git a/conn/features_default.go b/conn/features_default.go index 9fc5088..d53ff5f 100644 --- a/conn/features_default.go +++ b/conn/features_default.go @@ -3,13 +3,13 @@ /* SPDX-License-Identifier: MIT * - * Copyright (C) 2017-2025 WireGuard LLC. All Rights Reserved. + * Copyright (C) 2017-2023 WireGuard LLC. All Rights Reserved. */ package conn import "net" -func supportsUDPOffload(_ *net.UDPConn) (txOffload, rxOffload bool) { +func supportsUDPOffload(conn *net.UDPConn) (txOffload, rxOffload bool) { return } diff --git a/conn/features_linux.go b/conn/features_linux.go index 936029e..a6de8c1 100644 --- a/conn/features_linux.go +++ b/conn/features_linux.go @@ -1,6 +1,6 @@ /* SPDX-License-Identifier: MIT * - * Copyright (C) 2017-2025 WireGuard LLC. All Rights Reserved. + * Copyright (C) 2017-2023 WireGuard LLC. All Rights Reserved. */ package conn diff --git a/conn/gso_default.go b/conn/gso_default.go index a9a3e80..57780db 100644 --- a/conn/gso_default.go +++ b/conn/gso_default.go @@ -2,7 +2,7 @@ /* SPDX-License-Identifier: MIT * - * Copyright (C) 2017-2025 WireGuard LLC. All Rights Reserved. + * Copyright (C) 2017-2023 WireGuard LLC. All Rights Reserved. */ package conn diff --git a/conn/gso_linux.go b/conn/gso_linux.go index 4ee31fa..8596b29 100644 --- a/conn/gso_linux.go +++ b/conn/gso_linux.go @@ -2,7 +2,7 @@ /* SPDX-License-Identifier: MIT * - * Copyright (C) 2017-2025 WireGuard LLC. All Rights Reserved. + * Copyright (C) 2017-2023 WireGuard LLC. All Rights Reserved. */ package conn diff --git a/conn/mark_default.go b/conn/mark_default.go index 72b266e..3102384 100644 --- a/conn/mark_default.go +++ b/conn/mark_default.go @@ -2,7 +2,7 @@ /* SPDX-License-Identifier: MIT * - * Copyright (C) 2017-2025 WireGuard LLC. All Rights Reserved. + * Copyright (C) 2017-2023 WireGuard LLC. All Rights Reserved. */ package conn diff --git a/conn/mark_unix.go b/conn/mark_unix.go index d0580d5..d9e46ee 100644 --- a/conn/mark_unix.go +++ b/conn/mark_unix.go @@ -2,7 +2,7 @@ /* SPDX-License-Identifier: MIT * - * Copyright (C) 2017-2025 WireGuard LLC. All Rights Reserved. + * Copyright (C) 2017-2023 WireGuard LLC. All Rights Reserved. */ package conn diff --git a/conn/sticky_default.go b/conn/sticky_default.go index 15b65af..0b21386 100644 --- a/conn/sticky_default.go +++ b/conn/sticky_default.go @@ -2,7 +2,7 @@ /* SPDX-License-Identifier: MIT * - * Copyright (C) 2017-2025 WireGuard LLC. All Rights Reserved. + * Copyright (C) 2017-2023 WireGuard LLC. All Rights Reserved. */ package conn diff --git a/conn/sticky_linux.go b/conn/sticky_linux.go index adfedc1..8e206e9 100644 --- a/conn/sticky_linux.go +++ b/conn/sticky_linux.go @@ -2,7 +2,7 @@ /* SPDX-License-Identifier: MIT * - * Copyright (C) 2017-2025 WireGuard LLC. All Rights Reserved. + * Copyright (C) 2017-2023 WireGuard LLC. All Rights Reserved. */ package conn diff --git a/conn/sticky_linux_test.go b/conn/sticky_linux_test.go index 1b1ee68..d2bd584 100644 --- a/conn/sticky_linux_test.go +++ b/conn/sticky_linux_test.go @@ -2,7 +2,7 @@ /* SPDX-License-Identifier: MIT * - * Copyright (C) 2017-2025 WireGuard LLC. All Rights Reserved. + * Copyright (C) 2017-2023 WireGuard LLC. All Rights Reserved. */ package conn diff --git a/conn/winrio/rio_windows.go b/conn/winrio/rio_windows.go index c396658..d1037bb 100644 --- a/conn/winrio/rio_windows.go +++ b/conn/winrio/rio_windows.go @@ -1,6 +1,6 @@ /* SPDX-License-Identifier: MIT * - * Copyright (C) 2017-2025 WireGuard LLC. All Rights Reserved. + * Copyright (C) 2017-2023 WireGuard LLC. All Rights Reserved. */ package winrio diff --git a/device/allowedips.go b/device/allowedips.go index d15373c..fa46f97 100644 --- a/device/allowedips.go +++ b/device/allowedips.go @@ -1,6 +1,6 @@ /* SPDX-License-Identifier: MIT * - * Copyright (C) 2017-2025 WireGuard LLC. All Rights Reserved. + * Copyright (C) 2017-2023 WireGuard LLC. All Rights Reserved. */ package device @@ -223,60 +223,6 @@ func (table *AllowedIPs) EntriesForPeer(peer *Peer, cb func(prefix netip.Prefix) } } -func (node *trieEntry) remove() { - node.removeFromPeerEntries() - node.peer = nil - if node.child[0] != nil && node.child[1] != nil { - return - } - bit := 0 - if node.child[0] == nil { - bit = 1 - } - child := node.child[bit] - if child != nil { - child.parent = node.parent - } - *node.parent.parentBit = child - if node.child[0] != nil || node.child[1] != nil || node.parent.parentBitType > 1 { - node.zeroizePointers() - return - } - parent := (*trieEntry)(unsafe.Pointer(uintptr(unsafe.Pointer(node.parent.parentBit)) - unsafe.Offsetof(node.child) - unsafe.Sizeof(node.child[0])*uintptr(node.parent.parentBitType))) - if parent.peer != nil { - node.zeroizePointers() - return - } - child = parent.child[node.parent.parentBitType^1] - if child != nil { - child.parent = parent.parent - } - *parent.parent.parentBit = child - node.zeroizePointers() - parent.zeroizePointers() -} - -func (table *AllowedIPs) Remove(prefix netip.Prefix, peer *Peer) { - table.mutex.Lock() - defer table.mutex.Unlock() - var node *trieEntry - var exact bool - - if prefix.Addr().Is6() { - ip := prefix.Addr().As16() - node, exact = table.IPv6.nodePlacement(ip[:], uint8(prefix.Bits())) - } else if prefix.Addr().Is4() { - ip := prefix.Addr().As4() - node, exact = table.IPv4.nodePlacement(ip[:], uint8(prefix.Bits())) - } else { - panic(errors.New("removing unknown address type")) - } - if !exact || node == nil || peer != node.peer { - return - } - node.remove() -} - func (table *AllowedIPs) RemoveByPeer(peer *Peer) { table.mutex.Lock() defer table.mutex.Unlock() @@ -284,7 +230,38 @@ func (table *AllowedIPs) RemoveByPeer(peer *Peer) { var next *list.Element for elem := peer.trieEntries.Front(); elem != nil; elem = next { next = elem.Next() - elem.Value.(*trieEntry).remove() + node := elem.Value.(*trieEntry) + + node.removeFromPeerEntries() + node.peer = nil + if node.child[0] != nil && node.child[1] != nil { + continue + } + bit := 0 + if node.child[0] == nil { + bit = 1 + } + child := node.child[bit] + if child != nil { + child.parent = node.parent + } + *node.parent.parentBit = child + if node.child[0] != nil || node.child[1] != nil || node.parent.parentBitType > 1 { + node.zeroizePointers() + continue + } + parent := (*trieEntry)(unsafe.Pointer(uintptr(unsafe.Pointer(node.parent.parentBit)) - unsafe.Offsetof(node.child) - unsafe.Sizeof(node.child[0])*uintptr(node.parent.parentBitType))) + if parent.peer != nil { + node.zeroizePointers() + continue + } + child = parent.child[node.parent.parentBitType^1] + if child != nil { + child.parent = parent.parent + } + *parent.parent.parentBit = child + node.zeroizePointers() + parent.zeroizePointers() } } diff --git a/device/allowedips_rand_test.go b/device/allowedips_rand_test.go index b863696..07065c3 100644 --- a/device/allowedips_rand_test.go +++ b/device/allowedips_rand_test.go @@ -1,6 +1,6 @@ /* SPDX-License-Identifier: MIT * - * Copyright (C) 2017-2025 WireGuard LLC. All Rights Reserved. + * Copyright (C) 2017-2023 WireGuard LLC. All Rights Reserved. */ package device @@ -83,7 +83,7 @@ func TestTrieRandom(t *testing.T) { var peers []*Peer var allowedIPs AllowedIPs - rng := rand.New(rand.NewSource(1)) + rand.Seed(1) for n := 0; n < NumberOfPeers; n++ { peers = append(peers, &Peer{}) @@ -91,14 +91,14 @@ func TestTrieRandom(t *testing.T) { for n := 0; n < NumberOfAddresses; n++ { var addr4 [4]byte - rng.Read(addr4[:]) + rand.Read(addr4[:]) cidr := uint8(rand.Intn(32) + 1) index := rand.Intn(NumberOfPeers) allowedIPs.Insert(netip.PrefixFrom(netip.AddrFrom4(addr4), int(cidr)), peers[index]) slow4 = slow4.Insert(addr4[:], cidr, peers[index]) var addr6 [16]byte - rng.Read(addr6[:]) + rand.Read(addr6[:]) cidr = uint8(rand.Intn(128) + 1) index = rand.Intn(NumberOfPeers) allowedIPs.Insert(netip.PrefixFrom(netip.AddrFrom16(addr6), int(cidr)), peers[index]) @@ -109,7 +109,7 @@ func TestTrieRandom(t *testing.T) { for p = 0; ; p++ { for n := 0; n < NumberOfTests; n++ { var addr4 [4]byte - rng.Read(addr4[:]) + rand.Read(addr4[:]) peer1 := slow4.Lookup(addr4[:]) peer2 := allowedIPs.Lookup(addr4[:]) if peer1 != peer2 { @@ -117,7 +117,7 @@ func TestTrieRandom(t *testing.T) { } var addr6 [16]byte - rng.Read(addr6[:]) + rand.Read(addr6[:]) peer1 = slow6.Lookup(addr6[:]) peer2 = allowedIPs.Lookup(addr6[:]) if peer1 != peer2 { diff --git a/device/allowedips_test.go b/device/allowedips_test.go index a4b08a3..cde068e 100644 --- a/device/allowedips_test.go +++ b/device/allowedips_test.go @@ -1,6 +1,6 @@ /* SPDX-License-Identifier: MIT * - * Copyright (C) 2017-2025 WireGuard LLC. All Rights Reserved. + * Copyright (C) 2017-2023 WireGuard LLC. All Rights Reserved. */ package device @@ -39,12 +39,12 @@ func TestCommonBits(t *testing.T) { } } -func benchmarkTrie(peerNumber, addressNumber, _ int, b *testing.B) { +func benchmarkTrie(peerNumber, addressNumber, addressLength int, b *testing.B) { var trie *trieEntry var peers []*Peer root := parentIndirection{&trie, 2} - rng := rand.New(rand.NewSource(1)) + rand.Seed(1) const AddressLength = 4 @@ -54,15 +54,15 @@ func benchmarkTrie(peerNumber, addressNumber, _ int, b *testing.B) { for n := 0; n < addressNumber; n++ { var addr [AddressLength]byte - rng.Read(addr[:]) - cidr := uint8(rng.Uint32() % (AddressLength * 8)) - index := rng.Int() % peerNumber + rand.Read(addr[:]) + cidr := uint8(rand.Uint32() % (AddressLength * 8)) + index := rand.Int() % peerNumber root.insert(addr[:], cidr, peers[index]) } for n := 0; n < b.N; n++ { var addr [AddressLength]byte - rng.Read(addr[:]) + rand.Read(addr[:]) trie.lookup(addr[:]) } } @@ -101,10 +101,6 @@ func TestTrieIPv4(t *testing.T) { allowedIPs.Insert(netip.PrefixFrom(netip.AddrFrom4([4]byte{a, b, c, d}), int(cidr)), peer) } - remove := func(peer *Peer, a, b, c, d byte, cidr uint8) { - allowedIPs.Remove(netip.PrefixFrom(netip.AddrFrom4([4]byte{a, b, c, d}), int(cidr)), peer) - } - assertEQ := func(peer *Peer, a, b, c, d byte) { p := allowedIPs.Lookup([]byte{a, b, c, d}) if p != peer { @@ -180,21 +176,6 @@ func TestTrieIPv4(t *testing.T) { allowedIPs.RemoveByPeer(a) assertNEQ(a, 192, 168, 0, 1) - - insert(a, 1, 0, 0, 0, 32) - insert(a, 192, 0, 0, 0, 24) - assertEQ(a, 1, 0, 0, 0) - assertEQ(a, 192, 0, 0, 1) - remove(a, 192, 0, 0, 0, 32) - assertEQ(a, 192, 0, 0, 1) - remove(nil, 192, 0, 0, 0, 24) - assertEQ(a, 192, 0, 0, 1) - remove(b, 192, 0, 0, 0, 24) - assertEQ(a, 192, 0, 0, 1) - remove(a, 192, 0, 0, 0, 24) - assertNEQ(a, 192, 0, 0, 1) - remove(a, 1, 0, 0, 0, 32) - assertNEQ(a, 1, 0, 0, 0) } /* Test ported from kernel implementation: @@ -230,15 +211,6 @@ func TestTrieIPv6(t *testing.T) { allowedIPs.Insert(netip.PrefixFrom(netip.AddrFrom16(*(*[16]byte)(addr)), int(cidr)), peer) } - remove := func(peer *Peer, a, b, c, d uint32, cidr uint8) { - var addr []byte - addr = append(addr, expand(a)...) - addr = append(addr, expand(b)...) - addr = append(addr, expand(c)...) - addr = append(addr, expand(d)...) - allowedIPs.Remove(netip.PrefixFrom(netip.AddrFrom16(*(*[16]byte)(addr)), int(cidr)), peer) - } - assertEQ := func(peer *Peer, a, b, c, d uint32) { var addr []byte addr = append(addr, expand(a)...) @@ -251,18 +223,6 @@ func TestTrieIPv6(t *testing.T) { } } - assertNEQ := func(peer *Peer, a, b, c, d uint32) { - var addr []byte - addr = append(addr, expand(a)...) - addr = append(addr, expand(b)...) - addr = append(addr, expand(c)...) - addr = append(addr, expand(d)...) - p := allowedIPs.Lookup(addr) - if p == peer { - t.Error("Assert NEQ failed") - } - } - insert(d, 0x26075300, 0x60006b00, 0, 0xc05f0543, 128) insert(c, 0x26075300, 0x60006b00, 0, 0, 64) insert(e, 0, 0, 0, 0, 0) @@ -284,21 +244,4 @@ func TestTrieIPv6(t *testing.T) { assertEQ(h, 0x24046800, 0x40040800, 0, 0) assertEQ(h, 0x24046800, 0x40040800, 0x10101010, 0x10101010) assertEQ(a, 0x24046800, 0x40040800, 0xdeadbeef, 0xdeadbeef) - - insert(a, 0x24446801, 0x40e40800, 0xdeaebeef, 0xdefbeef, 128) - insert(a, 0x24446800, 0xf0e40800, 0xeeaebeef, 0, 98) - assertEQ(a, 0x24446801, 0x40e40800, 0xdeaebeef, 0xdefbeef) - assertEQ(a, 0x24446800, 0xf0e40800, 0xeeaebeef, 0x10101010) - remove(a, 0x24446801, 0x40e40800, 0xdeaebeef, 0xdefbeef, 96) - assertEQ(a, 0x24446801, 0x40e40800, 0xdeaebeef, 0xdefbeef) - remove(nil, 0x24446801, 0x40e40800, 0xdeaebeef, 0xdefbeef, 128) - assertEQ(a, 0x24446801, 0x40e40800, 0xdeaebeef, 0xdefbeef) - remove(b, 0x24446801, 0x40e40800, 0xdeaebeef, 0xdefbeef, 128) - assertEQ(a, 0x24446801, 0x40e40800, 0xdeaebeef, 0xdefbeef) - remove(a, 0x24446801, 0x40e40800, 0xdeaebeef, 0xdefbeef, 128) - assertNEQ(a, 0x24446801, 0x40e40800, 0xdeaebeef, 0xdefbeef) - remove(b, 0x24446800, 0xf0e40800, 0xeeaebeef, 0, 98) - assertEQ(a, 0x24446800, 0xf0e40800, 0xeeaebeef, 0x10101010) - remove(a, 0x24446800, 0xf0e40800, 0xeeaebeef, 0, 98) - assertNEQ(a, 0x24446800, 0xf0e40800, 0xeeaebeef, 0x10101010) } diff --git a/device/bind_test.go b/device/bind_test.go index 24dec1f..34d1c4a 100644 --- a/device/bind_test.go +++ b/device/bind_test.go @@ -1,6 +1,6 @@ /* SPDX-License-Identifier: MIT * - * Copyright (C) 2017-2025 WireGuard LLC. All Rights Reserved. + * Copyright (C) 2017-2023 WireGuard LLC. All Rights Reserved. */ package device diff --git a/device/channels.go b/device/channels.go index be15d1c..e526f6b 100644 --- a/device/channels.go +++ b/device/channels.go @@ -1,6 +1,6 @@ /* SPDX-License-Identifier: MIT * - * Copyright (C) 2017-2025 WireGuard LLC. All Rights Reserved. + * Copyright (C) 2017-2023 WireGuard LLC. All Rights Reserved. */ package device diff --git a/device/constants.go b/device/constants.go index 41da618..59854a1 100644 --- a/device/constants.go +++ b/device/constants.go @@ -1,6 +1,6 @@ /* SPDX-License-Identifier: MIT * - * Copyright (C) 2017-2025 WireGuard LLC. All Rights Reserved. + * Copyright (C) 2017-2023 WireGuard LLC. All Rights Reserved. */ package device diff --git a/device/cookie.go b/device/cookie.go index a093c8b..876f05d 100644 --- a/device/cookie.go +++ b/device/cookie.go @@ -1,6 +1,6 @@ /* SPDX-License-Identifier: MIT * - * Copyright (C) 2017-2025 WireGuard LLC. All Rights Reserved. + * Copyright (C) 2017-2023 WireGuard LLC. All Rights Reserved. */ package device diff --git a/device/cookie_test.go b/device/cookie_test.go index c937290..4f1e50a 100644 --- a/device/cookie_test.go +++ b/device/cookie_test.go @@ -1,6 +1,6 @@ /* SPDX-License-Identifier: MIT * - * Copyright (C) 2017-2025 WireGuard LLC. All Rights Reserved. + * Copyright (C) 2017-2023 WireGuard LLC. All Rights Reserved. */ package device diff --git a/device/device.go b/device/device.go index c67183d..42a81c7 100644 --- a/device/device.go +++ b/device/device.go @@ -1,6 +1,6 @@ /* SPDX-License-Identifier: MIT * - * Copyright (C) 2017-2025 WireGuard LLC. All Rights Reserved. + * Copyright (C) 2017-2023 WireGuard LLC. All Rights Reserved. */ package device diff --git a/device/device_test.go b/device/device_test.go index a15ce97..7aec4c2 100644 --- a/device/device_test.go +++ b/device/device_test.go @@ -1,6 +1,6 @@ /* SPDX-License-Identifier: MIT * - * Copyright (C) 2017-2025 WireGuard LLC. All Rights Reserved. + * Copyright (C) 2017-2023 WireGuard LLC. All Rights Reserved. */ package device diff --git a/device/endpoint_test.go b/device/endpoint_test.go index 85482d8..93a4998 100644 --- a/device/endpoint_test.go +++ b/device/endpoint_test.go @@ -1,6 +1,6 @@ /* SPDX-License-Identifier: MIT * - * Copyright (C) 2017-2025 WireGuard LLC. All Rights Reserved. + * Copyright (C) 2017-2023 WireGuard LLC. All Rights Reserved. */ package device diff --git a/device/indextable.go b/device/indextable.go index 2460fa6..00ade7d 100644 --- a/device/indextable.go +++ b/device/indextable.go @@ -1,6 +1,6 @@ /* SPDX-License-Identifier: MIT * - * Copyright (C) 2017-2025 WireGuard LLC. All Rights Reserved. + * Copyright (C) 2017-2023 WireGuard LLC. All Rights Reserved. */ package device diff --git a/device/ip.go b/device/ip.go index f558744..eaf2363 100644 --- a/device/ip.go +++ b/device/ip.go @@ -1,6 +1,6 @@ /* SPDX-License-Identifier: MIT * - * Copyright (C) 2017-2025 WireGuard LLC. All Rights Reserved. + * Copyright (C) 2017-2023 WireGuard LLC. All Rights Reserved. */ package device diff --git a/device/kdf_test.go b/device/kdf_test.go index 325db59..f9c76d6 100644 --- a/device/kdf_test.go +++ b/device/kdf_test.go @@ -1,6 +1,6 @@ /* SPDX-License-Identifier: MIT * - * Copyright (C) 2017-2025 WireGuard LLC. All Rights Reserved. + * Copyright (C) 2017-2023 WireGuard LLC. All Rights Reserved. */ package device diff --git a/device/keypair.go b/device/keypair.go index 05bce68..cc2941a 100644 --- a/device/keypair.go +++ b/device/keypair.go @@ -1,6 +1,6 @@ /* SPDX-License-Identifier: MIT * - * Copyright (C) 2017-2025 WireGuard LLC. All Rights Reserved. + * Copyright (C) 2017-2023 WireGuard LLC. All Rights Reserved. */ package device diff --git a/device/logger.go b/device/logger.go index a2adea3..22b0df0 100644 --- a/device/logger.go +++ b/device/logger.go @@ -1,6 +1,6 @@ /* SPDX-License-Identifier: MIT * - * Copyright (C) 2017-2025 WireGuard LLC. All Rights Reserved. + * Copyright (C) 2017-2023 WireGuard LLC. All Rights Reserved. */ package device diff --git a/device/mobilequirks.go b/device/mobilequirks.go index af4be31..0a0080e 100644 --- a/device/mobilequirks.go +++ b/device/mobilequirks.go @@ -1,6 +1,6 @@ /* SPDX-License-Identifier: MIT * - * Copyright (C) 2017-2025 WireGuard LLC. All Rights Reserved. + * Copyright (C) 2017-2023 WireGuard LLC. All Rights Reserved. */ package device diff --git a/device/noise-helpers.go b/device/noise-helpers.go index 35dd907..c2f356b 100644 --- a/device/noise-helpers.go +++ b/device/noise-helpers.go @@ -1,6 +1,6 @@ /* SPDX-License-Identifier: MIT * - * Copyright (C) 2017-2025 WireGuard LLC. All Rights Reserved. + * Copyright (C) 2017-2023 WireGuard LLC. All Rights Reserved. */ package device diff --git a/device/noise-protocol.go b/device/noise-protocol.go index 98f279d..89c634c 100644 --- a/device/noise-protocol.go +++ b/device/noise-protocol.go @@ -1,6 +1,6 @@ /* SPDX-License-Identifier: MIT * - * Copyright (C) 2017-2025 WireGuard LLC. All Rights Reserved. + * Copyright (C) 2017-2023 WireGuard LLC. All Rights Reserved. */ package device diff --git a/device/noise-types.go b/device/noise-types.go index 41c944e..e850359 100644 --- a/device/noise-types.go +++ b/device/noise-types.go @@ -1,6 +1,6 @@ /* SPDX-License-Identifier: MIT * - * Copyright (C) 2017-2025 WireGuard LLC. All Rights Reserved. + * Copyright (C) 2017-2023 WireGuard LLC. All Rights Reserved. */ package device diff --git a/device/noise_test.go b/device/noise_test.go index 8f72f29..075b6d3 100644 --- a/device/noise_test.go +++ b/device/noise_test.go @@ -1,6 +1,6 @@ /* SPDX-License-Identifier: MIT * - * Copyright (C) 2017-2025 WireGuard LLC. All Rights Reserved. + * Copyright (C) 2017-2023 WireGuard LLC. All Rights Reserved. */ package device diff --git a/device/peer.go b/device/peer.go index 467b211..fdc0b86 100644 --- a/device/peer.go +++ b/device/peer.go @@ -1,6 +1,6 @@ /* SPDX-License-Identifier: MIT * - * Copyright (C) 2017-2025 WireGuard LLC. All Rights Reserved. + * Copyright (C) 2017-2023 WireGuard LLC. All Rights Reserved. */ package device diff --git a/device/pools.go b/device/pools.go index 2c18f41..94f3dc7 100644 --- a/device/pools.go +++ b/device/pools.go @@ -1,19 +1,20 @@ /* SPDX-License-Identifier: MIT * - * Copyright (C) 2017-2025 WireGuard LLC. All Rights Reserved. + * Copyright (C) 2017-2023 WireGuard LLC. All Rights Reserved. */ package device import ( "sync" + "sync/atomic" ) type WaitPool struct { pool sync.Pool cond sync.Cond lock sync.Mutex - count uint32 // Get calls not yet Put back + count atomic.Uint32 max uint32 } @@ -26,10 +27,10 @@ func NewWaitPool(max uint32, new func() any) *WaitPool { func (p *WaitPool) Get() any { if p.max != 0 { p.lock.Lock() - for p.count >= p.max { + for p.count.Load() >= p.max { p.cond.Wait() } - p.count++ + p.count.Add(1) p.lock.Unlock() } return p.pool.Get() @@ -40,9 +41,7 @@ func (p *WaitPool) Put(x any) { if p.max == 0 { return } - p.lock.Lock() - defer p.lock.Unlock() - p.count-- + p.count.Add(^uint32(0)) p.cond.Signal() } diff --git a/device/pools_test.go b/device/pools_test.go index 8381d5a..82d7493 100644 --- a/device/pools_test.go +++ b/device/pools_test.go @@ -1,6 +1,6 @@ /* SPDX-License-Identifier: MIT * - * Copyright (C) 2017-2025 WireGuard LLC. All Rights Reserved. + * Copyright (C) 2017-2023 WireGuard LLC. All Rights Reserved. */ package device @@ -32,9 +32,7 @@ func TestWaitPool(t *testing.T) { wg.Add(workers) var max atomic.Uint32 updateMax := func() { - p.lock.Lock() - count := p.count - p.lock.Unlock() + count := p.count.Load() if count > p.max { t.Errorf("count (%d) > max (%d)", count, p.max) } diff --git a/device/queueconstants_android.go b/device/queueconstants_android.go index 741fcf3..1bff95a 100644 --- a/device/queueconstants_android.go +++ b/device/queueconstants_android.go @@ -1,6 +1,6 @@ /* SPDX-License-Identifier: MIT * - * Copyright (C) 2017-2025 WireGuard LLC. All Rights Reserved. + * Copyright (C) 2017-2023 WireGuard LLC. All Rights Reserved. */ package device diff --git a/device/queueconstants_default.go b/device/queueconstants_default.go index f19e9b1..0061b63 100644 --- a/device/queueconstants_default.go +++ b/device/queueconstants_default.go @@ -2,7 +2,7 @@ /* SPDX-License-Identifier: MIT * - * Copyright (C) 2017-2025 WireGuard LLC. All Rights Reserved. + * Copyright (C) 2017-2023 WireGuard LLC. All Rights Reserved. */ package device diff --git a/device/queueconstants_ios.go b/device/queueconstants_ios.go index 632e29d..acd3cec 100644 --- a/device/queueconstants_ios.go +++ b/device/queueconstants_ios.go @@ -2,7 +2,7 @@ /* SPDX-License-Identifier: MIT * - * Copyright (C) 2017-2025 WireGuard LLC. All Rights Reserved. + * Copyright (C) 2017-2023 WireGuard LLC. All Rights Reserved. */ package device diff --git a/device/queueconstants_windows.go b/device/queueconstants_windows.go index 9a296d6..1eee32b 100644 --- a/device/queueconstants_windows.go +++ b/device/queueconstants_windows.go @@ -1,6 +1,6 @@ /* SPDX-License-Identifier: MIT * - * Copyright (C) 2017-2025 WireGuard LLC. All Rights Reserved. + * Copyright (C) 2017-2023 WireGuard LLC. All Rights Reserved. */ package device diff --git a/device/race_disabled_test.go b/device/race_disabled_test.go index 14b3284..bb5c450 100644 --- a/device/race_disabled_test.go +++ b/device/race_disabled_test.go @@ -2,7 +2,7 @@ /* SPDX-License-Identifier: MIT * - * Copyright (C) 2017-2025 WireGuard LLC. All Rights Reserved. + * Copyright (C) 2017-2023 WireGuard LLC. All Rights Reserved. */ package device diff --git a/device/race_enabled_test.go b/device/race_enabled_test.go index f1ea5cf..4e9daea 100644 --- a/device/race_enabled_test.go +++ b/device/race_enabled_test.go @@ -2,7 +2,7 @@ /* SPDX-License-Identifier: MIT * - * Copyright (C) 2017-2025 WireGuard LLC. All Rights Reserved. + * Copyright (C) 2017-2023 WireGuard LLC. All Rights Reserved. */ package device diff --git a/device/receive.go b/device/receive.go index fa4f753..1ab7cd9 100644 --- a/device/receive.go +++ b/device/receive.go @@ -1,6 +1,6 @@ /* SPDX-License-Identifier: MIT * - * Copyright (C) 2017-2025 WireGuard LLC. All Rights Reserved. + * Copyright (C) 2017-2023 WireGuard LLC. All Rights Reserved. */ package device diff --git a/device/send.go b/device/send.go index 6136683..305589a 100644 --- a/device/send.go +++ b/device/send.go @@ -1,6 +1,6 @@ /* SPDX-License-Identifier: MIT * - * Copyright (C) 2017-2025 WireGuard LLC. All Rights Reserved. + * Copyright (C) 2017-2023 WireGuard LLC. All Rights Reserved. */ package device @@ -586,7 +586,6 @@ func (peer *Peer) RoutineSequentialSender(maxBatchSize int) { device.PutMessageBuffer(elem.buffer) device.PutOutboundElement(elem) } - device.PutOutboundElementsContainer(elemsContainer) continue } dataSent := false diff --git a/device/sticky_default.go b/device/sticky_default.go index 1751927..da776e8 100644 --- a/device/sticky_default.go +++ b/device/sticky_default.go @@ -7,6 +7,6 @@ import ( "github.com/amnezia-vpn/amneziawg-go/rwcancel" ) -func (device *Device) startRouteListener(_ conn.Bind) (*rwcancel.RWCancel, error) { +func (device *Device) startRouteListener(bind conn.Bind) (*rwcancel.RWCancel, error) { return nil, nil } diff --git a/device/sticky_linux.go b/device/sticky_linux.go index 2edb628..63164a7 100644 --- a/device/sticky_linux.go +++ b/device/sticky_linux.go @@ -1,6 +1,6 @@ /* SPDX-License-Identifier: MIT * - * Copyright (C) 2017-2025 WireGuard LLC. All Rights Reserved. + * Copyright (C) 2017-2023 WireGuard LLC. All Rights Reserved. * * This implements userspace semantics of "sticky sockets", modeled after * WireGuard's kernelspace implementation. This is more or less a straight port @@ -9,7 +9,7 @@ * * Currently there is no way to achieve this within the net package: * See e.g. https://github.com/golang/go/issues/17930 - * So this code remains platform dependent. + * So this code is remains platform dependent. */ package device @@ -47,7 +47,7 @@ func (device *Device) startRouteListener(bind conn.Bind) (*rwcancel.RWCancel, er return netlinkCancel, nil } -func (device *Device) routineRouteListener(_ conn.Bind, netlinkSock int, netlinkCancel *rwcancel.RWCancel) { +func (device *Device) routineRouteListener(bind conn.Bind, netlinkSock int, netlinkCancel *rwcancel.RWCancel) { type peerEndpointPtr struct { peer *Peer endpoint *conn.Endpoint diff --git a/device/timers.go b/device/timers.go index 32519aa..d4a4ed4 100644 --- a/device/timers.go +++ b/device/timers.go @@ -1,6 +1,6 @@ /* SPDX-License-Identifier: MIT * - * Copyright (C) 2017-2025 WireGuard LLC. All Rights Reserved. + * Copyright (C) 2017-2023 WireGuard LLC. All Rights Reserved. * * This is based heavily on timers.c from the kernel implementation. */ diff --git a/device/tun.go b/device/tun.go index 42178b2..600a5e5 100644 --- a/device/tun.go +++ b/device/tun.go @@ -1,6 +1,6 @@ /* SPDX-License-Identifier: MIT * - * Copyright (C) 2017-2025 WireGuard LLC. All Rights Reserved. + * Copyright (C) 2017-2023 WireGuard LLC. All Rights Reserved. */ package device diff --git a/device/uapi.go b/device/uapi.go index 126c2eb..9f2718d 100644 --- a/device/uapi.go +++ b/device/uapi.go @@ -1,6 +1,6 @@ /* SPDX-License-Identifier: MIT * - * Copyright (C) 2017-2025 WireGuard LLC. All Rights Reserved. + * Copyright (C) 2017-2023 WireGuard LLC. All Rights Reserved. */ package device @@ -561,14 +561,7 @@ func (device *Device) handlePeerLine( device.allowedips.RemoveByPeer(peer.Peer) case "allowed_ip": - add := true - verb := "Adding" - if len(value) > 0 && value[0] == '-' { - add = false - verb = "Removing" - value = value[1:] - } - device.log.Verbosef("%v - UAPI: %s allowedip", peer.Peer, verb) + device.log.Verbosef("%v - UAPI: Adding allowedip", peer.Peer) prefix, err := netip.ParsePrefix(value) if err != nil { return ipcErrorf(ipc.IpcErrorInvalid, "failed to set allowed ip: %w", err) @@ -576,11 +569,7 @@ func (device *Device) handlePeerLine( if peer.dummy { return nil } - if add { - device.allowedips.Insert(prefix, peer.Peer) - } else { - device.allowedips.Remove(prefix, peer.Peer) - } + device.allowedips.Insert(prefix, peer.Peer) case "protocol_version": if value != "1" { diff --git a/format_test.go b/format_test.go index 4d02c48..6f6cab7 100644 --- a/format_test.go +++ b/format_test.go @@ -1,6 +1,6 @@ /* SPDX-License-Identifier: MIT * - * Copyright (C) 2017-2025 WireGuard LLC. All Rights Reserved. + * Copyright (C) 2017-2023 WireGuard LLC. All Rights Reserved. */ package main diff --git a/ipc/uapi_bsd.go b/ipc/uapi_bsd.go index fd433a5..ddcaf27 100644 --- a/ipc/uapi_bsd.go +++ b/ipc/uapi_bsd.go @@ -2,7 +2,7 @@ /* SPDX-License-Identifier: MIT * - * Copyright (C) 2017-2025 WireGuard LLC. All Rights Reserved. + * Copyright (C) 2017-2023 WireGuard LLC. All Rights Reserved. */ package ipc diff --git a/ipc/uapi_linux.go b/ipc/uapi_linux.go index 058e8e7..9738aea 100644 --- a/ipc/uapi_linux.go +++ b/ipc/uapi_linux.go @@ -1,6 +1,6 @@ /* SPDX-License-Identifier: MIT * - * Copyright (C) 2017-2025 WireGuard LLC. All Rights Reserved. + * Copyright (C) 2017-2023 WireGuard LLC. All Rights Reserved. */ package ipc diff --git a/ipc/uapi_unix.go b/ipc/uapi_unix.go index 79604ee..0da452a 100644 --- a/ipc/uapi_unix.go +++ b/ipc/uapi_unix.go @@ -2,7 +2,7 @@ /* SPDX-License-Identifier: MIT * - * Copyright (C) 2017-2025 WireGuard LLC. All Rights Reserved. + * Copyright (C) 2017-2023 WireGuard LLC. All Rights Reserved. */ package ipc diff --git a/ipc/uapi_wasm.go b/ipc/uapi_wasm.go index 50ac091..fa84684 100644 --- a/ipc/uapi_wasm.go +++ b/ipc/uapi_wasm.go @@ -1,6 +1,6 @@ /* SPDX-License-Identifier: MIT * - * Copyright (C) 2017-2025 WireGuard LLC. All Rights Reserved. + * Copyright (C) 2017-2023 WireGuard LLC. All Rights Reserved. */ package ipc diff --git a/ipc/uapi_windows.go b/ipc/uapi_windows.go index 321fe60..31d2a63 100644 --- a/ipc/uapi_windows.go +++ b/ipc/uapi_windows.go @@ -1,6 +1,6 @@ /* SPDX-License-Identifier: MIT * - * Copyright (C) 2017-2025 WireGuard LLC. All Rights Reserved. + * Copyright (C) 2017-2023 WireGuard LLC. All Rights Reserved. */ package ipc diff --git a/main.go b/main.go index f8fded9..5a3dfef 100644 --- a/main.go +++ b/main.go @@ -2,7 +2,7 @@ /* SPDX-License-Identifier: MIT * - * Copyright (C) 2017-2025 WireGuard LLC. All Rights Reserved. + * Copyright (C) 2017-2023 WireGuard LLC. All Rights Reserved. */ package main diff --git a/main_windows.go b/main_windows.go index d3e2fe6..bbfa690 100644 --- a/main_windows.go +++ b/main_windows.go @@ -1,6 +1,6 @@ /* SPDX-License-Identifier: MIT * - * Copyright (C) 2017-2025 WireGuard LLC. All Rights Reserved. + * Copyright (C) 2017-2023 WireGuard LLC. All Rights Reserved. */ package main diff --git a/ratelimiter/ratelimiter.go b/ratelimiter/ratelimiter.go index ac69e3a..f7d05ef 100644 --- a/ratelimiter/ratelimiter.go +++ b/ratelimiter/ratelimiter.go @@ -1,6 +1,6 @@ /* SPDX-License-Identifier: MIT * - * Copyright (C) 2017-2025 WireGuard LLC. All Rights Reserved. + * Copyright (C) 2017-2023 WireGuard LLC. All Rights Reserved. */ package ratelimiter diff --git a/ratelimiter/ratelimiter_test.go b/ratelimiter/ratelimiter_test.go index 71140da..0bfa3af 100644 --- a/ratelimiter/ratelimiter_test.go +++ b/ratelimiter/ratelimiter_test.go @@ -1,6 +1,6 @@ /* SPDX-License-Identifier: MIT * - * Copyright (C) 2017-2025 WireGuard LLC. All Rights Reserved. + * Copyright (C) 2017-2023 WireGuard LLC. All Rights Reserved. */ package ratelimiter diff --git a/replay/replay.go b/replay/replay.go index 46e224d..8b99e23 100644 --- a/replay/replay.go +++ b/replay/replay.go @@ -1,6 +1,6 @@ /* SPDX-License-Identifier: MIT * - * Copyright (C) 2017-2025 WireGuard LLC. All Rights Reserved. + * Copyright (C) 2017-2023 WireGuard LLC. All Rights Reserved. */ // Package replay implements an efficient anti-replay algorithm as specified in RFC 6479. diff --git a/replay/replay_test.go b/replay/replay_test.go index 8378ec3..9a9e4a8 100644 --- a/replay/replay_test.go +++ b/replay/replay_test.go @@ -1,6 +1,6 @@ /* SPDX-License-Identifier: MIT * - * Copyright (C) 2017-2025 WireGuard LLC. All Rights Reserved. + * Copyright (C) 2017-2023 WireGuard LLC. All Rights Reserved. */ package replay diff --git a/rwcancel/rwcancel.go b/rwcancel/rwcancel.go index 4372453..e397c0e 100644 --- a/rwcancel/rwcancel.go +++ b/rwcancel/rwcancel.go @@ -2,7 +2,7 @@ /* SPDX-License-Identifier: MIT * - * Copyright (C) 2017-2025 WireGuard LLC. All Rights Reserved. + * Copyright (C) 2017-2023 WireGuard LLC. All Rights Reserved. */ // Package rwcancel implements cancelable read/write operations on @@ -64,7 +64,7 @@ func (rw *RWCancel) ReadyRead() bool { func (rw *RWCancel) ReadyWrite() bool { closeFd := int32(rw.closingReader.Fd()) - pollFds := []unix.PollFd{{Fd: int32(rw.fd), Events: unix.POLLOUT}, {Fd: closeFd, Events: unix.POLLIN}} + pollFds := []unix.PollFd{{Fd: int32(rw.fd), Events: unix.POLLOUT}, {Fd: closeFd, Events: unix.POLLOUT}} var err error for { _, err = unix.Poll(pollFds, -1) diff --git a/tai64n/tai64n.go b/tai64n/tai64n.go index e1a97a5..8f10b39 100644 --- a/tai64n/tai64n.go +++ b/tai64n/tai64n.go @@ -1,6 +1,6 @@ /* SPDX-License-Identifier: MIT * - * Copyright (C) 2017-2025 WireGuard LLC. All Rights Reserved. + * Copyright (C) 2017-2023 WireGuard LLC. All Rights Reserved. */ package tai64n diff --git a/tai64n/tai64n_test.go b/tai64n/tai64n_test.go index d0b4425..c70fc1a 100644 --- a/tai64n/tai64n_test.go +++ b/tai64n/tai64n_test.go @@ -1,6 +1,6 @@ /* SPDX-License-Identifier: MIT * - * Copyright (C) 2017-2025 WireGuard LLC. All Rights Reserved. + * Copyright (C) 2017-2023 WireGuard LLC. All Rights Reserved. */ package tai64n diff --git a/tun/alignment_windows_test.go b/tun/alignment_windows_test.go index e3252b2..67a785e 100644 --- a/tun/alignment_windows_test.go +++ b/tun/alignment_windows_test.go @@ -1,6 +1,6 @@ /* SPDX-License-Identifier: MIT * - * Copyright (C) 2017-2025 WireGuard LLC. All Rights Reserved. + * Copyright (C) 2017-2023 WireGuard LLC. All Rights Reserved. */ package tun diff --git a/tun/checksum.go b/tun/checksum.go index b489c56..29a8fc8 100644 --- a/tun/checksum.go +++ b/tun/checksum.go @@ -1,86 +1,102 @@ package tun -import ( - "encoding/binary" - "math/bits" -) +import "encoding/binary" // TODO: Explore SIMD and/or other assembly optimizations. +// TODO: Test native endian loads. See RFC 1071 section 2 part B. func checksumNoFold(b []byte, initial uint64) uint64 { - tmp := make([]byte, 8) - binary.NativeEndian.PutUint64(tmp, initial) - ac := binary.BigEndian.Uint64(tmp) - var carry uint64 + ac := initial for len(b) >= 128 { - ac, carry = bits.Add64(ac, binary.NativeEndian.Uint64(b[:8]), 0) - ac, carry = bits.Add64(ac, binary.NativeEndian.Uint64(b[8:16]), carry) - ac, carry = bits.Add64(ac, binary.NativeEndian.Uint64(b[16:24]), carry) - ac, carry = bits.Add64(ac, binary.NativeEndian.Uint64(b[24:32]), carry) - ac, carry = bits.Add64(ac, binary.NativeEndian.Uint64(b[32:40]), carry) - ac, carry = bits.Add64(ac, binary.NativeEndian.Uint64(b[40:48]), carry) - ac, carry = bits.Add64(ac, binary.NativeEndian.Uint64(b[48:56]), carry) - ac, carry = bits.Add64(ac, binary.NativeEndian.Uint64(b[56:64]), carry) - ac, carry = bits.Add64(ac, binary.NativeEndian.Uint64(b[64:72]), carry) - ac, carry = bits.Add64(ac, binary.NativeEndian.Uint64(b[72:80]), carry) - ac, carry = bits.Add64(ac, binary.NativeEndian.Uint64(b[80:88]), carry) - ac, carry = bits.Add64(ac, binary.NativeEndian.Uint64(b[88:96]), carry) - ac, carry = bits.Add64(ac, binary.NativeEndian.Uint64(b[96:104]), carry) - ac, carry = bits.Add64(ac, binary.NativeEndian.Uint64(b[104:112]), carry) - ac, carry = bits.Add64(ac, binary.NativeEndian.Uint64(b[112:120]), carry) - ac, carry = bits.Add64(ac, binary.NativeEndian.Uint64(b[120:128]), carry) - ac += carry + ac += uint64(binary.BigEndian.Uint32(b[:4])) + ac += uint64(binary.BigEndian.Uint32(b[4:8])) + ac += uint64(binary.BigEndian.Uint32(b[8:12])) + ac += uint64(binary.BigEndian.Uint32(b[12:16])) + ac += uint64(binary.BigEndian.Uint32(b[16:20])) + ac += uint64(binary.BigEndian.Uint32(b[20:24])) + ac += uint64(binary.BigEndian.Uint32(b[24:28])) + ac += uint64(binary.BigEndian.Uint32(b[28:32])) + ac += uint64(binary.BigEndian.Uint32(b[32:36])) + ac += uint64(binary.BigEndian.Uint32(b[36:40])) + ac += uint64(binary.BigEndian.Uint32(b[40:44])) + ac += uint64(binary.BigEndian.Uint32(b[44:48])) + ac += uint64(binary.BigEndian.Uint32(b[48:52])) + ac += uint64(binary.BigEndian.Uint32(b[52:56])) + ac += uint64(binary.BigEndian.Uint32(b[56:60])) + ac += uint64(binary.BigEndian.Uint32(b[60:64])) + ac += uint64(binary.BigEndian.Uint32(b[64:68])) + ac += uint64(binary.BigEndian.Uint32(b[68:72])) + ac += uint64(binary.BigEndian.Uint32(b[72:76])) + ac += uint64(binary.BigEndian.Uint32(b[76:80])) + ac += uint64(binary.BigEndian.Uint32(b[80:84])) + ac += uint64(binary.BigEndian.Uint32(b[84:88])) + ac += uint64(binary.BigEndian.Uint32(b[88:92])) + ac += uint64(binary.BigEndian.Uint32(b[92:96])) + ac += uint64(binary.BigEndian.Uint32(b[96:100])) + ac += uint64(binary.BigEndian.Uint32(b[100:104])) + ac += uint64(binary.BigEndian.Uint32(b[104:108])) + ac += uint64(binary.BigEndian.Uint32(b[108:112])) + ac += uint64(binary.BigEndian.Uint32(b[112:116])) + ac += uint64(binary.BigEndian.Uint32(b[116:120])) + ac += uint64(binary.BigEndian.Uint32(b[120:124])) + ac += uint64(binary.BigEndian.Uint32(b[124:128])) b = b[128:] } if len(b) >= 64 { - ac, carry = bits.Add64(ac, binary.NativeEndian.Uint64(b[:8]), 0) - ac, carry = bits.Add64(ac, binary.NativeEndian.Uint64(b[8:16]), carry) - ac, carry = bits.Add64(ac, binary.NativeEndian.Uint64(b[16:24]), carry) - ac, carry = bits.Add64(ac, binary.NativeEndian.Uint64(b[24:32]), carry) - ac, carry = bits.Add64(ac, binary.NativeEndian.Uint64(b[32:40]), carry) - ac, carry = bits.Add64(ac, binary.NativeEndian.Uint64(b[40:48]), carry) - ac, carry = bits.Add64(ac, binary.NativeEndian.Uint64(b[48:56]), carry) - ac, carry = bits.Add64(ac, binary.NativeEndian.Uint64(b[56:64]), carry) - ac += carry + ac += uint64(binary.BigEndian.Uint32(b[:4])) + ac += uint64(binary.BigEndian.Uint32(b[4:8])) + ac += uint64(binary.BigEndian.Uint32(b[8:12])) + ac += uint64(binary.BigEndian.Uint32(b[12:16])) + ac += uint64(binary.BigEndian.Uint32(b[16:20])) + ac += uint64(binary.BigEndian.Uint32(b[20:24])) + ac += uint64(binary.BigEndian.Uint32(b[24:28])) + ac += uint64(binary.BigEndian.Uint32(b[28:32])) + ac += uint64(binary.BigEndian.Uint32(b[32:36])) + ac += uint64(binary.BigEndian.Uint32(b[36:40])) + ac += uint64(binary.BigEndian.Uint32(b[40:44])) + ac += uint64(binary.BigEndian.Uint32(b[44:48])) + ac += uint64(binary.BigEndian.Uint32(b[48:52])) + ac += uint64(binary.BigEndian.Uint32(b[52:56])) + ac += uint64(binary.BigEndian.Uint32(b[56:60])) + ac += uint64(binary.BigEndian.Uint32(b[60:64])) b = b[64:] } if len(b) >= 32 { - ac, carry = bits.Add64(ac, binary.NativeEndian.Uint64(b[:8]), 0) - ac, carry = bits.Add64(ac, binary.NativeEndian.Uint64(b[8:16]), carry) - ac, carry = bits.Add64(ac, binary.NativeEndian.Uint64(b[16:24]), carry) - ac, carry = bits.Add64(ac, binary.NativeEndian.Uint64(b[24:32]), carry) - ac += carry + ac += uint64(binary.BigEndian.Uint32(b[:4])) + ac += uint64(binary.BigEndian.Uint32(b[4:8])) + ac += uint64(binary.BigEndian.Uint32(b[8:12])) + ac += uint64(binary.BigEndian.Uint32(b[12:16])) + ac += uint64(binary.BigEndian.Uint32(b[16:20])) + ac += uint64(binary.BigEndian.Uint32(b[20:24])) + ac += uint64(binary.BigEndian.Uint32(b[24:28])) + ac += uint64(binary.BigEndian.Uint32(b[28:32])) b = b[32:] } if len(b) >= 16 { - ac, carry = bits.Add64(ac, binary.NativeEndian.Uint64(b[:8]), 0) - ac, carry = bits.Add64(ac, binary.NativeEndian.Uint64(b[8:16]), carry) - ac += carry + ac += uint64(binary.BigEndian.Uint32(b[:4])) + ac += uint64(binary.BigEndian.Uint32(b[4:8])) + ac += uint64(binary.BigEndian.Uint32(b[8:12])) + ac += uint64(binary.BigEndian.Uint32(b[12:16])) b = b[16:] } if len(b) >= 8 { - ac, carry = bits.Add64(ac, binary.NativeEndian.Uint64(b[:8]), 0) - ac += carry + ac += uint64(binary.BigEndian.Uint32(b[:4])) + ac += uint64(binary.BigEndian.Uint32(b[4:8])) b = b[8:] } if len(b) >= 4 { - ac, carry = bits.Add64(ac, uint64(binary.NativeEndian.Uint32(b[:4])), 0) - ac += carry + ac += uint64(binary.BigEndian.Uint32(b)) b = b[4:] } if len(b) >= 2 { - ac, carry = bits.Add64(ac, uint64(binary.NativeEndian.Uint16(b[:2])), 0) - ac += carry + ac += uint64(binary.BigEndian.Uint16(b)) b = b[2:] } if len(b) == 1 { - tmp := binary.NativeEndian.Uint16([]byte{b[0], 0}) - ac, carry = bits.Add64(ac, uint64(tmp), 0) - ac += carry + ac += uint64(b[0]) << 8 } - binary.NativeEndian.PutUint64(tmp, ac) - return binary.BigEndian.Uint64(tmp) + return ac } func checksum(b []byte, initial uint64) uint16 { diff --git a/tun/checksum_test.go b/tun/checksum_test.go index 4ea9b8b..c1ccff5 100644 --- a/tun/checksum_test.go +++ b/tun/checksum_test.go @@ -1,74 +1,11 @@ package tun import ( - "encoding/binary" "fmt" "math/rand" "testing" - - "golang.org/x/sys/unix" ) -func checksumRef(b []byte, initial uint16) uint16 { - ac := uint64(initial) - - for len(b) >= 2 { - ac += uint64(binary.BigEndian.Uint16(b)) - b = b[2:] - } - if len(b) == 1 { - ac += uint64(b[0]) << 8 - } - - for (ac >> 16) > 0 { - ac = (ac >> 16) + (ac & 0xffff) - } - return uint16(ac) -} - -func pseudoHeaderChecksumRefNoFold(protocol uint8, srcAddr, dstAddr []byte, totalLen uint16) uint16 { - sum := checksumRef(srcAddr, 0) - sum = checksumRef(dstAddr, sum) - sum = checksumRef([]byte{0, protocol}, sum) - tmp := make([]byte, 2) - binary.BigEndian.PutUint16(tmp, totalLen) - return checksumRef(tmp, sum) -} - -func TestChecksum(t *testing.T) { - for length := 0; length <= 9001; length++ { - buf := make([]byte, length) - rng := rand.New(rand.NewSource(1)) - rng.Read(buf) - csum := checksum(buf, 0x1234) - csumRef := checksumRef(buf, 0x1234) - if csum != csumRef { - t.Error("Expected checksum", csumRef, "got", csum) - } - } -} - -func TestPseudoHeaderChecksum(t *testing.T) { - for _, addrLen := range []int{4, 16} { - for length := 0; length <= 9001; length++ { - srcAddr := make([]byte, addrLen) - dstAddr := make([]byte, addrLen) - buf := make([]byte, length) - rng := rand.New(rand.NewSource(1)) - rng.Read(srcAddr) - rng.Read(dstAddr) - rng.Read(buf) - phSum := pseudoHeaderChecksumNoFold(unix.IPPROTO_TCP, srcAddr, dstAddr, uint16(length)) - csum := checksum(buf, phSum) - phSumRef := pseudoHeaderChecksumRefNoFold(unix.IPPROTO_TCP, srcAddr, dstAddr, uint16(length)) - csumRef := checksumRef(buf, phSumRef) - if csum != csumRef { - t.Error("Expected checksumRef", csumRef, "got", csum) - } - } - } -} - func BenchmarkChecksum(b *testing.B) { lengths := []int{ 64, diff --git a/tun/netstack/examples/http_client.go b/tun/netstack/examples/http_client.go index 8b12ecc..4c4ea12 100644 --- a/tun/netstack/examples/http_client.go +++ b/tun/netstack/examples/http_client.go @@ -2,7 +2,7 @@ /* SPDX-License-Identifier: MIT * - * Copyright (C) 2017-2025 WireGuard LLC. All Rights Reserved. + * Copyright (C) 2017-2023 WireGuard LLC. All Rights Reserved. */ package main diff --git a/tun/netstack/examples/http_server.go b/tun/netstack/examples/http_server.go index 80cd036..09929e0 100644 --- a/tun/netstack/examples/http_server.go +++ b/tun/netstack/examples/http_server.go @@ -2,7 +2,7 @@ /* SPDX-License-Identifier: MIT * - * Copyright (C) 2017-2025 WireGuard LLC. All Rights Reserved. + * Copyright (C) 2017-2023 WireGuard LLC. All Rights Reserved. */ package main diff --git a/tun/netstack/examples/ping_client.go b/tun/netstack/examples/ping_client.go index b243b5c..d7897b2 100644 --- a/tun/netstack/examples/ping_client.go +++ b/tun/netstack/examples/ping_client.go @@ -2,7 +2,7 @@ /* SPDX-License-Identifier: MIT * - * Copyright (C) 2017-2025 WireGuard LLC. All Rights Reserved. + * Copyright (C) 2017-2023 WireGuard LLC. All Rights Reserved. */ package main diff --git a/tun/netstack/tun.go b/tun/netstack/tun.go index 48a428b..2275173 100644 --- a/tun/netstack/tun.go +++ b/tun/netstack/tun.go @@ -1,6 +1,6 @@ /* SPDX-License-Identifier: MIT * - * Copyright (C) 2017-2025 WireGuard LLC. All Rights Reserved. + * Copyright (C) 2017-2023 WireGuard LLC. All Rights Reserved. */ package netstack @@ -43,7 +43,6 @@ type netTun struct { ep *channel.Endpoint stack *stack.Stack events chan tun.Event - notifyHandle *channel.NotificationHandle incomingPacket chan *buffer.View mtu int dnsServers []netip.Addr @@ -71,7 +70,7 @@ func CreateNetTUN(localAddresses, dnsServers []netip.Addr, mtu int) (tun.Device, if tcpipErr != nil { return nil, nil, fmt.Errorf("could not enable TCP SACK: %v", tcpipErr) } - dev.notifyHandle = dev.ep.AddNotify(dev) + dev.ep.AddNotify(dev) tcpipErr = dev.stack.CreateNIC(1, dev.ep) if tcpipErr != nil { return nil, nil, fmt.Errorf("CreateNIC: %v", tcpipErr) @@ -156,7 +155,7 @@ func (tun *netTun) Write(buf [][]byte, offset int) (int, error) { func (tun *netTun) WriteNotify() { pkt := tun.ep.Read() - if pkt == nil { + if pkt.IsNil() { return } @@ -168,14 +167,13 @@ func (tun *netTun) WriteNotify() { func (tun *netTun) Close() error { tun.stack.RemoveNIC(1) - tun.stack.Close() - tun.ep.RemoveNotify(tun.notifyHandle) - tun.ep.Close() if tun.events != nil { close(tun.events) } + tun.ep.Close() + if tun.incomingPacket != nil { close(tun.incomingPacket) } diff --git a/tun/offload_linux.go b/tun/offload_linux.go index b61654b..89cf024 100644 --- a/tun/offload_linux.go +++ b/tun/offload_linux.go @@ -1,6 +1,6 @@ /* SPDX-License-Identifier: MIT * - * Copyright (C) 2017-2025 WireGuard LLC. All Rights Reserved. + * Copyright (C) 2017-2023 WireGuard LLC. All Rights Reserved. */ package tun diff --git a/tun/offload_linux_test.go b/tun/offload_linux_test.go index c04e003..a68cd98 100644 --- a/tun/offload_linux_test.go +++ b/tun/offload_linux_test.go @@ -1,6 +1,6 @@ /* SPDX-License-Identifier: MIT * - * Copyright (C) 2017-2025 WireGuard LLC. All Rights Reserved. + * Copyright (C) 2017-2023 WireGuard LLC. All Rights Reserved. */ package tun diff --git a/tun/operateonfd.go b/tun/operateonfd.go index 343f754..f1beb6d 100644 --- a/tun/operateonfd.go +++ b/tun/operateonfd.go @@ -2,7 +2,7 @@ /* SPDX-License-Identifier: MIT * - * Copyright (C) 2017-2025 WireGuard LLC. All Rights Reserved. + * Copyright (C) 2017-2023 WireGuard LLC. All Rights Reserved. */ package tun diff --git a/tun/tun.go b/tun/tun.go index 336d642..0ae53d0 100644 --- a/tun/tun.go +++ b/tun/tun.go @@ -1,6 +1,6 @@ /* SPDX-License-Identifier: MIT * - * Copyright (C) 2017-2025 WireGuard LLC. All Rights Reserved. + * Copyright (C) 2017-2023 WireGuard LLC. All Rights Reserved. */ package tun diff --git a/tun/tun_darwin.go b/tun/tun_darwin.go index 341afe3..c9a6c0b 100644 --- a/tun/tun_darwin.go +++ b/tun/tun_darwin.go @@ -1,17 +1,19 @@ /* SPDX-License-Identifier: MIT * - * Copyright (C) 2017-2025 WireGuard LLC. All Rights Reserved. + * Copyright (C) 2017-2023 WireGuard LLC. All Rights Reserved. */ package tun import ( + "errors" "fmt" "io" "net" "os" "sync" "syscall" + "time" "unsafe" "golang.org/x/sys/unix" @@ -28,6 +30,18 @@ type NativeTun struct { closeOnce sync.Once } +func retryInterfaceByIndex(index int) (iface *net.Interface, err error) { + for i := 0; i < 20; i++ { + iface, err = net.InterfaceByIndex(index) + if err != nil && errors.Is(err, unix.ENOMEM) { + time.Sleep(time.Duration(i) * time.Second / 3) + continue + } + return iface, err + } + return nil, err +} + func (tun *NativeTun) routineRouteListener(tunIfindex int) { var ( statusUp bool @@ -48,22 +62,26 @@ func (tun *NativeTun) routineRouteListener(tunIfindex int) { return } - if n < 28 { + if n < 14 { continue } - if data[3 /* ifm_type */] != unix.RTM_IFINFO { + if data[3 /* type */] != unix.RTM_IFINFO { continue } - ifindex := int(*(*uint16)(unsafe.Pointer(&data[12 /* ifm_index */]))) + ifindex := int(*(*uint16)(unsafe.Pointer(&data[12 /* ifindex */]))) if ifindex != tunIfindex { continue } - flags := int(*(*uint32)(unsafe.Pointer(&data[8 /* ifm_flags */]))) + iface, err := retryInterfaceByIndex(ifindex) + if err != nil { + tun.errors <- err + return + } // Up / Down event - up := (flags & syscall.IFF_UP) != 0 + up := (iface.Flags & net.FlagUp) != 0 if up != statusUp && up { tun.events <- EventUp } @@ -72,13 +90,11 @@ func (tun *NativeTun) routineRouteListener(tunIfindex int) { } statusUp = up - mtu := int(*(*uint32)(unsafe.Pointer(&data[24 /* ifm_data.ifi_mtu */]))) - // MTU changes - if mtu != statusMTU { + if iface.MTU != statusMTU { tun.events <- EventMTUUpdate } - statusMTU = mtu + statusMTU = iface.MTU } } diff --git a/tun/tun_freebsd.go b/tun/tun_freebsd.go index 4adf3a1..7c65fd9 100644 --- a/tun/tun_freebsd.go +++ b/tun/tun_freebsd.go @@ -1,6 +1,6 @@ /* SPDX-License-Identifier: MIT * - * Copyright (C) 2017-2025 WireGuard LLC. All Rights Reserved. + * Copyright (C) 2017-2023 WireGuard LLC. All Rights Reserved. */ package tun diff --git a/tun/tun_linux.go b/tun/tun_linux.go index bc6e7c1..011e56a 100644 --- a/tun/tun_linux.go +++ b/tun/tun_linux.go @@ -1,6 +1,6 @@ /* SPDX-License-Identifier: MIT * - * Copyright (C) 2017-2025 WireGuard LLC. All Rights Reserved. + * Copyright (C) 2017-2023 WireGuard LLC. All Rights Reserved. */ package tun diff --git a/tun/tun_openbsd.go b/tun/tun_openbsd.go index 5aa9070..ae571b9 100644 --- a/tun/tun_openbsd.go +++ b/tun/tun_openbsd.go @@ -1,6 +1,6 @@ /* SPDX-License-Identifier: MIT * - * Copyright (C) 2017-2025 WireGuard LLC. All Rights Reserved. + * Copyright (C) 2017-2023 WireGuard LLC. All Rights Reserved. */ package tun diff --git a/tun/tun_windows.go b/tun/tun_windows.go index de65fb4..2af8e3e 100644 --- a/tun/tun_windows.go +++ b/tun/tun_windows.go @@ -1,6 +1,6 @@ /* SPDX-License-Identifier: MIT * - * Copyright (C) 2017-2025 WireGuard LLC. All Rights Reserved. + * Copyright (C) 2017-2023 WireGuard LLC. All Rights Reserved. */ package tun diff --git a/tun/tuntest/tuntest.go b/tun/tuntest/tuntest.go index 0fa70b0..f620e0a 100644 --- a/tun/tuntest/tuntest.go +++ b/tun/tuntest/tuntest.go @@ -1,6 +1,6 @@ /* SPDX-License-Identifier: MIT * - * Copyright (C) 2017-2025 WireGuard LLC. All Rights Reserved. + * Copyright (C) 2017-2023 WireGuard LLC. All Rights Reserved. */ package tuntest diff --git a/version.go b/version.go index d5524e8..db75bb9 100644 --- a/version.go +++ b/version.go @@ -1,3 +1,3 @@ package main -const Version = "0.0.20250522" +const Version = "0.0.20230223"