may have actually fixed the whole hostkey changed flow, however accepting the new key causes the wierd keyboard issue when it opens the terminal

you can now forget hostkeys
removed the dispatchqueue on the disconnect function
updated updatehost to remove stupid ahh logic
This commit is contained in:
neon443
2025-08-05 11:14:00 +01:00
parent d6822f7614
commit ca34d3eafb
4 changed files with 23 additions and 15 deletions

View File

@@ -223,15 +223,16 @@ class HostsManager: ObservableObject, @unchecked Sendable {
}
func updateHost(_ updatedHost: Host) {
let oldID = updatedHost.id
// let oldID = updatedHost.id
if let index = hosts.firstIndex(where: { $0.id == updatedHost.id }) {
var updateHostWithNewID = updatedHost
updateHostWithNewID.id = UUID()
withAnimation { hosts[index] = updateHostWithNewID }
updateHostWithNewID.id = oldID
withAnimation { hosts[index] = updateHostWithNewID }
withAnimation { hosts[index] = updatedHost }
// var updateHostWithNewID = updatedHost
// updateHostWithNewID.id = UUID()
// withAnimation { hosts[index] = updateHostWithNewID }
//
// updateHostWithNewID.id = oldID
// withAnimation { hosts[index] = updateHostWithNewID }
saveHosts()
} else {
withAnimation { hosts.append(updatedHost) }

View File

@@ -142,10 +142,9 @@ class SSHHandler: @unchecked Sendable, ObservableObject {
}
func disconnect() {
DispatchQueue.main.async {
self.hostkeyChanged = false
withAnimation { self.state = .idle }
withAnimation { self.testSuceeded = nil }
}
if let sessionID {
Task { @MainActor in

View File

@@ -112,8 +112,9 @@ struct ConnectionView: View {
.alert("Hostkey changed", isPresented: $handler.hostkeyChanged) {
Button(role: .destructive) {
handler.host.key = handler.getHostkey()
hostsManager.updateHost(handler.host)
handler.disconnect()
handler.go()
showTerminal = checkShell(handler.state)
} label: {
Text("Accept Hostkey")
}
@@ -140,7 +141,6 @@ Hostkey fingerprint is \(handler.getHostkey() ?? "nil")
.toolbar {
ToolbarItem() {
Button() {
hostsManager.updateHost(handler.host)
handler.go()
showTerminal = checkShell(handler.state)
} label: {

View File

@@ -25,7 +25,7 @@ struct HostkeysView: View {
VStack(alignment: .leading) {
Text("Connect to some hosts to collect more hostkeys!")
.padding(.bottom)
Text("ShhShell remembers hostkey fingerprints for you, and can alert you if they change.")
Text("ShhShell remembers hostkey fingerprints for you, and will alert you if they change.")
.font(.subheadline)
Text("This could be due a man in the middle attack, where a bad actor tries to impersonate your server.")
.font(.subheadline)
@@ -33,7 +33,7 @@ struct HostkeysView: View {
}
}
ForEach(hostsManager.hosts) { host in
ForEach($hostsManager.hosts) { $host in
VStack(alignment: .leading) {
if !host.name.isEmpty {
Text("name")
@@ -49,6 +49,14 @@ struct HostkeysView: View {
.bold()
Text(host.key ?? "nil")
}
.swipeActions(edge: .trailing, allowsFullSwipe: true) {
Button(/*role: .destructive*/) {
host.key = nil
hostsManager.updateHost(host)
} label: {
Label("Forget", systemImage: "trash")
}
}
}
}
.scrollContentBackground(.hidden)