UI with custom host, username and pw

not hardcoded anymore
set host port username and pw
currently only password auth lol
can get hostkeys
replaced lots of fatalerrors with false returns
This commit is contained in:
neon443
2025-06-06 21:14:11 +01:00
parent 8d68125b3f
commit 7adc2b7059
3 changed files with 141 additions and 61 deletions

View File

@@ -8,21 +8,41 @@
import SwiftUI
struct ContentView: View {
var sshHandler = SSHHandler()
@ObservedObject var handler: SSHHandler
var body: some View {
VStack {
Image(systemName: "globe")
.imageScale(.large)
.foregroundStyle(.tint)
Text("Hello, world!")
Button("go") {
sshHandler.testExec()
TextField("address", text: $handler.address)
.textFieldStyle(.roundedBorder)
TextField(
"port",
text: Binding(
get: { String(handler.port) },
set: { handler.port = Int($0) ?? 22} )
)
.keyboardType(.numberPad)
.textFieldStyle(.roundedBorder)
TextField("username", text: $handler.username)
.textFieldStyle(.roundedBorder)
TextField("password", text: $handler.password)
.textFieldStyle(.roundedBorder)
Button("connect & auth") {
handler.connect()
handler.authWithPw()
}
Button("disconnect & free") {
handler.disconnect()
}
Button("testExec") {
handler.testExec()
}
}
}
}
#Preview {
ContentView()
ContentView(
handler: SSHHandler(username: "root", password: "root")
)
}