tailcfg_clone.go 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875
  1. // Copyright (c) Tailscale Inc & AUTHORS
  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. ExitNodeID StableNodeID
  180. Location *Location
  181. TPM *TPMInfo
  182. StateEncrypted opt.Bool
  183. }{})
  184. // Clone makes a deep copy of NetInfo.
  185. // The result aliases no memory with the original.
  186. func (src *NetInfo) Clone() *NetInfo {
  187. if src == nil {
  188. return nil
  189. }
  190. dst := new(NetInfo)
  191. *dst = *src
  192. dst.DERPLatency = maps.Clone(src.DERPLatency)
  193. return dst
  194. }
  195. // A compilation failure here means this code must be regenerated, with the command at the top of this file.
  196. var _NetInfoCloneNeedsRegeneration = NetInfo(struct {
  197. MappingVariesByDestIP opt.Bool
  198. WorkingIPv6 opt.Bool
  199. OSHasIPv6 opt.Bool
  200. WorkingUDP opt.Bool
  201. WorkingICMPv4 opt.Bool
  202. HavePortMap bool
  203. UPnP opt.Bool
  204. PMP opt.Bool
  205. PCP opt.Bool
  206. PreferredDERP int
  207. LinkType string
  208. DERPLatency map[string]float64
  209. FirewallMode string
  210. }{})
  211. // Clone makes a deep copy of Login.
  212. // The result aliases no memory with the original.
  213. func (src *Login) Clone() *Login {
  214. if src == nil {
  215. return nil
  216. }
  217. dst := new(Login)
  218. *dst = *src
  219. return dst
  220. }
  221. // A compilation failure here means this code must be regenerated, with the command at the top of this file.
  222. var _LoginCloneNeedsRegeneration = Login(struct {
  223. _ structs.Incomparable
  224. ID LoginID
  225. Provider string
  226. LoginName string
  227. DisplayName string
  228. ProfilePicURL string
  229. }{})
  230. // Clone makes a deep copy of DNSConfig.
  231. // The result aliases no memory with the original.
  232. func (src *DNSConfig) Clone() *DNSConfig {
  233. if src == nil {
  234. return nil
  235. }
  236. dst := new(DNSConfig)
  237. *dst = *src
  238. if src.Resolvers != nil {
  239. dst.Resolvers = make([]*dnstype.Resolver, len(src.Resolvers))
  240. for i := range dst.Resolvers {
  241. if src.Resolvers[i] == nil {
  242. dst.Resolvers[i] = nil
  243. } else {
  244. dst.Resolvers[i] = src.Resolvers[i].Clone()
  245. }
  246. }
  247. }
  248. if dst.Routes != nil {
  249. dst.Routes = map[string][]*dnstype.Resolver{}
  250. for k := range src.Routes {
  251. dst.Routes[k] = append([]*dnstype.Resolver{}, src.Routes[k]...)
  252. }
  253. }
  254. if src.FallbackResolvers != nil {
  255. dst.FallbackResolvers = make([]*dnstype.Resolver, len(src.FallbackResolvers))
  256. for i := range dst.FallbackResolvers {
  257. if src.FallbackResolvers[i] == nil {
  258. dst.FallbackResolvers[i] = nil
  259. } else {
  260. dst.FallbackResolvers[i] = src.FallbackResolvers[i].Clone()
  261. }
  262. }
  263. }
  264. dst.Domains = append(src.Domains[:0:0], src.Domains...)
  265. dst.Nameservers = append(src.Nameservers[:0:0], src.Nameservers...)
  266. dst.CertDomains = append(src.CertDomains[:0:0], src.CertDomains...)
  267. dst.ExtraRecords = append(src.ExtraRecords[:0:0], src.ExtraRecords...)
  268. dst.ExitNodeFilteredSet = append(src.ExitNodeFilteredSet[:0:0], src.ExitNodeFilteredSet...)
  269. return dst
  270. }
  271. // A compilation failure here means this code must be regenerated, with the command at the top of this file.
  272. var _DNSConfigCloneNeedsRegeneration = DNSConfig(struct {
  273. Resolvers []*dnstype.Resolver
  274. Routes map[string][]*dnstype.Resolver
  275. FallbackResolvers []*dnstype.Resolver
  276. Domains []string
  277. Proxied bool
  278. Nameservers []netip.Addr
  279. CertDomains []string
  280. ExtraRecords []DNSRecord
  281. ExitNodeFilteredSet []string
  282. TempCorpIssue13969 string
  283. }{})
  284. // Clone makes a deep copy of RegisterResponse.
  285. // The result aliases no memory with the original.
  286. func (src *RegisterResponse) Clone() *RegisterResponse {
  287. if src == nil {
  288. return nil
  289. }
  290. dst := new(RegisterResponse)
  291. *dst = *src
  292. dst.NodeKeySignature = append(src.NodeKeySignature[:0:0], src.NodeKeySignature...)
  293. return dst
  294. }
  295. // A compilation failure here means this code must be regenerated, with the command at the top of this file.
  296. var _RegisterResponseCloneNeedsRegeneration = RegisterResponse(struct {
  297. User User
  298. Login Login
  299. NodeKeyExpired bool
  300. MachineAuthorized bool
  301. AuthURL string
  302. NodeKeySignature tkatype.MarshaledSignature
  303. Error string
  304. }{})
  305. // Clone makes a deep copy of RegisterResponseAuth.
  306. // The result aliases no memory with the original.
  307. func (src *RegisterResponseAuth) Clone() *RegisterResponseAuth {
  308. if src == nil {
  309. return nil
  310. }
  311. dst := new(RegisterResponseAuth)
  312. *dst = *src
  313. if dst.Oauth2Token != nil {
  314. dst.Oauth2Token = ptr.To(*src.Oauth2Token)
  315. }
  316. return dst
  317. }
  318. // A compilation failure here means this code must be regenerated, with the command at the top of this file.
  319. var _RegisterResponseAuthCloneNeedsRegeneration = RegisterResponseAuth(struct {
  320. _ structs.Incomparable
  321. Oauth2Token *Oauth2Token
  322. AuthKey string
  323. }{})
  324. // Clone makes a deep copy of RegisterRequest.
  325. // The result aliases no memory with the original.
  326. func (src *RegisterRequest) Clone() *RegisterRequest {
  327. if src == nil {
  328. return nil
  329. }
  330. dst := new(RegisterRequest)
  331. *dst = *src
  332. dst.Auth = src.Auth.Clone()
  333. dst.Hostinfo = src.Hostinfo.Clone()
  334. dst.NodeKeySignature = append(src.NodeKeySignature[:0:0], src.NodeKeySignature...)
  335. if dst.Timestamp != nil {
  336. dst.Timestamp = ptr.To(*src.Timestamp)
  337. }
  338. dst.DeviceCert = append(src.DeviceCert[:0:0], src.DeviceCert...)
  339. dst.Signature = append(src.Signature[:0:0], src.Signature...)
  340. return dst
  341. }
  342. // A compilation failure here means this code must be regenerated, with the command at the top of this file.
  343. var _RegisterRequestCloneNeedsRegeneration = RegisterRequest(struct {
  344. _ structs.Incomparable
  345. Version CapabilityVersion
  346. NodeKey key.NodePublic
  347. OldNodeKey key.NodePublic
  348. NLKey key.NLPublic
  349. Auth *RegisterResponseAuth
  350. Expiry time.Time
  351. Followup string
  352. Hostinfo *Hostinfo
  353. Ephemeral bool
  354. NodeKeySignature tkatype.MarshaledSignature
  355. SignatureType SignatureType
  356. Timestamp *time.Time
  357. DeviceCert []byte
  358. Signature []byte
  359. Tailnet string
  360. }{})
  361. // Clone makes a deep copy of DERPHomeParams.
  362. // The result aliases no memory with the original.
  363. func (src *DERPHomeParams) Clone() *DERPHomeParams {
  364. if src == nil {
  365. return nil
  366. }
  367. dst := new(DERPHomeParams)
  368. *dst = *src
  369. dst.RegionScore = maps.Clone(src.RegionScore)
  370. return dst
  371. }
  372. // A compilation failure here means this code must be regenerated, with the command at the top of this file.
  373. var _DERPHomeParamsCloneNeedsRegeneration = DERPHomeParams(struct {
  374. RegionScore map[int]float64
  375. }{})
  376. // Clone makes a deep copy of DERPRegion.
  377. // The result aliases no memory with the original.
  378. func (src *DERPRegion) Clone() *DERPRegion {
  379. if src == nil {
  380. return nil
  381. }
  382. dst := new(DERPRegion)
  383. *dst = *src
  384. if src.Nodes != nil {
  385. dst.Nodes = make([]*DERPNode, len(src.Nodes))
  386. for i := range dst.Nodes {
  387. if src.Nodes[i] == nil {
  388. dst.Nodes[i] = nil
  389. } else {
  390. dst.Nodes[i] = ptr.To(*src.Nodes[i])
  391. }
  392. }
  393. }
  394. return dst
  395. }
  396. // A compilation failure here means this code must be regenerated, with the command at the top of this file.
  397. var _DERPRegionCloneNeedsRegeneration = DERPRegion(struct {
  398. RegionID int
  399. RegionCode string
  400. RegionName string
  401. Latitude float64
  402. Longitude float64
  403. Avoid bool
  404. NoMeasureNoHome bool
  405. Nodes []*DERPNode
  406. }{})
  407. // Clone makes a deep copy of DERPMap.
  408. // The result aliases no memory with the original.
  409. func (src *DERPMap) Clone() *DERPMap {
  410. if src == nil {
  411. return nil
  412. }
  413. dst := new(DERPMap)
  414. *dst = *src
  415. dst.HomeParams = src.HomeParams.Clone()
  416. if dst.Regions != nil {
  417. dst.Regions = map[int]*DERPRegion{}
  418. for k, v := range src.Regions {
  419. if v == nil {
  420. dst.Regions[k] = nil
  421. } else {
  422. dst.Regions[k] = v.Clone()
  423. }
  424. }
  425. }
  426. return dst
  427. }
  428. // A compilation failure here means this code must be regenerated, with the command at the top of this file.
  429. var _DERPMapCloneNeedsRegeneration = DERPMap(struct {
  430. HomeParams *DERPHomeParams
  431. Regions map[int]*DERPRegion
  432. OmitDefaultRegions bool
  433. }{})
  434. // Clone makes a deep copy of DERPNode.
  435. // The result aliases no memory with the original.
  436. func (src *DERPNode) Clone() *DERPNode {
  437. if src == nil {
  438. return nil
  439. }
  440. dst := new(DERPNode)
  441. *dst = *src
  442. return dst
  443. }
  444. // A compilation failure here means this code must be regenerated, with the command at the top of this file.
  445. var _DERPNodeCloneNeedsRegeneration = DERPNode(struct {
  446. Name string
  447. RegionID int
  448. HostName string
  449. CertName string
  450. IPv4 string
  451. IPv6 string
  452. STUNPort int
  453. STUNOnly bool
  454. DERPPort int
  455. InsecureForTests bool
  456. STUNTestIP string
  457. CanPort80 bool
  458. }{})
  459. // Clone makes a deep copy of SSHRule.
  460. // The result aliases no memory with the original.
  461. func (src *SSHRule) Clone() *SSHRule {
  462. if src == nil {
  463. return nil
  464. }
  465. dst := new(SSHRule)
  466. *dst = *src
  467. if dst.RuleExpires != nil {
  468. dst.RuleExpires = ptr.To(*src.RuleExpires)
  469. }
  470. if src.Principals != nil {
  471. dst.Principals = make([]*SSHPrincipal, len(src.Principals))
  472. for i := range dst.Principals {
  473. if src.Principals[i] == nil {
  474. dst.Principals[i] = nil
  475. } else {
  476. dst.Principals[i] = src.Principals[i].Clone()
  477. }
  478. }
  479. }
  480. dst.SSHUsers = maps.Clone(src.SSHUsers)
  481. dst.Action = src.Action.Clone()
  482. dst.AcceptEnv = append(src.AcceptEnv[:0:0], src.AcceptEnv...)
  483. return dst
  484. }
  485. // A compilation failure here means this code must be regenerated, with the command at the top of this file.
  486. var _SSHRuleCloneNeedsRegeneration = SSHRule(struct {
  487. RuleExpires *time.Time
  488. Principals []*SSHPrincipal
  489. SSHUsers map[string]string
  490. Action *SSHAction
  491. AcceptEnv []string
  492. }{})
  493. // Clone makes a deep copy of SSHAction.
  494. // The result aliases no memory with the original.
  495. func (src *SSHAction) Clone() *SSHAction {
  496. if src == nil {
  497. return nil
  498. }
  499. dst := new(SSHAction)
  500. *dst = *src
  501. dst.Recorders = append(src.Recorders[:0:0], src.Recorders...)
  502. if dst.OnRecordingFailure != nil {
  503. dst.OnRecordingFailure = ptr.To(*src.OnRecordingFailure)
  504. }
  505. return dst
  506. }
  507. // A compilation failure here means this code must be regenerated, with the command at the top of this file.
  508. var _SSHActionCloneNeedsRegeneration = SSHAction(struct {
  509. Message string
  510. Reject bool
  511. Accept bool
  512. SessionDuration time.Duration
  513. AllowAgentForwarding bool
  514. HoldAndDelegate string
  515. AllowLocalPortForwarding bool
  516. AllowRemotePortForwarding bool
  517. Recorders []netip.AddrPort
  518. OnRecordingFailure *SSHRecorderFailureAction
  519. }{})
  520. // Clone makes a deep copy of SSHPrincipal.
  521. // The result aliases no memory with the original.
  522. func (src *SSHPrincipal) Clone() *SSHPrincipal {
  523. if src == nil {
  524. return nil
  525. }
  526. dst := new(SSHPrincipal)
  527. *dst = *src
  528. dst.UnusedPubKeys = append(src.UnusedPubKeys[:0:0], src.UnusedPubKeys...)
  529. return dst
  530. }
  531. // A compilation failure here means this code must be regenerated, with the command at the top of this file.
  532. var _SSHPrincipalCloneNeedsRegeneration = SSHPrincipal(struct {
  533. Node StableNodeID
  534. NodeIP string
  535. UserLogin string
  536. Any bool
  537. UnusedPubKeys []string
  538. }{})
  539. // Clone makes a deep copy of ControlDialPlan.
  540. // The result aliases no memory with the original.
  541. func (src *ControlDialPlan) Clone() *ControlDialPlan {
  542. if src == nil {
  543. return nil
  544. }
  545. dst := new(ControlDialPlan)
  546. *dst = *src
  547. dst.Candidates = append(src.Candidates[:0:0], src.Candidates...)
  548. return dst
  549. }
  550. // A compilation failure here means this code must be regenerated, with the command at the top of this file.
  551. var _ControlDialPlanCloneNeedsRegeneration = ControlDialPlan(struct {
  552. Candidates []ControlIPCandidate
  553. }{})
  554. // Clone makes a deep copy of Location.
  555. // The result aliases no memory with the original.
  556. func (src *Location) Clone() *Location {
  557. if src == nil {
  558. return nil
  559. }
  560. dst := new(Location)
  561. *dst = *src
  562. return dst
  563. }
  564. // A compilation failure here means this code must be regenerated, with the command at the top of this file.
  565. var _LocationCloneNeedsRegeneration = Location(struct {
  566. Country string
  567. CountryCode string
  568. City string
  569. CityCode string
  570. Latitude float64
  571. Longitude float64
  572. Priority int
  573. }{})
  574. // Clone makes a deep copy of UserProfile.
  575. // The result aliases no memory with the original.
  576. func (src *UserProfile) Clone() *UserProfile {
  577. if src == nil {
  578. return nil
  579. }
  580. dst := new(UserProfile)
  581. *dst = *src
  582. return dst
  583. }
  584. // A compilation failure here means this code must be regenerated, with the command at the top of this file.
  585. var _UserProfileCloneNeedsRegeneration = UserProfile(struct {
  586. ID UserID
  587. LoginName string
  588. DisplayName string
  589. ProfilePicURL string
  590. }{})
  591. // Clone makes a deep copy of VIPService.
  592. // The result aliases no memory with the original.
  593. func (src *VIPService) Clone() *VIPService {
  594. if src == nil {
  595. return nil
  596. }
  597. dst := new(VIPService)
  598. *dst = *src
  599. dst.Ports = append(src.Ports[:0:0], src.Ports...)
  600. return dst
  601. }
  602. // A compilation failure here means this code must be regenerated, with the command at the top of this file.
  603. var _VIPServiceCloneNeedsRegeneration = VIPService(struct {
  604. Name ServiceName
  605. Ports []ProtoPortRange
  606. Active bool
  607. }{})
  608. // Clone makes a deep copy of SSHPolicy.
  609. // The result aliases no memory with the original.
  610. func (src *SSHPolicy) Clone() *SSHPolicy {
  611. if src == nil {
  612. return nil
  613. }
  614. dst := new(SSHPolicy)
  615. *dst = *src
  616. if src.Rules != nil {
  617. dst.Rules = make([]*SSHRule, len(src.Rules))
  618. for i := range dst.Rules {
  619. if src.Rules[i] == nil {
  620. dst.Rules[i] = nil
  621. } else {
  622. dst.Rules[i] = src.Rules[i].Clone()
  623. }
  624. }
  625. }
  626. return dst
  627. }
  628. // A compilation failure here means this code must be regenerated, with the command at the top of this file.
  629. var _SSHPolicyCloneNeedsRegeneration = SSHPolicy(struct {
  630. Rules []*SSHRule
  631. }{})
  632. // Clone duplicates src into dst and reports whether it succeeded.
  633. // To succeed, <src, dst> must be of types <*T, *T> or <*T, **T>,
  634. // 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.
  635. func Clone(dst, src any) bool {
  636. switch src := src.(type) {
  637. case *User:
  638. switch dst := dst.(type) {
  639. case *User:
  640. *dst = *src.Clone()
  641. return true
  642. case **User:
  643. *dst = src.Clone()
  644. return true
  645. }
  646. case *Node:
  647. switch dst := dst.(type) {
  648. case *Node:
  649. *dst = *src.Clone()
  650. return true
  651. case **Node:
  652. *dst = src.Clone()
  653. return true
  654. }
  655. case *Hostinfo:
  656. switch dst := dst.(type) {
  657. case *Hostinfo:
  658. *dst = *src.Clone()
  659. return true
  660. case **Hostinfo:
  661. *dst = src.Clone()
  662. return true
  663. }
  664. case *NetInfo:
  665. switch dst := dst.(type) {
  666. case *NetInfo:
  667. *dst = *src.Clone()
  668. return true
  669. case **NetInfo:
  670. *dst = src.Clone()
  671. return true
  672. }
  673. case *Login:
  674. switch dst := dst.(type) {
  675. case *Login:
  676. *dst = *src.Clone()
  677. return true
  678. case **Login:
  679. *dst = src.Clone()
  680. return true
  681. }
  682. case *DNSConfig:
  683. switch dst := dst.(type) {
  684. case *DNSConfig:
  685. *dst = *src.Clone()
  686. return true
  687. case **DNSConfig:
  688. *dst = src.Clone()
  689. return true
  690. }
  691. case *RegisterResponse:
  692. switch dst := dst.(type) {
  693. case *RegisterResponse:
  694. *dst = *src.Clone()
  695. return true
  696. case **RegisterResponse:
  697. *dst = src.Clone()
  698. return true
  699. }
  700. case *RegisterResponseAuth:
  701. switch dst := dst.(type) {
  702. case *RegisterResponseAuth:
  703. *dst = *src.Clone()
  704. return true
  705. case **RegisterResponseAuth:
  706. *dst = src.Clone()
  707. return true
  708. }
  709. case *RegisterRequest:
  710. switch dst := dst.(type) {
  711. case *RegisterRequest:
  712. *dst = *src.Clone()
  713. return true
  714. case **RegisterRequest:
  715. *dst = src.Clone()
  716. return true
  717. }
  718. case *DERPHomeParams:
  719. switch dst := dst.(type) {
  720. case *DERPHomeParams:
  721. *dst = *src.Clone()
  722. return true
  723. case **DERPHomeParams:
  724. *dst = src.Clone()
  725. return true
  726. }
  727. case *DERPRegion:
  728. switch dst := dst.(type) {
  729. case *DERPRegion:
  730. *dst = *src.Clone()
  731. return true
  732. case **DERPRegion:
  733. *dst = src.Clone()
  734. return true
  735. }
  736. case *DERPMap:
  737. switch dst := dst.(type) {
  738. case *DERPMap:
  739. *dst = *src.Clone()
  740. return true
  741. case **DERPMap:
  742. *dst = src.Clone()
  743. return true
  744. }
  745. case *DERPNode:
  746. switch dst := dst.(type) {
  747. case *DERPNode:
  748. *dst = *src.Clone()
  749. return true
  750. case **DERPNode:
  751. *dst = src.Clone()
  752. return true
  753. }
  754. case *SSHRule:
  755. switch dst := dst.(type) {
  756. case *SSHRule:
  757. *dst = *src.Clone()
  758. return true
  759. case **SSHRule:
  760. *dst = src.Clone()
  761. return true
  762. }
  763. case *SSHAction:
  764. switch dst := dst.(type) {
  765. case *SSHAction:
  766. *dst = *src.Clone()
  767. return true
  768. case **SSHAction:
  769. *dst = src.Clone()
  770. return true
  771. }
  772. case *SSHPrincipal:
  773. switch dst := dst.(type) {
  774. case *SSHPrincipal:
  775. *dst = *src.Clone()
  776. return true
  777. case **SSHPrincipal:
  778. *dst = src.Clone()
  779. return true
  780. }
  781. case *ControlDialPlan:
  782. switch dst := dst.(type) {
  783. case *ControlDialPlan:
  784. *dst = *src.Clone()
  785. return true
  786. case **ControlDialPlan:
  787. *dst = src.Clone()
  788. return true
  789. }
  790. case *Location:
  791. switch dst := dst.(type) {
  792. case *Location:
  793. *dst = *src.Clone()
  794. return true
  795. case **Location:
  796. *dst = src.Clone()
  797. return true
  798. }
  799. case *UserProfile:
  800. switch dst := dst.(type) {
  801. case *UserProfile:
  802. *dst = *src.Clone()
  803. return true
  804. case **UserProfile:
  805. *dst = src.Clone()
  806. return true
  807. }
  808. case *VIPService:
  809. switch dst := dst.(type) {
  810. case *VIPService:
  811. *dst = *src.Clone()
  812. return true
  813. case **VIPService:
  814. *dst = src.Clone()
  815. return true
  816. }
  817. case *SSHPolicy:
  818. switch dst := dst.(type) {
  819. case *SSHPolicy:
  820. *dst = *src.Clone()
  821. return true
  822. case **SSHPolicy:
  823. *dst = src.Clone()
  824. return true
  825. }
  826. }
  827. return false
  828. }