structs.go 9.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330
  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 map[string]Channel `json:"groundseg"`
  87. }
  88. // version server payload substruct
  89. type Channel struct {
  90. Groundseg VersionDetails `json:"groundseg"`
  91. Manual VersionDetails `json:"manual"`
  92. Minio VersionDetails `json:"minio"`
  93. Miniomc VersionDetails `json:"miniomc"`
  94. Netdata VersionDetails `json:"netdata"`
  95. Vere VersionDetails `json:"vere"`
  96. Webui VersionDetails `json:"webui"`
  97. Wireguard VersionDetails `json:"wireguard"`
  98. }
  99. // version server payload substruct
  100. type VersionDetails struct {
  101. Amd64Sha256 string `json:"amd64_sha256"`
  102. Amd64URL string `json:"amd64_url,omitempty"`
  103. Arm64Sha256 string `json:"arm64_sha256"`
  104. Arm64URL string `json:"arm64_url,omitempty"`
  105. Major int `json:"major,omitempty"`
  106. Minor int `json:"minor,omitempty"`
  107. Patch int `json:"patch,omitempty"`
  108. Repo string `json:"repo,omitempty"`
  109. Tag string `json:"tag,omitempty"`
  110. }
  111. // broadcast payload object struct
  112. type AuthBroadcast struct {
  113. Type string `json:"type"`
  114. AuthLevel string `json:"auth_level"`
  115. Upload Upload `json:"upload"`
  116. Logs Logs `json:"logs"`
  117. System SystemInfo `json:"system"`
  118. Profile Profile `json:"profile"`
  119. Urbits map[string]Urbit `json:"urbits"`
  120. }
  121. // broadcast payload subobject
  122. type SystemUsage struct {
  123. RAM []uint64 `json:"ram"`
  124. CPU int `json:"cpu"`
  125. CPUTemp float64 `json:"cpu_temp"`
  126. Disk []uint64 `json:"disk"`
  127. SwapFile int `json:"swap"`
  128. }
  129. // broadcast payload subobject
  130. type SystemUpdates struct {
  131. Linux struct {
  132. State string `json:"state"`
  133. Upgrade int `json:"upgrade"`
  134. New int `json:"new"`
  135. Remove int `json:"remove"`
  136. Ignore int `json:"ignore"`
  137. } `json:"linux"`
  138. }
  139. // broadcast payload subobject
  140. type SystemWifi struct {
  141. Status string `json:"status"`
  142. Active string `json:"active"`
  143. Networks []string `json:"networks"`
  144. }
  145. // broadcast payload subobject
  146. type SystemInfo struct {
  147. Usage SystemUsage `json:"usage"`
  148. Updates SystemUpdates `json:"updates"`
  149. Wifi SystemWifi `json:"wifi"`
  150. }
  151. // broadcast payload subobject
  152. type Profile struct {
  153. Startram Startram `json:"startram"`
  154. }
  155. // broadcast payload subobject
  156. type Startram struct {
  157. Info struct {
  158. Registered bool `json:"registered"`
  159. Running bool `json:"running"`
  160. Region any `json:"region"`
  161. Expiry any `json:"expiry"`
  162. Renew bool `json:"renew"`
  163. Endpoint string `json:"endpoint"`
  164. Regions map[string]StartramRegion `json:"regions"`
  165. } `json:"info"`
  166. Transition struct {
  167. Register any `json:"register"`
  168. Toggle any `json:"toggle"`
  169. } `json:"transition"`
  170. }
  171. // broadcast payload subobject
  172. type Urbit struct {
  173. Info struct {
  174. Network string `json:"network"`
  175. Running bool `json:"running"`
  176. URL string `json:"url"`
  177. UrbAlias bool `json:"urbAlias"`
  178. MemUsage uint64 `json:"memUsage"`
  179. DiskUsage int64 `json:"diskUsage"`
  180. LoomSize int `json:"loomSize"`
  181. DevMode bool `json:"devMode"`
  182. DetectBootStatus bool `json:"detectBootStatus"`
  183. Remote bool `json:"remote"`
  184. Vere any `json:"vere"`
  185. } `json:"info"`
  186. Transition struct {
  187. Meld any `json:"meld"`
  188. ServiceRegistrationStatus string `json:"serviceRegistrationStatus"`
  189. TogglePower any `json:"togglePower"`
  190. DeleteShip any `json:"deleteShip"`
  191. } `json:"transition"`
  192. }
  193. // used to construct broadcast pier info subobject
  194. type ContainerStats struct {
  195. MemoryUsage uint64
  196. DiskUsage int64
  197. }
  198. // broadcast payload subobject
  199. type Logs struct {
  200. Containers struct {
  201. Wireguard struct {
  202. Logs []any `json:"logs"`
  203. } `json:"wireguard"`
  204. } `json:"containers"`
  205. System struct {
  206. Stream bool `json:"stream"`
  207. Logs []any `json:"logs"`
  208. } `json:"system"`
  209. }
  210. // broadcast payload subobject
  211. type Upload struct {
  212. Status string `json:"status"`
  213. Size int `json:"size"`
  214. Uploaded int `json:"uploaded"`
  215. Patp any `json:"patp"`
  216. }
  217. // broadcast payload subobject
  218. type UnauthBroadcast struct {
  219. Type string `json:"type"`
  220. AuthLevel string `json:"auth_level"`
  221. Login struct {
  222. Remainder int `json:"remainder"`
  223. } `json:"login"`
  224. }
  225. // broadcast payload subobject
  226. type SetupBroadcast struct {
  227. Type string `json:"type"`
  228. AuthLevel string `json:"auth_level"`
  229. Stage string `json:"stage"`
  230. Page string `json:"page"`
  231. Regions map[string]StartramRegion `json:"regions"`
  232. }
  233. // startram region server subobject
  234. type StartramRegion struct {
  235. Country string `json:"country"`
  236. Desc string `json:"desc"`
  237. }
  238. // pier json struct
  239. type UrbitDocker struct {
  240. PierName string `json:"pier_name"`
  241. HTTPPort int `json:"http_port"`
  242. AmesPort int `json:"ames_port"`
  243. LoomSize int `json:"loom_size"`
  244. UrbitVersion string `json:"urbit_version"`
  245. MinioVersion string `json:"minio_version"`
  246. UrbitRepo string `json:"urbit_repo"`
  247. MinioRepo string `json:"minio_repo"`
  248. UrbitAmd64Sha256 string `json:"urbit_amd64_sha256"`
  249. UrbitArm64Sha256 string `json:"urbit_arm64_sha256"`
  250. MinioAmd64Sha256 string `json:"minio_amd64_sha256"`
  251. MinioArm64Sha256 string `json:"minio_arm64_sha256"`
  252. MinioPassword string `json:"minio_password"`
  253. Network string `json:"network"`
  254. WgURL string `json:"wg_url"`
  255. WgHTTPPort int `json:"wg_http_port"`
  256. WgAmesPort int `json:"wg_ames_port"`
  257. WgS3Port int `json:"wg_s3_port"`
  258. WgConsolePort int `json:"wg_console_port"`
  259. MeldSchedule bool `json:"meld_schedule"`
  260. MeldFrequency int `json:"meld_frequency"`
  261. MeldTime string `json:"meld_time"`
  262. MeldLast string `json:"meld_last"`
  263. MeldNext string `json:"meld_next"`
  264. BootStatus string `json:"boot_status"`
  265. CustomUrbitWeb string `json:"custom_urbit_web"`
  266. CustomS3Web string `json:"custom_s3_web"`
  267. ShowUrbitWeb string `json:"show_urbit_web"`
  268. DevMode bool `json:"dev_mode"`
  269. Click bool `json:"click"`
  270. }
  271. type WgConfig struct {
  272. WireguardName string `json:"wireguard_name"`
  273. WireguardVersion string `json:"wireguard_version"`
  274. Repo string `json:"repo"`
  275. Amd64Sha256 string `json:"amd64_sha256"`
  276. Arm64Sha256 string `json:"arm64_sha256"`
  277. CapAdd []string `json:"cap_add"`
  278. Volumes []string `json:"volumes"`
  279. Sysctls struct {
  280. NetIpv4ConfAllSrcValidMark int `json:"net.ipv4.conf.all.src_valid_mark"`
  281. } `json:"sysctls"`
  282. }
  283. type McConfig struct {
  284. McName string `json:"mc_name"`
  285. McVersion string `json:"mc_version"`
  286. Repo string `json:"repo"`
  287. Amd64Sha256 string `json:"amd64_sha256"`
  288. Arm64Sha256 string `json:"arm64_sha256"`
  289. }
  290. type NetdataConfig struct {
  291. NetdataName string `json:"netdata_name"`
  292. Repo string `json:"repo"`
  293. NetdataVersion string `json:"netdata_version"`
  294. Amd64Sha256 string `json:"amd64_sha256"`
  295. Arm64Sha256 string `json:"arm64_sha256"`
  296. CapAdd []string `json:"cap_add"`
  297. Port int `json:"port"`
  298. Restart string `json:"restart"`
  299. SecurityOpt string `json:"security_opt"`
  300. Volumes []string `json:"volumes"`
  301. }