util/endian: delete package; use updated josharian/native instead

See josharian/native#3

Updates golang/go#57237

Change-Id: I238c04c6654e5b9e7d9cfb81a7bbc5e1043a84a2
Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
pull/6719/head
Brad Fitzpatrick 2 years ago committed by Brad Fitzpatrick
parent bd2995c14b
commit ca08e316af

@ -11,7 +11,7 @@ tailscale.com/cmd/derper dependencies: (generated by github.com/tailscale/depawa
github.com/fxamacker/cbor/v2 from tailscale.com/tka github.com/fxamacker/cbor/v2 from tailscale.com/tka
github.com/golang/groupcache/lru from tailscale.com/net/dnscache github.com/golang/groupcache/lru from tailscale.com/net/dnscache
github.com/hdevalence/ed25519consensus from tailscale.com/tka github.com/hdevalence/ed25519consensus from tailscale.com/tka
L github.com/josharian/native from github.com/mdlayher/netlink+ LW github.com/josharian/native from github.com/mdlayher/netlink+
L 💣 github.com/jsimonetti/rtnetlink from tailscale.com/net/interfaces L 💣 github.com/jsimonetti/rtnetlink from tailscale.com/net/interfaces
L github.com/jsimonetti/rtnetlink/internal/unix from github.com/jsimonetti/rtnetlink L github.com/jsimonetti/rtnetlink/internal/unix from github.com/jsimonetti/rtnetlink
github.com/klauspost/compress/flate from nhooyr.io/websocket github.com/klauspost/compress/flate from nhooyr.io/websocket
@ -78,7 +78,6 @@ tailscale.com/cmd/derper dependencies: (generated by github.com/tailscale/depawa
W tailscale.com/util/cmpver from tailscale.com/net/tshttpproxy W tailscale.com/util/cmpver from tailscale.com/net/tshttpproxy
L 💣 tailscale.com/util/dirwalk from tailscale.com/metrics L 💣 tailscale.com/util/dirwalk from tailscale.com/metrics
tailscale.com/util/dnsname from tailscale.com/hostinfo+ tailscale.com/util/dnsname from tailscale.com/hostinfo+
W tailscale.com/util/endian from tailscale.com/net/netns
tailscale.com/util/lineread from tailscale.com/hostinfo+ tailscale.com/util/lineread from tailscale.com/hostinfo+
tailscale.com/util/mak from tailscale.com/syncs tailscale.com/util/mak from tailscale.com/syncs
tailscale.com/util/singleflight from tailscale.com/net/dnscache tailscale.com/util/singleflight from tailscale.com/net/dnscache

@ -12,7 +12,7 @@ tailscale.com/cmd/tailscale dependencies: (generated by github.com/tailscale/dep
github.com/golang/groupcache/lru from tailscale.com/net/dnscache github.com/golang/groupcache/lru from tailscale.com/net/dnscache
D github.com/google/uuid from tailscale.com/util/quarantine D github.com/google/uuid from tailscale.com/util/quarantine
github.com/hdevalence/ed25519consensus from tailscale.com/tka github.com/hdevalence/ed25519consensus from tailscale.com/tka
L github.com/josharian/native from github.com/mdlayher/netlink+ LW github.com/josharian/native from github.com/mdlayher/netlink+
L 💣 github.com/jsimonetti/rtnetlink from tailscale.com/net/interfaces L 💣 github.com/jsimonetti/rtnetlink from tailscale.com/net/interfaces
L github.com/jsimonetti/rtnetlink/internal/unix from github.com/jsimonetti/rtnetlink L github.com/jsimonetti/rtnetlink/internal/unix from github.com/jsimonetti/rtnetlink
github.com/kballard/go-shellquote from tailscale.com/cmd/tailscale/cli github.com/kballard/go-shellquote from tailscale.com/cmd/tailscale/cli
@ -107,7 +107,6 @@ tailscale.com/cmd/tailscale dependencies: (generated by github.com/tailscale/dep
W tailscale.com/util/cmpver from tailscale.com/net/tshttpproxy W tailscale.com/util/cmpver from tailscale.com/net/tshttpproxy
L 💣 tailscale.com/util/dirwalk from tailscale.com/metrics L 💣 tailscale.com/util/dirwalk from tailscale.com/metrics
tailscale.com/util/dnsname from tailscale.com/cmd/tailscale/cli+ tailscale.com/util/dnsname from tailscale.com/cmd/tailscale/cli+
W tailscale.com/util/endian from tailscale.com/net/netns
tailscale.com/util/groupmember from tailscale.com/cmd/tailscale/cli tailscale.com/util/groupmember from tailscale.com/cmd/tailscale/cli
tailscale.com/util/lineread from tailscale.com/net/interfaces+ tailscale.com/util/lineread from tailscale.com/net/interfaces+
tailscale.com/util/mak from tailscale.com/net/netcheck+ tailscale.com/util/mak from tailscale.com/net/netcheck+

@ -82,7 +82,7 @@ tailscale.com/cmd/tailscaled dependencies: (generated by github.com/tailscale/de
L github.com/insomniacslk/dhcp/interfaces from github.com/insomniacslk/dhcp/dhcpv4 L github.com/insomniacslk/dhcp/interfaces from github.com/insomniacslk/dhcp/dhcpv4
L github.com/insomniacslk/dhcp/rfc1035label from github.com/insomniacslk/dhcp/dhcpv4 L github.com/insomniacslk/dhcp/rfc1035label from github.com/insomniacslk/dhcp/dhcpv4
L github.com/jmespath/go-jmespath from github.com/aws/aws-sdk-go-v2/service/ssm L github.com/jmespath/go-jmespath from github.com/aws/aws-sdk-go-v2/service/ssm
L github.com/josharian/native from github.com/mdlayher/netlink+ LW github.com/josharian/native from github.com/mdlayher/netlink+
L 💣 github.com/jsimonetti/rtnetlink from tailscale.com/net/interfaces+ L 💣 github.com/jsimonetti/rtnetlink from tailscale.com/net/interfaces+
L github.com/jsimonetti/rtnetlink/internal/unix from github.com/jsimonetti/rtnetlink L github.com/jsimonetti/rtnetlink/internal/unix from github.com/jsimonetti/rtnetlink
github.com/klauspost/compress from github.com/klauspost/compress/zstd github.com/klauspost/compress from github.com/klauspost/compress/zstd
@ -288,7 +288,6 @@ tailscale.com/cmd/tailscaled dependencies: (generated by github.com/tailscale/de
💣 tailscale.com/util/deephash from tailscale.com/ipn/ipnlocal+ 💣 tailscale.com/util/deephash from tailscale.com/ipn/ipnlocal+
L 💣 tailscale.com/util/dirwalk from tailscale.com/metrics+ L 💣 tailscale.com/util/dirwalk from tailscale.com/metrics+
tailscale.com/util/dnsname from tailscale.com/hostinfo+ tailscale.com/util/dnsname from tailscale.com/hostinfo+
LW tailscale.com/util/endian from tailscale.com/net/dns+
tailscale.com/util/goroutines from tailscale.com/control/controlclient+ tailscale.com/util/goroutines from tailscale.com/control/controlclient+
tailscale.com/util/groupmember from tailscale.com/ipn/ipnauth tailscale.com/util/groupmember from tailscale.com/ipn/ipnauth
💣 tailscale.com/util/hashx from tailscale.com/util/deephash 💣 tailscale.com/util/hashx from tailscale.com/util/deephash

@ -34,6 +34,7 @@ require (
github.com/iancoleman/strcase v0.2.0 github.com/iancoleman/strcase v0.2.0
github.com/illarion/gonotify v1.0.1 github.com/illarion/gonotify v1.0.1
github.com/insomniacslk/dhcp v0.0.0-20211209223715-7d93572ebe8e github.com/insomniacslk/dhcp v0.0.0-20211209223715-7d93572ebe8e
github.com/josharian/native v1.0.1-0.20221213033349-c1e37c09b531
github.com/jsimonetti/rtnetlink v1.1.2-0.20220408201609-d380b505068b github.com/jsimonetti/rtnetlink v1.1.2-0.20220408201609-d380b505068b
github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51 github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51
github.com/klauspost/compress v1.15.4 github.com/klauspost/compress v1.15.4
@ -203,7 +204,6 @@ require (
github.com/jirfag/go-printf-func-name v0.0.0-20200119135958-7558a9eaa5af // indirect github.com/jirfag/go-printf-func-name v0.0.0-20200119135958-7558a9eaa5af // indirect
github.com/jmespath/go-jmespath v0.4.0 // indirect github.com/jmespath/go-jmespath v0.4.0 // indirect
github.com/josharian/intern v1.0.0 // indirect github.com/josharian/intern v1.0.0 // indirect
github.com/josharian/native v1.0.1-0.20220222152702-a938fb150d47 // indirect
github.com/json-iterator/go v1.1.12 // indirect github.com/json-iterator/go v1.1.12 // indirect
github.com/julz/importas v0.0.0-20210922140945-27e0a5d4dee2 // indirect github.com/julz/importas v0.0.0-20210922140945-27e0a5d4dee2 // indirect
github.com/kevinburke/ssh_config v1.1.0 // indirect github.com/kevinburke/ssh_config v1.1.0 // indirect

@ -688,8 +688,8 @@ github.com/jonboulle/clockwork v0.2.0/go.mod h1:Pkfl5aHPm1nk2H9h0bjmnJD/BcgbGXUB
github.com/josharian/intern v1.0.0 h1:vlS4z54oSdjm0bgjRigI+G1HpF+tI+9rE5LLzOg8HmY= github.com/josharian/intern v1.0.0 h1:vlS4z54oSdjm0bgjRigI+G1HpF+tI+9rE5LLzOg8HmY=
github.com/josharian/intern v1.0.0/go.mod h1:5DoeVV0s6jJacbCEi61lwdGj/aVlrQvzHFFd8Hwg//Y= github.com/josharian/intern v1.0.0/go.mod h1:5DoeVV0s6jJacbCEi61lwdGj/aVlrQvzHFFd8Hwg//Y=
github.com/josharian/native v1.0.0/go.mod h1:7X/raswPFr05uY3HiLlYeyQntB6OO7E/d2Cu7qoaN2w= github.com/josharian/native v1.0.0/go.mod h1:7X/raswPFr05uY3HiLlYeyQntB6OO7E/d2Cu7qoaN2w=
github.com/josharian/native v1.0.1-0.20220222152702-a938fb150d47 h1:pjoS5mbQDjErivWYVYrsy5SRSgTOPAcCNc1oYE3by6M= github.com/josharian/native v1.0.1-0.20221213033349-c1e37c09b531 h1:3HNVAxEgGca1i23Ai/8DeCmibx02jBvTHAT11INaVfU=
github.com/josharian/native v1.0.1-0.20220222152702-a938fb150d47/go.mod h1:7X/raswPFr05uY3HiLlYeyQntB6OO7E/d2Cu7qoaN2w= github.com/josharian/native v1.0.1-0.20221213033349-c1e37c09b531/go.mod h1:7X/raswPFr05uY3HiLlYeyQntB6OO7E/d2Cu7qoaN2w=
github.com/josharian/txtarfs v0.0.0-20210218200122-0702f000015a/go.mod h1:izVPOvVRsHiKkeGCT6tYBNWyDVuzj9wAaBb5R9qamfw= github.com/josharian/txtarfs v0.0.0-20210218200122-0702f000015a/go.mod h1:izVPOvVRsHiKkeGCT6tYBNWyDVuzj9wAaBb5R9qamfw=
github.com/jpillora/backoff v1.0.0/go.mod h1:J/6gKK9jxlEcS3zixgDgUAsiuZ7yrSoa/FX5e0EB2j4= github.com/jpillora/backoff v1.0.0/go.mod h1:J/6gKK9jxlEcS3zixgDgUAsiuZ7yrSoa/FX5e0EB2j4=
github.com/jsimonetti/rtnetlink v0.0.0-20190606172950-9527aa82566a/go.mod h1:Oz+70psSo5OFh8DBl0Zv2ACw7Esh6pPUphlvZG9x7uw= github.com/jsimonetti/rtnetlink v0.0.0-20190606172950-9527aa82566a/go.mod h1:Oz+70psSo5OFh8DBl0Zv2ACw7Esh6pPUphlvZG9x7uw=

@ -14,9 +14,9 @@ import (
"time" "time"
"github.com/godbus/dbus/v5" "github.com/godbus/dbus/v5"
"github.com/josharian/native"
"tailscale.com/net/interfaces" "tailscale.com/net/interfaces"
"tailscale.com/util/dnsname" "tailscale.com/util/dnsname"
"tailscale.com/util/endian"
) )
const ( const (
@ -130,7 +130,7 @@ func (m *nmManager) trySet(ctx context.Context, config OSConfig) error {
for _, ip := range config.Nameservers { for _, ip := range config.Nameservers {
b := ip.As16() b := ip.As16()
if ip.Is4() { if ip.Is4() {
dnsv4 = append(dnsv4, endian.Native.Uint32(b[12:])) dnsv4 = append(dnsv4, native.Endian.Uint32(b[12:]))
} else { } else {
dnsv6 = append(dnsv6, b[:]) dnsv6 = append(dnsv6, b[:])
} }

@ -9,11 +9,11 @@ import (
"strings" "strings"
"syscall" "syscall"
"github.com/josharian/native"
"golang.org/x/sys/windows" "golang.org/x/sys/windows"
"golang.zx2c4.com/wireguard/windows/tunnel/winipcfg" "golang.zx2c4.com/wireguard/windows/tunnel/winipcfg"
"tailscale.com/net/interfaces" "tailscale.com/net/interfaces"
"tailscale.com/types/logger" "tailscale.com/types/logger"
"tailscale.com/util/endian"
) )
func interfaceIndex(iface *winipcfg.IPAdapterAddresses) uint32 { func interfaceIndex(iface *winipcfg.IPAdapterAddresses) uint32 {
@ -119,7 +119,7 @@ func bindSocket6(c syscall.RawConn, ifidx uint32) error {
// representation, suitable for passing to Windows APIs that require a // representation, suitable for passing to Windows APIs that require a
// mangled uint32. // mangled uint32.
func nativeToBigEndian(i uint32) uint32 { func nativeToBigEndian(i uint32) uint32 {
if endian.Big { if native.IsBigEndian {
return i return i
} }
return bits.ReverseBytes32(i) return bits.ReverseBytes32(i)

@ -13,9 +13,9 @@ import (
"syscall" "syscall"
"unsafe" "unsafe"
"github.com/josharian/native"
"golang.org/x/sys/windows" "golang.org/x/sys/windows"
"tailscale.com/net/netaddr" "tailscale.com/net/netaddr"
"tailscale.com/util/endian"
) )
// See https://docs.microsoft.com/en-us/windows/win32/api/iphlpapi/nf-iphlpapi-getextendedtcptable // See https://docs.microsoft.com/en-us/windows/win32/api/iphlpapi/nf-iphlpapi-getextendedtcptable
@ -94,7 +94,7 @@ func (t *Table) addEntries(fam int) error {
} }
buf = buf[:size] buf = buf[:size]
numEntries := endian.Native.Uint32(buf[:4]) numEntries := native.Endian.Uint32(buf[:4])
buf = buf[4:] buf = buf[4:]
var recSize int var recSize int
@ -155,7 +155,7 @@ func state(v uint32) string {
} }
func ipport4(addr uint32, port uint16) netip.AddrPort { func ipport4(addr uint32, port uint16) netip.AddrPort {
if !endian.Big { if !native.IsBigEndian {
addr = bits.ReverseBytes32(addr) addr = bits.ReverseBytes32(addr)
} }
return netip.AddrPortFrom( return netip.AddrPortFrom(
@ -173,7 +173,7 @@ func ipport6(addr [16]byte, scope uint32, port uint16) netip.AddrPort {
} }
func port(v *uint32) uint16 { func port(v *uint32) uint16 {
if !endian.Big { if !native.IsBigEndian {
return uint16(bits.ReverseBytes32(*v) >> 16) return uint16(bits.ReverseBytes32(*v) >> 16)
} }
return uint16(*v >> 16) return uint16(*v >> 16)

@ -10,7 +10,7 @@ import (
"errors" "errors"
"io" "io"
"tailscale.com/util/endian" "github.com/josharian/native"
) )
// Size of a pointer-typed value, in bits // Size of a pointer-typed value, in bits
@ -121,7 +121,7 @@ func (d *Decoder) Uint16() uint16 {
d.err = err d.err = err
return 0 return 0
} }
return endian.Native.Uint16(d.dbuf[0:2]) return native.Endian.Uint16(d.dbuf[0:2])
} }
// Uint32 returns a uint32 decoded from the buffer. // Uint32 returns a uint32 decoded from the buffer.
@ -134,7 +134,7 @@ func (d *Decoder) Uint32() uint32 {
d.err = err d.err = err
return 0 return 0
} }
return endian.Native.Uint32(d.dbuf[0:4]) return native.Endian.Uint32(d.dbuf[0:4])
} }
// Uint64 returns a uint64 decoded from the buffer. // Uint64 returns a uint64 decoded from the buffer.
@ -147,7 +147,7 @@ func (d *Decoder) Uint64() uint64 {
d.err = err d.err = err
return 0 return 0
} }
return endian.Native.Uint64(d.dbuf[0:8]) return native.Endian.Uint64(d.dbuf[0:8])
} }
// Uintptr returns a uintptr decoded from the buffer. // Uintptr returns a uintptr decoded from the buffer.

@ -1,15 +0,0 @@
// Copyright (c) 2020 Tailscale Inc & AUTHORS All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
//go:build mips || mips64 || ppc64 || s390x
package endian
import "encoding/binary"
// Big is whether the current platform is big endian.
const Big = true
// Native is the platform's native byte order.
var Native = binary.BigEndian

@ -1,6 +0,0 @@
// Copyright (c) 2020 Tailscale Inc & AUTHORS All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
// Package endian exports a constant about whether the machine is big endian.
package endian

@ -1,15 +0,0 @@
// Copyright (c) 2020 Tailscale Inc & AUTHORS All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
//go:build 386 || amd64 || arm || arm64 || mips64le || mipsle || ppc64le || riscv64 || wasm || loong64
package endian
import "encoding/binary"
// Big is whether the current platform is big endian.
const Big = false
// Native is the platform's native byte order.
var Native = binary.LittleEndian
Loading…
Cancel
Save