tailcfg_clone.go 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593
  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. "net/netip"
  7. "time"
  8. "tailscale.com/types/dnstype"
  9. "tailscale.com/types/key"
  10. "tailscale.com/types/opt"
  11. "tailscale.com/types/structs"
  12. "tailscale.com/types/tkatype"
  13. )
  14. // Clone makes a deep copy of User.
  15. // The result aliases no memory with the original.
  16. func (src *User) Clone() *User {
  17. if src == nil {
  18. return nil
  19. }
  20. dst := new(User)
  21. *dst = *src
  22. dst.Logins = append(src.Logins[:0:0], src.Logins...)
  23. return dst
  24. }
  25. // A compilation failure here means this code must be regenerated, with the command at the top of this file.
  26. var _UserCloneNeedsRegeneration = User(struct {
  27. ID UserID
  28. LoginName string
  29. DisplayName string
  30. ProfilePicURL string
  31. Domain string
  32. Logins []LoginID
  33. Created time.Time
  34. }{})
  35. // Clone makes a deep copy of Node.
  36. // The result aliases no memory with the original.
  37. func (src *Node) Clone() *Node {
  38. if src == nil {
  39. return nil
  40. }
  41. dst := new(Node)
  42. *dst = *src
  43. dst.KeySignature = append(src.KeySignature[:0:0], src.KeySignature...)
  44. dst.Addresses = append(src.Addresses[:0:0], src.Addresses...)
  45. dst.AllowedIPs = append(src.AllowedIPs[:0:0], src.AllowedIPs...)
  46. dst.Endpoints = append(src.Endpoints[:0:0], src.Endpoints...)
  47. dst.Hostinfo = src.Hostinfo
  48. dst.Tags = append(src.Tags[:0:0], src.Tags...)
  49. dst.PrimaryRoutes = append(src.PrimaryRoutes[:0:0], src.PrimaryRoutes...)
  50. if dst.LastSeen != nil {
  51. dst.LastSeen = new(time.Time)
  52. *dst.LastSeen = *src.LastSeen
  53. }
  54. if dst.Online != nil {
  55. dst.Online = new(bool)
  56. *dst.Online = *src.Online
  57. }
  58. dst.Capabilities = append(src.Capabilities[:0:0], src.Capabilities...)
  59. if dst.SelfNodeV4MasqAddrForThisPeer != nil {
  60. dst.SelfNodeV4MasqAddrForThisPeer = new(netip.Addr)
  61. *dst.SelfNodeV4MasqAddrForThisPeer = *src.SelfNodeV4MasqAddrForThisPeer
  62. }
  63. return dst
  64. }
  65. // A compilation failure here means this code must be regenerated, with the command at the top of this file.
  66. var _NodeCloneNeedsRegeneration = Node(struct {
  67. ID NodeID
  68. StableID StableNodeID
  69. Name string
  70. User UserID
  71. Sharer UserID
  72. Key key.NodePublic
  73. KeyExpiry time.Time
  74. KeySignature tkatype.MarshaledSignature
  75. Machine key.MachinePublic
  76. DiscoKey key.DiscoPublic
  77. Addresses []netip.Prefix
  78. AllowedIPs []netip.Prefix
  79. Endpoints []string
  80. DERP string
  81. Hostinfo HostinfoView
  82. Created time.Time
  83. Cap CapabilityVersion
  84. Tags []string
  85. PrimaryRoutes []netip.Prefix
  86. LastSeen *time.Time
  87. Online *bool
  88. KeepAlive bool
  89. MachineAuthorized bool
  90. Capabilities []string
  91. UnsignedPeerAPIOnly bool
  92. ComputedName string
  93. computedHostIfDifferent string
  94. ComputedNameWithHost string
  95. DataPlaneAuditLogID string
  96. Expired bool
  97. SelfNodeV4MasqAddrForThisPeer *netip.Addr
  98. IsWireGuardOnly bool
  99. }{})
  100. // Clone makes a deep copy of Hostinfo.
  101. // The result aliases no memory with the original.
  102. func (src *Hostinfo) Clone() *Hostinfo {
  103. if src == nil {
  104. return nil
  105. }
  106. dst := new(Hostinfo)
  107. *dst = *src
  108. dst.RoutableIPs = append(src.RoutableIPs[:0:0], src.RoutableIPs...)
  109. dst.RequestTags = append(src.RequestTags[:0:0], src.RequestTags...)
  110. dst.Services = append(src.Services[:0:0], src.Services...)
  111. dst.NetInfo = src.NetInfo.Clone()
  112. dst.SSH_HostKeys = append(src.SSH_HostKeys[:0:0], src.SSH_HostKeys...)
  113. return dst
  114. }
  115. // A compilation failure here means this code must be regenerated, with the command at the top of this file.
  116. var _HostinfoCloneNeedsRegeneration = Hostinfo(struct {
  117. IPNVersion string
  118. FrontendLogID string
  119. BackendLogID string
  120. OS string
  121. OSVersion string
  122. Container opt.Bool
  123. Env string
  124. Distro string
  125. DistroVersion string
  126. DistroCodeName string
  127. App string
  128. Desktop opt.Bool
  129. Package string
  130. DeviceModel string
  131. PushDeviceToken string
  132. Hostname string
  133. ShieldsUp bool
  134. ShareeNode bool
  135. NoLogsNoSupport bool
  136. WireIngress bool
  137. AllowsUpdate bool
  138. Machine string
  139. GoArch string
  140. GoArchVar string
  141. GoVersion string
  142. RoutableIPs []netip.Prefix
  143. RequestTags []string
  144. Services []Service
  145. NetInfo *NetInfo
  146. SSH_HostKeys []string
  147. Cloud string
  148. Userspace opt.Bool
  149. UserspaceRouter opt.Bool
  150. }{})
  151. // Clone makes a deep copy of NetInfo.
  152. // The result aliases no memory with the original.
  153. func (src *NetInfo) Clone() *NetInfo {
  154. if src == nil {
  155. return nil
  156. }
  157. dst := new(NetInfo)
  158. *dst = *src
  159. if dst.DERPLatency != nil {
  160. dst.DERPLatency = map[string]float64{}
  161. for k, v := range src.DERPLatency {
  162. dst.DERPLatency[k] = v
  163. }
  164. }
  165. return dst
  166. }
  167. // A compilation failure here means this code must be regenerated, with the command at the top of this file.
  168. var _NetInfoCloneNeedsRegeneration = NetInfo(struct {
  169. MappingVariesByDestIP opt.Bool
  170. HairPinning opt.Bool
  171. WorkingIPv6 opt.Bool
  172. OSHasIPv6 opt.Bool
  173. WorkingUDP opt.Bool
  174. WorkingICMPv4 opt.Bool
  175. HavePortMap bool
  176. UPnP opt.Bool
  177. PMP opt.Bool
  178. PCP opt.Bool
  179. PreferredDERP int
  180. LinkType string
  181. DERPLatency map[string]float64
  182. }{})
  183. // Clone makes a deep copy of Login.
  184. // The result aliases no memory with the original.
  185. func (src *Login) Clone() *Login {
  186. if src == nil {
  187. return nil
  188. }
  189. dst := new(Login)
  190. *dst = *src
  191. return dst
  192. }
  193. // A compilation failure here means this code must be regenerated, with the command at the top of this file.
  194. var _LoginCloneNeedsRegeneration = Login(struct {
  195. _ structs.Incomparable
  196. ID LoginID
  197. Provider string
  198. LoginName string
  199. DisplayName string
  200. ProfilePicURL string
  201. Domain string
  202. }{})
  203. // Clone makes a deep copy of DNSConfig.
  204. // The result aliases no memory with the original.
  205. func (src *DNSConfig) Clone() *DNSConfig {
  206. if src == nil {
  207. return nil
  208. }
  209. dst := new(DNSConfig)
  210. *dst = *src
  211. dst.Resolvers = make([]*dnstype.Resolver, len(src.Resolvers))
  212. for i := range dst.Resolvers {
  213. dst.Resolvers[i] = src.Resolvers[i].Clone()
  214. }
  215. if dst.Routes != nil {
  216. dst.Routes = map[string][]*dnstype.Resolver{}
  217. for k := range src.Routes {
  218. dst.Routes[k] = append([]*dnstype.Resolver{}, src.Routes[k]...)
  219. }
  220. }
  221. dst.FallbackResolvers = make([]*dnstype.Resolver, len(src.FallbackResolvers))
  222. for i := range dst.FallbackResolvers {
  223. dst.FallbackResolvers[i] = src.FallbackResolvers[i].Clone()
  224. }
  225. dst.Domains = append(src.Domains[:0:0], src.Domains...)
  226. dst.Nameservers = append(src.Nameservers[:0:0], src.Nameservers...)
  227. dst.CertDomains = append(src.CertDomains[:0:0], src.CertDomains...)
  228. dst.ExtraRecords = append(src.ExtraRecords[:0:0], src.ExtraRecords...)
  229. dst.ExitNodeFilteredSet = append(src.ExitNodeFilteredSet[:0:0], src.ExitNodeFilteredSet...)
  230. return dst
  231. }
  232. // A compilation failure here means this code must be regenerated, with the command at the top of this file.
  233. var _DNSConfigCloneNeedsRegeneration = DNSConfig(struct {
  234. Resolvers []*dnstype.Resolver
  235. Routes map[string][]*dnstype.Resolver
  236. FallbackResolvers []*dnstype.Resolver
  237. Domains []string
  238. Proxied bool
  239. Nameservers []netip.Addr
  240. CertDomains []string
  241. ExtraRecords []DNSRecord
  242. ExitNodeFilteredSet []string
  243. }{})
  244. // Clone makes a deep copy of RegisterResponse.
  245. // The result aliases no memory with the original.
  246. func (src *RegisterResponse) Clone() *RegisterResponse {
  247. if src == nil {
  248. return nil
  249. }
  250. dst := new(RegisterResponse)
  251. *dst = *src
  252. dst.User = *src.User.Clone()
  253. dst.NodeKeySignature = append(src.NodeKeySignature[:0:0], src.NodeKeySignature...)
  254. return dst
  255. }
  256. // A compilation failure here means this code must be regenerated, with the command at the top of this file.
  257. var _RegisterResponseCloneNeedsRegeneration = RegisterResponse(struct {
  258. User User
  259. Login Login
  260. NodeKeyExpired bool
  261. MachineAuthorized bool
  262. AuthURL string
  263. NodeKeySignature tkatype.MarshaledSignature
  264. Error string
  265. }{})
  266. // Clone makes a deep copy of DERPRegion.
  267. // The result aliases no memory with the original.
  268. func (src *DERPRegion) Clone() *DERPRegion {
  269. if src == nil {
  270. return nil
  271. }
  272. dst := new(DERPRegion)
  273. *dst = *src
  274. dst.Nodes = make([]*DERPNode, len(src.Nodes))
  275. for i := range dst.Nodes {
  276. dst.Nodes[i] = src.Nodes[i].Clone()
  277. }
  278. return dst
  279. }
  280. // A compilation failure here means this code must be regenerated, with the command at the top of this file.
  281. var _DERPRegionCloneNeedsRegeneration = DERPRegion(struct {
  282. RegionID int
  283. RegionCode string
  284. RegionName string
  285. Avoid bool
  286. Nodes []*DERPNode
  287. }{})
  288. // Clone makes a deep copy of DERPMap.
  289. // The result aliases no memory with the original.
  290. func (src *DERPMap) Clone() *DERPMap {
  291. if src == nil {
  292. return nil
  293. }
  294. dst := new(DERPMap)
  295. *dst = *src
  296. if dst.Regions != nil {
  297. dst.Regions = map[int]*DERPRegion{}
  298. for k, v := range src.Regions {
  299. dst.Regions[k] = v.Clone()
  300. }
  301. }
  302. return dst
  303. }
  304. // A compilation failure here means this code must be regenerated, with the command at the top of this file.
  305. var _DERPMapCloneNeedsRegeneration = DERPMap(struct {
  306. Regions map[int]*DERPRegion
  307. OmitDefaultRegions bool
  308. }{})
  309. // Clone makes a deep copy of DERPNode.
  310. // The result aliases no memory with the original.
  311. func (src *DERPNode) Clone() *DERPNode {
  312. if src == nil {
  313. return nil
  314. }
  315. dst := new(DERPNode)
  316. *dst = *src
  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 _DERPNodeCloneNeedsRegeneration = DERPNode(struct {
  321. Name string
  322. RegionID int
  323. HostName string
  324. CertName string
  325. IPv4 string
  326. IPv6 string
  327. STUNPort int
  328. STUNOnly bool
  329. DERPPort int
  330. InsecureForTests bool
  331. STUNTestIP string
  332. CanPort80 bool
  333. }{})
  334. // Clone makes a deep copy of SSHRule.
  335. // The result aliases no memory with the original.
  336. func (src *SSHRule) Clone() *SSHRule {
  337. if src == nil {
  338. return nil
  339. }
  340. dst := new(SSHRule)
  341. *dst = *src
  342. if dst.RuleExpires != nil {
  343. dst.RuleExpires = new(time.Time)
  344. *dst.RuleExpires = *src.RuleExpires
  345. }
  346. dst.Principals = make([]*SSHPrincipal, len(src.Principals))
  347. for i := range dst.Principals {
  348. dst.Principals[i] = src.Principals[i].Clone()
  349. }
  350. if dst.SSHUsers != nil {
  351. dst.SSHUsers = map[string]string{}
  352. for k, v := range src.SSHUsers {
  353. dst.SSHUsers[k] = v
  354. }
  355. }
  356. dst.Action = src.Action.Clone()
  357. return dst
  358. }
  359. // A compilation failure here means this code must be regenerated, with the command at the top of this file.
  360. var _SSHRuleCloneNeedsRegeneration = SSHRule(struct {
  361. RuleExpires *time.Time
  362. Principals []*SSHPrincipal
  363. SSHUsers map[string]string
  364. Action *SSHAction
  365. }{})
  366. // Clone makes a deep copy of SSHAction.
  367. // The result aliases no memory with the original.
  368. func (src *SSHAction) Clone() *SSHAction {
  369. if src == nil {
  370. return nil
  371. }
  372. dst := new(SSHAction)
  373. *dst = *src
  374. dst.Recorders = append(src.Recorders[:0:0], src.Recorders...)
  375. if dst.OnRecordingFailure != nil {
  376. dst.OnRecordingFailure = new(SSHRecorderFailureAction)
  377. *dst.OnRecordingFailure = *src.OnRecordingFailure
  378. }
  379. return dst
  380. }
  381. // A compilation failure here means this code must be regenerated, with the command at the top of this file.
  382. var _SSHActionCloneNeedsRegeneration = SSHAction(struct {
  383. Message string
  384. Reject bool
  385. Accept bool
  386. SessionDuration time.Duration
  387. AllowAgentForwarding bool
  388. HoldAndDelegate string
  389. AllowLocalPortForwarding bool
  390. Recorders []netip.AddrPort
  391. OnRecordingFailure *SSHRecorderFailureAction
  392. }{})
  393. // Clone makes a deep copy of SSHPrincipal.
  394. // The result aliases no memory with the original.
  395. func (src *SSHPrincipal) Clone() *SSHPrincipal {
  396. if src == nil {
  397. return nil
  398. }
  399. dst := new(SSHPrincipal)
  400. *dst = *src
  401. dst.PubKeys = append(src.PubKeys[:0:0], src.PubKeys...)
  402. return dst
  403. }
  404. // A compilation failure here means this code must be regenerated, with the command at the top of this file.
  405. var _SSHPrincipalCloneNeedsRegeneration = SSHPrincipal(struct {
  406. Node StableNodeID
  407. NodeIP string
  408. UserLogin string
  409. Any bool
  410. PubKeys []string
  411. }{})
  412. // Clone makes a deep copy of ControlDialPlan.
  413. // The result aliases no memory with the original.
  414. func (src *ControlDialPlan) Clone() *ControlDialPlan {
  415. if src == nil {
  416. return nil
  417. }
  418. dst := new(ControlDialPlan)
  419. *dst = *src
  420. dst.Candidates = append(src.Candidates[:0:0], src.Candidates...)
  421. return dst
  422. }
  423. // A compilation failure here means this code must be regenerated, with the command at the top of this file.
  424. var _ControlDialPlanCloneNeedsRegeneration = ControlDialPlan(struct {
  425. Candidates []ControlIPCandidate
  426. }{})
  427. // Clone duplicates src into dst and reports whether it succeeded.
  428. // To succeed, <src, dst> must be of types <*T, *T> or <*T, **T>,
  429. // where T is one of User,Node,Hostinfo,NetInfo,Login,DNSConfig,RegisterResponse,DERPRegion,DERPMap,DERPNode,SSHRule,SSHAction,SSHPrincipal,ControlDialPlan.
  430. func Clone(dst, src any) bool {
  431. switch src := src.(type) {
  432. case *User:
  433. switch dst := dst.(type) {
  434. case *User:
  435. *dst = *src.Clone()
  436. return true
  437. case **User:
  438. *dst = src.Clone()
  439. return true
  440. }
  441. case *Node:
  442. switch dst := dst.(type) {
  443. case *Node:
  444. *dst = *src.Clone()
  445. return true
  446. case **Node:
  447. *dst = src.Clone()
  448. return true
  449. }
  450. case *Hostinfo:
  451. switch dst := dst.(type) {
  452. case *Hostinfo:
  453. *dst = *src.Clone()
  454. return true
  455. case **Hostinfo:
  456. *dst = src.Clone()
  457. return true
  458. }
  459. case *NetInfo:
  460. switch dst := dst.(type) {
  461. case *NetInfo:
  462. *dst = *src.Clone()
  463. return true
  464. case **NetInfo:
  465. *dst = src.Clone()
  466. return true
  467. }
  468. case *Login:
  469. switch dst := dst.(type) {
  470. case *Login:
  471. *dst = *src.Clone()
  472. return true
  473. case **Login:
  474. *dst = src.Clone()
  475. return true
  476. }
  477. case *DNSConfig:
  478. switch dst := dst.(type) {
  479. case *DNSConfig:
  480. *dst = *src.Clone()
  481. return true
  482. case **DNSConfig:
  483. *dst = src.Clone()
  484. return true
  485. }
  486. case *RegisterResponse:
  487. switch dst := dst.(type) {
  488. case *RegisterResponse:
  489. *dst = *src.Clone()
  490. return true
  491. case **RegisterResponse:
  492. *dst = src.Clone()
  493. return true
  494. }
  495. case *DERPRegion:
  496. switch dst := dst.(type) {
  497. case *DERPRegion:
  498. *dst = *src.Clone()
  499. return true
  500. case **DERPRegion:
  501. *dst = src.Clone()
  502. return true
  503. }
  504. case *DERPMap:
  505. switch dst := dst.(type) {
  506. case *DERPMap:
  507. *dst = *src.Clone()
  508. return true
  509. case **DERPMap:
  510. *dst = src.Clone()
  511. return true
  512. }
  513. case *DERPNode:
  514. switch dst := dst.(type) {
  515. case *DERPNode:
  516. *dst = *src.Clone()
  517. return true
  518. case **DERPNode:
  519. *dst = src.Clone()
  520. return true
  521. }
  522. case *SSHRule:
  523. switch dst := dst.(type) {
  524. case *SSHRule:
  525. *dst = *src.Clone()
  526. return true
  527. case **SSHRule:
  528. *dst = src.Clone()
  529. return true
  530. }
  531. case *SSHAction:
  532. switch dst := dst.(type) {
  533. case *SSHAction:
  534. *dst = *src.Clone()
  535. return true
  536. case **SSHAction:
  537. *dst = src.Clone()
  538. return true
  539. }
  540. case *SSHPrincipal:
  541. switch dst := dst.(type) {
  542. case *SSHPrincipal:
  543. *dst = *src.Clone()
  544. return true
  545. case **SSHPrincipal:
  546. *dst = src.Clone()
  547. return true
  548. }
  549. case *ControlDialPlan:
  550. switch dst := dst.(type) {
  551. case *ControlDialPlan:
  552. *dst = *src.Clone()
  553. return true
  554. case **ControlDialPlan:
  555. *dst = src.Clone()
  556. return true
  557. }
  558. }
  559. return false
  560. }