mirror of
https://github.com/tailscale/tailscale.git
synced 2025-10-25 02:02:51 +00:00
all: add extra information to serialized endpoints
magicsock.Conn.ParseEndpoint requires a peer's public key, disco key, and legacy ip/ports in order to do its job. We currently accomplish that by: * adding the public key in our wireguard-go fork * encoding the disco key as magic hostname * using a bespoke comma-separated encoding It's a bit messy. Instead, switch to something simpler: use a json-encoded struct containing exactly the information we need, in the form we use it. Our wireguard-go fork still adds the public key to the address when it passes it to ParseEndpoint, but now the code compensating for that is just a couple of simple, well-commented lines. Once this commit is in, we can remove that part of the fork and remove the compensating code. Signed-off-by: Josh Bleecher Snyder <josharian@gmail.com>
This commit is contained in:
@@ -2,12 +2,13 @@
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
// Code generated by tailscale.com/cmd/cloner -type Config,Peer; DO NOT EDIT.
|
||||
// Code generated by tailscale.com/cmd/cloner -type Config,Peer,Endpoints,IPPortSet; DO NOT EDIT.
|
||||
|
||||
package wgcfg
|
||||
|
||||
import (
|
||||
"inet.af/netaddr"
|
||||
"tailscale.com/tailcfg"
|
||||
"tailscale.com/types/wgkey"
|
||||
)
|
||||
|
||||
@@ -29,7 +30,7 @@ func (src *Config) Clone() *Config {
|
||||
}
|
||||
|
||||
// A compilation failure here means this code must be regenerated, with command:
|
||||
// tailscale.com/cmd/cloner -type Config,Peer
|
||||
// tailscale.com/cmd/cloner -type Config,Peer,Endpoints,IPPortSet
|
||||
var _ConfigNeedsRegeneration = Config(struct {
|
||||
Name string
|
||||
PrivateKey wgkey.Private
|
||||
@@ -48,14 +49,53 @@ func (src *Peer) Clone() *Peer {
|
||||
dst := new(Peer)
|
||||
*dst = *src
|
||||
dst.AllowedIPs = append(src.AllowedIPs[:0:0], src.AllowedIPs...)
|
||||
dst.Endpoints = *src.Endpoints.Clone()
|
||||
return dst
|
||||
}
|
||||
|
||||
// A compilation failure here means this code must be regenerated, with command:
|
||||
// tailscale.com/cmd/cloner -type Config,Peer
|
||||
// tailscale.com/cmd/cloner -type Config,Peer,Endpoints,IPPortSet
|
||||
var _PeerNeedsRegeneration = Peer(struct {
|
||||
PublicKey wgkey.Key
|
||||
AllowedIPs []netaddr.IPPrefix
|
||||
Endpoints string
|
||||
Endpoints Endpoints
|
||||
PersistentKeepalive uint16
|
||||
}{})
|
||||
|
||||
// Clone makes a deep copy of Endpoints.
|
||||
// The result aliases no memory with the original.
|
||||
func (src *Endpoints) Clone() *Endpoints {
|
||||
if src == nil {
|
||||
return nil
|
||||
}
|
||||
dst := new(Endpoints)
|
||||
*dst = *src
|
||||
dst.IPPorts = *src.IPPorts.Clone()
|
||||
return dst
|
||||
}
|
||||
|
||||
// A compilation failure here means this code must be regenerated, with command:
|
||||
// tailscale.com/cmd/cloner -type Config,Peer,Endpoints,IPPortSet
|
||||
var _EndpointsNeedsRegeneration = Endpoints(struct {
|
||||
PublicKey wgkey.Key
|
||||
DiscoKey tailcfg.DiscoKey
|
||||
IPPorts IPPortSet
|
||||
}{})
|
||||
|
||||
// Clone makes a deep copy of IPPortSet.
|
||||
// The result aliases no memory with the original.
|
||||
func (src *IPPortSet) Clone() *IPPortSet {
|
||||
if src == nil {
|
||||
return nil
|
||||
}
|
||||
dst := new(IPPortSet)
|
||||
*dst = *src
|
||||
dst.ipp = append(src.ipp[:0:0], src.ipp...)
|
||||
return dst
|
||||
}
|
||||
|
||||
// A compilation failure here means this code must be regenerated, with command:
|
||||
// tailscale.com/cmd/cloner -type Config,Peer,Endpoints,IPPortSet
|
||||
var _IPPortSetNeedsRegeneration = IPPortSet(struct {
|
||||
ipp []netaddr.IPPort
|
||||
}{})
|
||||
|
||||
Reference in New Issue
Block a user