This commit is contained in:
2026-02-19 10:07:43 +00:00
parent 007438e372
commit 6e637ecf77
1763 changed files with 60820 additions and 279516 deletions

View File

@@ -5,7 +5,10 @@
package tailcfg
import "net/netip"
import (
"encoding/json"
"net/netip"
)
// C2NSSHUsernamesRequest is the request for the /ssh/usernames.
// A GET request without a request body is equivalent to the zero value of this type.
@@ -117,3 +120,29 @@ type C2NVIPServicesResponse struct {
// changes. This value matches what is reported in latest [Hostinfo.ServicesHash].
ServicesHash string
}
// C2NDebugNetmapRequest is the request (from control to node) for the
// /debug/netmap handler.
type C2NDebugNetmapRequest struct {
// Candidate is an optional full MapResponse to be used for generating a candidate
// network map. If unset, only the current network map is returned.
Candidate *MapResponse `json:"candidate,omitzero"`
// OmitFields is an optional list of netmap fields to omit from the response.
// If unset, no fields are omitted.
OmitFields []string `json:"omitFields,omitzero"`
}
// C2NDebugNetmapResponse is the response (from node to control) from the
// /debug/netmap handler. It contains the current network map and, if a
// candidate full MapResponse was provided in the request, a candidate network
// map generated from it.
// To avoid import cycles, and reflect the non-stable nature of
// netmap.NetworkMap values, they are returned as json.RawMessage.
type C2NDebugNetmapResponse struct {
// Current is the current network map (netmap.NetworkMap).
Current json.RawMessage `json:"current"`
// Candidate is a network map produced based on the candidate MapResponse.
Candidate json.RawMessage `json:"candidate,omitzero"`
}

View File

@@ -5,7 +5,6 @@ package tailcfg
import (
"errors"
"fmt"
"strconv"
"strings"
@@ -70,14 +69,7 @@ func (ppr ProtoPortRange) String() string {
buf.Write(text)
buf.Write([]byte(":"))
}
pr := ppr.Ports
if pr.First == pr.Last {
fmt.Fprintf(&buf, "%d", pr.First)
} else if pr == PortRangeAny {
buf.WriteByte('*')
} else {
fmt.Fprintf(&buf, "%d-%d", pr.First, pr.Last)
}
buf.WriteString(ppr.Ports.String())
return buf.String()
}
@@ -104,7 +96,7 @@ func parseProtoPortRange(ipProtoPort string) (*ProtoPortRange, error) {
if !strings.Contains(ipProtoPort, ":") {
ipProtoPort = "*:" + ipProtoPort
}
protoStr, portRange, err := parseHostPortRange(ipProtoPort)
protoStr, portRange, err := ParseHostPortRange(ipProtoPort)
if err != nil {
return nil, err
}
@@ -126,9 +118,9 @@ func parseProtoPortRange(ipProtoPort string) (*ProtoPortRange, error) {
return ppr, nil
}
// parseHostPortRange parses hostport as HOST:PORTS where HOST is
// ParseHostPortRange parses hostport as HOST:PORTS where HOST is
// returned unchanged and PORTS is is either "*" or PORTLOW-PORTHIGH ranges.
func parseHostPortRange(hostport string) (host string, ports PortRange, err error) {
func ParseHostPortRange(hostport string) (host string, ports PortRange, err error) {
hostport = strings.ToLower(hostport)
colon := strings.LastIndexByte(hostport, ':')
if colon < 0 {

File diff suppressed because it is too large Load Diff

View File

@@ -141,6 +141,9 @@ func (src *Hostinfo) Clone() *Hostinfo {
if dst.Location != nil {
dst.Location = ptr.To(*src.Location)
}
if dst.TPM != nil {
dst.TPM = ptr.To(*src.TPM)
}
return dst
}
@@ -183,7 +186,10 @@ var _HostinfoCloneNeedsRegeneration = Hostinfo(struct {
UserspaceRouter opt.Bool
AppConnector opt.Bool
ServicesHash string
ExitNodeID StableNodeID
Location *Location
TPM *TPMInfo
StateEncrypted opt.Bool
}{})
// Clone makes a deep copy of NetInfo.
@@ -201,7 +207,6 @@ func (src *NetInfo) Clone() *NetInfo {
// A compilation failure here means this code must be regenerated, with the command at the top of this file.
var _NetInfoCloneNeedsRegeneration = NetInfo(struct {
MappingVariesByDestIP opt.Bool
HairPinning opt.Bool
WorkingIPv6 opt.Bool
OSHasIPv6 opt.Bool
WorkingUDP opt.Bool
@@ -626,9 +631,54 @@ var _UserProfileCloneNeedsRegeneration = UserProfile(struct {
ProfilePicURL string
}{})
// Clone makes a deep copy of VIPService.
// The result aliases no memory with the original.
func (src *VIPService) Clone() *VIPService {
if src == nil {
return nil
}
dst := new(VIPService)
*dst = *src
dst.Ports = append(src.Ports[:0:0], src.Ports...)
return dst
}
// A compilation failure here means this code must be regenerated, with the command at the top of this file.
var _VIPServiceCloneNeedsRegeneration = VIPService(struct {
Name ServiceName
Ports []ProtoPortRange
Active bool
}{})
// Clone makes a deep copy of SSHPolicy.
// The result aliases no memory with the original.
func (src *SSHPolicy) Clone() *SSHPolicy {
if src == nil {
return nil
}
dst := new(SSHPolicy)
*dst = *src
if src.Rules != nil {
dst.Rules = make([]*SSHRule, len(src.Rules))
for i := range dst.Rules {
if src.Rules[i] == nil {
dst.Rules[i] = nil
} else {
dst.Rules[i] = src.Rules[i].Clone()
}
}
}
return dst
}
// A compilation failure here means this code must be regenerated, with the command at the top of this file.
var _SSHPolicyCloneNeedsRegeneration = SSHPolicy(struct {
Rules []*SSHRule
}{})
// Clone duplicates src into dst and reports whether it succeeded.
// To succeed, <src, dst> must be of types <*T, *T> or <*T, **T>,
// where T is one of User,Node,Hostinfo,NetInfo,Login,DNSConfig,RegisterResponse,RegisterResponseAuth,RegisterRequest,DERPHomeParams,DERPRegion,DERPMap,DERPNode,SSHRule,SSHAction,SSHPrincipal,ControlDialPlan,Location,UserProfile.
// where T is one of User,Node,Hostinfo,NetInfo,Login,DNSConfig,RegisterResponse,RegisterResponseAuth,RegisterRequest,DERPHomeParams,DERPRegion,DERPMap,DERPNode,SSHRule,SSHAction,SSHPrincipal,ControlDialPlan,Location,UserProfile,VIPService,SSHPolicy.
func Clone(dst, src any) bool {
switch src := src.(type) {
case *User:
@@ -802,6 +852,24 @@ func Clone(dst, src any) bool {
*dst = src.Clone()
return true
}
case *VIPService:
switch dst := dst.(type) {
case *VIPService:
*dst = *src.Clone()
return true
case **VIPService:
*dst = src.Clone()
return true
}
case *SSHPolicy:
switch dst := dst.(type) {
case *SSHPolicy:
*dst = *src.Clone()
return true
case **SSHPolicy:
*dst = src.Clone()
return true
}
}
return false
}

File diff suppressed because it is too large Load Diff