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 <Jason@zx2c4.com>
This commit is contained in:
parent
86a58b51c0
commit
294d3bedf9
@ -204,7 +204,7 @@ func (bind *nativeBind) ReceiveIPv6(buff []byte) (int, Endpoint, error) {
|
|||||||
|
|
||||||
var end NativeEndpoint
|
var end NativeEndpoint
|
||||||
if bind.sock6 == -1 {
|
if bind.sock6 == -1 {
|
||||||
return 0, nil, net.ErrClosed
|
return 0, nil, NetErrClosed
|
||||||
}
|
}
|
||||||
n, err := receive6(
|
n, err := receive6(
|
||||||
bind.sock6,
|
bind.sock6,
|
||||||
@ -220,7 +220,7 @@ func (bind *nativeBind) ReceiveIPv4(buff []byte) (int, Endpoint, error) {
|
|||||||
|
|
||||||
var end NativeEndpoint
|
var end NativeEndpoint
|
||||||
if bind.sock4 == -1 {
|
if bind.sock4 == -1 {
|
||||||
return 0, nil, net.ErrClosed
|
return 0, nil, NetErrClosed
|
||||||
}
|
}
|
||||||
n, err := receive4(
|
n, err := receive4(
|
||||||
bind.sock4,
|
bind.sock4,
|
||||||
@ -237,12 +237,12 @@ func (bind *nativeBind) Send(buff []byte, end Endpoint) error {
|
|||||||
nend := end.(*NativeEndpoint)
|
nend := end.(*NativeEndpoint)
|
||||||
if !nend.isV6 {
|
if !nend.isV6 {
|
||||||
if bind.sock4 == -1 {
|
if bind.sock4 == -1 {
|
||||||
return net.ErrClosed
|
return NetErrClosed
|
||||||
}
|
}
|
||||||
return send4(bind.sock4, nend, buff)
|
return send4(bind.sock4, nend, buff)
|
||||||
} else {
|
} else {
|
||||||
if bind.sock6 == -1 {
|
if bind.sock6 == -1 {
|
||||||
return net.ErrClosed
|
return NetErrClosed
|
||||||
}
|
}
|
||||||
return send6(bind.sock6, nend, buff)
|
return send6(bind.sock6, nend, buff)
|
||||||
}
|
}
|
||||||
|
13
conn/net_err_closed.go
Normal file
13
conn/net_err_closed.go
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
/* SPDX-License-Identifier: MIT
|
||||||
|
*
|
||||||
|
* Copyright (C) 2021 WireGuard LLC. All Rights Reserved.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package conn
|
||||||
|
|
||||||
|
import _ "unsafe"
|
||||||
|
|
||||||
|
//TODO: replace this with net.ErrClosed for Go 1.16
|
||||||
|
|
||||||
|
//go:linkname NetErrClosed internal/poll.ErrNetClosing
|
||||||
|
var NetErrClosed error
|
@ -112,7 +112,7 @@ func (device *Device) RoutineReceiveIncoming(IP int, bind conn.Bind) {
|
|||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
device.PutMessageBuffer(buffer)
|
device.PutMessageBuffer(buffer)
|
||||||
if errors.Is(err, net.ErrClosed) {
|
if errors.Is(err, conn.NetErrClosed) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
device.log.Error.Printf("Failed to receive packet: %v", err)
|
device.log.Error.Printf("Failed to receive packet: %v", err)
|
||||||
|
Loading…
Reference in New Issue
Block a user