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:
@@ -0,0 +1,42 @@
|
||||
package store
|
||||
|
||||
import "git.tukangketik.id/swanadiva/hostkeeper/v2/internal/model"
|
||||
|
||||
type SettingsStore struct {
|
||||
cfg model.AppConfig
|
||||
}
|
||||
|
||||
func NewSettingsStore() *SettingsStore {
|
||||
s := &SettingsStore{cfg: defaultConfig()}
|
||||
mu.RLock()
|
||||
readFile("settings.json", &s.cfg)
|
||||
mu.RUnlock()
|
||||
return s
|
||||
}
|
||||
|
||||
func (s *SettingsStore) Get() model.AppConfig {
|
||||
mu.RLock()
|
||||
defer mu.RUnlock()
|
||||
return s.cfg
|
||||
}
|
||||
|
||||
func (s *SettingsStore) Update(cfg model.AppConfig) {
|
||||
mu.Lock()
|
||||
defer mu.Unlock()
|
||||
s.cfg = cfg
|
||||
writeFile("settings.json", &s.cfg)
|
||||
}
|
||||
|
||||
func defaultConfig() model.AppConfig {
|
||||
return model.AppConfig{
|
||||
Theme: "light",
|
||||
FontSize: 14,
|
||||
Scrollback: 5000,
|
||||
AutoLock: 5,
|
||||
Keepalive: true,
|
||||
CopyOnSelect: true,
|
||||
BellEnabled: false,
|
||||
AutoReconnect: true,
|
||||
BlinkCursor: false,
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user