structs.go 9.0 KB

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