tailcfg_clone.go 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876
  1. // Copyright (c) Tailscale Inc & contributors
  2. // SPDX-License-Identifier: BSD-3-Clause
  3. // Code generated by tailscale.com/cmd/cloner; DO NOT EDIT.
  4. package tailcfg
  5. import (
  6. "maps"
  7. "net/netip"
  8. "time"
  9. "tailscale.com/types/dnstype"
  10. "tailscale.com/types/key"
  11. "tailscale.com/types/opt"
  12. "tailscale.com/types/ptr"
  13. "tailscale.com/types/structs"
  14. "tailscale.com/types/tkatype"
  15. )
  16. // Clone makes a deep copy of User.
  17. // The result aliases no memory with the original.
  18. func (src *User) Clone() *User {
  19. if src == nil {
  20. return nil
  21. }
  22. dst := new(User)
  23. *dst = *src
  24. return dst
  25. }
  26. // A compilation failure here means this code must be regenerated, with the command at the top of this file.
  27. var _UserCloneNeedsRegeneration = User(struct {
  28. ID UserID
  29. DisplayName string
  30. ProfilePicURL string
  31. Created time.Time
  32. }{})
  33. // Clone makes a deep copy of Node.
  34. // The result aliases no memory with the original.
  35. func (src *Node) Clone() *Node {
  36. if src == nil {
  37. return nil
  38. }
  39. dst := new(Node)
  40. *dst = *src
  41. dst.KeySignature = append(src.KeySignature[:0:0], src.KeySignature...)
  42. dst.Addresses = append(src.Addresses[:0:0], src.Addresses...)
  43. dst.AllowedIPs = append(src.AllowedIPs[:0:0], src.AllowedIPs...)
  44. dst.Endpoints = append(src.Endpoints[:0:0], src.Endpoints...)
  45. dst.Hostinfo = src.Hostinfo
  46. dst.Tags = append(src.Tags[:0:0], src.Tags...)
  47. dst.PrimaryRoutes = append(src.PrimaryRoutes[:0:0], src.PrimaryRoutes...)
  48. if dst.LastSeen != nil {
  49. dst.LastSeen = ptr.To(*src.LastSeen)
  50. }
  51. if dst.Online != nil {
  52. dst.Online = ptr.To(*src.Online)
  53. }
  54. dst.Capabilities = append(src.Capabilities[:0:0], src.Capabilities...)
  55. if dst.CapMap != nil {
  56. dst.CapMap = map[NodeCapability][]RawMessage{}
  57. for k := range src.CapMap {
  58. dst.CapMap[k] = append([]RawMessage{}, src.CapMap[k]...)
  59. }
  60. }
  61. if dst.SelfNodeV4MasqAddrForThisPeer != nil {
  62. dst.SelfNodeV4MasqAddrForThisPeer = ptr.To(*src.SelfNodeV4MasqAddrForThisPeer)
  63. }
  64. if dst.SelfNodeV6MasqAddrForThisPeer != nil {
  65. dst.SelfNodeV6MasqAddrForThisPeer = ptr.To(*src.SelfNodeV6MasqAddrForThisPeer)
  66. }
  67. if src.ExitNodeDNSResolvers != nil {
  68. dst.ExitNodeDNSResolvers = make([]*dnstype.Resolver, len(src.ExitNodeDNSResolvers))
  69. for i := range dst.ExitNodeDNSResolvers {
  70. if src.ExitNodeDNSResolvers[i] == nil {
  71. dst.ExitNodeDNSResolvers[i] = nil
  72. } else {
  73. dst.ExitNodeDNSResolvers[i] = src.ExitNodeDNSResolvers[i].Clone()
  74. }
  75. }
  76. }
  77. return dst
  78. }
  79. // A compilation failure here means this code must be regenerated, with the command at the top of this file.
  80. var _NodeCloneNeedsRegeneration = Node(struct {
  81. ID NodeID
  82. StableID StableNodeID
  83. Name string
  84. User UserID
  85. Sharer UserID
  86. Key key.NodePublic
  87. KeyExpiry time.Time
  88. KeySignature tkatype.MarshaledSignature
  89. Machine key.MachinePublic
  90. DiscoKey key.DiscoPublic
  91. Addresses []netip.Prefix
  92. AllowedIPs []netip.Prefix
  93. Endpoints []netip.AddrPort
  94. LegacyDERPString string
  95. HomeDERP int
  96. Hostinfo HostinfoView
  97. Created time.Time
  98. Cap CapabilityVersion
  99. Tags []string
  100. PrimaryRoutes []netip.Prefix
  101. LastSeen *time.Time
  102. Online *bool
  103. MachineAuthorized bool
  104. Capabilities []NodeCapability
  105. CapMap NodeCapMap
  106. UnsignedPeerAPIOnly bool
  107. ComputedName string
  108. computedHostIfDifferent string
  109. ComputedNameWithHost string
  110. DataPlaneAuditLogID string
  111. Expired bool
  112. SelfNodeV4MasqAddrForThisPeer *netip.Addr
  113. SelfNodeV6MasqAddrForThisPeer *netip.Addr
  114. IsWireGuardOnly bool
  115. IsJailed bool
  116. ExitNodeDNSResolvers []*dnstype.Resolver
  117. }{})
  118. // Clone makes a deep copy of Hostinfo.
  119. // The result aliases no memory with the original.
  120. func (src *Hostinfo) Clone() *Hostinfo {
  121. if src == nil {
  122. return nil
  123. }
  124. dst := new(Hostinfo)
  125. *dst = *src
  126. dst.RoutableIPs = append(src.RoutableIPs[:0:0], src.RoutableIPs...)
  127. dst.RequestTags = append(src.RequestTags[:0:0], src.RequestTags...)
  128. dst.WoLMACs = append(src.WoLMACs[:0:0], src.WoLMACs...)
  129. dst.Services = append(src.Services[:0:0], src.Services...)
  130. dst.NetInfo = src.NetInfo.Clone()
  131. dst.SSH_HostKeys = append(src.SSH_HostKeys[:0:0], src.SSH_HostKeys...)
  132. if dst.Location != nil {
  133. dst.Location = ptr.To(*src.Location)
  134. }
  135. if dst.TPM != nil {
  136. dst.TPM = ptr.To(*src.TPM)
  137. }
  138. return dst
  139. }
  140. // A compilation failure here means this code must be regenerated, with the command at the top of this file.
  141. var _HostinfoCloneNeedsRegeneration = Hostinfo(struct {
  142. IPNVersion string
  143. FrontendLogID string
  144. BackendLogID string
  145. OS string
  146. OSVersion string
  147. Container opt.Bool
  148. Env string
  149. Distro string
  150. DistroVersion string
  151. DistroCodeName string
  152. App string
  153. Desktop opt.Bool
  154. Package string
  155. DeviceModel string
  156. PushDeviceToken string
  157. Hostname string
  158. ShieldsUp bool
  159. ShareeNode bool
  160. NoLogsNoSupport bool
  161. WireIngress bool
  162. IngressEnabled bool
  163. AllowsUpdate bool
  164. Machine string
  165. GoArch string
  166. GoArchVar string
  167. GoVersion string
  168. RoutableIPs []netip.Prefix
  169. RequestTags []string
  170. WoLMACs []string
  171. Services []Service
  172. NetInfo *NetInfo
  173. SSH_HostKeys []string
  174. Cloud string
  175. Userspace opt.Bool
  176. UserspaceRouter opt.Bool
  177. AppConnector opt.Bool
  178. ServicesHash string
  179. PeerRelay bool
  180. ExitNodeID StableNodeID
  181. Location *Location
  182. TPM *TPMInfo
  183. StateEncrypted opt.Bool
  184. }{})
  185. // Clone makes a deep copy of NetInfo.
  186. // The result aliases no memory with the original.
  187. func (src *NetInfo) Clone() *NetInfo {
  188. if src == nil {
  189. return nil
  190. }
  191. dst := new(NetInfo)
  192. *dst = *src
  193. dst.DERPLatency = maps.Clone(src.DERPLatency)
  194. return dst
  195. }
  196. // A compilation failure here means this code must be regenerated, with the command at the top of this file.
  197. var _NetInfoCloneNeedsRegeneration = NetInfo(struct {
  198. MappingVariesByDestIP opt.Bool
  199. WorkingIPv6 opt.Bool
  200. OSHasIPv6 opt.Bool
  201. WorkingUDP opt.Bool
  202. WorkingICMPv4 opt.Bool
  203. HavePortMap bool
  204. UPnP opt.Bool
  205. PMP opt.Bool
  206. PCP opt.Bool
  207. PreferredDERP int
  208. LinkType string
  209. DERPLatency map[string]float64
  210. FirewallMode string
  211. }{})
  212. // Clone makes a deep copy of Login.
  213. // The result aliases no memory with the original.
  214. func (src *Login) Clone() *Login {
  215. if src == nil {
  216. return nil
  217. }
  218. dst := new(Login)
  219. *dst = *src
  220. return dst
  221. }
  222. // A compilation failure here means this code must be regenerated, with the command at the top of this file.
  223. var _LoginCloneNeedsRegeneration = Login(struct {
  224. _ structs.Incomparable
  225. ID LoginID
  226. Provider string
  227. LoginName string
  228. DisplayName string
  229. ProfilePicURL string
  230. }{})
  231. // Clone makes a deep copy of DNSConfig.
  232. // The result aliases no memory with the original.
  233. func (src *DNSConfig) Clone() *DNSConfig {
  234. if src == nil {
  235. return nil
  236. }
  237. dst := new(DNSConfig)
  238. *dst = *src
  239. if src.Resolvers != nil {
  240. dst.Resolvers = make([]*dnstype.Resolver, len(src.Resolvers))
  241. for i := range dst.Resolvers {
  242. if src.Resolvers[i] == nil {
  243. dst.Resolvers[i] = nil
  244. } else {
  245. dst.Resolvers[i] = src.Resolvers[i].Clone()
  246. }
  247. }
  248. }
  249. if dst.Routes != nil {
  250. dst.Routes = map[string][]*dnstype.Resolver{}
  251. for k := range src.Routes {
  252. dst.Routes[k] = append([]*dnstype.Resolver{}, src.Routes[k]...)
  253. }
  254. }
  255. if src.FallbackResolvers != nil {
  256. dst.FallbackResolvers = make([]*dnstype.Resolver, len(src.FallbackResolvers))
  257. for i := range dst.FallbackResolvers {
  258. if src.FallbackResolvers[i] == nil {
  259. dst.FallbackResolvers[i] = nil
  260. } else {
  261. dst.FallbackResolvers[i] = src.FallbackResolvers[i].Clone()
  262. }
  263. }
  264. }
  265. dst.Domains = append(src.Domains[:0:0], src.Domains...)
  266. dst.Nameservers = append(src.Nameservers[:0:0], src.Nameservers...)
  267. dst.CertDomains = append(src.CertDomains[:0:0], src.CertDomains...)
  268. dst.ExtraRecords = append(src.ExtraRecords[:0:0], src.ExtraRecords...)
  269. dst.ExitNodeFilteredSet = append(src.ExitNodeFilteredSet[:0:0], src.ExitNodeFilteredSet...)
  270. return dst
  271. }
  272. // A compilation failure here means this code must be regenerated, with the command at the top of this file.
  273. var _DNSConfigCloneNeedsRegeneration = DNSConfig(struct {
  274. Resolvers []*dnstype.Resolver
  275. Routes map[string][]*dnstype.Resolver
  276. FallbackResolvers []*dnstype.Resolver
  277. Domains []string
  278. Proxied bool
  279. Nameservers []netip.Addr
  280. CertDomains []string
  281. ExtraRecords []DNSRecord
  282. ExitNodeFilteredSet []string
  283. TempCorpIssue13969 string
  284. }{})
  285. // Clone makes a deep copy of RegisterResponse.
  286. // The result aliases no memory with the original.
  287. func (src *RegisterResponse) Clone() *RegisterResponse {
  288. if src == nil {
  289. return nil
  290. }
  291. dst := new(RegisterResponse)
  292. *dst = *src
  293. dst.NodeKeySignature = append(src.NodeKeySignature[:0:0], src.NodeKeySignature...)
  294. return dst
  295. }
  296. // A compilation failure here means this code must be regenerated, with the command at the top of this file.
  297. var _RegisterResponseCloneNeedsRegeneration = RegisterResponse(struct {
  298. User User
  299. Login Login
  300. NodeKeyExpired bool
  301. MachineAuthorized bool
  302. AuthURL string
  303. NodeKeySignature tkatype.MarshaledSignature
  304. Error string
  305. }{})
  306. // Clone makes a deep copy of RegisterResponseAuth.
  307. // The result aliases no memory with the original.
  308. func (src *RegisterResponseAuth) Clone() *RegisterResponseAuth {
  309. if src == nil {
  310. return nil
  311. }
  312. dst := new(RegisterResponseAuth)
  313. *dst = *src
  314. if dst.Oauth2Token != nil {
  315. dst.Oauth2Token = ptr.To(*src.Oauth2Token)
  316. }
  317. return dst
  318. }
  319. // A compilation failure here means this code must be regenerated, with the command at the top of this file.
  320. var _RegisterResponseAuthCloneNeedsRegeneration = RegisterResponseAuth(struct {
  321. _ structs.Incomparable
  322. Oauth2Token *Oauth2Token
  323. AuthKey string
  324. }{})
  325. // Clone makes a deep copy of RegisterRequest.
  326. // The result aliases no memory with the original.
  327. func (src *RegisterRequest) Clone() *RegisterRequest {
  328. if src == nil {
  329. return nil
  330. }
  331. dst := new(RegisterRequest)
  332. *dst = *src
  333. dst.Auth = src.Auth.Clone()
  334. dst.Hostinfo = src.Hostinfo.Clone()
  335. dst.NodeKeySignature = append(src.NodeKeySignature[:0:0], src.NodeKeySignature...)
  336. if dst.Timestamp != nil {
  337. dst.Timestamp = ptr.To(*src.Timestamp)
  338. }
  339. dst.DeviceCert = append(src.DeviceCert[:0:0], src.DeviceCert...)
  340. dst.Signature = append(src.Signature[:0:0], src.Signature...)
  341. return dst
  342. }
  343. // A compilation failure here means this code must be regenerated, with the command at the top of this file.
  344. var _RegisterRequestCloneNeedsRegeneration = RegisterRequest(struct {
  345. _ structs.Incomparable
  346. Version CapabilityVersion
  347. NodeKey key.NodePublic
  348. OldNodeKey key.NodePublic
  349. NLKey key.NLPublic
  350. Auth *RegisterResponseAuth
  351. Expiry time.Time
  352. Followup string
  353. Hostinfo *Hostinfo
  354. Ephemeral bool
  355. NodeKeySignature tkatype.MarshaledSignature
  356. SignatureType SignatureType
  357. Timestamp *time.Time
  358. DeviceCert []byte
  359. Signature []byte
  360. Tailnet string
  361. }{})
  362. // Clone makes a deep copy of DERPHomeParams.
  363. // The result aliases no memory with the original.
  364. func (src *DERPHomeParams) Clone() *DERPHomeParams {
  365. if src == nil {
  366. return nil
  367. }
  368. dst := new(DERPHomeParams)
  369. *dst = *src
  370. dst.RegionScore = maps.Clone(src.RegionScore)
  371. return dst
  372. }
  373. // A compilation failure here means this code must be regenerated, with the command at the top of this file.
  374. var _DERPHomeParamsCloneNeedsRegeneration = DERPHomeParams(struct {
  375. RegionScore map[int]float64
  376. }{})
  377. // Clone makes a deep copy of DERPRegion.
  378. // The result aliases no memory with the original.
  379. func (src *DERPRegion) Clone() *DERPRegion {
  380. if src == nil {
  381. return nil
  382. }
  383. dst := new(DERPRegion)
  384. *dst = *src
  385. if src.Nodes != nil {
  386. dst.Nodes = make([]*DERPNode, len(src.Nodes))
  387. for i := range dst.Nodes {
  388. if src.Nodes[i] == nil {
  389. dst.Nodes[i] = nil
  390. } else {
  391. dst.Nodes[i] = ptr.To(*src.Nodes[i])
  392. }
  393. }
  394. }
  395. return dst
  396. }
  397. // A compilation failure here means this code must be regenerated, with the command at the top of this file.
  398. var _DERPRegionCloneNeedsRegeneration = DERPRegion(struct {
  399. RegionID int
  400. RegionCode string
  401. RegionName string
  402. Latitude float64
  403. Longitude float64
  404. Avoid bool
  405. NoMeasureNoHome bool
  406. Nodes []*DERPNode
  407. }{})
  408. // Clone makes a deep copy of DERPMap.
  409. // The result aliases no memory with the original.
  410. func (src *DERPMap) Clone() *DERPMap {
  411. if src == nil {
  412. return nil
  413. }
  414. dst := new(DERPMap)
  415. *dst = *src
  416. dst.HomeParams = src.HomeParams.Clone()
  417. if dst.Regions != nil {
  418. dst.Regions = map[int]*DERPRegion{}
  419. for k, v := range src.Regions {
  420. if v == nil {
  421. dst.Regions[k] = nil
  422. } else {
  423. dst.Regions[k] = v.Clone()
  424. }
  425. }
  426. }
  427. return dst
  428. }
  429. // A compilation failure here means this code must be regenerated, with the command at the top of this file.
  430. var _DERPMapCloneNeedsRegeneration = DERPMap(struct {
  431. HomeParams *DERPHomeParams
  432. Regions map[int]*DERPRegion
  433. OmitDefaultRegions bool
  434. }{})
  435. // Clone makes a deep copy of DERPNode.
  436. // The result aliases no memory with the original.
  437. func (src *DERPNode) Clone() *DERPNode {
  438. if src == nil {
  439. return nil
  440. }
  441. dst := new(DERPNode)
  442. *dst = *src
  443. return dst
  444. }
  445. // A compilation failure here means this code must be regenerated, with the command at the top of this file.
  446. var _DERPNodeCloneNeedsRegeneration = DERPNode(struct {
  447. Name string
  448. RegionID int
  449. HostName string
  450. CertName string
  451. IPv4 string
  452. IPv6 string
  453. STUNPort int
  454. STUNOnly bool
  455. DERPPort int
  456. InsecureForTests bool
  457. STUNTestIP string
  458. CanPort80 bool
  459. }{})
  460. // Clone makes a deep copy of SSHRule.
  461. // The result aliases no memory with the original.
  462. func (src *SSHRule) Clone() *SSHRule {
  463. if src == nil {
  464. return nil
  465. }
  466. dst := new(SSHRule)
  467. *dst = *src
  468. if dst.RuleExpires != nil {
  469. dst.RuleExpires = ptr.To(*src.RuleExpires)
  470. }
  471. if src.Principals != nil {
  472. dst.Principals = make([]*SSHPrincipal, len(src.Principals))
  473. for i := range dst.Principals {
  474. if src.Principals[i] == nil {
  475. dst.Principals[i] = nil
  476. } else {
  477. dst.Principals[i] = src.Principals[i].Clone()
  478. }
  479. }
  480. }
  481. dst.SSHUsers = maps.Clone(src.SSHUsers)
  482. dst.Action = src.Action.Clone()
  483. dst.AcceptEnv = append(src.AcceptEnv[:0:0], src.AcceptEnv...)
  484. return dst
  485. }
  486. // A compilation failure here means this code must be regenerated, with the command at the top of this file.
  487. var _SSHRuleCloneNeedsRegeneration = SSHRule(struct {
  488. RuleExpires *time.Time
  489. Principals []*SSHPrincipal
  490. SSHUsers map[string]string
  491. Action *SSHAction
  492. AcceptEnv []string
  493. }{})
  494. // Clone makes a deep copy of SSHAction.
  495. // The result aliases no memory with the original.
  496. func (src *SSHAction) Clone() *SSHAction {
  497. if src == nil {
  498. return nil
  499. }
  500. dst := new(SSHAction)
  501. *dst = *src
  502. dst.Recorders = append(src.Recorders[:0:0], src.Recorders...)
  503. if dst.OnRecordingFailure != nil {
  504. dst.OnRecordingFailure = ptr.To(*src.OnRecordingFailure)
  505. }
  506. return dst
  507. }
  508. // A compilation failure here means this code must be regenerated, with the command at the top of this file.
  509. var _SSHActionCloneNeedsRegeneration = SSHAction(struct {
  510. Message string
  511. Reject bool
  512. Accept bool
  513. SessionDuration time.Duration
  514. AllowAgentForwarding bool
  515. HoldAndDelegate string
  516. AllowLocalPortForwarding bool
  517. AllowRemotePortForwarding bool
  518. Recorders []netip.AddrPort
  519. OnRecordingFailure *SSHRecorderFailureAction
  520. }{})
  521. // Clone makes a deep copy of SSHPrincipal.
  522. // The result aliases no memory with the original.
  523. func (src *SSHPrincipal) Clone() *SSHPrincipal {
  524. if src == nil {
  525. return nil
  526. }
  527. dst := new(SSHPrincipal)
  528. *dst = *src
  529. dst.UnusedPubKeys = append(src.UnusedPubKeys[:0:0], src.UnusedPubKeys...)
  530. return dst
  531. }
  532. // A compilation failure here means this code must be regenerated, with the command at the top of this file.
  533. var _SSHPrincipalCloneNeedsRegeneration = SSHPrincipal(struct {
  534. Node StableNodeID
  535. NodeIP string
  536. UserLogin string
  537. Any bool
  538. UnusedPubKeys []string
  539. }{})
  540. // Clone makes a deep copy of ControlDialPlan.
  541. // The result aliases no memory with the original.
  542. func (src *ControlDialPlan) Clone() *ControlDialPlan {
  543. if src == nil {
  544. return nil
  545. }
  546. dst := new(ControlDialPlan)
  547. *dst = *src
  548. dst.Candidates = append(src.Candidates[:0:0], src.Candidates...)
  549. return dst
  550. }
  551. // A compilation failure here means this code must be regenerated, with the command at the top of this file.
  552. var _ControlDialPlanCloneNeedsRegeneration = ControlDialPlan(struct {
  553. Candidates []ControlIPCandidate
  554. }{})
  555. // Clone makes a deep copy of Location.
  556. // The result aliases no memory with the original.
  557. func (src *Location) Clone() *Location {
  558. if src == nil {
  559. return nil
  560. }
  561. dst := new(Location)
  562. *dst = *src
  563. return dst
  564. }
  565. // A compilation failure here means this code must be regenerated, with the command at the top of this file.
  566. var _LocationCloneNeedsRegeneration = Location(struct {
  567. Country string
  568. CountryCode string
  569. City string
  570. CityCode string
  571. Latitude float64
  572. Longitude float64
  573. Priority int
  574. }{})
  575. // Clone makes a deep copy of UserProfile.
  576. // The result aliases no memory with the original.
  577. func (src *UserProfile) Clone() *UserProfile {
  578. if src == nil {
  579. return nil
  580. }
  581. dst := new(UserProfile)
  582. *dst = *src
  583. return dst
  584. }
  585. // A compilation failure here means this code must be regenerated, with the command at the top of this file.
  586. var _UserProfileCloneNeedsRegeneration = UserProfile(struct {
  587. ID UserID
  588. LoginName string
  589. DisplayName string
  590. ProfilePicURL string
  591. }{})
  592. // Clone makes a deep copy of VIPService.
  593. // The result aliases no memory with the original.
  594. func (src *VIPService) Clone() *VIPService {
  595. if src == nil {
  596. return nil
  597. }
  598. dst := new(VIPService)
  599. *dst = *src
  600. dst.Ports = append(src.Ports[:0:0], src.Ports...)
  601. return dst
  602. }
  603. // A compilation failure here means this code must be regenerated, with the command at the top of this file.
  604. var _VIPServiceCloneNeedsRegeneration = VIPService(struct {
  605. Name ServiceName
  606. Ports []ProtoPortRange
  607. Active bool
  608. }{})
  609. // Clone makes a deep copy of SSHPolicy.
  610. // The result aliases no memory with the original.
  611. func (src *SSHPolicy) Clone() *SSHPolicy {
  612. if src == nil {
  613. return nil
  614. }
  615. dst := new(SSHPolicy)
  616. *dst = *src
  617. if src.Rules != nil {
  618. dst.Rules = make([]*SSHRule, len(src.Rules))
  619. for i := range dst.Rules {
  620. if src.Rules[i] == nil {
  621. dst.Rules[i] = nil
  622. } else {
  623. dst.Rules[i] = src.Rules[i].Clone()
  624. }
  625. }
  626. }
  627. return dst
  628. }
  629. // A compilation failure here means this code must be regenerated, with the command at the top of this file.
  630. var _SSHPolicyCloneNeedsRegeneration = SSHPolicy(struct {
  631. Rules []*SSHRule
  632. }{})
  633. // Clone duplicates src into dst and reports whether it succeeded.
  634. // To succeed, <src, dst> must be of types <*T, *T> or <*T, **T>,
  635. // 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.
  636. func Clone(dst, src any) bool {
  637. switch src := src.(type) {
  638. case *User:
  639. switch dst := dst.(type) {
  640. case *User:
  641. *dst = *src.Clone()
  642. return true
  643. case **User:
  644. *dst = src.Clone()
  645. return true
  646. }
  647. case *Node:
  648. switch dst := dst.(type) {
  649. case *Node:
  650. *dst = *src.Clone()
  651. return true
  652. case **Node:
  653. *dst = src.Clone()
  654. return true
  655. }
  656. case *Hostinfo:
  657. switch dst := dst.(type) {
  658. case *Hostinfo:
  659. *dst = *src.Clone()
  660. return true
  661. case **Hostinfo:
  662. *dst = src.Clone()
  663. return true
  664. }
  665. case *NetInfo:
  666. switch dst := dst.(type) {
  667. case *NetInfo:
  668. *dst = *src.Clone()
  669. return true
  670. case **NetInfo:
  671. *dst = src.Clone()
  672. return true
  673. }
  674. case *Login:
  675. switch dst := dst.(type) {
  676. case *Login:
  677. *dst = *src.Clone()
  678. return true
  679. case **Login:
  680. *dst = src.Clone()
  681. return true
  682. }
  683. case *DNSConfig:
  684. switch dst := dst.(type) {
  685. case *DNSConfig:
  686. *dst = *src.Clone()
  687. return true
  688. case **DNSConfig:
  689. *dst = src.Clone()
  690. return true
  691. }
  692. case *RegisterResponse:
  693. switch dst := dst.(type) {
  694. case *RegisterResponse:
  695. *dst = *src.Clone()
  696. return true
  697. case **RegisterResponse:
  698. *dst = src.Clone()
  699. return true
  700. }
  701. case *RegisterResponseAuth:
  702. switch dst := dst.(type) {
  703. case *RegisterResponseAuth:
  704. *dst = *src.Clone()
  705. return true
  706. case **RegisterResponseAuth:
  707. *dst = src.Clone()
  708. return true
  709. }
  710. case *RegisterRequest:
  711. switch dst := dst.(type) {
  712. case *RegisterRequest:
  713. *dst = *src.Clone()
  714. return true
  715. case **RegisterRequest:
  716. *dst = src.Clone()
  717. return true
  718. }
  719. case *DERPHomeParams:
  720. switch dst := dst.(type) {
  721. case *DERPHomeParams:
  722. *dst = *src.Clone()
  723. return true
  724. case **DERPHomeParams:
  725. *dst = src.Clone()
  726. return true
  727. }
  728. case *DERPRegion:
  729. switch dst := dst.(type) {
  730. case *DERPRegion:
  731. *dst = *src.Clone()
  732. return true
  733. case **DERPRegion:
  734. *dst = src.Clone()
  735. return true
  736. }
  737. case *DERPMap:
  738. switch dst := dst.(type) {
  739. case *DERPMap:
  740. *dst = *src.Clone()
  741. return true
  742. case **DERPMap:
  743. *dst = src.Clone()
  744. return true
  745. }
  746. case *DERPNode:
  747. switch dst := dst.(type) {
  748. case *DERPNode:
  749. *dst = *src.Clone()
  750. return true
  751. case **DERPNode:
  752. *dst = src.Clone()
  753. return true
  754. }
  755. case *SSHRule:
  756. switch dst := dst.(type) {
  757. case *SSHRule:
  758. *dst = *src.Clone()
  759. return true
  760. case **SSHRule:
  761. *dst = src.Clone()
  762. return true
  763. }
  764. case *SSHAction:
  765. switch dst := dst.(type) {
  766. case *SSHAction:
  767. *dst = *src.Clone()
  768. return true
  769. case **SSHAction:
  770. *dst = src.Clone()
  771. return true
  772. }
  773. case *SSHPrincipal:
  774. switch dst := dst.(type) {
  775. case *SSHPrincipal:
  776. *dst = *src.Clone()
  777. return true
  778. case **SSHPrincipal:
  779. *dst = src.Clone()
  780. return true
  781. }
  782. case *ControlDialPlan:
  783. switch dst := dst.(type) {
  784. case *ControlDialPlan:
  785. *dst = *src.Clone()
  786. return true
  787. case **ControlDialPlan:
  788. *dst = src.Clone()
  789. return true
  790. }
  791. case *Location:
  792. switch dst := dst.(type) {
  793. case *Location:
  794. *dst = *src.Clone()
  795. return true
  796. case **Location:
  797. *dst = src.Clone()
  798. return true
  799. }
  800. case *UserProfile:
  801. switch dst := dst.(type) {
  802. case *UserProfile:
  803. *dst = *src.Clone()
  804. return true
  805. case **UserProfile:
  806. *dst = src.Clone()
  807. return true
  808. }
  809. case *VIPService:
  810. switch dst := dst.(type) {
  811. case *VIPService:
  812. *dst = *src.Clone()
  813. return true
  814. case **VIPService:
  815. *dst = src.Clone()
  816. return true
  817. }
  818. case *SSHPolicy:
  819. switch dst := dst.(type) {
  820. case *SSHPolicy:
  821. *dst = *src.Clone()
  822. return true
  823. case **SSHPolicy:
  824. *dst = src.Clone()
  825. return true
  826. }
  827. }
  828. return false
  829. }