Update
This commit is contained in:
1 parent
3530afb854
commit
6903fcff27
2146 files changed
+112256
-190703
No files matched your search
+14
-10
@@ -1,4 +1,4 @@
|
||||
// Copyright (c) Tailscale Inc & AUTHORS
|
||||
// Copyright (c) Tailscale Inc & contributors
|
||||
// SPDX-License-Identifier: BSD-3-Clause
|
||||
|
||||
// Package disco contains the discovery message types.
|
||||
@@ -177,8 +177,13 @@ func parsePing(ver uint8, p []byte) (m *Ping, err error) {
|
||||
// Deliberately lax on longer-than-expected messages, for future
|
||||
// compatibility.
|
||||
if len(p) >= key.NodePublicRawLen {
|
||||
m.NodeKey = key.NodePublicFromRaw32(mem.B(p[:key.NodePublicRawLen]))
|
||||
m.Padding -= key.NodePublicRawLen
|
||||
// Skip all-zero trailing bytes: treat them as padding, not a NodeKey,
|
||||
// to match AppendMarshal (which omits zero keys).
|
||||
nk := key.NodePublicFromRaw32(mem.B(p[:key.NodePublicRawLen]))
|
||||
if !nk.IsZero() {
|
||||
m.NodeKey = nk
|
||||
m.Padding -= key.NodePublicRawLen
|
||||
}
|
||||
}
|
||||
return m, nil
|
||||
}
|
||||
@@ -307,8 +312,7 @@ func MessageSummary(m Message) string {
|
||||
// BindUDPRelayHandshakeState represents the state of the 3-way bind handshake
|
||||
// between UDP relay client and UDP relay server. Its potential values include
|
||||
// those for both participants, UDP relay client and UDP relay server. A UDP
|
||||
// relay server implementation can be found in net/udprelay. This is currently
|
||||
// considered experimental.
|
||||
// relay server implementation can be found in net/udprelay.
|
||||
type BindUDPRelayHandshakeState int
|
||||
|
||||
const (
|
||||
@@ -475,7 +479,7 @@ const allocateUDPRelayEndpointRequestLen = key.DiscoPublicRawLen*2 + // ClientDi
|
||||
|
||||
func (m *AllocateUDPRelayEndpointRequest) AppendMarshal(b []byte) []byte {
|
||||
ret, p := appendMsgHeader(b, TypeAllocateUDPRelayEndpointRequest, v0, allocateUDPRelayEndpointRequestLen)
|
||||
for i := 0; i < len(m.ClientDisco); i++ {
|
||||
for i := range len(m.ClientDisco) {
|
||||
disco := m.ClientDisco[i].AppendTo(nil)
|
||||
copy(p, disco)
|
||||
p = p[key.DiscoPublicRawLen:]
|
||||
@@ -492,7 +496,7 @@ func parseAllocateUDPRelayEndpointRequest(ver uint8, p []byte) (m *AllocateUDPRe
|
||||
if len(p) < allocateUDPRelayEndpointRequestLen {
|
||||
return m, errShort
|
||||
}
|
||||
for i := 0; i < len(m.ClientDisco); i++ {
|
||||
for i := range len(m.ClientDisco) {
|
||||
m.ClientDisco[i] = key.DiscoPublicFromRaw32(mem.B(p[:key.DiscoPublicRawLen]))
|
||||
p = p[key.DiscoPublicRawLen:]
|
||||
}
|
||||
@@ -565,7 +569,7 @@ func (m *UDPRelayEndpoint) encode(b []byte) {
|
||||
disco := m.ServerDisco.AppendTo(nil)
|
||||
copy(b, disco)
|
||||
b = b[key.DiscoPublicRawLen:]
|
||||
for i := 0; i < len(m.ClientDisco); i++ {
|
||||
for i := range len(m.ClientDisco) {
|
||||
disco = m.ClientDisco[i].AppendTo(nil)
|
||||
copy(b, disco)
|
||||
b = b[key.DiscoPublicRawLen:]
|
||||
@@ -594,7 +598,7 @@ func (m *UDPRelayEndpoint) decode(b []byte) error {
|
||||
}
|
||||
m.ServerDisco = key.DiscoPublicFromRaw32(mem.B(b[:key.DiscoPublicRawLen]))
|
||||
b = b[key.DiscoPublicRawLen:]
|
||||
for i := 0; i < len(m.ClientDisco); i++ {
|
||||
for i := range len(m.ClientDisco) {
|
||||
m.ClientDisco[i] = key.DiscoPublicFromRaw32(mem.B(b[:key.DiscoPublicRawLen]))
|
||||
b = b[key.DiscoPublicRawLen:]
|
||||
}
|
||||
@@ -606,7 +610,7 @@ func (m *UDPRelayEndpoint) decode(b []byte) error {
|
||||
b = b[8:]
|
||||
m.SteadyStateLifetime = time.Duration(binary.BigEndian.Uint64(b[:8]))
|
||||
b = b[8:]
|
||||
m.AddrPorts = make([]netip.AddrPort, 0, len(b)-udpRelayEndpointLenMinusAddrPorts/epLength)
|
||||
m.AddrPorts = make([]netip.AddrPort, 0, len(b)/epLength)
|
||||
for len(b) > 0 {
|
||||
var a [16]byte
|
||||
copy(a[:], b)
|
||||
|
||||
Reference in new issue
Block a user