added dialogview for custom dialogs

added nice green color
updated debug host
reduced sleep greatly
removed channel checker in sshqueasync loop
set dark mode on the app
gonna start work on async in sshhandler
This commit is contained in:
neon443
2025-06-24 12:33:52 +01:00
parent 3f2c92cd91
commit 1e3a57d788
8 changed files with 112 additions and 8 deletions

View File

@@ -12,7 +12,8 @@ import SwiftUI
class SSHHandler: @unchecked Sendable, ObservableObject {
private var session: ssh_session?
var channel: ssh_channel?
private var channel: ssh_channel?
private let sshQueue = DispatchQueue(label: "SSH Queue")
@Published var connected: Bool = false
@Published var authorized: Bool = false
@@ -332,22 +333,22 @@ class SSHHandler: @unchecked Sendable, ObservableObject {
}
func readFromChannel() -> String? {
if !connected {
return nil
}
guard connected else { return nil }
guard ssh_channel_is_open(channel) != 0 || ssh_channel_is_eof(channel) == 0 else {
disconnect()
return nil
}
var buffer: [CChar] = Array(repeating: 0, count: 512)
var buffer: [CChar] = Array(repeating: 0, count: 4096)
let nbytes = ssh_channel_read_nonblocking(channel, &buffer, UInt32(buffer.count), 0)
guard nbytes > 0 else { return nil }
let data = Data(bytes: buffer, count: Int(nbytes))
if let string = String(data: data, encoding: .utf8) {
#if DEBUG
print(String(data: Data(bytes: buffer, count: Int(nbytes)), encoding: .utf8)!)
#endif
return string
}
return nil