Skip to content

Commit 06f1482

Browse files
committed
device: allow compiling with Go 1.15
Until we depend on Go 1.16 (which isn't released yet), alias our own variable to the private member of the net package. This will allow an easy find replace to make this go away when we eventually switch to 1.16. Signed-off-by: Jason A. Donenfeld <[email protected]>
1 parent 86a58b5 commit 06f1482

File tree

4 files changed

+19
-6
lines changed

4 files changed

+19
-6
lines changed

conn/conn_linux.go

+4-4
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ func (bind *nativeBind) ReceiveIPv6(buff []byte) (int, Endpoint, error) {
204204

205205
var end NativeEndpoint
206206
if bind.sock6 == -1 {
207-
return 0, nil, net.ErrClosed
207+
return 0, nil, NetErrClosed
208208
}
209209
n, err := receive6(
210210
bind.sock6,
@@ -220,7 +220,7 @@ func (bind *nativeBind) ReceiveIPv4(buff []byte) (int, Endpoint, error) {
220220

221221
var end NativeEndpoint
222222
if bind.sock4 == -1 {
223-
return 0, nil, net.ErrClosed
223+
return 0, nil, NetErrClosed
224224
}
225225
n, err := receive4(
226226
bind.sock4,
@@ -237,12 +237,12 @@ func (bind *nativeBind) Send(buff []byte, end Endpoint) error {
237237
nend := end.(*NativeEndpoint)
238238
if !nend.isV6 {
239239
if bind.sock4 == -1 {
240-
return net.ErrClosed
240+
return NetErrClosed
241241
}
242242
return send4(bind.sock4, nend, buff)
243243
} else {
244244
if bind.sock6 == -1 {
245-
return net.ErrClosed
245+
return NetErrClosed
246246
}
247247
return send6(bind.sock6, nend, buff)
248248
}

conn/net_err_closed.go

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
/* SPDX-License-Identifier: MIT
2+
*
3+
* Copyright (C) 2021 WireGuard LLC. All Rights Reserved.
4+
*/
5+
6+
package conn
7+
8+
import _ "unsafe"
9+
10+
//TODO: replace this with net.ErrClosed for Go 1.16
11+
12+
//go:linkname net.errClosed
13+
var NetErrClosed error

device/receive.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ func (device *Device) RoutineReceiveIncoming(IP int, bind conn.Bind) {
112112

113113
if err != nil {
114114
device.PutMessageBuffer(buffer)
115-
if errors.Is(err, net.ErrClosed) {
115+
if errors.Is(err, conn.NetErrClosed) {
116116
return
117117
}
118118
device.log.Error.Printf("Failed to receive packet: %v", err)

go.mod

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
module golang.zx2c4.com/wireguard
22

3-
go 1.16
3+
go 1.15
44

55
require (
66
golang.org/x/crypto v0.0.0-20201221181555-eec23a3978ad

0 commit comments

Comments
 (0)