mirror of
https://github.com/neon443/ShhShell.git
synced 2026-03-11 13:26:16 +00:00
added a disconnected info thingy, with a reconnect button that umm kinda doesnt let u use the terminal 💀
fix runtime errors when calling handler.disconnect() from bg threads
This commit is contained in:
@@ -140,9 +140,11 @@ class SSHHandler: @unchecked Sendable, ObservableObject {
|
||||
}
|
||||
|
||||
func disconnect() {
|
||||
self.hostkeyChanged = false
|
||||
withAnimation { self.state = .idle }
|
||||
withAnimation { self.testSuceeded = nil }
|
||||
// Task {
|
||||
self.hostkeyChanged = false
|
||||
withAnimation { self.state = .idle }
|
||||
withAnimation { self.testSuceeded = nil }
|
||||
// }
|
||||
|
||||
if let sessionID {
|
||||
Task { @MainActor in
|
||||
@@ -303,21 +305,6 @@ class SSHHandler: @unchecked Sendable, ObservableObject {
|
||||
return
|
||||
}
|
||||
|
||||
//MARK: very wip
|
||||
// func authWithKbint() {
|
||||
// withAnimation { state = .authorizingKbint }
|
||||
//
|
||||
// let status = ssh_userauth_kbdint(session, nil, nil)
|
||||
// if status == SSH_AUTH_INFO.rawValue {
|
||||
// print(ssh_userauth_kbdint_getnprompts(session))
|
||||
// print(ssh_userauth_kbdint_getname(session))
|
||||
// print(ssh_userauth_kbdint_getinstruction(session))
|
||||
// print(ssh_userauth_kbdint_getprompt(session, <#T##i: UInt32##UInt32#>, <#T##echo: UnsafeMutablePointer<CChar>!##UnsafeMutablePointer<CChar>!#>))
|
||||
// }
|
||||
//
|
||||
//// for prompt in
|
||||
// }
|
||||
|
||||
func getAuthMethods() -> [AuthType] {
|
||||
var result: [AuthType] = []
|
||||
let recievedMethod = UInt32(ssh_userauth_list(session, nil))
|
||||
@@ -390,7 +377,7 @@ class SSHHandler: @unchecked Sendable, ObservableObject {
|
||||
func writeToChannel(_ string: String?) {
|
||||
guard let string else { return }
|
||||
guard ssh_channel_is_open(channel) == 1 && ssh_channel_is_eof(channel) == 0 else {
|
||||
Task { disconnect() }
|
||||
Task { @MainActor in disconnect() }
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
@@ -55,6 +55,38 @@ struct ShellView: View {
|
||||
AudioServicesPlaySystemSound(1103)
|
||||
}
|
||||
}
|
||||
|
||||
if !checkShell(handler.state) {
|
||||
ZStack {
|
||||
RoundedRectangle(cornerRadius: 25)
|
||||
.fill(hostsManager.selectedTheme.foreground.suiColor.opacity(0.5))
|
||||
.blur(radius: 5)
|
||||
.shadow(color: hostsManager.selectedTheme.foreground.suiColor, radius: 5)
|
||||
VStack {
|
||||
HStack {
|
||||
Image(systemName: "wifi.exclamationmark")
|
||||
.resizable().scaledToFit()
|
||||
.foregroundStyle(hostsManager.selectedTheme.background.suiColor)
|
||||
.frame(width: 30)
|
||||
Text("Disconnected")
|
||||
.foregroundStyle(hostsManager.selectedTheme.background.suiColor)
|
||||
.font(.title)
|
||||
}
|
||||
Button {
|
||||
handler.go()
|
||||
} label: {
|
||||
Text("Connect")
|
||||
.foregroundStyle(hostsManager.selectedTheme.background.suiColor)
|
||||
.padding(5)
|
||||
.frame(maxWidth: .infinity)
|
||||
.background(.tint)
|
||||
.clipShape(RoundedRectangle(cornerRadius: 15))
|
||||
}
|
||||
}
|
||||
.padding(10)
|
||||
}
|
||||
.fixedSize()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user