structs.go 8.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298
  1. package structs
  2. import (
  3. "time"
  4. )
  5. // incoming websocket payloads
  6. type WsPayload struct {
  7. Type string `json:"type"`
  8. Action string `json:"action"`
  9. }
  10. // eventbus event payloads
  11. type Event struct {
  12. Type string
  13. Data interface{}
  14. }
  15. // for keeping track of container desired/actual state
  16. type ContainerState struct {
  17. ID string
  18. Name string
  19. Image string
  20. Status string
  21. CreatedAt time.Time
  22. }
  23. // authenticated browser sessions
  24. type SessionInfo struct {
  25. Hash string `json:"hash"`
  26. Created string `json:"created"`
  27. }
  28. // system.json config struct
  29. type SysConfig struct {
  30. Setup string `json:"setup"`
  31. EndpointUrl string `json:"endpointUrl"`
  32. ApiVersion string `json:"apiVersion"`
  33. Piers []string `json:"piers"`
  34. NetCheck string `json:"netCheck"`
  35. UpdateMode string `json:"updateMode"`
  36. UpdateUrl string `json:"updateUrl"`
  37. UpdateBranch string `json:"updateBranch"`
  38. SwapVal int `json:"swapVal"`
  39. SwapFile string `json:"swapFile"`
  40. KeyFile string `json:"keyFile"`
  41. Sessions struct {
  42. Authorized map[string]SessionInfo `json:"authorized"`
  43. Unauthorized map[string]SessionInfo `json:"unauthorized"`
  44. } `json:"sessions"`
  45. LinuxUpdates struct {
  46. Value int `json:"value"`
  47. Interval string `json:"interval"`
  48. Previous bool `json:"previous"`
  49. } `json:"linuxUpdates"`
  50. DockerData string `json:"dockerData"`
  51. WgOn bool `json:"wgOn"`
  52. WgRegistered bool `json:"wgRegistered"`
  53. PwHash string `json:"pwHash"`
  54. C2cInterval int `json:"c2cInterval"`
  55. FirstBoot bool `json:"firstBoot"`
  56. WgRegisterd bool `json:"wgRegisterd"`
  57. GsVersion string `json:"gsVersion"`
  58. CfgDir string `json:"CFG_DIR"`
  59. UpdateInterval int `json:"updateInterval"`
  60. BinHash string `json:"binHash"`
  61. Pubkey string `json:"pubkey"`
  62. Privkey string `json:"privkey"`
  63. Salt string `json:"salt"`
  64. }
  65. // broadcast subobject
  66. type LoginStatus struct {
  67. Locked bool
  68. End time.Time
  69. Attempts int
  70. }
  71. // broadcast subobject
  72. type LoginKeys struct {
  73. Old struct {
  74. Pub string
  75. Priv string
  76. }
  77. Cur struct {
  78. Pub string
  79. Priv string
  80. }
  81. }
  82. // version server payload root struct
  83. type Version struct {
  84. Groundseg struct {
  85. Canary Channel `json:"canary"`
  86. Edge Channel `json:"edge"`
  87. Latest Channel `json:"latest"`
  88. } `json:"groundseg"`
  89. }
  90. // version server payload substruct
  91. type Channel struct {
  92. Groundseg VersionDetails `json:"groundseg"`
  93. Manual VersionDetails `json:"manual"`
  94. Minio VersionDetails `json:"minio"`
  95. Miniomc VersionDetails `json:"miniomc"`
  96. Netdata VersionDetails `json:"netdata"`
  97. Vere VersionDetails `json:"vere"`
  98. Webui VersionDetails `json:"webui"`
  99. Wireguard VersionDetails `json:"wireguard"`
  100. }
  101. // version server payload substruct
  102. type VersionDetails struct {
  103. Amd64Sha256 string `json:"amd64_sha256"`
  104. Amd64URL string `json:"amd64_url,omitempty"`
  105. Arm64Sha256 string `json:"arm64_sha256"`
  106. Arm64URL string `json:"arm64_url,omitempty"`
  107. Major int `json:"major,omitempty"`
  108. Minor int `json:"minor,omitempty"`
  109. Patch int `json:"patch,omitempty"`
  110. Repo string `json:"repo,omitempty"`
  111. Tag string `json:"tag,omitempty"`
  112. }
  113. // broadcast payload object struct
  114. type AuthBroadcast struct {
  115. Type string `json:"type"`
  116. AuthLevel string `json:"auth_level"`
  117. Upload Upload `json:"upload"`
  118. Logs Logs `json:"logs"`
  119. System SystemInfo `json:"system"`
  120. Profile Profile `json:"profile"`
  121. Urbits map[string]Urbit `json:"urbits"`
  122. }
  123. // broadcast payload subobject
  124. type SystemUsage struct {
  125. RAM []uint64 `json:"ram"`
  126. CPU int `json:"cpu"`
  127. CPUTemp float64 `json:"cpu_temp"`
  128. Disk []uint64 `json:"disk"`
  129. SwapFile int `json:"swap"`
  130. }
  131. // broadcast payload subobject
  132. type SystemUpdates struct {
  133. Linux struct {
  134. State string `json:"state"`
  135. Upgrade int `json:"upgrade"`
  136. New int `json:"new"`
  137. Remove int `json:"remove"`
  138. Ignore int `json:"ignore"`
  139. } `json:"linux"`
  140. }
  141. // broadcast payload subobject
  142. type SystemWifi struct {
  143. Status string `json:"status"`
  144. Active string `json:"active"`
  145. Networks []string `json:"networks"`
  146. }
  147. // broadcast payload subobject
  148. type SystemInfo struct {
  149. Usage SystemUsage `json:"usage"`
  150. Updates SystemUpdates `json:"updates"`
  151. Wifi SystemWifi `json:"wifi"`
  152. }
  153. // broadcast payload subobject
  154. type Profile struct {
  155. Startram Startram `json:"startram"`
  156. }
  157. // broadcast payload subobject
  158. type Startram struct {
  159. Info struct {
  160. Registered bool `json:"registered"`
  161. Running bool `json:"running"`
  162. Region any `json:"region"`
  163. Expiry any `json:"expiry"`
  164. Renew bool `json:"renew"`
  165. Endpoint string `json:"endpoint"`
  166. Regions map[string]StartramRegion `json:"regions"`
  167. } `json:"info"`
  168. Transition struct {
  169. Register any `json:"register"`
  170. Toggle any `json:"toggle"`
  171. } `json:"transition"`
  172. }
  173. // broadcast payload subobject
  174. type Urbit struct {
  175. Info struct {
  176. Network string `json:"network"`
  177. Running bool `json:"running"`
  178. URL string `json:"url"`
  179. UrbAlias bool `json:"urbAlias"`
  180. MemUsage uint64 `json:"memUsage"`
  181. DiskUsage int64 `json:"diskUsage"`
  182. LoomSize int `json:"loomSize"`
  183. DevMode bool `json:"devMode"`
  184. DetectBootStatus bool `json:"detectBootStatus"`
  185. Remote bool `json:"remote"`
  186. Vere any `json:"vere"`
  187. } `json:"info"`
  188. Transition struct {
  189. Meld any `json:"meld"`
  190. ServiceRegistrationStatus string `json:"serviceRegistrationStatus"`
  191. TogglePower any `json:"togglePower"`
  192. DeleteShip any `json:"deleteShip"`
  193. } `json:"transition"`
  194. }
  195. // used to construct broadcast pier info subobject
  196. type ContainerStats struct {
  197. MemoryUsage uint64
  198. DiskUsage int64
  199. }
  200. // broadcast payload subobject
  201. type Logs struct {
  202. Containers struct {
  203. Wireguard struct {
  204. Logs []any `json:"logs"`
  205. } `json:"wireguard"`
  206. } `json:"containers"`
  207. System struct {
  208. Stream bool `json:"stream"`
  209. Logs []any `json:"logs"`
  210. } `json:"system"`
  211. }
  212. // broadcast payload subobject
  213. type Upload struct {
  214. Status string `json:"status"`
  215. Size int `json:"size"`
  216. Uploaded int `json:"uploaded"`
  217. Patp any `json:"patp"`
  218. }
  219. // broadcast payload subobject
  220. type UnauthBroadcast struct {
  221. Type string `json:"type"`
  222. AuthLevel string `json:"auth_level"`
  223. Login struct {
  224. Remainder int `json:"remainder"`
  225. } `json:"login"`
  226. }
  227. // broadcast payload subobject
  228. type SetupBroadcast struct {
  229. Type string `json:"type"`
  230. AuthLevel string `json:"auth_level"`
  231. Stage string `json:"stage"`
  232. Page string `json:"page"`
  233. Regions map[string]StartramRegion `json:"regions"`
  234. }
  235. // startram region server subobject
  236. type StartramRegion struct {
  237. Country string `json:"country"`
  238. Desc string `json:"desc"`
  239. }
  240. // pier json struct
  241. type UrbitDocker struct {
  242. PierName string `json:"pier_name"`
  243. HTTPPort int `json:"http_port"`
  244. AmesPort int `json:"ames_port"`
  245. LoomSize int `json:"loom_size"`
  246. UrbitVersion string `json:"urbit_version"`
  247. MinioVersion string `json:"minio_version"`
  248. UrbitRepo string `json:"urbit_repo"`
  249. MinioRepo string `json:"minio_repo"`
  250. UrbitAmd64Sha256 string `json:"urbit_amd64_sha256"`
  251. UrbitArm64Sha256 string `json:"urbit_arm64_sha256"`
  252. MinioAmd64Sha256 string `json:"minio_amd64_sha256"`
  253. MinioArm64Sha256 string `json:"minio_arm64_sha256"`
  254. MinioPassword string `json:"minio_password"`
  255. Network string `json:"network"`
  256. WgURL string `json:"wg_url"`
  257. WgHTTPPort int `json:"wg_http_port"`
  258. WgAmesPort int `json:"wg_ames_port"`
  259. WgS3Port int `json:"wg_s3_port"`
  260. WgConsolePort int `json:"wg_console_port"`
  261. MeldSchedule bool `json:"meld_schedule"`
  262. MeldFrequency int `json:"meld_frequency"`
  263. MeldTime string `json:"meld_time"`
  264. MeldLast string `json:"meld_last"`
  265. MeldNext string `json:"meld_next"`
  266. BootStatus string `json:"boot_status"`
  267. CustomUrbitWeb string `json:"custom_urbit_web"`
  268. CustomS3Web string `json:"custom_s3_web"`
  269. ShowUrbitWeb string `json:"show_urbit_web"`
  270. DevMode bool `json:"dev_mode"`
  271. Click bool `json:"click"`
  272. }