Sprint 6: JSON file persistence + real SSH terminal + V1 crypto/knownhosts integration

- go.mod replace directive for git.tukangketik.id/swanadiva/hostkeeper → ../../v1
- store/ package: JSON file persistence for hosts, snippets, keys, settings
  (~/Library/Application Support/hostkeeper/v2/)
- model SSH fields: Hostname, Port, Username, AuthType, Password, KeyID
- sshconn/ package: real SSH client via golang.org/x/crypto/ssh
- Terminal WS: real SSH connection with fallback to mock shell
- Dynamic host list in terminal (server-rendered JSON script tag)
- All mock data defaults removed from model packages
- Settings persist via store/settings.go
This commit is contained in:
swanadiva
2026-07-07 13:53:50 +07:00
parent 04d9cfb096
commit fd7361aa14
21 changed files with 746 additions and 306 deletions
+8 -7
View File
@@ -3,9 +3,10 @@ package handler
import (
"github.com/gofiber/fiber/v2"
"git.tukangketik.id/swanadiva/hostkeeper/v2/internal/model"
"git.tukangketik.id/swanadiva/hostkeeper/v2/internal/store"
)
var store = model.NewHostStore()
var hostStore = store.NewHostStore()
var navItems = []fiber.Map{
{"ID": "hosts", "Label": "Hosts", "Icon": "server"},
@@ -17,7 +18,7 @@ var navItems = []fiber.Map{
}
func Dashboard(c *fiber.Ctx) error {
hosts := store.All()
hosts := hostStore.All()
return c.Render("index", fiber.Map{
"View": "hosts",
"Title": "Hosts",
@@ -31,7 +32,7 @@ func Dashboard(c *fiber.Ctx) error {
func DashboardList(c *fiber.Ctx) error {
q := c.Query("q")
filter := c.Query("filter", "all")
hosts := store.Search(q, filter)
hosts := hostStore.Search(q, filter)
return c.Render("host_list", fiber.Map{
"Hosts": hosts,
"Active": countByStatus(hosts, "active"),
@@ -50,8 +51,8 @@ func CreateHost(c *fiber.Ctx) error {
return c.Status(400).SendString("name and ip required")
}
store.Add(name, ip, os, provider, hostType)
hosts := store.All()
hostStore.Add(name, ip, os, provider, hostType)
hosts := hostStore.All()
return c.Render("host_list", fiber.Map{
"Hosts": hosts,
"Active": countByStatus(hosts, "active"),
@@ -61,8 +62,8 @@ func CreateHost(c *fiber.Ctx) error {
func DeleteHost(c *fiber.Ctx) error {
id := c.Params("id")
store.Delete(id)
hosts := store.All()
hostStore.Delete(id)
hosts := hostStore.All()
return c.Render("host_list", fiber.Map{
"Hosts": hosts,
"Active": countByStatus(hosts, "active"),