mirror of
https://github.com/db9979/sshtermy.git
synced 2026-12-06 20:54:09 +01:00
* Debug-Protokoll für Fehlerberichte, Barrierearm-Modus und Farbenblind-Themes - internal/debuglog: Ereignisse (SSH-Aufbau, Abbrüche, Updates, KI-Anfragen, Sync), Rotation 4 MiB - Schalter in Einstellungen, --debug, bereinigte Kopie (crash.Clean) nach Downloads - Barrierearm: keine Animationen, × für nicht erreichbar, Startanimation aus; geht mit dem Sync - Themes Farbenblind dunkel/hell (Okabe-Ito) - README, README.de, Webseite, Kurzreferenz Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_018i4GUifSEzjZLFvqVjcUxz * Release-Signatur: Schlüssel tolerant lesen, klare Fehlermeldung, Abgleich mit UPDATE_PUBKEY Der Release-Lauf nach #81 brach mit „UPDATE_SIGNING_KEY fehlt oder ist ungültig“ ab. sshtermy-sign ignoriert jetzt Zeilenumbrüche, Leerzeichen, Anführungszeichen und die keygen-Überschrift, nennt bei Fehlern die gefundene Länge (nie den Schlüssel) und prüft, dass der private Schlüssel zu UPDATE_PUBKEY passt. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_018i4GUifSEzjZLFvqVjcUxz * Gesamtsicherung/Umzug und KI-Datenschutz - Gesamtsicherung: ganzer Datenordner als eine mit dem Master-Passwort verschlüsselte Datei (.sshtbak, Argon2id + AES-256-GCM in Blöcken); Einstellungen › Import / Export oder sshtermy backup / restore. Einspielen nach Rückfrage beim Neustart, der alte Ordner bleibt als <ordner>.vorher-<zeit> - KI-Datenschutz (Einstellungen › KI): alle Anbieter / nur lokale KI / KI aus, pro Verbindung per Tag ki-lokal / ki-aus (no-ai, ai-local); strengere Stufe gilt - „Letzte KI-Anfrage ansehen“: was zuletzt an welchen Host/welches Modell ging - Doku: README DE/EN, Webseite, Handout Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_018i4GUifSEzjZLFvqVjcUxz * Audit-Protokoll und Herstellerprofile Juniper, MikroTik, Fortinet - internal/audit: fälschungssicheres Protokoll (HMAC-Kette mit Schlüssel aus dem Store, signierter Kopf gegen abgeschnittene Enden), Monatsdateien im Datenordner - Einstellungen › Sicherheit: Audit-Protokoll an/aus (nur dieser Rechner), prüfen und speichern; erfasst Verbindungen, Befehle (Agent/Broadcast markiert, private nur als „(privat)“), Übertragungen, Config-Sicherungen, Verbindungen, Master-Passwort, Gesamtsicherungen, KI-Anfragen (Host/Modell) - Host-Übersicht und Config-Sicherung für Juniper Junos, MikroTik RouterOS, FortiGate: eigene Befehle und Parser, Prompts „[admin@MikroTik] >“ / „FGT #“, Blättern „---(more)---“ / „-- [Q quit|D dump|down]“; geplante Sicherung nimmt den passenden Befehl - Schnellbefehle Juniper und FortiGate; „nur lesen“ kennt get …, /… print, /export - Doku: README DE/EN, Webseite, Handout Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_018i4GUifSEzjZLFvqVjcUxz * Verbindungen überstehen Ruhezustand und Netzwechsel - internal/netwatch: Ruhezustand (Wanduhr läuft der monotonen Uhr davon oder der Takt kommt viel zu spät) und Netzwechsel (andere eigene Adressen) erkennen - danach prüft sshTermy jede SSH-Leitung sofort (sshx.Client.Check, 4 s) statt bis zu 30 s auf den Keepalive zu warten; wartende Neuverbindungen starten gleich neu - ohne Netz zählen Neuverbindungsversuche nicht, die Sitzung wartet auf eine Adresse - Doku: README DE/EN, Webseite Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_018i4GUifSEzjZLFvqVjcUxz * sshTermy als MCP-Server für KI-Clients - sshtermy mcp: MCP-Server (JSON-RPC über stdin/stdout) als Brücke zur laufenden, entsperrten App (internal/mcp, lokaler Socket mit Token, internal/localsock auch für das eigene Fenster) - Werkzeuge list_connections, list_tabs, read_tab, run_command (eigene unsichtbare Sitzung über broadcast; Netzwerkgeräte per Shell) - Einstellungen › Sicherheit › MCP-Zugriff: aus / nur lesen / mit Rückfrage; nicht lesende oder gefährliche Befehle nur nach j im Fenster - KI-Datenschutz gilt: Tags ki-aus/ki-lokal und „KI aus“ sperren; Geheimnisse in Ausgaben entfernt; jeder Aufruf im Audit-Protokoll - Doku: README DE/EN (Einrichtung Claude Code/Desktop), Webseite, Handout Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_018i4GUifSEzjZLFvqVjcUxz --------- Co-authored-by: Claude <noreply@anthropic.com>
184 lines
5.0 KiB
Go
184 lines
5.0 KiB
Go
package ui
|
||
|
||
import (
|
||
"runtime"
|
||
"strings"
|
||
|
||
"charm.land/bubbles/v2/textinput"
|
||
tea "charm.land/bubbletea/v2"
|
||
"charm.land/lipgloss/v2"
|
||
|
||
"github.com/db9979/sshtermy/internal/domain"
|
||
"github.com/db9979/sshtermy/internal/i18n"
|
||
"github.com/db9979/sshtermy/internal/store"
|
||
"github.com/db9979/sshtermy/internal/vault"
|
||
"github.com/db9979/sshtermy/internal/version"
|
||
)
|
||
|
||
// unlockState: Ersteinrichtung oder Entsperren.
|
||
type unlockState struct {
|
||
setup bool
|
||
pw, pw2 textinput.Model
|
||
focus int
|
||
dpapi bool
|
||
err string
|
||
busy bool
|
||
}
|
||
|
||
func newUnlock(st *store.Store) unlockState {
|
||
u := unlockState{setup: !st.V.Exists(), pw: newInput("", true), pw2: newInput("", true), dpapi: vault.DPAPIAvailable()}
|
||
u.pw.Placeholder = i18n.T("Master-Passwort")
|
||
u.pw2.Placeholder = i18n.T("wiederholen")
|
||
u.pw.Focus()
|
||
return u
|
||
}
|
||
|
||
type unlockedMsg struct{ err error }
|
||
|
||
// init: unter Windows zuerst still per DPAPI entsperren.
|
||
func (u unlockState) init() tea.Cmd { return nil }
|
||
|
||
func (a *App) tryDPAPI() tea.Cmd {
|
||
if a.unlock.setup || !a.st.V.HasDPAPI() {
|
||
return nil
|
||
}
|
||
st := a.st
|
||
return func() tea.Msg {
|
||
if err := st.V.UnlockDPAPI(); err != nil {
|
||
return unlockedMsg{err}
|
||
}
|
||
return unlockedMsg{st.AfterUnlock()}
|
||
}
|
||
}
|
||
|
||
func (a *App) updateUnlock(msg tea.Msg) tea.Cmd {
|
||
u := &a.unlock
|
||
switch m := msg.(type) {
|
||
case unlockedMsg:
|
||
u.busy = false
|
||
if m.err != nil {
|
||
if !strings.Contains(m.err.Error(), "DPAPI") {
|
||
u.err = m.err.Error()
|
||
}
|
||
return nil
|
||
}
|
||
a.scr = scrManager
|
||
if u.setup {
|
||
// Neuer Store: die Sprache des Entsperr-Bildschirms übernehmen.
|
||
_ = a.st.UpdateSettings(func(s *domain.Settings) { s.Language = i18n.Lang() })
|
||
}
|
||
a.lookSig = ""
|
||
a.applyLook()
|
||
a.startDebugLog()
|
||
a.startAudit()
|
||
a.startMCP()
|
||
a.mgr = newManager()
|
||
a.showWhatsNew(u.setup)
|
||
a.maybeTour(u.setup)
|
||
a.checkCrash()
|
||
a.showStartNotice()
|
||
return tea.Batch(checkUpdate(), a.runSync(), a.restoreTabs())
|
||
case tea.KeyPressMsg:
|
||
if u.busy {
|
||
return nil
|
||
}
|
||
switch m.String() {
|
||
case "esc":
|
||
return a.quit()
|
||
case "tab", "down", "up", "shift+tab":
|
||
if u.setup {
|
||
u.focus = (u.focus + 1) % 3
|
||
u.pw.Blur()
|
||
u.pw2.Blur()
|
||
if u.focus == 0 {
|
||
return u.pw.Focus()
|
||
} else if u.focus == 1 {
|
||
return u.pw2.Focus()
|
||
}
|
||
}
|
||
return nil
|
||
case "space":
|
||
if u.setup && u.focus == 2 {
|
||
u.dpapi = !u.dpapi && vault.DPAPIAvailable()
|
||
return nil
|
||
}
|
||
case "enter":
|
||
pw := []byte(u.pw.Value())
|
||
st := a.st
|
||
if u.setup {
|
||
if u.focus == 0 {
|
||
u.focus = 1
|
||
u.pw.Blur()
|
||
return u.pw2.Focus()
|
||
}
|
||
if u.pw.Value() != u.pw2.Value() {
|
||
u.err = i18n.T("Passwörter stimmen nicht überein")
|
||
return nil
|
||
}
|
||
dp := u.dpapi
|
||
u.busy, u.err = true, ""
|
||
return func() tea.Msg { return unlockedMsg{st.Init(pw, dp)} }
|
||
}
|
||
u.busy, u.err = true, ""
|
||
return func() tea.Msg {
|
||
if err := st.V.UnlockPassword(pw); err != nil {
|
||
return unlockedMsg{err}
|
||
}
|
||
return unlockedMsg{st.AfterUnlock()}
|
||
}
|
||
}
|
||
}
|
||
var cmd tea.Cmd
|
||
if u.focus == 0 {
|
||
u.pw, cmd = u.pw.Update(msg)
|
||
} else if u.focus == 1 {
|
||
u.pw2, cmd = u.pw2.Update(msg)
|
||
}
|
||
return cmd
|
||
}
|
||
|
||
const logoArt = `
|
||
┌─┐┌─┐┬ ┬╔╦╗┌─┐┬─┐┌┬┐┬ ┬
|
||
└─┐└─┐├─┤ ║ ├┤ ├┬┘│││└┬┘
|
||
└─┘└─┘┴ ┴ ╩ └─┘┴└─┴ ┴ ┴ `
|
||
|
||
func (a *App) viewUnlock() string {
|
||
u := a.unlock
|
||
s := a.s
|
||
var b strings.Builder
|
||
b.WriteString(s.Accent.Render(logoArt) + "\n")
|
||
b.WriteString(s.Muted.Render(" "+i18n.T(version.Slogan)+" · v"+version.Version) + "\n")
|
||
b.WriteString(s.Muted.Italic(true).Render(" "+i18n.T(version.Idea)) + "\n\n")
|
||
if u.setup {
|
||
b.WriteString(s.Text.Render(i18n.T("Willkommen! Lege ein Master-Passwort für deinen verschlüsselten Store an.")) + "\n")
|
||
b.WriteString(s.Muted.Render(i18n.T("Es wird nie gespeichert. Argon2id + AES-256-GCM schützen Passwörter, Keys und API-Keys.")) + "\n\n")
|
||
b.WriteString(s.Label.Render(i18n.T("Master-Passwort")) + u.pw.View() + "\n")
|
||
b.WriteString(s.Label.Render(i18n.T("Wiederholen")) + u.pw2.View() + "\n")
|
||
mark := "○"
|
||
if u.dpapi {
|
||
mark = s.OK.Render("●")
|
||
}
|
||
lbl := i18n.T("Mit Windows-Anmeldung entsperren (DPAPI)")
|
||
if !vault.DPAPIAvailable() {
|
||
lbl = i18n.T("DPAPI nur unter Windows (") + runtime.GOOS + i18n.T(": nur Master-Passwort)")
|
||
}
|
||
focus := " "
|
||
if u.focus == 2 {
|
||
focus = s.Accent.Render("▌ ")
|
||
}
|
||
b.WriteString(focus + mark + " " + s.Text.Render(lbl) + "\n")
|
||
} else {
|
||
b.WriteString(s.Text.Render(i18n.T("Store gesperrt.")) + "\n\n")
|
||
b.WriteString(s.Label.Render(i18n.T("Master-Passwort")) + u.pw.View() + "\n")
|
||
}
|
||
if u.busy {
|
||
b.WriteString("\n" + s.AI.Render(i18n.T("⠿ Schlüssel wird abgeleitet (Argon2id) …")))
|
||
}
|
||
if u.err != "" {
|
||
b.WriteString("\n" + s.Danger.Render("× "+u.err))
|
||
}
|
||
keys := [][2]string{{"⏎", i18n.T("weiter")}, {"Tab", i18n.T("Feld")}, {"Esc", i18n.T("beenden")}}
|
||
box := s.dialog(dialog{icon: "◆", title: version.Name, sub: "v" + version.Version, body: b.String(), keys: keys, width: min(80, a.w-8), noClose: true}, a.w)
|
||
return lipgloss.Place(a.w, a.h, lipgloss.Center, lipgloss.Center, box)
|
||
}
|