tailcfg_view.go 49 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449
  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. "tailscale.com/types/dnstype"
  11. "tailscale.com/types/key"
  12. "tailscale.com/types/opt"
  13. "tailscale.com/types/structs"
  14. "tailscale.com/types/tkatype"
  15. "tailscale.com/types/views"
  16. )
  17. //go:generate go run tailscale.com/cmd/cloner -clonefunc=true -type=User,Node,Hostinfo,NetInfo,Login,DNSConfig,RegisterResponse,RegisterResponseAuth,RegisterRequest,DERPHomeParams,DERPRegion,DERPMap,DERPNode,SSHRule,SSHAction,SSHPrincipal,ControlDialPlan,Location,UserProfile
  18. // View returns a readonly view of User.
  19. func (p *User) View() UserView {
  20. return UserView{ж: p}
  21. }
  22. // UserView provides a read-only view over User.
  23. //
  24. // Its methods should only be called if `Valid()` returns true.
  25. type UserView struct {
  26. // ж is the underlying mutable value, named with a hard-to-type
  27. // character that looks pointy like a pointer.
  28. // It is named distinctively to make you think of how dangerous it is to escape
  29. // to callers. You must not let callers be able to mutate it.
  30. ж *User
  31. }
  32. // Valid reports whether underlying value is non-nil.
  33. func (v UserView) Valid() bool { return v.ж != nil }
  34. // AsStruct returns a clone of the underlying value which aliases no memory with
  35. // the original.
  36. func (v UserView) AsStruct() *User {
  37. if v.ж == nil {
  38. return nil
  39. }
  40. return v.ж.Clone()
  41. }
  42. func (v UserView) MarshalJSON() ([]byte, error) { return json.Marshal(v.ж) }
  43. func (v *UserView) UnmarshalJSON(b []byte) error {
  44. if v.ж != nil {
  45. return errors.New("already initialized")
  46. }
  47. if len(b) == 0 {
  48. return nil
  49. }
  50. var x User
  51. if err := json.Unmarshal(b, &x); err != nil {
  52. return err
  53. }
  54. v.ж = &x
  55. return nil
  56. }
  57. func (v UserView) ID() UserID { return v.ж.ID }
  58. func (v UserView) LoginName() string { return v.ж.LoginName }
  59. func (v UserView) DisplayName() string { return v.ж.DisplayName }
  60. func (v UserView) ProfilePicURL() string { return v.ж.ProfilePicURL }
  61. func (v UserView) Logins() views.Slice[LoginID] { return views.SliceOf(v.ж.Logins) }
  62. func (v UserView) Created() time.Time { return v.ж.Created }
  63. // A compilation failure here means this code must be regenerated, with the command at the top of this file.
  64. var _UserViewNeedsRegeneration = User(struct {
  65. ID UserID
  66. LoginName string
  67. DisplayName string
  68. ProfilePicURL string
  69. Logins []LoginID
  70. Created time.Time
  71. }{})
  72. // View returns a readonly view of Node.
  73. func (p *Node) View() NodeView {
  74. return NodeView{ж: p}
  75. }
  76. // NodeView provides a read-only view over Node.
  77. //
  78. // Its methods should only be called if `Valid()` returns true.
  79. type NodeView struct {
  80. // ж is the underlying mutable value, named with a hard-to-type
  81. // character that looks pointy like a pointer.
  82. // It is named distinctively to make you think of how dangerous it is to escape
  83. // to callers. You must not let callers be able to mutate it.
  84. ж *Node
  85. }
  86. // Valid reports whether underlying value is non-nil.
  87. func (v NodeView) Valid() bool { return v.ж != nil }
  88. // AsStruct returns a clone of the underlying value which aliases no memory with
  89. // the original.
  90. func (v NodeView) AsStruct() *Node {
  91. if v.ж == nil {
  92. return nil
  93. }
  94. return v.ж.Clone()
  95. }
  96. func (v NodeView) MarshalJSON() ([]byte, error) { return json.Marshal(v.ж) }
  97. func (v *NodeView) UnmarshalJSON(b []byte) error {
  98. if v.ж != nil {
  99. return errors.New("already initialized")
  100. }
  101. if len(b) == 0 {
  102. return nil
  103. }
  104. var x Node
  105. if err := json.Unmarshal(b, &x); err != nil {
  106. return err
  107. }
  108. v.ж = &x
  109. return nil
  110. }
  111. func (v NodeView) ID() NodeID { return v.ж.ID }
  112. func (v NodeView) StableID() StableNodeID { return v.ж.StableID }
  113. func (v NodeView) Name() string { return v.ж.Name }
  114. func (v NodeView) User() UserID { return v.ж.User }
  115. func (v NodeView) Sharer() UserID { return v.ж.Sharer }
  116. func (v NodeView) Key() key.NodePublic { return v.ж.Key }
  117. func (v NodeView) KeyExpiry() time.Time { return v.ж.KeyExpiry }
  118. func (v NodeView) KeySignature() views.ByteSlice[tkatype.MarshaledSignature] {
  119. return views.ByteSliceOf(v.ж.KeySignature)
  120. }
  121. func (v NodeView) Machine() key.MachinePublic { return v.ж.Machine }
  122. func (v NodeView) DiscoKey() key.DiscoPublic { return v.ж.DiscoKey }
  123. func (v NodeView) Addresses() views.Slice[netip.Prefix] { return views.SliceOf(v.ж.Addresses) }
  124. func (v NodeView) AllowedIPs() views.Slice[netip.Prefix] { return views.SliceOf(v.ж.AllowedIPs) }
  125. func (v NodeView) Endpoints() views.Slice[netip.AddrPort] { return views.SliceOf(v.ж.Endpoints) }
  126. func (v NodeView) DERP() string { return v.ж.DERP }
  127. func (v NodeView) Hostinfo() HostinfoView { return v.ж.Hostinfo }
  128. func (v NodeView) Created() time.Time { return v.ж.Created }
  129. func (v NodeView) Cap() CapabilityVersion { return v.ж.Cap }
  130. func (v NodeView) Tags() views.Slice[string] { return views.SliceOf(v.ж.Tags) }
  131. func (v NodeView) PrimaryRoutes() views.Slice[netip.Prefix] { return views.SliceOf(v.ж.PrimaryRoutes) }
  132. func (v NodeView) LastSeen() *time.Time {
  133. if v.ж.LastSeen == nil {
  134. return nil
  135. }
  136. x := *v.ж.LastSeen
  137. return &x
  138. }
  139. func (v NodeView) Online() *bool {
  140. if v.ж.Online == nil {
  141. return nil
  142. }
  143. x := *v.ж.Online
  144. return &x
  145. }
  146. func (v NodeView) MachineAuthorized() bool { return v.ж.MachineAuthorized }
  147. func (v NodeView) Capabilities() views.Slice[NodeCapability] { return views.SliceOf(v.ж.Capabilities) }
  148. func (v NodeView) CapMap() views.MapFn[NodeCapability, []RawMessage, views.Slice[RawMessage]] {
  149. return views.MapFnOf(v.ж.CapMap, func(t []RawMessage) views.Slice[RawMessage] {
  150. return views.SliceOf(t)
  151. })
  152. }
  153. func (v NodeView) UnsignedPeerAPIOnly() bool { return v.ж.UnsignedPeerAPIOnly }
  154. func (v NodeView) ComputedName() string { return v.ж.ComputedName }
  155. func (v NodeView) ComputedNameWithHost() string { return v.ж.ComputedNameWithHost }
  156. func (v NodeView) DataPlaneAuditLogID() string { return v.ж.DataPlaneAuditLogID }
  157. func (v NodeView) Expired() bool { return v.ж.Expired }
  158. func (v NodeView) SelfNodeV4MasqAddrForThisPeer() *netip.Addr {
  159. if v.ж.SelfNodeV4MasqAddrForThisPeer == nil {
  160. return nil
  161. }
  162. x := *v.ж.SelfNodeV4MasqAddrForThisPeer
  163. return &x
  164. }
  165. func (v NodeView) SelfNodeV6MasqAddrForThisPeer() *netip.Addr {
  166. if v.ж.SelfNodeV6MasqAddrForThisPeer == nil {
  167. return nil
  168. }
  169. x := *v.ж.SelfNodeV6MasqAddrForThisPeer
  170. return &x
  171. }
  172. func (v NodeView) IsWireGuardOnly() bool { return v.ж.IsWireGuardOnly }
  173. func (v NodeView) ExitNodeDNSResolvers() views.SliceView[*dnstype.Resolver, dnstype.ResolverView] {
  174. return views.SliceOfViews[*dnstype.Resolver, dnstype.ResolverView](v.ж.ExitNodeDNSResolvers)
  175. }
  176. func (v NodeView) Equal(v2 NodeView) bool { return v.ж.Equal(v2.ж) }
  177. // A compilation failure here means this code must be regenerated, with the command at the top of this file.
  178. var _NodeViewNeedsRegeneration = Node(struct {
  179. ID NodeID
  180. StableID StableNodeID
  181. Name string
  182. User UserID
  183. Sharer UserID
  184. Key key.NodePublic
  185. KeyExpiry time.Time
  186. KeySignature tkatype.MarshaledSignature
  187. Machine key.MachinePublic
  188. DiscoKey key.DiscoPublic
  189. Addresses []netip.Prefix
  190. AllowedIPs []netip.Prefix
  191. Endpoints []netip.AddrPort
  192. DERP string
  193. Hostinfo HostinfoView
  194. Created time.Time
  195. Cap CapabilityVersion
  196. Tags []string
  197. PrimaryRoutes []netip.Prefix
  198. LastSeen *time.Time
  199. Online *bool
  200. MachineAuthorized bool
  201. Capabilities []NodeCapability
  202. CapMap NodeCapMap
  203. UnsignedPeerAPIOnly bool
  204. ComputedName string
  205. computedHostIfDifferent string
  206. ComputedNameWithHost string
  207. DataPlaneAuditLogID string
  208. Expired bool
  209. SelfNodeV4MasqAddrForThisPeer *netip.Addr
  210. SelfNodeV6MasqAddrForThisPeer *netip.Addr
  211. IsWireGuardOnly bool
  212. ExitNodeDNSResolvers []*dnstype.Resolver
  213. }{})
  214. // View returns a readonly view of Hostinfo.
  215. func (p *Hostinfo) View() HostinfoView {
  216. return HostinfoView{ж: p}
  217. }
  218. // HostinfoView provides a read-only view over Hostinfo.
  219. //
  220. // Its methods should only be called if `Valid()` returns true.
  221. type HostinfoView struct {
  222. // ж is the underlying mutable value, named with a hard-to-type
  223. // character that looks pointy like a pointer.
  224. // It is named distinctively to make you think of how dangerous it is to escape
  225. // to callers. You must not let callers be able to mutate it.
  226. ж *Hostinfo
  227. }
  228. // Valid reports whether underlying value is non-nil.
  229. func (v HostinfoView) Valid() bool { return v.ж != nil }
  230. // AsStruct returns a clone of the underlying value which aliases no memory with
  231. // the original.
  232. func (v HostinfoView) AsStruct() *Hostinfo {
  233. if v.ж == nil {
  234. return nil
  235. }
  236. return v.ж.Clone()
  237. }
  238. func (v HostinfoView) MarshalJSON() ([]byte, error) { return json.Marshal(v.ж) }
  239. func (v *HostinfoView) UnmarshalJSON(b []byte) error {
  240. if v.ж != nil {
  241. return errors.New("already initialized")
  242. }
  243. if len(b) == 0 {
  244. return nil
  245. }
  246. var x Hostinfo
  247. if err := json.Unmarshal(b, &x); err != nil {
  248. return err
  249. }
  250. v.ж = &x
  251. return nil
  252. }
  253. func (v HostinfoView) IPNVersion() string { return v.ж.IPNVersion }
  254. func (v HostinfoView) FrontendLogID() string { return v.ж.FrontendLogID }
  255. func (v HostinfoView) BackendLogID() string { return v.ж.BackendLogID }
  256. func (v HostinfoView) OS() string { return v.ж.OS }
  257. func (v HostinfoView) OSVersion() string { return v.ж.OSVersion }
  258. func (v HostinfoView) Container() opt.Bool { return v.ж.Container }
  259. func (v HostinfoView) Env() string { return v.ж.Env }
  260. func (v HostinfoView) Distro() string { return v.ж.Distro }
  261. func (v HostinfoView) DistroVersion() string { return v.ж.DistroVersion }
  262. func (v HostinfoView) DistroCodeName() string { return v.ж.DistroCodeName }
  263. func (v HostinfoView) App() string { return v.ж.App }
  264. func (v HostinfoView) Desktop() opt.Bool { return v.ж.Desktop }
  265. func (v HostinfoView) Package() string { return v.ж.Package }
  266. func (v HostinfoView) DeviceModel() string { return v.ж.DeviceModel }
  267. func (v HostinfoView) PushDeviceToken() string { return v.ж.PushDeviceToken }
  268. func (v HostinfoView) Hostname() string { return v.ж.Hostname }
  269. func (v HostinfoView) ShieldsUp() bool { return v.ж.ShieldsUp }
  270. func (v HostinfoView) ShareeNode() bool { return v.ж.ShareeNode }
  271. func (v HostinfoView) NoLogsNoSupport() bool { return v.ж.NoLogsNoSupport }
  272. func (v HostinfoView) WireIngress() bool { return v.ж.WireIngress }
  273. func (v HostinfoView) AllowsUpdate() bool { return v.ж.AllowsUpdate }
  274. func (v HostinfoView) Machine() string { return v.ж.Machine }
  275. func (v HostinfoView) GoArch() string { return v.ж.GoArch }
  276. func (v HostinfoView) GoArchVar() string { return v.ж.GoArchVar }
  277. func (v HostinfoView) GoVersion() string { return v.ж.GoVersion }
  278. func (v HostinfoView) RoutableIPs() views.Slice[netip.Prefix] { return views.SliceOf(v.ж.RoutableIPs) }
  279. func (v HostinfoView) RequestTags() views.Slice[string] { return views.SliceOf(v.ж.RequestTags) }
  280. func (v HostinfoView) WoLMACs() views.Slice[string] { return views.SliceOf(v.ж.WoLMACs) }
  281. func (v HostinfoView) Services() views.Slice[Service] { return views.SliceOf(v.ж.Services) }
  282. func (v HostinfoView) NetInfo() NetInfoView { return v.ж.NetInfo.View() }
  283. func (v HostinfoView) SSH_HostKeys() views.Slice[string] { return views.SliceOf(v.ж.SSH_HostKeys) }
  284. func (v HostinfoView) Cloud() string { return v.ж.Cloud }
  285. func (v HostinfoView) Userspace() opt.Bool { return v.ж.Userspace }
  286. func (v HostinfoView) UserspaceRouter() opt.Bool { return v.ж.UserspaceRouter }
  287. func (v HostinfoView) AppConnector() opt.Bool { return v.ж.AppConnector }
  288. func (v HostinfoView) Location() *Location {
  289. if v.ж.Location == nil {
  290. return nil
  291. }
  292. x := *v.ж.Location
  293. return &x
  294. }
  295. func (v HostinfoView) Equal(v2 HostinfoView) bool { return v.ж.Equal(v2.ж) }
  296. // A compilation failure here means this code must be regenerated, with the command at the top of this file.
  297. var _HostinfoViewNeedsRegeneration = Hostinfo(struct {
  298. IPNVersion string
  299. FrontendLogID string
  300. BackendLogID string
  301. OS string
  302. OSVersion string
  303. Container opt.Bool
  304. Env string
  305. Distro string
  306. DistroVersion string
  307. DistroCodeName string
  308. App string
  309. Desktop opt.Bool
  310. Package string
  311. DeviceModel string
  312. PushDeviceToken string
  313. Hostname string
  314. ShieldsUp bool
  315. ShareeNode bool
  316. NoLogsNoSupport bool
  317. WireIngress bool
  318. AllowsUpdate bool
  319. Machine string
  320. GoArch string
  321. GoArchVar string
  322. GoVersion string
  323. RoutableIPs []netip.Prefix
  324. RequestTags []string
  325. WoLMACs []string
  326. Services []Service
  327. NetInfo *NetInfo
  328. SSH_HostKeys []string
  329. Cloud string
  330. Userspace opt.Bool
  331. UserspaceRouter opt.Bool
  332. AppConnector opt.Bool
  333. Location *Location
  334. }{})
  335. // View returns a readonly view of NetInfo.
  336. func (p *NetInfo) View() NetInfoView {
  337. return NetInfoView{ж: p}
  338. }
  339. // NetInfoView provides a read-only view over NetInfo.
  340. //
  341. // Its methods should only be called if `Valid()` returns true.
  342. type NetInfoView struct {
  343. // ж is the underlying mutable value, named with a hard-to-type
  344. // character that looks pointy like a pointer.
  345. // It is named distinctively to make you think of how dangerous it is to escape
  346. // to callers. You must not let callers be able to mutate it.
  347. ж *NetInfo
  348. }
  349. // Valid reports whether underlying value is non-nil.
  350. func (v NetInfoView) Valid() bool { return v.ж != nil }
  351. // AsStruct returns a clone of the underlying value which aliases no memory with
  352. // the original.
  353. func (v NetInfoView) AsStruct() *NetInfo {
  354. if v.ж == nil {
  355. return nil
  356. }
  357. return v.ж.Clone()
  358. }
  359. func (v NetInfoView) MarshalJSON() ([]byte, error) { return json.Marshal(v.ж) }
  360. func (v *NetInfoView) UnmarshalJSON(b []byte) error {
  361. if v.ж != nil {
  362. return errors.New("already initialized")
  363. }
  364. if len(b) == 0 {
  365. return nil
  366. }
  367. var x NetInfo
  368. if err := json.Unmarshal(b, &x); err != nil {
  369. return err
  370. }
  371. v.ж = &x
  372. return nil
  373. }
  374. func (v NetInfoView) MappingVariesByDestIP() opt.Bool { return v.ж.MappingVariesByDestIP }
  375. func (v NetInfoView) HairPinning() opt.Bool { return v.ж.HairPinning }
  376. func (v NetInfoView) WorkingIPv6() opt.Bool { return v.ж.WorkingIPv6 }
  377. func (v NetInfoView) OSHasIPv6() opt.Bool { return v.ж.OSHasIPv6 }
  378. func (v NetInfoView) WorkingUDP() opt.Bool { return v.ж.WorkingUDP }
  379. func (v NetInfoView) WorkingICMPv4() opt.Bool { return v.ж.WorkingICMPv4 }
  380. func (v NetInfoView) HavePortMap() bool { return v.ж.HavePortMap }
  381. func (v NetInfoView) UPnP() opt.Bool { return v.ж.UPnP }
  382. func (v NetInfoView) PMP() opt.Bool { return v.ж.PMP }
  383. func (v NetInfoView) PCP() opt.Bool { return v.ж.PCP }
  384. func (v NetInfoView) PreferredDERP() int { return v.ж.PreferredDERP }
  385. func (v NetInfoView) LinkType() string { return v.ж.LinkType }
  386. func (v NetInfoView) DERPLatency() views.Map[string, float64] { return views.MapOf(v.ж.DERPLatency) }
  387. func (v NetInfoView) FirewallMode() string { return v.ж.FirewallMode }
  388. func (v NetInfoView) String() string { return v.ж.String() }
  389. // A compilation failure here means this code must be regenerated, with the command at the top of this file.
  390. var _NetInfoViewNeedsRegeneration = NetInfo(struct {
  391. MappingVariesByDestIP opt.Bool
  392. HairPinning opt.Bool
  393. WorkingIPv6 opt.Bool
  394. OSHasIPv6 opt.Bool
  395. WorkingUDP opt.Bool
  396. WorkingICMPv4 opt.Bool
  397. HavePortMap bool
  398. UPnP opt.Bool
  399. PMP opt.Bool
  400. PCP opt.Bool
  401. PreferredDERP int
  402. LinkType string
  403. DERPLatency map[string]float64
  404. FirewallMode string
  405. }{})
  406. // View returns a readonly view of Login.
  407. func (p *Login) View() LoginView {
  408. return LoginView{ж: p}
  409. }
  410. // LoginView provides a read-only view over Login.
  411. //
  412. // Its methods should only be called if `Valid()` returns true.
  413. type LoginView struct {
  414. // ж is the underlying mutable value, named with a hard-to-type
  415. // character that looks pointy like a pointer.
  416. // It is named distinctively to make you think of how dangerous it is to escape
  417. // to callers. You must not let callers be able to mutate it.
  418. ж *Login
  419. }
  420. // Valid reports whether underlying value is non-nil.
  421. func (v LoginView) Valid() bool { return v.ж != nil }
  422. // AsStruct returns a clone of the underlying value which aliases no memory with
  423. // the original.
  424. func (v LoginView) AsStruct() *Login {
  425. if v.ж == nil {
  426. return nil
  427. }
  428. return v.ж.Clone()
  429. }
  430. func (v LoginView) MarshalJSON() ([]byte, error) { return json.Marshal(v.ж) }
  431. func (v *LoginView) UnmarshalJSON(b []byte) error {
  432. if v.ж != nil {
  433. return errors.New("already initialized")
  434. }
  435. if len(b) == 0 {
  436. return nil
  437. }
  438. var x Login
  439. if err := json.Unmarshal(b, &x); err != nil {
  440. return err
  441. }
  442. v.ж = &x
  443. return nil
  444. }
  445. func (v LoginView) ID() LoginID { return v.ж.ID }
  446. func (v LoginView) Provider() string { return v.ж.Provider }
  447. func (v LoginView) LoginName() string { return v.ж.LoginName }
  448. func (v LoginView) DisplayName() string { return v.ж.DisplayName }
  449. func (v LoginView) ProfilePicURL() string { return v.ж.ProfilePicURL }
  450. // A compilation failure here means this code must be regenerated, with the command at the top of this file.
  451. var _LoginViewNeedsRegeneration = Login(struct {
  452. _ structs.Incomparable
  453. ID LoginID
  454. Provider string
  455. LoginName string
  456. DisplayName string
  457. ProfilePicURL string
  458. }{})
  459. // View returns a readonly view of DNSConfig.
  460. func (p *DNSConfig) View() DNSConfigView {
  461. return DNSConfigView{ж: p}
  462. }
  463. // DNSConfigView provides a read-only view over DNSConfig.
  464. //
  465. // Its methods should only be called if `Valid()` returns true.
  466. type DNSConfigView struct {
  467. // ж is the underlying mutable value, named with a hard-to-type
  468. // character that looks pointy like a pointer.
  469. // It is named distinctively to make you think of how dangerous it is to escape
  470. // to callers. You must not let callers be able to mutate it.
  471. ж *DNSConfig
  472. }
  473. // Valid reports whether underlying value is non-nil.
  474. func (v DNSConfigView) Valid() bool { return v.ж != nil }
  475. // AsStruct returns a clone of the underlying value which aliases no memory with
  476. // the original.
  477. func (v DNSConfigView) AsStruct() *DNSConfig {
  478. if v.ж == nil {
  479. return nil
  480. }
  481. return v.ж.Clone()
  482. }
  483. func (v DNSConfigView) MarshalJSON() ([]byte, error) { return json.Marshal(v.ж) }
  484. func (v *DNSConfigView) UnmarshalJSON(b []byte) error {
  485. if v.ж != nil {
  486. return errors.New("already initialized")
  487. }
  488. if len(b) == 0 {
  489. return nil
  490. }
  491. var x DNSConfig
  492. if err := json.Unmarshal(b, &x); err != nil {
  493. return err
  494. }
  495. v.ж = &x
  496. return nil
  497. }
  498. func (v DNSConfigView) Resolvers() views.SliceView[*dnstype.Resolver, dnstype.ResolverView] {
  499. return views.SliceOfViews[*dnstype.Resolver, dnstype.ResolverView](v.ж.Resolvers)
  500. }
  501. func (v DNSConfigView) Routes() views.MapFn[string, []*dnstype.Resolver, views.SliceView[*dnstype.Resolver, dnstype.ResolverView]] {
  502. return views.MapFnOf(v.ж.Routes, func(t []*dnstype.Resolver) views.SliceView[*dnstype.Resolver, dnstype.ResolverView] {
  503. return views.SliceOfViews[*dnstype.Resolver, dnstype.ResolverView](t)
  504. })
  505. }
  506. func (v DNSConfigView) FallbackResolvers() views.SliceView[*dnstype.Resolver, dnstype.ResolverView] {
  507. return views.SliceOfViews[*dnstype.Resolver, dnstype.ResolverView](v.ж.FallbackResolvers)
  508. }
  509. func (v DNSConfigView) Domains() views.Slice[string] { return views.SliceOf(v.ж.Domains) }
  510. func (v DNSConfigView) Proxied() bool { return v.ж.Proxied }
  511. func (v DNSConfigView) Nameservers() views.Slice[netip.Addr] { return views.SliceOf(v.ж.Nameservers) }
  512. func (v DNSConfigView) CertDomains() views.Slice[string] { return views.SliceOf(v.ж.CertDomains) }
  513. func (v DNSConfigView) ExtraRecords() views.Slice[DNSRecord] { return views.SliceOf(v.ж.ExtraRecords) }
  514. func (v DNSConfigView) ExitNodeFilteredSet() views.Slice[string] {
  515. return views.SliceOf(v.ж.ExitNodeFilteredSet)
  516. }
  517. func (v DNSConfigView) TempCorpIssue13969() string { return v.ж.TempCorpIssue13969 }
  518. // A compilation failure here means this code must be regenerated, with the command at the top of this file.
  519. var _DNSConfigViewNeedsRegeneration = DNSConfig(struct {
  520. Resolvers []*dnstype.Resolver
  521. Routes map[string][]*dnstype.Resolver
  522. FallbackResolvers []*dnstype.Resolver
  523. Domains []string
  524. Proxied bool
  525. Nameservers []netip.Addr
  526. CertDomains []string
  527. ExtraRecords []DNSRecord
  528. ExitNodeFilteredSet []string
  529. TempCorpIssue13969 string
  530. }{})
  531. // View returns a readonly view of RegisterResponse.
  532. func (p *RegisterResponse) View() RegisterResponseView {
  533. return RegisterResponseView{ж: p}
  534. }
  535. // RegisterResponseView provides a read-only view over RegisterResponse.
  536. //
  537. // Its methods should only be called if `Valid()` returns true.
  538. type RegisterResponseView struct {
  539. // ж is the underlying mutable value, named with a hard-to-type
  540. // character that looks pointy like a pointer.
  541. // It is named distinctively to make you think of how dangerous it is to escape
  542. // to callers. You must not let callers be able to mutate it.
  543. ж *RegisterResponse
  544. }
  545. // Valid reports whether underlying value is non-nil.
  546. func (v RegisterResponseView) Valid() bool { return v.ж != nil }
  547. // AsStruct returns a clone of the underlying value which aliases no memory with
  548. // the original.
  549. func (v RegisterResponseView) AsStruct() *RegisterResponse {
  550. if v.ж == nil {
  551. return nil
  552. }
  553. return v.ж.Clone()
  554. }
  555. func (v RegisterResponseView) MarshalJSON() ([]byte, error) { return json.Marshal(v.ж) }
  556. func (v *RegisterResponseView) UnmarshalJSON(b []byte) error {
  557. if v.ж != nil {
  558. return errors.New("already initialized")
  559. }
  560. if len(b) == 0 {
  561. return nil
  562. }
  563. var x RegisterResponse
  564. if err := json.Unmarshal(b, &x); err != nil {
  565. return err
  566. }
  567. v.ж = &x
  568. return nil
  569. }
  570. func (v RegisterResponseView) User() UserView { return v.ж.User.View() }
  571. func (v RegisterResponseView) Login() Login { return v.ж.Login }
  572. func (v RegisterResponseView) NodeKeyExpired() bool { return v.ж.NodeKeyExpired }
  573. func (v RegisterResponseView) MachineAuthorized() bool { return v.ж.MachineAuthorized }
  574. func (v RegisterResponseView) AuthURL() string { return v.ж.AuthURL }
  575. func (v RegisterResponseView) NodeKeySignature() views.ByteSlice[tkatype.MarshaledSignature] {
  576. return views.ByteSliceOf(v.ж.NodeKeySignature)
  577. }
  578. func (v RegisterResponseView) Error() string { return v.ж.Error }
  579. // A compilation failure here means this code must be regenerated, with the command at the top of this file.
  580. var _RegisterResponseViewNeedsRegeneration = RegisterResponse(struct {
  581. User User
  582. Login Login
  583. NodeKeyExpired bool
  584. MachineAuthorized bool
  585. AuthURL string
  586. NodeKeySignature tkatype.MarshaledSignature
  587. Error string
  588. }{})
  589. // View returns a readonly view of RegisterResponseAuth.
  590. func (p *RegisterResponseAuth) View() RegisterResponseAuthView {
  591. return RegisterResponseAuthView{ж: p}
  592. }
  593. // RegisterResponseAuthView provides a read-only view over RegisterResponseAuth.
  594. //
  595. // Its methods should only be called if `Valid()` returns true.
  596. type RegisterResponseAuthView struct {
  597. // ж is the underlying mutable value, named with a hard-to-type
  598. // character that looks pointy like a pointer.
  599. // It is named distinctively to make you think of how dangerous it is to escape
  600. // to callers. You must not let callers be able to mutate it.
  601. ж *RegisterResponseAuth
  602. }
  603. // Valid reports whether underlying value is non-nil.
  604. func (v RegisterResponseAuthView) Valid() bool { return v.ж != nil }
  605. // AsStruct returns a clone of the underlying value which aliases no memory with
  606. // the original.
  607. func (v RegisterResponseAuthView) AsStruct() *RegisterResponseAuth {
  608. if v.ж == nil {
  609. return nil
  610. }
  611. return v.ж.Clone()
  612. }
  613. func (v RegisterResponseAuthView) MarshalJSON() ([]byte, error) { return json.Marshal(v.ж) }
  614. func (v *RegisterResponseAuthView) UnmarshalJSON(b []byte) error {
  615. if v.ж != nil {
  616. return errors.New("already initialized")
  617. }
  618. if len(b) == 0 {
  619. return nil
  620. }
  621. var x RegisterResponseAuth
  622. if err := json.Unmarshal(b, &x); err != nil {
  623. return err
  624. }
  625. v.ж = &x
  626. return nil
  627. }
  628. func (v RegisterResponseAuthView) Provider() string { return v.ж.Provider }
  629. func (v RegisterResponseAuthView) LoginName() string { return v.ж.LoginName }
  630. func (v RegisterResponseAuthView) Oauth2Token() *Oauth2Token {
  631. if v.ж.Oauth2Token == nil {
  632. return nil
  633. }
  634. x := *v.ж.Oauth2Token
  635. return &x
  636. }
  637. func (v RegisterResponseAuthView) AuthKey() string { return v.ж.AuthKey }
  638. // A compilation failure here means this code must be regenerated, with the command at the top of this file.
  639. var _RegisterResponseAuthViewNeedsRegeneration = RegisterResponseAuth(struct {
  640. _ structs.Incomparable
  641. Provider string
  642. LoginName string
  643. Oauth2Token *Oauth2Token
  644. AuthKey string
  645. }{})
  646. // View returns a readonly view of RegisterRequest.
  647. func (p *RegisterRequest) View() RegisterRequestView {
  648. return RegisterRequestView{ж: p}
  649. }
  650. // RegisterRequestView provides a read-only view over RegisterRequest.
  651. //
  652. // Its methods should only be called if `Valid()` returns true.
  653. type RegisterRequestView struct {
  654. // ж is the underlying mutable value, named with a hard-to-type
  655. // character that looks pointy like a pointer.
  656. // It is named distinctively to make you think of how dangerous it is to escape
  657. // to callers. You must not let callers be able to mutate it.
  658. ж *RegisterRequest
  659. }
  660. // Valid reports whether underlying value is non-nil.
  661. func (v RegisterRequestView) Valid() bool { return v.ж != nil }
  662. // AsStruct returns a clone of the underlying value which aliases no memory with
  663. // the original.
  664. func (v RegisterRequestView) AsStruct() *RegisterRequest {
  665. if v.ж == nil {
  666. return nil
  667. }
  668. return v.ж.Clone()
  669. }
  670. func (v RegisterRequestView) MarshalJSON() ([]byte, error) { return json.Marshal(v.ж) }
  671. func (v *RegisterRequestView) UnmarshalJSON(b []byte) error {
  672. if v.ж != nil {
  673. return errors.New("already initialized")
  674. }
  675. if len(b) == 0 {
  676. return nil
  677. }
  678. var x RegisterRequest
  679. if err := json.Unmarshal(b, &x); err != nil {
  680. return err
  681. }
  682. v.ж = &x
  683. return nil
  684. }
  685. func (v RegisterRequestView) Version() CapabilityVersion { return v.ж.Version }
  686. func (v RegisterRequestView) NodeKey() key.NodePublic { return v.ж.NodeKey }
  687. func (v RegisterRequestView) OldNodeKey() key.NodePublic { return v.ж.OldNodeKey }
  688. func (v RegisterRequestView) NLKey() key.NLPublic { return v.ж.NLKey }
  689. func (v RegisterRequestView) Auth() RegisterResponseAuthView { return v.ж.Auth.View() }
  690. func (v RegisterRequestView) Expiry() time.Time { return v.ж.Expiry }
  691. func (v RegisterRequestView) Followup() string { return v.ж.Followup }
  692. func (v RegisterRequestView) Hostinfo() HostinfoView { return v.ж.Hostinfo.View() }
  693. func (v RegisterRequestView) Ephemeral() bool { return v.ж.Ephemeral }
  694. func (v RegisterRequestView) NodeKeySignature() views.ByteSlice[tkatype.MarshaledSignature] {
  695. return views.ByteSliceOf(v.ж.NodeKeySignature)
  696. }
  697. func (v RegisterRequestView) SignatureType() SignatureType { return v.ж.SignatureType }
  698. func (v RegisterRequestView) Timestamp() *time.Time {
  699. if v.ж.Timestamp == nil {
  700. return nil
  701. }
  702. x := *v.ж.Timestamp
  703. return &x
  704. }
  705. func (v RegisterRequestView) DeviceCert() views.ByteSlice[[]byte] {
  706. return views.ByteSliceOf(v.ж.DeviceCert)
  707. }
  708. func (v RegisterRequestView) Signature() views.ByteSlice[[]byte] {
  709. return views.ByteSliceOf(v.ж.Signature)
  710. }
  711. func (v RegisterRequestView) Tailnet() string { return v.ж.Tailnet }
  712. // A compilation failure here means this code must be regenerated, with the command at the top of this file.
  713. var _RegisterRequestViewNeedsRegeneration = RegisterRequest(struct {
  714. _ structs.Incomparable
  715. Version CapabilityVersion
  716. NodeKey key.NodePublic
  717. OldNodeKey key.NodePublic
  718. NLKey key.NLPublic
  719. Auth RegisterResponseAuth
  720. Expiry time.Time
  721. Followup string
  722. Hostinfo *Hostinfo
  723. Ephemeral bool
  724. NodeKeySignature tkatype.MarshaledSignature
  725. SignatureType SignatureType
  726. Timestamp *time.Time
  727. DeviceCert []byte
  728. Signature []byte
  729. Tailnet string
  730. }{})
  731. // View returns a readonly view of DERPHomeParams.
  732. func (p *DERPHomeParams) View() DERPHomeParamsView {
  733. return DERPHomeParamsView{ж: p}
  734. }
  735. // DERPHomeParamsView provides a read-only view over DERPHomeParams.
  736. //
  737. // Its methods should only be called if `Valid()` returns true.
  738. type DERPHomeParamsView struct {
  739. // ж is the underlying mutable value, named with a hard-to-type
  740. // character that looks pointy like a pointer.
  741. // It is named distinctively to make you think of how dangerous it is to escape
  742. // to callers. You must not let callers be able to mutate it.
  743. ж *DERPHomeParams
  744. }
  745. // Valid reports whether underlying value is non-nil.
  746. func (v DERPHomeParamsView) Valid() bool { return v.ж != nil }
  747. // AsStruct returns a clone of the underlying value which aliases no memory with
  748. // the original.
  749. func (v DERPHomeParamsView) AsStruct() *DERPHomeParams {
  750. if v.ж == nil {
  751. return nil
  752. }
  753. return v.ж.Clone()
  754. }
  755. func (v DERPHomeParamsView) MarshalJSON() ([]byte, error) { return json.Marshal(v.ж) }
  756. func (v *DERPHomeParamsView) UnmarshalJSON(b []byte) error {
  757. if v.ж != nil {
  758. return errors.New("already initialized")
  759. }
  760. if len(b) == 0 {
  761. return nil
  762. }
  763. var x DERPHomeParams
  764. if err := json.Unmarshal(b, &x); err != nil {
  765. return err
  766. }
  767. v.ж = &x
  768. return nil
  769. }
  770. func (v DERPHomeParamsView) RegionScore() views.Map[int, float64] {
  771. return views.MapOf(v.ж.RegionScore)
  772. }
  773. // A compilation failure here means this code must be regenerated, with the command at the top of this file.
  774. var _DERPHomeParamsViewNeedsRegeneration = DERPHomeParams(struct {
  775. RegionScore map[int]float64
  776. }{})
  777. // View returns a readonly view of DERPRegion.
  778. func (p *DERPRegion) View() DERPRegionView {
  779. return DERPRegionView{ж: p}
  780. }
  781. // DERPRegionView provides a read-only view over DERPRegion.
  782. //
  783. // Its methods should only be called if `Valid()` returns true.
  784. type DERPRegionView struct {
  785. // ж is the underlying mutable value, named with a hard-to-type
  786. // character that looks pointy like a pointer.
  787. // It is named distinctively to make you think of how dangerous it is to escape
  788. // to callers. You must not let callers be able to mutate it.
  789. ж *DERPRegion
  790. }
  791. // Valid reports whether underlying value is non-nil.
  792. func (v DERPRegionView) Valid() bool { return v.ж != nil }
  793. // AsStruct returns a clone of the underlying value which aliases no memory with
  794. // the original.
  795. func (v DERPRegionView) AsStruct() *DERPRegion {
  796. if v.ж == nil {
  797. return nil
  798. }
  799. return v.ж.Clone()
  800. }
  801. func (v DERPRegionView) MarshalJSON() ([]byte, error) { return json.Marshal(v.ж) }
  802. func (v *DERPRegionView) UnmarshalJSON(b []byte) error {
  803. if v.ж != nil {
  804. return errors.New("already initialized")
  805. }
  806. if len(b) == 0 {
  807. return nil
  808. }
  809. var x DERPRegion
  810. if err := json.Unmarshal(b, &x); err != nil {
  811. return err
  812. }
  813. v.ж = &x
  814. return nil
  815. }
  816. func (v DERPRegionView) RegionID() int { return v.ж.RegionID }
  817. func (v DERPRegionView) RegionCode() string { return v.ж.RegionCode }
  818. func (v DERPRegionView) RegionName() string { return v.ж.RegionName }
  819. func (v DERPRegionView) Avoid() bool { return v.ж.Avoid }
  820. func (v DERPRegionView) Nodes() views.SliceView[*DERPNode, DERPNodeView] {
  821. return views.SliceOfViews[*DERPNode, DERPNodeView](v.ж.Nodes)
  822. }
  823. // A compilation failure here means this code must be regenerated, with the command at the top of this file.
  824. var _DERPRegionViewNeedsRegeneration = DERPRegion(struct {
  825. RegionID int
  826. RegionCode string
  827. RegionName string
  828. Avoid bool
  829. Nodes []*DERPNode
  830. }{})
  831. // View returns a readonly view of DERPMap.
  832. func (p *DERPMap) View() DERPMapView {
  833. return DERPMapView{ж: p}
  834. }
  835. // DERPMapView provides a read-only view over DERPMap.
  836. //
  837. // Its methods should only be called if `Valid()` returns true.
  838. type DERPMapView struct {
  839. // ж is the underlying mutable value, named with a hard-to-type
  840. // character that looks pointy like a pointer.
  841. // It is named distinctively to make you think of how dangerous it is to escape
  842. // to callers. You must not let callers be able to mutate it.
  843. ж *DERPMap
  844. }
  845. // Valid reports whether underlying value is non-nil.
  846. func (v DERPMapView) Valid() bool { return v.ж != nil }
  847. // AsStruct returns a clone of the underlying value which aliases no memory with
  848. // the original.
  849. func (v DERPMapView) AsStruct() *DERPMap {
  850. if v.ж == nil {
  851. return nil
  852. }
  853. return v.ж.Clone()
  854. }
  855. func (v DERPMapView) MarshalJSON() ([]byte, error) { return json.Marshal(v.ж) }
  856. func (v *DERPMapView) UnmarshalJSON(b []byte) error {
  857. if v.ж != nil {
  858. return errors.New("already initialized")
  859. }
  860. if len(b) == 0 {
  861. return nil
  862. }
  863. var x DERPMap
  864. if err := json.Unmarshal(b, &x); err != nil {
  865. return err
  866. }
  867. v.ж = &x
  868. return nil
  869. }
  870. func (v DERPMapView) HomeParams() DERPHomeParamsView { return v.ж.HomeParams.View() }
  871. func (v DERPMapView) Regions() views.MapFn[int, *DERPRegion, DERPRegionView] {
  872. return views.MapFnOf(v.ж.Regions, func(t *DERPRegion) DERPRegionView {
  873. return t.View()
  874. })
  875. }
  876. func (v DERPMapView) OmitDefaultRegions() bool { return v.ж.OmitDefaultRegions }
  877. // A compilation failure here means this code must be regenerated, with the command at the top of this file.
  878. var _DERPMapViewNeedsRegeneration = DERPMap(struct {
  879. HomeParams *DERPHomeParams
  880. Regions map[int]*DERPRegion
  881. OmitDefaultRegions bool
  882. }{})
  883. // View returns a readonly view of DERPNode.
  884. func (p *DERPNode) View() DERPNodeView {
  885. return DERPNodeView{ж: p}
  886. }
  887. // DERPNodeView provides a read-only view over DERPNode.
  888. //
  889. // Its methods should only be called if `Valid()` returns true.
  890. type DERPNodeView struct {
  891. // ж is the underlying mutable value, named with a hard-to-type
  892. // character that looks pointy like a pointer.
  893. // It is named distinctively to make you think of how dangerous it is to escape
  894. // to callers. You must not let callers be able to mutate it.
  895. ж *DERPNode
  896. }
  897. // Valid reports whether underlying value is non-nil.
  898. func (v DERPNodeView) Valid() bool { return v.ж != nil }
  899. // AsStruct returns a clone of the underlying value which aliases no memory with
  900. // the original.
  901. func (v DERPNodeView) AsStruct() *DERPNode {
  902. if v.ж == nil {
  903. return nil
  904. }
  905. return v.ж.Clone()
  906. }
  907. func (v DERPNodeView) MarshalJSON() ([]byte, error) { return json.Marshal(v.ж) }
  908. func (v *DERPNodeView) UnmarshalJSON(b []byte) error {
  909. if v.ж != nil {
  910. return errors.New("already initialized")
  911. }
  912. if len(b) == 0 {
  913. return nil
  914. }
  915. var x DERPNode
  916. if err := json.Unmarshal(b, &x); err != nil {
  917. return err
  918. }
  919. v.ж = &x
  920. return nil
  921. }
  922. func (v DERPNodeView) Name() string { return v.ж.Name }
  923. func (v DERPNodeView) RegionID() int { return v.ж.RegionID }
  924. func (v DERPNodeView) HostName() string { return v.ж.HostName }
  925. func (v DERPNodeView) CertName() string { return v.ж.CertName }
  926. func (v DERPNodeView) IPv4() string { return v.ж.IPv4 }
  927. func (v DERPNodeView) IPv6() string { return v.ж.IPv6 }
  928. func (v DERPNodeView) STUNPort() int { return v.ж.STUNPort }
  929. func (v DERPNodeView) STUNOnly() bool { return v.ж.STUNOnly }
  930. func (v DERPNodeView) DERPPort() int { return v.ж.DERPPort }
  931. func (v DERPNodeView) InsecureForTests() bool { return v.ж.InsecureForTests }
  932. func (v DERPNodeView) STUNTestIP() string { return v.ж.STUNTestIP }
  933. func (v DERPNodeView) CanPort80() bool { return v.ж.CanPort80 }
  934. // A compilation failure here means this code must be regenerated, with the command at the top of this file.
  935. var _DERPNodeViewNeedsRegeneration = DERPNode(struct {
  936. Name string
  937. RegionID int
  938. HostName string
  939. CertName string
  940. IPv4 string
  941. IPv6 string
  942. STUNPort int
  943. STUNOnly bool
  944. DERPPort int
  945. InsecureForTests bool
  946. STUNTestIP string
  947. CanPort80 bool
  948. }{})
  949. // View returns a readonly view of SSHRule.
  950. func (p *SSHRule) View() SSHRuleView {
  951. return SSHRuleView{ж: p}
  952. }
  953. // SSHRuleView provides a read-only view over SSHRule.
  954. //
  955. // Its methods should only be called if `Valid()` returns true.
  956. type SSHRuleView struct {
  957. // ж is the underlying mutable value, named with a hard-to-type
  958. // character that looks pointy like a pointer.
  959. // It is named distinctively to make you think of how dangerous it is to escape
  960. // to callers. You must not let callers be able to mutate it.
  961. ж *SSHRule
  962. }
  963. // Valid reports whether underlying value is non-nil.
  964. func (v SSHRuleView) Valid() bool { return v.ж != nil }
  965. // AsStruct returns a clone of the underlying value which aliases no memory with
  966. // the original.
  967. func (v SSHRuleView) AsStruct() *SSHRule {
  968. if v.ж == nil {
  969. return nil
  970. }
  971. return v.ж.Clone()
  972. }
  973. func (v SSHRuleView) MarshalJSON() ([]byte, error) { return json.Marshal(v.ж) }
  974. func (v *SSHRuleView) UnmarshalJSON(b []byte) error {
  975. if v.ж != nil {
  976. return errors.New("already initialized")
  977. }
  978. if len(b) == 0 {
  979. return nil
  980. }
  981. var x SSHRule
  982. if err := json.Unmarshal(b, &x); err != nil {
  983. return err
  984. }
  985. v.ж = &x
  986. return nil
  987. }
  988. func (v SSHRuleView) RuleExpires() *time.Time {
  989. if v.ж.RuleExpires == nil {
  990. return nil
  991. }
  992. x := *v.ж.RuleExpires
  993. return &x
  994. }
  995. func (v SSHRuleView) Principals() views.SliceView[*SSHPrincipal, SSHPrincipalView] {
  996. return views.SliceOfViews[*SSHPrincipal, SSHPrincipalView](v.ж.Principals)
  997. }
  998. func (v SSHRuleView) SSHUsers() views.Map[string, string] { return views.MapOf(v.ж.SSHUsers) }
  999. func (v SSHRuleView) Action() SSHActionView { return v.ж.Action.View() }
  1000. // A compilation failure here means this code must be regenerated, with the command at the top of this file.
  1001. var _SSHRuleViewNeedsRegeneration = SSHRule(struct {
  1002. RuleExpires *time.Time
  1003. Principals []*SSHPrincipal
  1004. SSHUsers map[string]string
  1005. Action *SSHAction
  1006. }{})
  1007. // View returns a readonly view of SSHAction.
  1008. func (p *SSHAction) View() SSHActionView {
  1009. return SSHActionView{ж: p}
  1010. }
  1011. // SSHActionView provides a read-only view over SSHAction.
  1012. //
  1013. // Its methods should only be called if `Valid()` returns true.
  1014. type SSHActionView struct {
  1015. // ж is the underlying mutable value, named with a hard-to-type
  1016. // character that looks pointy like a pointer.
  1017. // It is named distinctively to make you think of how dangerous it is to escape
  1018. // to callers. You must not let callers be able to mutate it.
  1019. ж *SSHAction
  1020. }
  1021. // Valid reports whether underlying value is non-nil.
  1022. func (v SSHActionView) Valid() bool { return v.ж != nil }
  1023. // AsStruct returns a clone of the underlying value which aliases no memory with
  1024. // the original.
  1025. func (v SSHActionView) AsStruct() *SSHAction {
  1026. if v.ж == nil {
  1027. return nil
  1028. }
  1029. return v.ж.Clone()
  1030. }
  1031. func (v SSHActionView) MarshalJSON() ([]byte, error) { return json.Marshal(v.ж) }
  1032. func (v *SSHActionView) UnmarshalJSON(b []byte) error {
  1033. if v.ж != nil {
  1034. return errors.New("already initialized")
  1035. }
  1036. if len(b) == 0 {
  1037. return nil
  1038. }
  1039. var x SSHAction
  1040. if err := json.Unmarshal(b, &x); err != nil {
  1041. return err
  1042. }
  1043. v.ж = &x
  1044. return nil
  1045. }
  1046. func (v SSHActionView) Message() string { return v.ж.Message }
  1047. func (v SSHActionView) Reject() bool { return v.ж.Reject }
  1048. func (v SSHActionView) Accept() bool { return v.ж.Accept }
  1049. func (v SSHActionView) SessionDuration() time.Duration { return v.ж.SessionDuration }
  1050. func (v SSHActionView) AllowAgentForwarding() bool { return v.ж.AllowAgentForwarding }
  1051. func (v SSHActionView) HoldAndDelegate() string { return v.ж.HoldAndDelegate }
  1052. func (v SSHActionView) AllowLocalPortForwarding() bool { return v.ж.AllowLocalPortForwarding }
  1053. func (v SSHActionView) AllowRemotePortForwarding() bool { return v.ж.AllowRemotePortForwarding }
  1054. func (v SSHActionView) Recorders() views.Slice[netip.AddrPort] { return views.SliceOf(v.ж.Recorders) }
  1055. func (v SSHActionView) OnRecordingFailure() *SSHRecorderFailureAction {
  1056. if v.ж.OnRecordingFailure == nil {
  1057. return nil
  1058. }
  1059. x := *v.ж.OnRecordingFailure
  1060. return &x
  1061. }
  1062. // A compilation failure here means this code must be regenerated, with the command at the top of this file.
  1063. var _SSHActionViewNeedsRegeneration = SSHAction(struct {
  1064. Message string
  1065. Reject bool
  1066. Accept bool
  1067. SessionDuration time.Duration
  1068. AllowAgentForwarding bool
  1069. HoldAndDelegate string
  1070. AllowLocalPortForwarding bool
  1071. AllowRemotePortForwarding bool
  1072. Recorders []netip.AddrPort
  1073. OnRecordingFailure *SSHRecorderFailureAction
  1074. }{})
  1075. // View returns a readonly view of SSHPrincipal.
  1076. func (p *SSHPrincipal) View() SSHPrincipalView {
  1077. return SSHPrincipalView{ж: p}
  1078. }
  1079. // SSHPrincipalView provides a read-only view over SSHPrincipal.
  1080. //
  1081. // Its methods should only be called if `Valid()` returns true.
  1082. type SSHPrincipalView struct {
  1083. // ж is the underlying mutable value, named with a hard-to-type
  1084. // character that looks pointy like a pointer.
  1085. // It is named distinctively to make you think of how dangerous it is to escape
  1086. // to callers. You must not let callers be able to mutate it.
  1087. ж *SSHPrincipal
  1088. }
  1089. // Valid reports whether underlying value is non-nil.
  1090. func (v SSHPrincipalView) Valid() bool { return v.ж != nil }
  1091. // AsStruct returns a clone of the underlying value which aliases no memory with
  1092. // the original.
  1093. func (v SSHPrincipalView) AsStruct() *SSHPrincipal {
  1094. if v.ж == nil {
  1095. return nil
  1096. }
  1097. return v.ж.Clone()
  1098. }
  1099. func (v SSHPrincipalView) MarshalJSON() ([]byte, error) { return json.Marshal(v.ж) }
  1100. func (v *SSHPrincipalView) UnmarshalJSON(b []byte) error {
  1101. if v.ж != nil {
  1102. return errors.New("already initialized")
  1103. }
  1104. if len(b) == 0 {
  1105. return nil
  1106. }
  1107. var x SSHPrincipal
  1108. if err := json.Unmarshal(b, &x); err != nil {
  1109. return err
  1110. }
  1111. v.ж = &x
  1112. return nil
  1113. }
  1114. func (v SSHPrincipalView) Node() StableNodeID { return v.ж.Node }
  1115. func (v SSHPrincipalView) NodeIP() string { return v.ж.NodeIP }
  1116. func (v SSHPrincipalView) UserLogin() string { return v.ж.UserLogin }
  1117. func (v SSHPrincipalView) Any() bool { return v.ж.Any }
  1118. func (v SSHPrincipalView) PubKeys() views.Slice[string] { return views.SliceOf(v.ж.PubKeys) }
  1119. // A compilation failure here means this code must be regenerated, with the command at the top of this file.
  1120. var _SSHPrincipalViewNeedsRegeneration = SSHPrincipal(struct {
  1121. Node StableNodeID
  1122. NodeIP string
  1123. UserLogin string
  1124. Any bool
  1125. PubKeys []string
  1126. }{})
  1127. // View returns a readonly view of ControlDialPlan.
  1128. func (p *ControlDialPlan) View() ControlDialPlanView {
  1129. return ControlDialPlanView{ж: p}
  1130. }
  1131. // ControlDialPlanView provides a read-only view over ControlDialPlan.
  1132. //
  1133. // Its methods should only be called if `Valid()` returns true.
  1134. type ControlDialPlanView struct {
  1135. // ж is the underlying mutable value, named with a hard-to-type
  1136. // character that looks pointy like a pointer.
  1137. // It is named distinctively to make you think of how dangerous it is to escape
  1138. // to callers. You must not let callers be able to mutate it.
  1139. ж *ControlDialPlan
  1140. }
  1141. // Valid reports whether underlying value is non-nil.
  1142. func (v ControlDialPlanView) Valid() bool { return v.ж != nil }
  1143. // AsStruct returns a clone of the underlying value which aliases no memory with
  1144. // the original.
  1145. func (v ControlDialPlanView) AsStruct() *ControlDialPlan {
  1146. if v.ж == nil {
  1147. return nil
  1148. }
  1149. return v.ж.Clone()
  1150. }
  1151. func (v ControlDialPlanView) MarshalJSON() ([]byte, error) { return json.Marshal(v.ж) }
  1152. func (v *ControlDialPlanView) UnmarshalJSON(b []byte) error {
  1153. if v.ж != nil {
  1154. return errors.New("already initialized")
  1155. }
  1156. if len(b) == 0 {
  1157. return nil
  1158. }
  1159. var x ControlDialPlan
  1160. if err := json.Unmarshal(b, &x); err != nil {
  1161. return err
  1162. }
  1163. v.ж = &x
  1164. return nil
  1165. }
  1166. func (v ControlDialPlanView) Candidates() views.Slice[ControlIPCandidate] {
  1167. return views.SliceOf(v.ж.Candidates)
  1168. }
  1169. // A compilation failure here means this code must be regenerated, with the command at the top of this file.
  1170. var _ControlDialPlanViewNeedsRegeneration = ControlDialPlan(struct {
  1171. Candidates []ControlIPCandidate
  1172. }{})
  1173. // View returns a readonly view of Location.
  1174. func (p *Location) View() LocationView {
  1175. return LocationView{ж: p}
  1176. }
  1177. // LocationView provides a read-only view over Location.
  1178. //
  1179. // Its methods should only be called if `Valid()` returns true.
  1180. type LocationView struct {
  1181. // ж is the underlying mutable value, named with a hard-to-type
  1182. // character that looks pointy like a pointer.
  1183. // It is named distinctively to make you think of how dangerous it is to escape
  1184. // to callers. You must not let callers be able to mutate it.
  1185. ж *Location
  1186. }
  1187. // Valid reports whether underlying value is non-nil.
  1188. func (v LocationView) Valid() bool { return v.ж != nil }
  1189. // AsStruct returns a clone of the underlying value which aliases no memory with
  1190. // the original.
  1191. func (v LocationView) AsStruct() *Location {
  1192. if v.ж == nil {
  1193. return nil
  1194. }
  1195. return v.ж.Clone()
  1196. }
  1197. func (v LocationView) MarshalJSON() ([]byte, error) { return json.Marshal(v.ж) }
  1198. func (v *LocationView) UnmarshalJSON(b []byte) error {
  1199. if v.ж != nil {
  1200. return errors.New("already initialized")
  1201. }
  1202. if len(b) == 0 {
  1203. return nil
  1204. }
  1205. var x Location
  1206. if err := json.Unmarshal(b, &x); err != nil {
  1207. return err
  1208. }
  1209. v.ж = &x
  1210. return nil
  1211. }
  1212. func (v LocationView) Country() string { return v.ж.Country }
  1213. func (v LocationView) CountryCode() string { return v.ж.CountryCode }
  1214. func (v LocationView) City() string { return v.ж.City }
  1215. func (v LocationView) CityCode() string { return v.ж.CityCode }
  1216. func (v LocationView) Priority() int { return v.ж.Priority }
  1217. // A compilation failure here means this code must be regenerated, with the command at the top of this file.
  1218. var _LocationViewNeedsRegeneration = Location(struct {
  1219. Country string
  1220. CountryCode string
  1221. City string
  1222. CityCode string
  1223. Priority int
  1224. }{})
  1225. // View returns a readonly view of UserProfile.
  1226. func (p *UserProfile) View() UserProfileView {
  1227. return UserProfileView{ж: p}
  1228. }
  1229. // UserProfileView provides a read-only view over UserProfile.
  1230. //
  1231. // Its methods should only be called if `Valid()` returns true.
  1232. type UserProfileView struct {
  1233. // ж is the underlying mutable value, named with a hard-to-type
  1234. // character that looks pointy like a pointer.
  1235. // It is named distinctively to make you think of how dangerous it is to escape
  1236. // to callers. You must not let callers be able to mutate it.
  1237. ж *UserProfile
  1238. }
  1239. // Valid reports whether underlying value is non-nil.
  1240. func (v UserProfileView) Valid() bool { return v.ж != nil }
  1241. // AsStruct returns a clone of the underlying value which aliases no memory with
  1242. // the original.
  1243. func (v UserProfileView) AsStruct() *UserProfile {
  1244. if v.ж == nil {
  1245. return nil
  1246. }
  1247. return v.ж.Clone()
  1248. }
  1249. func (v UserProfileView) MarshalJSON() ([]byte, error) { return json.Marshal(v.ж) }
  1250. func (v *UserProfileView) UnmarshalJSON(b []byte) error {
  1251. if v.ж != nil {
  1252. return errors.New("already initialized")
  1253. }
  1254. if len(b) == 0 {
  1255. return nil
  1256. }
  1257. var x UserProfile
  1258. if err := json.Unmarshal(b, &x); err != nil {
  1259. return err
  1260. }
  1261. v.ж = &x
  1262. return nil
  1263. }
  1264. func (v UserProfileView) ID() UserID { return v.ж.ID }
  1265. func (v UserProfileView) LoginName() string { return v.ж.LoginName }
  1266. func (v UserProfileView) DisplayName() string { return v.ж.DisplayName }
  1267. func (v UserProfileView) ProfilePicURL() string { return v.ж.ProfilePicURL }
  1268. func (v UserProfileView) Roles() emptyStructJSONSlice { return v.ж.Roles }
  1269. func (v UserProfileView) Groups() views.Slice[string] { return views.SliceOf(v.ж.Groups) }
  1270. func (v UserProfileView) Equal(v2 UserProfileView) bool { return v.ж.Equal(v2.ж) }
  1271. // A compilation failure here means this code must be regenerated, with the command at the top of this file.
  1272. var _UserProfileViewNeedsRegeneration = UserProfile(struct {
  1273. ID UserID
  1274. LoginName string
  1275. DisplayName string
  1276. ProfilePicURL string
  1277. Roles emptyStructJSONSlice
  1278. Groups []string
  1279. }{})