still fricking cooked sybau

This commit is contained in:
neon443
2025-06-19 16:32:17 +01:00
parent d2e2aed7ea
commit 73adfd8fc8

View File

@@ -10,8 +10,6 @@ import SwiftUI
struct ContentView: View { struct ContentView: View {
@ObservedObject var handler: SSHHandler @ObservedObject var handler: SSHHandler
@State var pubkey: String = ""
@State var privkey: String = ""
@State var passphrase: String = "" @State var passphrase: String = ""
@State var pubkeyData: Data? @State var pubkeyData: Data?
@@ -26,26 +24,29 @@ struct ContentView: View {
Button("Choose Publickey") { Button("Choose Publickey") {
pubPickerPresented.toggle() pubPickerPresented.toggle()
} }
Image(systemName: "globe")
.dropDestination(for: Data.self) { items, location in
pubkeyData = items.first
return true
}
.fileImporter(isPresented: $pubPickerPresented, allowedContentTypes: [.item, .content, .data]) { (Result) in .fileImporter(isPresented: $pubPickerPresented, allowedContentTypes: [.item, .content, .data]) { (Result) in
do { do {
let fileURL = try Result.get() let fileURL = try Result.get()
pubkeyData = try? Data(contentsOf: fileURL)
print(fileURL) print(fileURL)
} catch { } catch {
print(error.localizedDescription) print(error.localizedDescription)
} }
} }
// TextField("", text: $privkey) Button("Choose Privatekey") {
Image(systemName: "key.viewfinder") privPickerPresented.toggle()
.dropDestination(for: Data.self) { items, location in
privkeyData = items.first
return true
} }
.fileImporter(isPresented: $privPickerPresented, allowedContentTypes: [.item, .content, .data]) { (Result) in
do {
let fileURL = try Result.get()
privkeyData = try? Data(contentsOf: fileURL)
print(fileURL)
} catch {
print(error.localizedDescription)
}
}
TextField("", text: $passphrase) TextField("", text: $passphrase)
HStack { HStack {
Text(handler.connected ? "connected" : "not connected") Text(handler.connected ? "connected" : "not connected")
@@ -91,7 +92,7 @@ struct ContentView: View {
} else { } else {
Button() { Button() {
handler.connect() handler.connect()
if !pubkey.isEmpty && !privkey.isEmpty { if pubkeyData != nil && privkeyData != nil {
handler.authWithPubkey(pub: pubkeyData!, priv: privkeyData!, pass: passphrase) handler.authWithPubkey(pub: pubkeyData!, priv: privkeyData!, pass: passphrase)
} else { } else {
let _ = handler.authWithPw() let _ = handler.authWithPw()