all: adjust build tags for plan9

Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
This commit is contained in:
Brad Fitzpatrick 2023-08-24 14:39:23 -07:00 committed by James Tucker
parent 88b11b4a0d
commit 6cd5922a04
No known key found for this signature in database
6 changed files with 26 additions and 5 deletions

View file

@ -136,6 +136,11 @@ func listenNet(network string, port int) (*net.UDPConn, int, error) {
return conn.(*net.UDPConn), uaddr.Port, nil
}
// errEADDRINUSE is syscall.EADDRINUSE, boxed into an interface once
// in erraddrinuse.go on almost all platforms. For other platforms,
// it's at least non-nil.
var errEADDRINUSE error = errors.New("")
func (s *StdNetBind) Open(uport uint16) ([]ReceiveFunc, uint16, error) {
s.mu.Lock()
defer s.mu.Unlock()
@ -162,7 +167,7 @@ again:
// Listen on the same port as we're using for ipv4.
v6conn, port, err = listenNet("udp6", port)
if uport == 0 && errors.Is(err, syscall.EADDRINUSE) && tries < 100 {
if uport == 0 && errors.Is(err, errEADDRINUSE) && tries < 100 {
v4conn.Close()
tries++
goto again

View file

@ -1,4 +1,4 @@
//go:build !windows && !linux && !wasm
//go:build !windows && !linux && !wasm && !plan9
/* SPDX-License-Identifier: MIT
*

14
conn/erraddrinuse.go Normal file
View file

@ -0,0 +1,14 @@
//go:build !plan9
/* SPDX-License-Identifier: MIT
*
* Copyright (C) 2017-2023 WireGuard LLC. All Rights Reserved.
*/
package conn
import "syscall"
func init() {
errEADDRINUSE = syscall.EADDRINUSE
}