mirror of
https://github.com/neon443/ShhShell.git
synced 2026-03-11 13:26:16 +00:00
swift 6 underway
This commit is contained in:
@@ -616,6 +616,7 @@
|
||||
PRODUCT_BUNDLE_IDENTIFIER = com.neon443.ShhShell;
|
||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||
SWIFT_EMIT_LOC_STRINGS = YES;
|
||||
SWIFT_STRICT_CONCURRENCY = complete;
|
||||
SWIFT_VERSION = 5.0;
|
||||
TARGETED_DEVICE_FAMILY = "1,2";
|
||||
};
|
||||
@@ -648,6 +649,7 @@
|
||||
PRODUCT_BUNDLE_IDENTIFIER = com.neon443.ShhShell;
|
||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||
SWIFT_EMIT_LOC_STRINGS = YES;
|
||||
SWIFT_STRICT_CONCURRENCY = complete;
|
||||
SWIFT_VERSION = 5.0;
|
||||
TARGETED_DEVICE_FAMILY = "1,2";
|
||||
};
|
||||
|
||||
@@ -10,7 +10,7 @@ import LibSSH
|
||||
import OSLog
|
||||
import SwiftUI
|
||||
|
||||
class SSHHandler: ObservableObject {
|
||||
class SSHHandler: @unchecked Sendable, ObservableObject {
|
||||
private var session: ssh_session?
|
||||
var channel: ssh_channel?
|
||||
|
||||
@@ -240,12 +240,10 @@ class SSHHandler: ObservableObject {
|
||||
//if u got this far, youre authed!
|
||||
withAnimation { authorized = true }
|
||||
|
||||
DispatchQueue.main.asyncAfter(deadline: .now()+10) {
|
||||
ssh_key_free(pubkey)
|
||||
ssh_key_free(privkey)
|
||||
try? fileManager.removeItem(at: tempPubkey)
|
||||
try? fileManager.removeItem(at: tempKey)
|
||||
}
|
||||
try? FileManager.default.removeItem(at: tempPubkey)
|
||||
try? FileManager.default.removeItem(at: tempKey)
|
||||
return
|
||||
}
|
||||
|
||||
@@ -334,7 +332,6 @@ class SSHHandler: ObservableObject {
|
||||
}
|
||||
|
||||
func readFromChannel() -> String? {
|
||||
print(connected)
|
||||
if !connected {
|
||||
return nil
|
||||
}
|
||||
@@ -366,6 +363,7 @@ class SSHHandler: ObservableObject {
|
||||
|
||||
func writeToChannel(_ string: String?) {
|
||||
guard let string = string else { return }
|
||||
guard channel != nil else { return }
|
||||
guard ssh_channel_is_open(channel) != 0 || ssh_channel_is_eof(channel) == 0 else {
|
||||
disconnect()
|
||||
return
|
||||
|
||||
@@ -9,7 +9,8 @@ import Foundation
|
||||
import UIKit
|
||||
import SwiftTerm
|
||||
|
||||
class SSHTerminalView: TerminalView, TerminalViewDelegate {
|
||||
@MainActor
|
||||
class SSHTerminalView: TerminalView, Sendable, @preconcurrency TerminalViewDelegate {
|
||||
var handler: SSHHandler?
|
||||
var sshQueue: DispatchQueue
|
||||
|
||||
@@ -29,7 +30,7 @@ class SSHTerminalView: TerminalView, TerminalViewDelegate {
|
||||
|
||||
while handler.connected {
|
||||
if let read = handler.readFromChannel() {
|
||||
DispatchQueue.main.async { self.feed(text: read) }
|
||||
self.feed(text: read)
|
||||
} else {
|
||||
usleep(100_000)
|
||||
}
|
||||
@@ -42,11 +43,11 @@ class SSHTerminalView: TerminalView, TerminalViewDelegate {
|
||||
fatalError("unimplemented")
|
||||
}
|
||||
|
||||
public func scrolled(source: TerminalView, position: Double) {
|
||||
nonisolated public func scrolled(source: TerminalView, position: Double) {
|
||||
print("scrolled to \(position)")
|
||||
}
|
||||
|
||||
public func setTerminalTitle(source: TerminalView, title: String) {
|
||||
nonisolated public func setTerminalTitle(source: TerminalView, title: String) {
|
||||
print("set title to \(title)")
|
||||
}
|
||||
|
||||
@@ -59,11 +60,11 @@ class SSHTerminalView: TerminalView, TerminalViewDelegate {
|
||||
handler?.writeToChannel(String(data: data, encoding: .utf8))
|
||||
}
|
||||
|
||||
public func clipboardCopy(source: TerminalView, content: Data) {
|
||||
nonisolated public func clipboardCopy(source: TerminalView, content: Data) {
|
||||
print(content)
|
||||
}
|
||||
|
||||
public func hostCurrentDirectoryUpdate(source: TerminalView, directory: String?) {
|
||||
nonisolated public func hostCurrentDirectoryUpdate(source: TerminalView, directory: String?) {
|
||||
print("new dir: \(directory ?? "")")
|
||||
}
|
||||
|
||||
@@ -73,7 +74,7 @@ class SSHTerminalView: TerminalView, TerminalViewDelegate {
|
||||
UIApplication.shared.open(url, options: [:])
|
||||
}
|
||||
|
||||
public func rangeChanged(source: TerminalView, startY: Int, endY: Int) {
|
||||
nonisolated public func rangeChanged(source: TerminalView, startY: Int, endY: Int) {
|
||||
print(startY, endY)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user