fix test connection button

increase buffer to 512 bytes
made it a blocking read because its happening on a bg thread anyways
using a cchar bitpattern for each string.utf8 when writing
its made no diff yet
increased sleep if nothing is returned
This commit is contained in:
neon443
2025-06-23 13:41:20 +01:00
parent 8df8c77c7a
commit 31beda2124
3 changed files with 14 additions and 6 deletions

View File

@@ -320,8 +320,8 @@ class SSHHandler: ObservableObject {
guard ssh_channel_is_open(channel) != 0 else { return nil }
guard ssh_channel_is_eof(channel) == 0 else { return nil }
var buffer: [CChar] = Array(repeating: 0, count: 256)
let nbytes = ssh_channel_read_nonblocking(channel, &buffer, UInt32(buffer.count), 0)
var buffer: [CChar] = Array(repeating: 0, count: 512)
let nbytes = ssh_channel_read(channel, &buffer, UInt32(buffer.count), 0)
guard nbytes > 0 else { return nil }
@@ -345,7 +345,10 @@ class SSHHandler: ObservableObject {
guard ssh_channel_is_open(channel) != 0 else { return }
guard ssh_channel_is_eof(channel) == 0 else { return }
var buffer: [CChar] = Array(string.utf8CString)
var buffer: [CChar] = []
for byte in string.utf8 {
buffer.append(CChar(bitPattern: byte))
}
let nwritten = Int(ssh_channel_write(channel, &buffer, UInt32(buffer.count)))
if nwritten != buffer.count {
@@ -353,7 +356,7 @@ class SSHHandler: ObservableObject {
}
}
func resizeTTY(toRows: Int, toCols: Int) {
func resizePTY(toRows: Int, toCols: Int) {
guard ssh_channel_is_open(channel) != 0 else { return }
guard ssh_channel_is_eof(channel) == 0 else { return }