structs.go 8.5 KB

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