diff --git a/beszel/internal/agent/agent.go b/beszel/internal/agent/agent.go
index af830b3..ec0c3b0 100644
--- a/beszel/internal/agent/agent.go
+++ b/beszel/internal/agent/agent.go
@@ -1,6 +1,7 @@
package agent
import (
+ "beszel"
"beszel/internal/entities/container"
"beszel/internal/entities/system"
"bytes"
@@ -140,9 +141,10 @@ func (a *Agent) getSystemStats() (*system.Info, *system.Stats) {
}
systemInfo := &system.Info{
- Cpu: systemStats.Cpu,
- MemPct: systemStats.MemPct,
- DiskPct: systemStats.DiskPct,
+ Cpu: systemStats.Cpu,
+ MemPct: systemStats.MemPct,
+ DiskPct: systemStats.DiskPct,
+ AgentVersion: beszel.Version,
}
// add host info
@@ -162,7 +164,6 @@ func (a *Agent) getSystemStats() (*system.Info, *system.Stats) {
}
return systemInfo, systemStats
-
}
func (a *Agent) getDockerStats() ([]*container.Stats, error) {
diff --git a/beszel/internal/entities/system/system.go b/beszel/internal/entities/system/system.go
index 6c9550c..154ab1a 100644
--- a/beszel/internal/entities/system/system.go
+++ b/beszel/internal/entities/system/system.go
@@ -41,10 +41,11 @@ type Info struct {
Threads int `json:"t"`
CpuModel string `json:"m"`
// Os string `json:"o"`
- Uptime uint64 `json:"u"`
- Cpu float64 `json:"cpu"`
- MemPct float64 `json:"mp"`
- DiskPct float64 `json:"dp"`
+ Uptime uint64 `json:"u"`
+ Cpu float64 `json:"cpu"`
+ MemPct float64 `json:"mp"`
+ DiskPct float64 `json:"dp"`
+ AgentVersion string `json:"v"`
}
// Final data structure to return to the hub
diff --git a/beszel/internal/hub/hub.go b/beszel/internal/hub/hub.go
index 99b5acd..e06b91e 100644
--- a/beszel/internal/hub/hub.go
+++ b/beszel/internal/hub/hub.go
@@ -1,6 +1,7 @@
package hub
import (
+ "beszel"
"beszel/internal/alerts"
"beszel/internal/entities/system"
"beszel/internal/records"
@@ -34,6 +35,7 @@ type Hub struct {
connectionLock *sync.Mutex
systemConnections map[string]*ssh.Client
sshClientConfig *ssh.ClientConfig
+ pubKey string
}
func NewHub(app *pocketbase.PocketBase) *Hub {
@@ -127,11 +129,7 @@ func (h *Hub) Run() {
if requestData.AuthRecord == nil {
return apis.NewForbiddenError("Forbidden", nil)
}
- key, err := os.ReadFile(h.app.DataDir() + "/id_ed25519.pub")
- if err != nil {
- return err
- }
- return c.JSON(http.StatusOK, map[string]string{"key": strings.TrimSuffix(string(key), "\n")})
+ return c.JSON(http.StatusOK, map[string]string{"key": h.pubKey, "v": beszel.Version})
})
// check if first time setup on login page
e.Router.GET("/api/beszel/first-run", func(c echo.Context) error {
@@ -384,6 +382,10 @@ func (h *Hub) getSSHKey() ([]byte, error) {
// check if the key pair already exists
existingKey, err := os.ReadFile(dataDir + "/id_ed25519")
if err == nil {
+ if pubKey, err := os.ReadFile(h.app.DataDir() + "/id_ed25519.pub"); err == nil {
+ h.pubKey = strings.TrimSuffix(string(pubKey), "\n")
+ }
+ // return existing private key
return existingKey, nil
}
@@ -421,6 +423,7 @@ func (h *Hub) getSSHKey() ([]byte, error) {
}
pubKeyBytes := ssh.MarshalAuthorizedKey(publicKey)
+ h.pubKey = strings.TrimSuffix(string(pubKeyBytes), "\n")
// Save the public key to a file
publicFile, err := os.Create(dataDir + "/id_ed25519.pub")
diff --git a/beszel/site/src/components/add-system.tsx b/beszel/site/src/components/add-system.tsx
index 0732fc1..85f2567 100644
--- a/beszel/site/src/components/add-system.tsx
+++ b/beszel/site/src/components/add-system.tsx
@@ -14,7 +14,7 @@ import { Input } from '@/components/ui/input'
import { Label } from '@/components/ui/label'
import { $publicKey, pb } from '@/lib/stores'
import { Copy, Plus } from 'lucide-react'
-import { useState, useRef, MutableRefObject, useEffect } from 'react'
+import { useState, useRef, MutableRefObject } from 'react'
import { useStore } from '@nanostores/react'
import { copyToClipboard } from '@/lib/utils'
@@ -38,16 +38,6 @@ export function AddSystemButton() {
# FILESYSTEM: /dev/sda1 # set to the correct filesystem for disk I/O stats`)
}
- useEffect(() => {
- if (publicKey || !open) {
- return
- }
- // get public key
- pb.send('/api/beszel/getkey', {}).then(({ key }) => {
- $publicKey.set(key)
- })
- }, [open])
-
async function handleSubmit(e: SubmitEvent) {
e.preventDefault()
const formData = new FormData(e.target as HTMLFormElement)
diff --git a/beszel/site/src/components/routes/home.tsx b/beszel/site/src/components/routes/home.tsx
index 8516e72..60df5e7 100644
--- a/beszel/site/src/components/routes/home.tsx
+++ b/beszel/site/src/components/routes/home.tsx
@@ -1,30 +1,57 @@
import { Suspense, lazy, useEffect } from 'react'
import { Card, CardContent, CardDescription, CardHeader, CardTitle } from '../ui/card'
+import { $hubVersion } from '@/lib/stores'
+import { useStore } from '@nanostores/react'
+import { GithubIcon } from 'lucide-react'
+import { Separator } from '../ui/separator'
const SystemsTable = lazy(() => import('../systems-table/systems-table'))
export default function () {
+ const hubVersion = useStore($hubVersion)
+
useEffect(() => {
document.title = 'Dashboard / Beszel'
}, [])
return (
-