tailcfg_view.go 36 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077
  1. // Copyright (c) Tailscale Inc & AUTHORS
  2. // SPDX-License-Identifier: BSD-3-Clause
  3. // Code generated by tailscale/cmd/viewer; DO NOT EDIT.
  4. package tailcfg
  5. import (
  6. "encoding/json"
  7. "errors"
  8. "net/netip"
  9. "time"
  10. "go4.org/mem"
  11. "tailscale.com/types/dnstype"
  12. "tailscale.com/types/key"
  13. "tailscale.com/types/opt"
  14. "tailscale.com/types/structs"
  15. "tailscale.com/types/tkatype"
  16. "tailscale.com/types/views"
  17. )
  18. //go:generate go run tailscale.com/cmd/cloner -clonefunc=true -type=User,Node,Hostinfo,NetInfo,Login,DNSConfig,RegisterResponse,DERPRegion,DERPMap,DERPNode,SSHRule,SSHAction,SSHPrincipal,ControlDialPlan
  19. // View returns a readonly view of User.
  20. func (p *User) View() UserView {
  21. return UserView{ж: p}
  22. }
  23. // UserView provides a read-only view over User.
  24. //
  25. // Its methods should only be called if `Valid()` returns true.
  26. type UserView struct {
  27. // ж is the underlying mutable value, named with a hard-to-type
  28. // character that looks pointy like a pointer.
  29. // It is named distinctively to make you think of how dangerous it is to escape
  30. // to callers. You must not let callers be able to mutate it.
  31. ж *User
  32. }
  33. // Valid reports whether underlying value is non-nil.
  34. func (v UserView) Valid() bool { return v.ж != nil }
  35. // AsStruct returns a clone of the underlying value which aliases no memory with
  36. // the original.
  37. func (v UserView) AsStruct() *User {
  38. if v.ж == nil {
  39. return nil
  40. }
  41. return v.ж.Clone()
  42. }
  43. func (v UserView) MarshalJSON() ([]byte, error) { return json.Marshal(v.ж) }
  44. func (v *UserView) UnmarshalJSON(b []byte) error {
  45. if v.ж != nil {
  46. return errors.New("already initialized")
  47. }
  48. if len(b) == 0 {
  49. return nil
  50. }
  51. var x User
  52. if err := json.Unmarshal(b, &x); err != nil {
  53. return err
  54. }
  55. v.ж = &x
  56. return nil
  57. }
  58. func (v UserView) ID() UserID { return v.ж.ID }
  59. func (v UserView) LoginName() string { return v.ж.LoginName }
  60. func (v UserView) DisplayName() string { return v.ж.DisplayName }
  61. func (v UserView) ProfilePicURL() string { return v.ж.ProfilePicURL }
  62. func (v UserView) Domain() string { return v.ж.Domain }
  63. func (v UserView) Logins() views.Slice[LoginID] { return views.SliceOf(v.ж.Logins) }
  64. func (v UserView) Created() time.Time { return v.ж.Created }
  65. // A compilation failure here means this code must be regenerated, with the command at the top of this file.
  66. var _UserViewNeedsRegeneration = User(struct {
  67. ID UserID
  68. LoginName string
  69. DisplayName string
  70. ProfilePicURL string
  71. Domain string
  72. Logins []LoginID
  73. Created time.Time
  74. }{})
  75. // View returns a readonly view of Node.
  76. func (p *Node) View() NodeView {
  77. return NodeView{ж: p}
  78. }
  79. // NodeView provides a read-only view over Node.
  80. //
  81. // Its methods should only be called if `Valid()` returns true.
  82. type NodeView struct {
  83. // ж is the underlying mutable value, named with a hard-to-type
  84. // character that looks pointy like a pointer.
  85. // It is named distinctively to make you think of how dangerous it is to escape
  86. // to callers. You must not let callers be able to mutate it.
  87. ж *Node
  88. }
  89. // Valid reports whether underlying value is non-nil.
  90. func (v NodeView) Valid() bool { return v.ж != nil }
  91. // AsStruct returns a clone of the underlying value which aliases no memory with
  92. // the original.
  93. func (v NodeView) AsStruct() *Node {
  94. if v.ж == nil {
  95. return nil
  96. }
  97. return v.ж.Clone()
  98. }
  99. func (v NodeView) MarshalJSON() ([]byte, error) { return json.Marshal(v.ж) }
  100. func (v *NodeView) UnmarshalJSON(b []byte) error {
  101. if v.ж != nil {
  102. return errors.New("already initialized")
  103. }
  104. if len(b) == 0 {
  105. return nil
  106. }
  107. var x Node
  108. if err := json.Unmarshal(b, &x); err != nil {
  109. return err
  110. }
  111. v.ж = &x
  112. return nil
  113. }
  114. func (v NodeView) ID() NodeID { return v.ж.ID }
  115. func (v NodeView) StableID() StableNodeID { return v.ж.StableID }
  116. func (v NodeView) Name() string { return v.ж.Name }
  117. func (v NodeView) User() UserID { return v.ж.User }
  118. func (v NodeView) Sharer() UserID { return v.ж.Sharer }
  119. func (v NodeView) Key() key.NodePublic { return v.ж.Key }
  120. func (v NodeView) KeyExpiry() time.Time { return v.ж.KeyExpiry }
  121. func (v NodeView) KeySignature() mem.RO { return mem.B(v.ж.KeySignature) }
  122. func (v NodeView) Machine() key.MachinePublic { return v.ж.Machine }
  123. func (v NodeView) DiscoKey() key.DiscoPublic { return v.ж.DiscoKey }
  124. func (v NodeView) Addresses() views.IPPrefixSlice { return views.IPPrefixSliceOf(v.ж.Addresses) }
  125. func (v NodeView) AllowedIPs() views.IPPrefixSlice { return views.IPPrefixSliceOf(v.ж.AllowedIPs) }
  126. func (v NodeView) Endpoints() views.Slice[string] { return views.SliceOf(v.ж.Endpoints) }
  127. func (v NodeView) DERP() string { return v.ж.DERP }
  128. func (v NodeView) Hostinfo() HostinfoView { return v.ж.Hostinfo }
  129. func (v NodeView) Created() time.Time { return v.ж.Created }
  130. func (v NodeView) Cap() CapabilityVersion { return v.ж.Cap }
  131. func (v NodeView) Tags() views.Slice[string] { return views.SliceOf(v.ж.Tags) }
  132. func (v NodeView) PrimaryRoutes() views.IPPrefixSlice {
  133. return views.IPPrefixSliceOf(v.ж.PrimaryRoutes)
  134. }
  135. func (v NodeView) LastSeen() *time.Time {
  136. if v.ж.LastSeen == nil {
  137. return nil
  138. }
  139. x := *v.ж.LastSeen
  140. return &x
  141. }
  142. func (v NodeView) Online() *bool {
  143. if v.ж.Online == nil {
  144. return nil
  145. }
  146. x := *v.ж.Online
  147. return &x
  148. }
  149. func (v NodeView) KeepAlive() bool { return v.ж.KeepAlive }
  150. func (v NodeView) MachineAuthorized() bool { return v.ж.MachineAuthorized }
  151. func (v NodeView) Capabilities() views.Slice[string] { return views.SliceOf(v.ж.Capabilities) }
  152. func (v NodeView) UnsignedPeerAPIOnly() bool { return v.ж.UnsignedPeerAPIOnly }
  153. func (v NodeView) ComputedName() string { return v.ж.ComputedName }
  154. func (v NodeView) ComputedNameWithHost() string { return v.ж.ComputedNameWithHost }
  155. func (v NodeView) DataPlaneAuditLogID() string { return v.ж.DataPlaneAuditLogID }
  156. func (v NodeView) Expired() bool { return v.ж.Expired }
  157. func (v NodeView) SelfNodeV4MasqAddrForThisPeer() *netip.Addr {
  158. if v.ж.SelfNodeV4MasqAddrForThisPeer == nil {
  159. return nil
  160. }
  161. x := *v.ж.SelfNodeV4MasqAddrForThisPeer
  162. return &x
  163. }
  164. func (v NodeView) IsWireGuardOnly() bool { return v.ж.IsWireGuardOnly }
  165. func (v NodeView) Equal(v2 NodeView) bool { return v.ж.Equal(v2.ж) }
  166. // A compilation failure here means this code must be regenerated, with the command at the top of this file.
  167. var _NodeViewNeedsRegeneration = Node(struct {
  168. ID NodeID
  169. StableID StableNodeID
  170. Name string
  171. User UserID
  172. Sharer UserID
  173. Key key.NodePublic
  174. KeyExpiry time.Time
  175. KeySignature tkatype.MarshaledSignature
  176. Machine key.MachinePublic
  177. DiscoKey key.DiscoPublic
  178. Addresses []netip.Prefix
  179. AllowedIPs []netip.Prefix
  180. Endpoints []string
  181. DERP string
  182. Hostinfo HostinfoView
  183. Created time.Time
  184. Cap CapabilityVersion
  185. Tags []string
  186. PrimaryRoutes []netip.Prefix
  187. LastSeen *time.Time
  188. Online *bool
  189. KeepAlive bool
  190. MachineAuthorized bool
  191. Capabilities []string
  192. UnsignedPeerAPIOnly bool
  193. ComputedName string
  194. computedHostIfDifferent string
  195. ComputedNameWithHost string
  196. DataPlaneAuditLogID string
  197. Expired bool
  198. SelfNodeV4MasqAddrForThisPeer *netip.Addr
  199. IsWireGuardOnly bool
  200. }{})
  201. // View returns a readonly view of Hostinfo.
  202. func (p *Hostinfo) View() HostinfoView {
  203. return HostinfoView{ж: p}
  204. }
  205. // HostinfoView provides a read-only view over Hostinfo.
  206. //
  207. // Its methods should only be called if `Valid()` returns true.
  208. type HostinfoView struct {
  209. // ж is the underlying mutable value, named with a hard-to-type
  210. // character that looks pointy like a pointer.
  211. // It is named distinctively to make you think of how dangerous it is to escape
  212. // to callers. You must not let callers be able to mutate it.
  213. ж *Hostinfo
  214. }
  215. // Valid reports whether underlying value is non-nil.
  216. func (v HostinfoView) Valid() bool { return v.ж != nil }
  217. // AsStruct returns a clone of the underlying value which aliases no memory with
  218. // the original.
  219. func (v HostinfoView) AsStruct() *Hostinfo {
  220. if v.ж == nil {
  221. return nil
  222. }
  223. return v.ж.Clone()
  224. }
  225. func (v HostinfoView) MarshalJSON() ([]byte, error) { return json.Marshal(v.ж) }
  226. func (v *HostinfoView) UnmarshalJSON(b []byte) error {
  227. if v.ж != nil {
  228. return errors.New("already initialized")
  229. }
  230. if len(b) == 0 {
  231. return nil
  232. }
  233. var x Hostinfo
  234. if err := json.Unmarshal(b, &x); err != nil {
  235. return err
  236. }
  237. v.ж = &x
  238. return nil
  239. }
  240. func (v HostinfoView) IPNVersion() string { return v.ж.IPNVersion }
  241. func (v HostinfoView) FrontendLogID() string { return v.ж.FrontendLogID }
  242. func (v HostinfoView) BackendLogID() string { return v.ж.BackendLogID }
  243. func (v HostinfoView) OS() string { return v.ж.OS }
  244. func (v HostinfoView) OSVersion() string { return v.ж.OSVersion }
  245. func (v HostinfoView) Container() opt.Bool { return v.ж.Container }
  246. func (v HostinfoView) Env() string { return v.ж.Env }
  247. func (v HostinfoView) Distro() string { return v.ж.Distro }
  248. func (v HostinfoView) DistroVersion() string { return v.ж.DistroVersion }
  249. func (v HostinfoView) DistroCodeName() string { return v.ж.DistroCodeName }
  250. func (v HostinfoView) App() string { return v.ж.App }
  251. func (v HostinfoView) Desktop() opt.Bool { return v.ж.Desktop }
  252. func (v HostinfoView) Package() string { return v.ж.Package }
  253. func (v HostinfoView) DeviceModel() string { return v.ж.DeviceModel }
  254. func (v HostinfoView) PushDeviceToken() string { return v.ж.PushDeviceToken }
  255. func (v HostinfoView) Hostname() string { return v.ж.Hostname }
  256. func (v HostinfoView) ShieldsUp() bool { return v.ж.ShieldsUp }
  257. func (v HostinfoView) ShareeNode() bool { return v.ж.ShareeNode }
  258. func (v HostinfoView) NoLogsNoSupport() bool { return v.ж.NoLogsNoSupport }
  259. func (v HostinfoView) WireIngress() bool { return v.ж.WireIngress }
  260. func (v HostinfoView) AllowsUpdate() bool { return v.ж.AllowsUpdate }
  261. func (v HostinfoView) Machine() string { return v.ж.Machine }
  262. func (v HostinfoView) GoArch() string { return v.ж.GoArch }
  263. func (v HostinfoView) GoArchVar() string { return v.ж.GoArchVar }
  264. func (v HostinfoView) GoVersion() string { return v.ж.GoVersion }
  265. func (v HostinfoView) RoutableIPs() views.IPPrefixSlice {
  266. return views.IPPrefixSliceOf(v.ж.RoutableIPs)
  267. }
  268. func (v HostinfoView) RequestTags() views.Slice[string] { return views.SliceOf(v.ж.RequestTags) }
  269. func (v HostinfoView) Services() views.Slice[Service] { return views.SliceOf(v.ж.Services) }
  270. func (v HostinfoView) NetInfo() NetInfoView { return v.ж.NetInfo.View() }
  271. func (v HostinfoView) SSH_HostKeys() views.Slice[string] { return views.SliceOf(v.ж.SSH_HostKeys) }
  272. func (v HostinfoView) Cloud() string { return v.ж.Cloud }
  273. func (v HostinfoView) Userspace() opt.Bool { return v.ж.Userspace }
  274. func (v HostinfoView) UserspaceRouter() opt.Bool { return v.ж.UserspaceRouter }
  275. func (v HostinfoView) Equal(v2 HostinfoView) bool { return v.ж.Equal(v2.ж) }
  276. // A compilation failure here means this code must be regenerated, with the command at the top of this file.
  277. var _HostinfoViewNeedsRegeneration = Hostinfo(struct {
  278. IPNVersion string
  279. FrontendLogID string
  280. BackendLogID string
  281. OS string
  282. OSVersion string
  283. Container opt.Bool
  284. Env string
  285. Distro string
  286. DistroVersion string
  287. DistroCodeName string
  288. App string
  289. Desktop opt.Bool
  290. Package string
  291. DeviceModel string
  292. PushDeviceToken string
  293. Hostname string
  294. ShieldsUp bool
  295. ShareeNode bool
  296. NoLogsNoSupport bool
  297. WireIngress bool
  298. AllowsUpdate bool
  299. Machine string
  300. GoArch string
  301. GoArchVar string
  302. GoVersion string
  303. RoutableIPs []netip.Prefix
  304. RequestTags []string
  305. Services []Service
  306. NetInfo *NetInfo
  307. SSH_HostKeys []string
  308. Cloud string
  309. Userspace opt.Bool
  310. UserspaceRouter opt.Bool
  311. }{})
  312. // View returns a readonly view of NetInfo.
  313. func (p *NetInfo) View() NetInfoView {
  314. return NetInfoView{ж: p}
  315. }
  316. // NetInfoView provides a read-only view over NetInfo.
  317. //
  318. // Its methods should only be called if `Valid()` returns true.
  319. type NetInfoView struct {
  320. // ж is the underlying mutable value, named with a hard-to-type
  321. // character that looks pointy like a pointer.
  322. // It is named distinctively to make you think of how dangerous it is to escape
  323. // to callers. You must not let callers be able to mutate it.
  324. ж *NetInfo
  325. }
  326. // Valid reports whether underlying value is non-nil.
  327. func (v NetInfoView) Valid() bool { return v.ж != nil }
  328. // AsStruct returns a clone of the underlying value which aliases no memory with
  329. // the original.
  330. func (v NetInfoView) AsStruct() *NetInfo {
  331. if v.ж == nil {
  332. return nil
  333. }
  334. return v.ж.Clone()
  335. }
  336. func (v NetInfoView) MarshalJSON() ([]byte, error) { return json.Marshal(v.ж) }
  337. func (v *NetInfoView) UnmarshalJSON(b []byte) error {
  338. if v.ж != nil {
  339. return errors.New("already initialized")
  340. }
  341. if len(b) == 0 {
  342. return nil
  343. }
  344. var x NetInfo
  345. if err := json.Unmarshal(b, &x); err != nil {
  346. return err
  347. }
  348. v.ж = &x
  349. return nil
  350. }
  351. func (v NetInfoView) MappingVariesByDestIP() opt.Bool { return v.ж.MappingVariesByDestIP }
  352. func (v NetInfoView) HairPinning() opt.Bool { return v.ж.HairPinning }
  353. func (v NetInfoView) WorkingIPv6() opt.Bool { return v.ж.WorkingIPv6 }
  354. func (v NetInfoView) OSHasIPv6() opt.Bool { return v.ж.OSHasIPv6 }
  355. func (v NetInfoView) WorkingUDP() opt.Bool { return v.ж.WorkingUDP }
  356. func (v NetInfoView) WorkingICMPv4() opt.Bool { return v.ж.WorkingICMPv4 }
  357. func (v NetInfoView) HavePortMap() bool { return v.ж.HavePortMap }
  358. func (v NetInfoView) UPnP() opt.Bool { return v.ж.UPnP }
  359. func (v NetInfoView) PMP() opt.Bool { return v.ж.PMP }
  360. func (v NetInfoView) PCP() opt.Bool { return v.ж.PCP }
  361. func (v NetInfoView) PreferredDERP() int { return v.ж.PreferredDERP }
  362. func (v NetInfoView) LinkType() string { return v.ж.LinkType }
  363. func (v NetInfoView) DERPLatency() views.Map[string, float64] { return views.MapOf(v.ж.DERPLatency) }
  364. func (v NetInfoView) String() string { return v.ж.String() }
  365. // A compilation failure here means this code must be regenerated, with the command at the top of this file.
  366. var _NetInfoViewNeedsRegeneration = NetInfo(struct {
  367. MappingVariesByDestIP opt.Bool
  368. HairPinning opt.Bool
  369. WorkingIPv6 opt.Bool
  370. OSHasIPv6 opt.Bool
  371. WorkingUDP opt.Bool
  372. WorkingICMPv4 opt.Bool
  373. HavePortMap bool
  374. UPnP opt.Bool
  375. PMP opt.Bool
  376. PCP opt.Bool
  377. PreferredDERP int
  378. LinkType string
  379. DERPLatency map[string]float64
  380. }{})
  381. // View returns a readonly view of Login.
  382. func (p *Login) View() LoginView {
  383. return LoginView{ж: p}
  384. }
  385. // LoginView provides a read-only view over Login.
  386. //
  387. // Its methods should only be called if `Valid()` returns true.
  388. type LoginView struct {
  389. // ж is the underlying mutable value, named with a hard-to-type
  390. // character that looks pointy like a pointer.
  391. // It is named distinctively to make you think of how dangerous it is to escape
  392. // to callers. You must not let callers be able to mutate it.
  393. ж *Login
  394. }
  395. // Valid reports whether underlying value is non-nil.
  396. func (v LoginView) Valid() bool { return v.ж != nil }
  397. // AsStruct returns a clone of the underlying value which aliases no memory with
  398. // the original.
  399. func (v LoginView) AsStruct() *Login {
  400. if v.ж == nil {
  401. return nil
  402. }
  403. return v.ж.Clone()
  404. }
  405. func (v LoginView) MarshalJSON() ([]byte, error) { return json.Marshal(v.ж) }
  406. func (v *LoginView) UnmarshalJSON(b []byte) error {
  407. if v.ж != nil {
  408. return errors.New("already initialized")
  409. }
  410. if len(b) == 0 {
  411. return nil
  412. }
  413. var x Login
  414. if err := json.Unmarshal(b, &x); err != nil {
  415. return err
  416. }
  417. v.ж = &x
  418. return nil
  419. }
  420. func (v LoginView) ID() LoginID { return v.ж.ID }
  421. func (v LoginView) Provider() string { return v.ж.Provider }
  422. func (v LoginView) LoginName() string { return v.ж.LoginName }
  423. func (v LoginView) DisplayName() string { return v.ж.DisplayName }
  424. func (v LoginView) ProfilePicURL() string { return v.ж.ProfilePicURL }
  425. func (v LoginView) Domain() string { return v.ж.Domain }
  426. // A compilation failure here means this code must be regenerated, with the command at the top of this file.
  427. var _LoginViewNeedsRegeneration = Login(struct {
  428. _ structs.Incomparable
  429. ID LoginID
  430. Provider string
  431. LoginName string
  432. DisplayName string
  433. ProfilePicURL string
  434. Domain string
  435. }{})
  436. // View returns a readonly view of DNSConfig.
  437. func (p *DNSConfig) View() DNSConfigView {
  438. return DNSConfigView{ж: p}
  439. }
  440. // DNSConfigView provides a read-only view over DNSConfig.
  441. //
  442. // Its methods should only be called if `Valid()` returns true.
  443. type DNSConfigView struct {
  444. // ж is the underlying mutable value, named with a hard-to-type
  445. // character that looks pointy like a pointer.
  446. // It is named distinctively to make you think of how dangerous it is to escape
  447. // to callers. You must not let callers be able to mutate it.
  448. ж *DNSConfig
  449. }
  450. // Valid reports whether underlying value is non-nil.
  451. func (v DNSConfigView) Valid() bool { return v.ж != nil }
  452. // AsStruct returns a clone of the underlying value which aliases no memory with
  453. // the original.
  454. func (v DNSConfigView) AsStruct() *DNSConfig {
  455. if v.ж == nil {
  456. return nil
  457. }
  458. return v.ж.Clone()
  459. }
  460. func (v DNSConfigView) MarshalJSON() ([]byte, error) { return json.Marshal(v.ж) }
  461. func (v *DNSConfigView) UnmarshalJSON(b []byte) error {
  462. if v.ж != nil {
  463. return errors.New("already initialized")
  464. }
  465. if len(b) == 0 {
  466. return nil
  467. }
  468. var x DNSConfig
  469. if err := json.Unmarshal(b, &x); err != nil {
  470. return err
  471. }
  472. v.ж = &x
  473. return nil
  474. }
  475. func (v DNSConfigView) Resolvers() views.SliceView[*dnstype.Resolver, dnstype.ResolverView] {
  476. return views.SliceOfViews[*dnstype.Resolver, dnstype.ResolverView](v.ж.Resolvers)
  477. }
  478. func (v DNSConfigView) Routes() views.MapFn[string, []*dnstype.Resolver, views.SliceView[*dnstype.Resolver, dnstype.ResolverView]] {
  479. return views.MapFnOf(v.ж.Routes, func(t []*dnstype.Resolver) views.SliceView[*dnstype.Resolver, dnstype.ResolverView] {
  480. return views.SliceOfViews[*dnstype.Resolver, dnstype.ResolverView](t)
  481. })
  482. }
  483. func (v DNSConfigView) FallbackResolvers() views.SliceView[*dnstype.Resolver, dnstype.ResolverView] {
  484. return views.SliceOfViews[*dnstype.Resolver, dnstype.ResolverView](v.ж.FallbackResolvers)
  485. }
  486. func (v DNSConfigView) Domains() views.Slice[string] { return views.SliceOf(v.ж.Domains) }
  487. func (v DNSConfigView) Proxied() bool { return v.ж.Proxied }
  488. func (v DNSConfigView) Nameservers() views.Slice[netip.Addr] { return views.SliceOf(v.ж.Nameservers) }
  489. func (v DNSConfigView) CertDomains() views.Slice[string] { return views.SliceOf(v.ж.CertDomains) }
  490. func (v DNSConfigView) ExtraRecords() views.Slice[DNSRecord] { return views.SliceOf(v.ж.ExtraRecords) }
  491. func (v DNSConfigView) ExitNodeFilteredSet() views.Slice[string] {
  492. return views.SliceOf(v.ж.ExitNodeFilteredSet)
  493. }
  494. // A compilation failure here means this code must be regenerated, with the command at the top of this file.
  495. var _DNSConfigViewNeedsRegeneration = DNSConfig(struct {
  496. Resolvers []*dnstype.Resolver
  497. Routes map[string][]*dnstype.Resolver
  498. FallbackResolvers []*dnstype.Resolver
  499. Domains []string
  500. Proxied bool
  501. Nameservers []netip.Addr
  502. CertDomains []string
  503. ExtraRecords []DNSRecord
  504. ExitNodeFilteredSet []string
  505. }{})
  506. // View returns a readonly view of RegisterResponse.
  507. func (p *RegisterResponse) View() RegisterResponseView {
  508. return RegisterResponseView{ж: p}
  509. }
  510. // RegisterResponseView provides a read-only view over RegisterResponse.
  511. //
  512. // Its methods should only be called if `Valid()` returns true.
  513. type RegisterResponseView struct {
  514. // ж is the underlying mutable value, named with a hard-to-type
  515. // character that looks pointy like a pointer.
  516. // It is named distinctively to make you think of how dangerous it is to escape
  517. // to callers. You must not let callers be able to mutate it.
  518. ж *RegisterResponse
  519. }
  520. // Valid reports whether underlying value is non-nil.
  521. func (v RegisterResponseView) Valid() bool { return v.ж != nil }
  522. // AsStruct returns a clone of the underlying value which aliases no memory with
  523. // the original.
  524. func (v RegisterResponseView) AsStruct() *RegisterResponse {
  525. if v.ж == nil {
  526. return nil
  527. }
  528. return v.ж.Clone()
  529. }
  530. func (v RegisterResponseView) MarshalJSON() ([]byte, error) { return json.Marshal(v.ж) }
  531. func (v *RegisterResponseView) UnmarshalJSON(b []byte) error {
  532. if v.ж != nil {
  533. return errors.New("already initialized")
  534. }
  535. if len(b) == 0 {
  536. return nil
  537. }
  538. var x RegisterResponse
  539. if err := json.Unmarshal(b, &x); err != nil {
  540. return err
  541. }
  542. v.ж = &x
  543. return nil
  544. }
  545. func (v RegisterResponseView) User() UserView { return v.ж.User.View() }
  546. func (v RegisterResponseView) Login() Login { return v.ж.Login }
  547. func (v RegisterResponseView) NodeKeyExpired() bool { return v.ж.NodeKeyExpired }
  548. func (v RegisterResponseView) MachineAuthorized() bool { return v.ж.MachineAuthorized }
  549. func (v RegisterResponseView) AuthURL() string { return v.ж.AuthURL }
  550. func (v RegisterResponseView) NodeKeySignature() mem.RO { return mem.B(v.ж.NodeKeySignature) }
  551. func (v RegisterResponseView) Error() string { return v.ж.Error }
  552. // A compilation failure here means this code must be regenerated, with the command at the top of this file.
  553. var _RegisterResponseViewNeedsRegeneration = RegisterResponse(struct {
  554. User User
  555. Login Login
  556. NodeKeyExpired bool
  557. MachineAuthorized bool
  558. AuthURL string
  559. NodeKeySignature tkatype.MarshaledSignature
  560. Error string
  561. }{})
  562. // View returns a readonly view of DERPRegion.
  563. func (p *DERPRegion) View() DERPRegionView {
  564. return DERPRegionView{ж: p}
  565. }
  566. // DERPRegionView provides a read-only view over DERPRegion.
  567. //
  568. // Its methods should only be called if `Valid()` returns true.
  569. type DERPRegionView struct {
  570. // ж is the underlying mutable value, named with a hard-to-type
  571. // character that looks pointy like a pointer.
  572. // It is named distinctively to make you think of how dangerous it is to escape
  573. // to callers. You must not let callers be able to mutate it.
  574. ж *DERPRegion
  575. }
  576. // Valid reports whether underlying value is non-nil.
  577. func (v DERPRegionView) Valid() bool { return v.ж != nil }
  578. // AsStruct returns a clone of the underlying value which aliases no memory with
  579. // the original.
  580. func (v DERPRegionView) AsStruct() *DERPRegion {
  581. if v.ж == nil {
  582. return nil
  583. }
  584. return v.ж.Clone()
  585. }
  586. func (v DERPRegionView) MarshalJSON() ([]byte, error) { return json.Marshal(v.ж) }
  587. func (v *DERPRegionView) UnmarshalJSON(b []byte) error {
  588. if v.ж != nil {
  589. return errors.New("already initialized")
  590. }
  591. if len(b) == 0 {
  592. return nil
  593. }
  594. var x DERPRegion
  595. if err := json.Unmarshal(b, &x); err != nil {
  596. return err
  597. }
  598. v.ж = &x
  599. return nil
  600. }
  601. func (v DERPRegionView) RegionID() int { return v.ж.RegionID }
  602. func (v DERPRegionView) RegionCode() string { return v.ж.RegionCode }
  603. func (v DERPRegionView) RegionName() string { return v.ж.RegionName }
  604. func (v DERPRegionView) Avoid() bool { return v.ж.Avoid }
  605. func (v DERPRegionView) Nodes() views.SliceView[*DERPNode, DERPNodeView] {
  606. return views.SliceOfViews[*DERPNode, DERPNodeView](v.ж.Nodes)
  607. }
  608. // A compilation failure here means this code must be regenerated, with the command at the top of this file.
  609. var _DERPRegionViewNeedsRegeneration = DERPRegion(struct {
  610. RegionID int
  611. RegionCode string
  612. RegionName string
  613. Avoid bool
  614. Nodes []*DERPNode
  615. }{})
  616. // View returns a readonly view of DERPMap.
  617. func (p *DERPMap) View() DERPMapView {
  618. return DERPMapView{ж: p}
  619. }
  620. // DERPMapView provides a read-only view over DERPMap.
  621. //
  622. // Its methods should only be called if `Valid()` returns true.
  623. type DERPMapView struct {
  624. // ж is the underlying mutable value, named with a hard-to-type
  625. // character that looks pointy like a pointer.
  626. // It is named distinctively to make you think of how dangerous it is to escape
  627. // to callers. You must not let callers be able to mutate it.
  628. ж *DERPMap
  629. }
  630. // Valid reports whether underlying value is non-nil.
  631. func (v DERPMapView) Valid() bool { return v.ж != nil }
  632. // AsStruct returns a clone of the underlying value which aliases no memory with
  633. // the original.
  634. func (v DERPMapView) AsStruct() *DERPMap {
  635. if v.ж == nil {
  636. return nil
  637. }
  638. return v.ж.Clone()
  639. }
  640. func (v DERPMapView) MarshalJSON() ([]byte, error) { return json.Marshal(v.ж) }
  641. func (v *DERPMapView) UnmarshalJSON(b []byte) error {
  642. if v.ж != nil {
  643. return errors.New("already initialized")
  644. }
  645. if len(b) == 0 {
  646. return nil
  647. }
  648. var x DERPMap
  649. if err := json.Unmarshal(b, &x); err != nil {
  650. return err
  651. }
  652. v.ж = &x
  653. return nil
  654. }
  655. func (v DERPMapView) Regions() views.MapFn[int, *DERPRegion, DERPRegionView] {
  656. return views.MapFnOf(v.ж.Regions, func(t *DERPRegion) DERPRegionView {
  657. return t.View()
  658. })
  659. }
  660. func (v DERPMapView) OmitDefaultRegions() bool { return v.ж.OmitDefaultRegions }
  661. // A compilation failure here means this code must be regenerated, with the command at the top of this file.
  662. var _DERPMapViewNeedsRegeneration = DERPMap(struct {
  663. Regions map[int]*DERPRegion
  664. OmitDefaultRegions bool
  665. }{})
  666. // View returns a readonly view of DERPNode.
  667. func (p *DERPNode) View() DERPNodeView {
  668. return DERPNodeView{ж: p}
  669. }
  670. // DERPNodeView provides a read-only view over DERPNode.
  671. //
  672. // Its methods should only be called if `Valid()` returns true.
  673. type DERPNodeView struct {
  674. // ж is the underlying mutable value, named with a hard-to-type
  675. // character that looks pointy like a pointer.
  676. // It is named distinctively to make you think of how dangerous it is to escape
  677. // to callers. You must not let callers be able to mutate it.
  678. ж *DERPNode
  679. }
  680. // Valid reports whether underlying value is non-nil.
  681. func (v DERPNodeView) Valid() bool { return v.ж != nil }
  682. // AsStruct returns a clone of the underlying value which aliases no memory with
  683. // the original.
  684. func (v DERPNodeView) AsStruct() *DERPNode {
  685. if v.ж == nil {
  686. return nil
  687. }
  688. return v.ж.Clone()
  689. }
  690. func (v DERPNodeView) MarshalJSON() ([]byte, error) { return json.Marshal(v.ж) }
  691. func (v *DERPNodeView) UnmarshalJSON(b []byte) error {
  692. if v.ж != nil {
  693. return errors.New("already initialized")
  694. }
  695. if len(b) == 0 {
  696. return nil
  697. }
  698. var x DERPNode
  699. if err := json.Unmarshal(b, &x); err != nil {
  700. return err
  701. }
  702. v.ж = &x
  703. return nil
  704. }
  705. func (v DERPNodeView) Name() string { return v.ж.Name }
  706. func (v DERPNodeView) RegionID() int { return v.ж.RegionID }
  707. func (v DERPNodeView) HostName() string { return v.ж.HostName }
  708. func (v DERPNodeView) CertName() string { return v.ж.CertName }
  709. func (v DERPNodeView) IPv4() string { return v.ж.IPv4 }
  710. func (v DERPNodeView) IPv6() string { return v.ж.IPv6 }
  711. func (v DERPNodeView) STUNPort() int { return v.ж.STUNPort }
  712. func (v DERPNodeView) STUNOnly() bool { return v.ж.STUNOnly }
  713. func (v DERPNodeView) DERPPort() int { return v.ж.DERPPort }
  714. func (v DERPNodeView) InsecureForTests() bool { return v.ж.InsecureForTests }
  715. func (v DERPNodeView) STUNTestIP() string { return v.ж.STUNTestIP }
  716. func (v DERPNodeView) CanPort80() bool { return v.ж.CanPort80 }
  717. // A compilation failure here means this code must be regenerated, with the command at the top of this file.
  718. var _DERPNodeViewNeedsRegeneration = DERPNode(struct {
  719. Name string
  720. RegionID int
  721. HostName string
  722. CertName string
  723. IPv4 string
  724. IPv6 string
  725. STUNPort int
  726. STUNOnly bool
  727. DERPPort int
  728. InsecureForTests bool
  729. STUNTestIP string
  730. CanPort80 bool
  731. }{})
  732. // View returns a readonly view of SSHRule.
  733. func (p *SSHRule) View() SSHRuleView {
  734. return SSHRuleView{ж: p}
  735. }
  736. // SSHRuleView provides a read-only view over SSHRule.
  737. //
  738. // Its methods should only be called if `Valid()` returns true.
  739. type SSHRuleView struct {
  740. // ж is the underlying mutable value, named with a hard-to-type
  741. // character that looks pointy like a pointer.
  742. // It is named distinctively to make you think of how dangerous it is to escape
  743. // to callers. You must not let callers be able to mutate it.
  744. ж *SSHRule
  745. }
  746. // Valid reports whether underlying value is non-nil.
  747. func (v SSHRuleView) Valid() bool { return v.ж != nil }
  748. // AsStruct returns a clone of the underlying value which aliases no memory with
  749. // the original.
  750. func (v SSHRuleView) AsStruct() *SSHRule {
  751. if v.ж == nil {
  752. return nil
  753. }
  754. return v.ж.Clone()
  755. }
  756. func (v SSHRuleView) MarshalJSON() ([]byte, error) { return json.Marshal(v.ж) }
  757. func (v *SSHRuleView) UnmarshalJSON(b []byte) error {
  758. if v.ж != nil {
  759. return errors.New("already initialized")
  760. }
  761. if len(b) == 0 {
  762. return nil
  763. }
  764. var x SSHRule
  765. if err := json.Unmarshal(b, &x); err != nil {
  766. return err
  767. }
  768. v.ж = &x
  769. return nil
  770. }
  771. func (v SSHRuleView) RuleExpires() *time.Time {
  772. if v.ж.RuleExpires == nil {
  773. return nil
  774. }
  775. x := *v.ж.RuleExpires
  776. return &x
  777. }
  778. func (v SSHRuleView) Principals() views.SliceView[*SSHPrincipal, SSHPrincipalView] {
  779. return views.SliceOfViews[*SSHPrincipal, SSHPrincipalView](v.ж.Principals)
  780. }
  781. func (v SSHRuleView) SSHUsers() views.Map[string, string] { return views.MapOf(v.ж.SSHUsers) }
  782. func (v SSHRuleView) Action() SSHActionView { return v.ж.Action.View() }
  783. // A compilation failure here means this code must be regenerated, with the command at the top of this file.
  784. var _SSHRuleViewNeedsRegeneration = SSHRule(struct {
  785. RuleExpires *time.Time
  786. Principals []*SSHPrincipal
  787. SSHUsers map[string]string
  788. Action *SSHAction
  789. }{})
  790. // View returns a readonly view of SSHAction.
  791. func (p *SSHAction) View() SSHActionView {
  792. return SSHActionView{ж: p}
  793. }
  794. // SSHActionView provides a read-only view over SSHAction.
  795. //
  796. // Its methods should only be called if `Valid()` returns true.
  797. type SSHActionView struct {
  798. // ж is the underlying mutable value, named with a hard-to-type
  799. // character that looks pointy like a pointer.
  800. // It is named distinctively to make you think of how dangerous it is to escape
  801. // to callers. You must not let callers be able to mutate it.
  802. ж *SSHAction
  803. }
  804. // Valid reports whether underlying value is non-nil.
  805. func (v SSHActionView) Valid() bool { return v.ж != nil }
  806. // AsStruct returns a clone of the underlying value which aliases no memory with
  807. // the original.
  808. func (v SSHActionView) AsStruct() *SSHAction {
  809. if v.ж == nil {
  810. return nil
  811. }
  812. return v.ж.Clone()
  813. }
  814. func (v SSHActionView) MarshalJSON() ([]byte, error) { return json.Marshal(v.ж) }
  815. func (v *SSHActionView) UnmarshalJSON(b []byte) error {
  816. if v.ж != nil {
  817. return errors.New("already initialized")
  818. }
  819. if len(b) == 0 {
  820. return nil
  821. }
  822. var x SSHAction
  823. if err := json.Unmarshal(b, &x); err != nil {
  824. return err
  825. }
  826. v.ж = &x
  827. return nil
  828. }
  829. func (v SSHActionView) Message() string { return v.ж.Message }
  830. func (v SSHActionView) Reject() bool { return v.ж.Reject }
  831. func (v SSHActionView) Accept() bool { return v.ж.Accept }
  832. func (v SSHActionView) SessionDuration() time.Duration { return v.ж.SessionDuration }
  833. func (v SSHActionView) AllowAgentForwarding() bool { return v.ж.AllowAgentForwarding }
  834. func (v SSHActionView) HoldAndDelegate() string { return v.ж.HoldAndDelegate }
  835. func (v SSHActionView) AllowLocalPortForwarding() bool { return v.ж.AllowLocalPortForwarding }
  836. func (v SSHActionView) Recorders() views.Slice[netip.AddrPort] { return views.SliceOf(v.ж.Recorders) }
  837. func (v SSHActionView) OnRecordingFailure() *SSHRecorderFailureAction {
  838. if v.ж.OnRecordingFailure == nil {
  839. return nil
  840. }
  841. x := *v.ж.OnRecordingFailure
  842. return &x
  843. }
  844. // A compilation failure here means this code must be regenerated, with the command at the top of this file.
  845. var _SSHActionViewNeedsRegeneration = SSHAction(struct {
  846. Message string
  847. Reject bool
  848. Accept bool
  849. SessionDuration time.Duration
  850. AllowAgentForwarding bool
  851. HoldAndDelegate string
  852. AllowLocalPortForwarding bool
  853. Recorders []netip.AddrPort
  854. OnRecordingFailure *SSHRecorderFailureAction
  855. }{})
  856. // View returns a readonly view of SSHPrincipal.
  857. func (p *SSHPrincipal) View() SSHPrincipalView {
  858. return SSHPrincipalView{ж: p}
  859. }
  860. // SSHPrincipalView provides a read-only view over SSHPrincipal.
  861. //
  862. // Its methods should only be called if `Valid()` returns true.
  863. type SSHPrincipalView struct {
  864. // ж is the underlying mutable value, named with a hard-to-type
  865. // character that looks pointy like a pointer.
  866. // It is named distinctively to make you think of how dangerous it is to escape
  867. // to callers. You must not let callers be able to mutate it.
  868. ж *SSHPrincipal
  869. }
  870. // Valid reports whether underlying value is non-nil.
  871. func (v SSHPrincipalView) Valid() bool { return v.ж != nil }
  872. // AsStruct returns a clone of the underlying value which aliases no memory with
  873. // the original.
  874. func (v SSHPrincipalView) AsStruct() *SSHPrincipal {
  875. if v.ж == nil {
  876. return nil
  877. }
  878. return v.ж.Clone()
  879. }
  880. func (v SSHPrincipalView) MarshalJSON() ([]byte, error) { return json.Marshal(v.ж) }
  881. func (v *SSHPrincipalView) UnmarshalJSON(b []byte) error {
  882. if v.ж != nil {
  883. return errors.New("already initialized")
  884. }
  885. if len(b) == 0 {
  886. return nil
  887. }
  888. var x SSHPrincipal
  889. if err := json.Unmarshal(b, &x); err != nil {
  890. return err
  891. }
  892. v.ж = &x
  893. return nil
  894. }
  895. func (v SSHPrincipalView) Node() StableNodeID { return v.ж.Node }
  896. func (v SSHPrincipalView) NodeIP() string { return v.ж.NodeIP }
  897. func (v SSHPrincipalView) UserLogin() string { return v.ж.UserLogin }
  898. func (v SSHPrincipalView) Any() bool { return v.ж.Any }
  899. func (v SSHPrincipalView) PubKeys() views.Slice[string] { return views.SliceOf(v.ж.PubKeys) }
  900. // A compilation failure here means this code must be regenerated, with the command at the top of this file.
  901. var _SSHPrincipalViewNeedsRegeneration = SSHPrincipal(struct {
  902. Node StableNodeID
  903. NodeIP string
  904. UserLogin string
  905. Any bool
  906. PubKeys []string
  907. }{})
  908. // View returns a readonly view of ControlDialPlan.
  909. func (p *ControlDialPlan) View() ControlDialPlanView {
  910. return ControlDialPlanView{ж: p}
  911. }
  912. // ControlDialPlanView provides a read-only view over ControlDialPlan.
  913. //
  914. // Its methods should only be called if `Valid()` returns true.
  915. type ControlDialPlanView struct {
  916. // ж is the underlying mutable value, named with a hard-to-type
  917. // character that looks pointy like a pointer.
  918. // It is named distinctively to make you think of how dangerous it is to escape
  919. // to callers. You must not let callers be able to mutate it.
  920. ж *ControlDialPlan
  921. }
  922. // Valid reports whether underlying value is non-nil.
  923. func (v ControlDialPlanView) Valid() bool { return v.ж != nil }
  924. // AsStruct returns a clone of the underlying value which aliases no memory with
  925. // the original.
  926. func (v ControlDialPlanView) AsStruct() *ControlDialPlan {
  927. if v.ж == nil {
  928. return nil
  929. }
  930. return v.ж.Clone()
  931. }
  932. func (v ControlDialPlanView) MarshalJSON() ([]byte, error) { return json.Marshal(v.ж) }
  933. func (v *ControlDialPlanView) UnmarshalJSON(b []byte) error {
  934. if v.ж != nil {
  935. return errors.New("already initialized")
  936. }
  937. if len(b) == 0 {
  938. return nil
  939. }
  940. var x ControlDialPlan
  941. if err := json.Unmarshal(b, &x); err != nil {
  942. return err
  943. }
  944. v.ж = &x
  945. return nil
  946. }
  947. func (v ControlDialPlanView) Candidates() views.Slice[ControlIPCandidate] {
  948. return views.SliceOf(v.ж.Candidates)
  949. }
  950. // A compilation failure here means this code must be regenerated, with the command at the top of this file.
  951. var _ControlDialPlanViewNeedsRegeneration = ControlDialPlan(struct {
  952. Candidates []ControlIPCandidate
  953. }{})