mirror of
https://github.com/tailscale/tailscale.git
synced 2025-08-14 23:17:29 +00:00
go.mod, wgengine/wgint: bump wireguard-go
For b51010ba13
Change-Id: Ibf767dfad98aef7e9f0505d91c0d26f924e046d5
Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
This commit is contained in:

committed by
Brad Fitzpatrick

parent
f52a659076
commit
56f6fe204b
@@ -22,38 +22,28 @@ var (
|
||||
|
||||
func getPeerStatsOffset(name string) uintptr {
|
||||
peerType := reflect.TypeOf(device.Peer{})
|
||||
sf, ok := peerType.FieldByName("stats")
|
||||
field, ok := peerType.FieldByName(name)
|
||||
if !ok {
|
||||
panic("no stats field in device.Peer")
|
||||
panic("no " + name + " field in device.Peer")
|
||||
}
|
||||
if sf.Type.Kind() != reflect.Struct {
|
||||
panic("stats field is not a struct")
|
||||
if s := field.Type.String(); s != "atomic.Int64" && s != "atomic.Uint64" {
|
||||
panic("unexpected type " + s + " of field " + name + " in device.Peer")
|
||||
}
|
||||
base := sf.Offset
|
||||
|
||||
st := sf.Type
|
||||
field, ok := st.FieldByName(name)
|
||||
if !ok {
|
||||
panic("no " + name + " field in device.Peer.stats")
|
||||
}
|
||||
if field.Type.Kind() != reflect.Int64 && field.Type.Kind() != reflect.Uint64 {
|
||||
panic("unexpected kind of " + name + " field in device.Peer.stats")
|
||||
}
|
||||
return base + field.Offset
|
||||
return field.Offset
|
||||
}
|
||||
|
||||
// PeerLastHandshakeNano returns the last handshake time in nanoseconds since the
|
||||
// unix epoch.
|
||||
func PeerLastHandshakeNano(peer *device.Peer) int64 {
|
||||
return atomic.LoadInt64((*int64)(unsafe.Add(unsafe.Pointer(peer), offHandshake)))
|
||||
return (*atomic.Int64)(unsafe.Add(unsafe.Pointer(peer), offHandshake)).Load()
|
||||
}
|
||||
|
||||
// PeerRxBytes returns the number of bytes received from this peer.
|
||||
func PeerRxBytes(peer *device.Peer) uint64 {
|
||||
return atomic.LoadUint64((*uint64)(unsafe.Add(unsafe.Pointer(peer), offRxBytes)))
|
||||
return (*atomic.Uint64)(unsafe.Add(unsafe.Pointer(peer), offRxBytes)).Load()
|
||||
}
|
||||
|
||||
// PeerTxBytes returns the number of bytes sent to this peer.
|
||||
func PeerTxBytes(peer *device.Peer) uint64 {
|
||||
return atomic.LoadUint64((*uint64)(unsafe.Add(unsafe.Pointer(peer), offTxBytes)))
|
||||
return (*atomic.Uint64)(unsafe.Add(unsafe.Pointer(peer), offTxBytes)).Load()
|
||||
}
|
||||
|
Reference in New Issue
Block a user