Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d0855ab45d | ||
|
|
4209c481dc | ||
|
|
8511e4fdae | ||
|
|
7a792fe680 | ||
|
|
69f9e9952c | ||
|
|
ed6e96b3c1 | ||
|
|
37a70edbab | ||
|
|
ebb838b6b1 | ||
|
|
4fd711474c | ||
|
|
7dc6ff75d2 |
+7
-1
@@ -7,12 +7,18 @@ let package = Package(
|
||||
.macOS(.v14)
|
||||
],
|
||||
products: [
|
||||
.executable(name: "RemminaMac", targets: ["RemminaMac"])
|
||||
.executable(name: "RemminaMac", targets: ["RemminaMac"]),
|
||||
.executable(name: "ctty-run", targets: ["ctty-run"])
|
||||
],
|
||||
targets: [
|
||||
.executableTarget(
|
||||
name: "RemminaMac",
|
||||
path: "Sources/RemminaMac"
|
||||
),
|
||||
.executableTarget(
|
||||
name: "ctty-run",
|
||||
path: "Sources/ctty-run",
|
||||
sources: ["ctty-run.c"]
|
||||
)
|
||||
]
|
||||
)
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
# RemminaMac — SSH / RDP Client für macOS
|
||||
|
||||

|
||||
|
||||
Remmina-inspirierter Connection-Manager für macOS, nativ in Swift + SwiftUI.
|
||||
|
||||

|
||||
|
||||
Binary file not shown.
@@ -10,6 +10,8 @@
|
||||
<string>RemminaMac</string>
|
||||
<key>CFBundleIdentifier</key>
|
||||
<string>xyz.sysdaemon.remmina-mac</string>
|
||||
<key>CFBundleIconFile</key>
|
||||
<string>AppIcon</string>
|
||||
<key>CFBundleInfoDictionaryVersion</key>
|
||||
<string>6.0</string>
|
||||
<key>CFBundleName</key>
|
||||
|
||||
@@ -0,0 +1,38 @@
|
||||
import Foundation
|
||||
|
||||
/// Eingabe-Prüfung + Bereinigung für Profile (reine Funktionen, testbar).
|
||||
/// Fängt die häufigsten „Verbindung falsch"-Ursachen ab: Leerzeichen,
|
||||
/// user@host im Host-Feld, Protokoll-Präfix, leerer Benutzername.
|
||||
enum ProfileValidation {
|
||||
static func cleaned(_ profile: ConnectionProfile) -> ConnectionProfile {
|
||||
var p = profile
|
||||
p.name = p.name.trimmingCharacters(in: .whitespacesAndNewlines)
|
||||
p.host = p.host.trimmingCharacters(in: .whitespacesAndNewlines)
|
||||
p.username = p.username.trimmingCharacters(in: .whitespacesAndNewlines)
|
||||
p.group = p.group.trimmingCharacters(in: .whitespacesAndNewlines)
|
||||
p.resolution = p.resolution.trimmingCharacters(in: .whitespacesAndNewlines)
|
||||
p.extraArgs = p.extraArgs.trimmingCharacters(in: .whitespacesAndNewlines)
|
||||
return p
|
||||
}
|
||||
|
||||
static func warnings(for profile: ConnectionProfile) -> [String] {
|
||||
var w: [String] = []
|
||||
let h = profile.host.trimmingCharacters(in: .whitespacesAndNewlines)
|
||||
if h.contains("@") {
|
||||
w.append("Host enthält „@“ — den Benutzernamen ins Feld darunter eintragen, hier nur Hostname/IP.")
|
||||
}
|
||||
if h.contains("://") {
|
||||
w.append("Host enthält „://“ — nur Hostname/IP, kein Protokoll (das steht oben).")
|
||||
}
|
||||
if h.contains(where: { $0.isWhitespace }) {
|
||||
w.append("Host enthält Leerzeichen.")
|
||||
}
|
||||
if profile.username.trimmingCharacters(in: .whitespacesAndNewlines).isEmpty {
|
||||
w.append("Benutzername fehlt.")
|
||||
}
|
||||
if !(1...65535).contains(profile.port) {
|
||||
w.append("Port ungültig (1–65535).")
|
||||
}
|
||||
return w
|
||||
}
|
||||
}
|
||||
@@ -39,6 +39,67 @@ enum SSHService {
|
||||
NSPasteboard.general.clearContents()
|
||||
NSPasteboard.general.setString(cmd, forType: .string)
|
||||
}
|
||||
|
||||
// MARK: - Passwort / Auto-Login
|
||||
|
||||
/// SSH-Agent-Socket für GUI-Prozesse auflösen (Finder-Apps erben SSH_AUTH_SOCK
|
||||
/// nicht, Terminal schon — ohne diesen Unterschied nutzt Terminal evtl. einen
|
||||
/// Agent-Key, während die App nach dem Passwort fragt und scheitert).
|
||||
static func agentSocket() -> String? {
|
||||
let p = Process()
|
||||
p.executableURL = URL(fileURLWithPath: "/bin/launchctl")
|
||||
p.arguments = ["getenv", "SSH_AUTH_SOCK"]
|
||||
let out = Pipe()
|
||||
let err = Pipe()
|
||||
p.standardOutput = out
|
||||
p.standardError = err
|
||||
do {
|
||||
try p.run()
|
||||
p.waitUntilExit()
|
||||
} catch {
|
||||
return nil
|
||||
}
|
||||
let path = String(data: out.fileHandleForReading.readDataToEndOfFile(), encoding: .utf8)?
|
||||
.trimmingCharacters(in: .whitespacesAndNewlines) ?? ""
|
||||
guard !path.isEmpty,
|
||||
FileManager.default.fileExists(atPath: path) else { return nil }
|
||||
return path
|
||||
}
|
||||
|
||||
/// Gespeichertes Login-Secret: erst Profil-Passwort, dann Key-Passphrase (Keychain, nie JSON).
|
||||
static func loginSecret(for profile: ConnectionProfile, key: StoredSSHKey?) -> String? {
|
||||
if let acct = profile.passwordAccount,
|
||||
let pw = KeychainHelper.load(account: acct), !pw.isEmpty {
|
||||
return pw
|
||||
}
|
||||
if let key, let acct = key.passphraseAccount,
|
||||
let pp = KeychainHelper.load(account: acct), !pp.isEmpty {
|
||||
return pp
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
static func findSshpass() -> String? {
|
||||
for p in ["/opt/homebrew/bin/sshpass", "/usr/local/bin/sshpass", "/usr/bin/sshpass"] {
|
||||
if FileManager.default.isExecutableFile(atPath: p) { return p }
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
/// true = beim Verbinden wird ohne Tippen eingeloggt (sshpass + Keychain-Secret).
|
||||
static func willAutoLogin(profile: ConnectionProfile, key: StoredSSHKey?) -> Bool {
|
||||
loginSecret(for: profile, key: key) != nil && findSshpass() != nil
|
||||
}
|
||||
|
||||
/// Reine Funktion (testbar): mit Secret+sshpass -> sshpass -e … + SSHPASS-Env,
|
||||
/// sonst direkter Aufruf. Passwort steht NIE in der Befehlszeile (nur im Env).
|
||||
static func sessionConfig(executable: String, args: [String], password: String?, sshpassPath: String?)
|
||||
-> (executable: String, arguments: [String], extraEnv: [String: String], autoLogin: Bool) {
|
||||
if let password, !password.isEmpty, let sshpass = sshpassPath, !sshpass.isEmpty {
|
||||
return (sshpass, ["-e", executable] + args, ["SSHPASS": password], true)
|
||||
}
|
||||
return (executable, args, [:], false)
|
||||
}
|
||||
}
|
||||
|
||||
enum RDPService {
|
||||
|
||||
@@ -0,0 +1,148 @@
|
||||
import Foundation
|
||||
|
||||
/// Host-Key-Prüfung OHNE interaktiven Yes/No-Prompt (der kommt ohne echtes
|
||||
/// Terminal/Ctty nicht an — ssh bricht dann mit „Host key verification failed." ab).
|
||||
/// Ablauf: ssh-keyscan → Fingerprint → Popup (akzeptieren/ablehnen) → known_hosts.
|
||||
/// Nutzt bewusst ~/.ssh/known_hosts gemeinsam mit Terminal.app.
|
||||
enum HostKeyStatus: Equatable {
|
||||
case known
|
||||
case unknown(HostKeyInfo)
|
||||
case changed(HostKeyInfo)
|
||||
case unreachable(String)
|
||||
}
|
||||
|
||||
struct HostKeyInfo: Equatable {
|
||||
var host: String
|
||||
var port: Int
|
||||
var keyType: String
|
||||
var fingerprintSHA256: String
|
||||
var fingerprintMD5: String
|
||||
var allKeyLines: [String]
|
||||
}
|
||||
|
||||
enum HostKeyService {
|
||||
static var knownHostsPath = NSHomeDirectory() + "/.ssh/known_hosts"
|
||||
static var scanTimeoutSeconds = "5"
|
||||
|
||||
static func canonicalHost(_ host: String, port: Int) -> String {
|
||||
port == 22 ? host : "[\(host)]:\(port)"
|
||||
}
|
||||
|
||||
@discardableResult
|
||||
static func run(_ exe: String, _ args: [String]) -> (Int32, String) {
|
||||
let p = Process()
|
||||
p.executableURL = URL(fileURLWithPath: exe)
|
||||
p.arguments = args
|
||||
let out = Pipe()
|
||||
p.standardOutput = out
|
||||
p.standardError = Pipe()
|
||||
do {
|
||||
try p.run()
|
||||
} catch {
|
||||
return (-1, "")
|
||||
}
|
||||
p.waitUntilExit()
|
||||
let data = out.fileHandleForReading.readDataToEndOfFile()
|
||||
return (p.terminationStatus, String(data: data, encoding: .utf8) ?? "")
|
||||
}
|
||||
|
||||
/// Rohe Key-Zeilen vom Server (ohne #-Kommentare).
|
||||
static func keyscan(host: String, port: Int) -> [String] {
|
||||
let (code, out) = run("/usr/bin/ssh-keyscan", ["-T", scanTimeoutSeconds, "-p", "\(port)", host])
|
||||
guard code == 0 else { return [] }
|
||||
return out.split(separator: "\n").map(String.init).filter { line in
|
||||
let t = line.trimmingCharacters(in: .whitespaces)
|
||||
return !t.isEmpty && !t.hasPrefix("#") && t.contains(" ")
|
||||
}
|
||||
}
|
||||
|
||||
static func knownHostsContent() -> String {
|
||||
(try? String(contentsOfFile: knownHostsPath, encoding: .utf8)) ?? ""
|
||||
}
|
||||
|
||||
static func status(host: String, port: Int) -> HostKeyStatus {
|
||||
let h = host.trimmingCharacters(in: .whitespacesAndNewlines)
|
||||
guard !h.isEmpty else { return .unreachable("Kein Host.") }
|
||||
let lines = keyscan(host: h, port: port)
|
||||
guard !lines.isEmpty else {
|
||||
return .unreachable("Host-Key nicht abfragbar (ssh-keyscan ohne Antwort).")
|
||||
}
|
||||
guard let info = info(host: h, port: port, lines: lines) else {
|
||||
return .unreachable("Fingerprint nicht berechenbar.")
|
||||
}
|
||||
let (fcode, fout) = run("/usr/bin/ssh-keygen", ["-F", canonicalHost(h, port: port), "-f", knownHostsPath])
|
||||
let hasEntry = fcode == 0 && fout.contains("found:")
|
||||
if hasEntry {
|
||||
let knownKeys = lines.compactMap { $0.split(separator: " ").last.map(String.init) }
|
||||
if knownKeys.contains(where: { knownHostsContent().contains($0) }) {
|
||||
return .known
|
||||
}
|
||||
return .changed(info)
|
||||
}
|
||||
return .unknown(info)
|
||||
}
|
||||
|
||||
/// Bevorzugter Key (ed25519 > ecdsa > Rest) + Fingerprints via ssh-keygen.
|
||||
static func info(host: String, port: Int, lines: [String]) -> HostKeyInfo? {
|
||||
func rank(_ l: String) -> Int {
|
||||
if l.contains("ssh-ed25519") { return 0 }
|
||||
if l.contains("ecdsa-") { return 1 }
|
||||
return 2
|
||||
}
|
||||
guard let line = lines.sorted(by: { rank($0) < rank($1) }).first else { return nil }
|
||||
let parts = line.split(separator: " ")
|
||||
guard parts.count >= 3 else { return nil }
|
||||
let tmp = FileManager.default.temporaryDirectory.appendingPathComponent("rmm-fp-\(UUID().uuidString)")
|
||||
do {
|
||||
try (line + "\n").write(to: tmp, atomically: true, encoding: .utf8)
|
||||
defer { try? FileManager.default.removeItem(at: tmp) }
|
||||
let (_, sha) = run("/usr/bin/ssh-keygen", ["-l", "-f", tmp.path])
|
||||
let (_, md5) = run("/usr/bin/ssh-keygen", ["-l", "-E", "md5", "-f", tmp.path])
|
||||
return HostKeyInfo(host: host, port: port, keyType: String(parts[1]),
|
||||
fingerprintSHA256: parseFP(sha), fingerprintMD5: parseFP(md5),
|
||||
allKeyLines: lines)
|
||||
} catch {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
/// Aus `256 SHA256:XYZ host (ED25519)` wird `SHA256:XYZ`.
|
||||
static func parseFP(_ out: String) -> String {
|
||||
let parts = out.trimmingCharacters(in: .whitespacesAndNewlines).split(separator: " ")
|
||||
guard parts.count >= 2 else { return out.trimmingCharacters(in: .whitespacesAndNewlines) }
|
||||
return String(parts[1])
|
||||
}
|
||||
|
||||
/// Fehlende Key-Zeilen an known_hosts anhängen (0600, ~/.ssh 0700).
|
||||
static func accept(_ info: HostKeyInfo) -> Bool {
|
||||
let dir = (knownHostsPath as NSString).deletingLastPathComponent
|
||||
do {
|
||||
try FileManager.default.createDirectory(atPath: dir, withIntermediateDirectories: true,
|
||||
attributes: [.posixPermissions: 0o700])
|
||||
let existing = knownHostsContent()
|
||||
let missing = info.allKeyLines.filter { line in
|
||||
let key = line.split(separator: " ").last.map(String.init) ?? line
|
||||
return !existing.contains(key)
|
||||
}
|
||||
guard !missing.isEmpty else { return true }
|
||||
if !FileManager.default.fileExists(atPath: knownHostsPath) {
|
||||
FileManager.default.createFile(atPath: knownHostsPath, contents: nil,
|
||||
attributes: [.posixPermissions: 0o600])
|
||||
}
|
||||
let fh = try FileHandle(forWritingTo: URL(fileURLWithPath: knownHostsPath))
|
||||
defer { try? fh.close() }
|
||||
try fh.seekToEnd()
|
||||
fh.write(((missing.joined(separator: "\n")) + "\n").data(using: .utf8)!)
|
||||
try FileManager.default.setAttributes([.posixPermissions: 0o600], ofItemAtPath: knownHostsPath)
|
||||
return true
|
||||
} catch {
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
/// Alle Einträge für Host entfernen (ssh-keygen -R).
|
||||
static func revoke(host: String, port: Int) -> Bool {
|
||||
let (code, _) = run("/usr/bin/ssh-keygen", ["-R", canonicalHost(host, port: port), "-f", knownHostsPath])
|
||||
return code == 0
|
||||
}
|
||||
}
|
||||
@@ -9,22 +9,33 @@ enum PTYState: Equatable {
|
||||
case done(exitCode: Int32?, message: String)
|
||||
}
|
||||
|
||||
/// SSH/SFTP-Session über ein echtes Pseudo-Terminal (PTY), damit interaktive
|
||||
/// Prompts (Passwort, Host-Key) funktionieren. Ausgabe wird via AnsiParser
|
||||
/// in gestylte Zeilen für die Dracula-Ansicht übersetzt.
|
||||
/// SSH/SFTP-Session über ein echtes Pseudo-Terminal (PTY).
|
||||
/// - stdin/stdout: PTY-Slave (interaktiv, TTY bleibt erhalten)
|
||||
/// - stderr: PIPE — macOS verwirft ungelesene PTY-Daten beim Slave-Close,
|
||||
/// dadurch gingen Fehlermeldungen bei Instant-Exit (z. B. Code 255) verloren.
|
||||
/// Pipes liefern gepufferte Daten garantiert aus (Bugfix, siehe docs/ERRORS.md #8).
|
||||
///
|
||||
/// FD-Regeln: masterFD wird NUR auf dem Main-Thread vergeben/geschlossen,
|
||||
/// auf ioQueue nur gelesen (EBADF-tolerant). Kein Close auf ioQueue.
|
||||
final class PTYSession: ObservableObject {
|
||||
@Published private(set) var lines: [[StyledText]] = [[]]
|
||||
@Published private(set) var state: PTYState = .never
|
||||
@Published private(set) var autoLogin = false
|
||||
|
||||
var executable = ""
|
||||
var arguments: [String] = []
|
||||
var customEnv: [String: String] = [:]
|
||||
/// Fingerprint der Konfiguration (TerminalManager) — bei Änderung wird neu konfiguriert.
|
||||
var configTag = ""
|
||||
|
||||
private var masterFD: Int32 = -1
|
||||
private var process: Process?
|
||||
private var readSource: DispatchSourceRead?
|
||||
private var errPipe: Pipe?
|
||||
private let ioQueue = DispatchQueue(label: "RemminaMac.pty")
|
||||
private var parser = AnsiParser()
|
||||
private var finished = false
|
||||
private var epoch = 0 // nur Main-Thread
|
||||
private let maxLines = 2000
|
||||
|
||||
var isRunning: Bool {
|
||||
@@ -41,8 +52,13 @@ final class PTYSession: ObservableObject {
|
||||
self.arguments = arguments
|
||||
}
|
||||
|
||||
func setAutoLogin(_ value: Bool) {
|
||||
autoLogin = value
|
||||
}
|
||||
|
||||
func start() {
|
||||
stop()
|
||||
cleanupSync()
|
||||
epoch += 1
|
||||
finished = false
|
||||
parser = AnsiParser()
|
||||
state = .running
|
||||
@@ -64,35 +80,68 @@ final class PTYSession: ObservableObject {
|
||||
}
|
||||
masterFD = master
|
||||
|
||||
// Ctty-Helper (gleiches Verzeichnis wie dieses Binary — .app wie .build):
|
||||
// Gibt ssh ein echtes Controlling-Terminal, damit Passwort- und
|
||||
// Yes/No-Prompts funktionieren (/dev/tty statt stiller Abbrüche).
|
||||
// Ohne Helper: Legacy-Direktstart (Prompts teils stumm).
|
||||
let pipe = Pipe()
|
||||
let p = Process()
|
||||
if let helper = Self.cttyHelperURL() {
|
||||
p.executableURL = helper
|
||||
p.arguments = [slavePath, executable] + arguments
|
||||
} else {
|
||||
p.executableURL = URL(fileURLWithPath: executable)
|
||||
p.arguments = arguments
|
||||
DispatchQueue.main.async { [weak self] in
|
||||
self?.note("Hinweis: ohne ctty-run-Helper (eingeschränkte Prompts).")
|
||||
}
|
||||
}
|
||||
var env = ProcessInfo.processInfo.environment
|
||||
env["TERM"] = "xterm-256color"
|
||||
if env["LANG"] == nil { env["LANG"] = "de_DE.UTF-8" }
|
||||
for (k, v) in customEnv { env[k] = v }
|
||||
p.environment = env
|
||||
// closeOnDealloc=false: Parent schließt slave explizit nach run().
|
||||
p.standardInput = FileHandle(fileDescriptor: slave)
|
||||
p.standardOutput = FileHandle(fileDescriptor: slave)
|
||||
p.standardError = FileHandle(fileDescriptor: slave)
|
||||
p.standardError = pipe.fileHandleForWriting
|
||||
let myEpoch = epoch
|
||||
p.terminationHandler = { [weak self] proc in
|
||||
DispatchQueue.main.async {
|
||||
self?.finish(message: "Sitzung beendet (Code \(proc.terminationStatus)).", code: proc.terminationStatus)
|
||||
DispatchQueue.main.async { [weak self] in
|
||||
guard let self, self.epoch == myEpoch else { return }
|
||||
self.ioQueue.async { [weak self] in
|
||||
self?.finalFlush(code: proc.terminationStatus, myEpoch: myEpoch)
|
||||
}
|
||||
}
|
||||
}
|
||||
do {
|
||||
try p.run()
|
||||
} catch {
|
||||
close(slave); close(master); masterFD = -1
|
||||
errPipe = nil
|
||||
finish(message: "Start fehlgeschlagen: \(error.localizedDescription)", code: nil)
|
||||
return
|
||||
}
|
||||
process = p
|
||||
close(slave) // Parent behält nur Master
|
||||
errPipe = pipe
|
||||
pipe.fileHandleForReading.readabilityHandler = { [weak self] h in
|
||||
let data = h.availableData
|
||||
guard let self else { return }
|
||||
if data.isEmpty {
|
||||
h.readabilityHandler = nil // EOF
|
||||
return
|
||||
}
|
||||
self.ioQueue.async { [weak self] in
|
||||
guard let self else { return }
|
||||
let events = self.parser.feed(data)
|
||||
DispatchQueue.main.async { self.apply(events) }
|
||||
}
|
||||
}
|
||||
|
||||
let source = DispatchSource.makeReadSource(fileDescriptor: master, queue: ioQueue)
|
||||
source.setEventHandler { [weak self] in self?.drain() }
|
||||
source.setCancelHandler { [master] in close(master) }
|
||||
// Kein Close hier (Eigentum: Main-Thread) — nur Cancel.
|
||||
readSource = source
|
||||
source.resume()
|
||||
}
|
||||
@@ -106,8 +155,27 @@ final class PTYSession: ObservableObject {
|
||||
let events = parser.feed(Data(buf[..<n]))
|
||||
DispatchQueue.main.async { [weak self] in self?.apply(events) }
|
||||
} else {
|
||||
readSource?.cancel()
|
||||
masterFD = -1
|
||||
readSource?.cancel() // EOF/EIO — Rest holt finalFlush bzw. ist verworfen
|
||||
}
|
||||
}
|
||||
|
||||
/// Letzte Reste vom PTY-Master einsammeln (non-blocking, EBADF-safe).
|
||||
/// Pipe-Reste kommen garantiert über den readabilityHandler.
|
||||
private func finalFlush(code: Int32, myEpoch: Int) {
|
||||
var events: [TerminalEvent] = []
|
||||
let fd = masterFD
|
||||
if fd >= 0 {
|
||||
var buf = [UInt8](repeating: 0, count: 65536)
|
||||
while true {
|
||||
let n = read(fd, &buf, buf.count)
|
||||
if n <= 0 { break }
|
||||
events += parser.feed(Data(buf[..<n]))
|
||||
}
|
||||
}
|
||||
DispatchQueue.main.async { [weak self] in
|
||||
guard let self, self.epoch == myEpoch, !self.finished else { return }
|
||||
self.apply(events)
|
||||
self.finish(message: "Sitzung beendet (Code \(code)).", code: code)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -151,12 +219,13 @@ final class PTYSession: ObservableObject {
|
||||
func send(_ string: String) {
|
||||
let fd = masterFD
|
||||
guard fd >= 0 else { return }
|
||||
guard let data = string.data(using: .utf8) else { return }
|
||||
guard let data = string.data(using: .utf8), !data.isEmpty else { return }
|
||||
ioQueue.async {
|
||||
data.withUnsafeBytes { ptr in
|
||||
guard let base = ptr.baseAddress else { return }
|
||||
var written = 0
|
||||
while written < data.count {
|
||||
let n = write(fd, ptr.baseAddress!.advanced(by: written), data.count - written)
|
||||
let n = write(fd, base.advanced(by: written), data.count - written)
|
||||
if n <= 0 { break }
|
||||
written += n
|
||||
}
|
||||
@@ -168,36 +237,84 @@ final class PTYSession: ObservableObject {
|
||||
lines = [[]]
|
||||
}
|
||||
|
||||
func stop() {
|
||||
process?.terminate()
|
||||
process = nil
|
||||
if !finished {
|
||||
/// ctty-run liegt neben diesem Binary (Contents/MacOS wie .build/debug).
|
||||
static func cttyHelperURL() -> URL? {
|
||||
let sibling = URL(fileURLWithPath: CommandLine.arguments[0])
|
||||
.deletingLastPathComponent()
|
||||
.appendingPathComponent("ctty-run")
|
||||
if FileManager.default.isExecutableFile(atPath: sibling.path) {
|
||||
return sibling
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func note(_ message: String) {
|
||||
lines.append([StyledText(text: message, style: TermStyle(fg: 8))])
|
||||
}
|
||||
|
||||
/// Vorab-Check-Fehlschlag (ohne Spawn): rote Notiz + done.
|
||||
func fail(_ message: String) {
|
||||
cleanupSync()
|
||||
epoch += 1
|
||||
finished = true
|
||||
state = .done(exitCode: nil, message: message)
|
||||
lines.append([StyledText(text: "— \(message) —", style: TermStyle(fg: 1))])
|
||||
lines.append([])
|
||||
}
|
||||
|
||||
func stop() {
|
||||
let wasRunning = isRunning
|
||||
killTree()
|
||||
cleanupSync()
|
||||
if wasRunning {
|
||||
epoch += 1 // späte terminationHandler-Ausläufer verwerfen
|
||||
finished = true
|
||||
state = .done(exitCode: nil, message: "Getrennt.")
|
||||
lines.append([StyledText(text: "— Getrennt. —", style: TermStyle(fg: 8))])
|
||||
lines.append([])
|
||||
}
|
||||
}
|
||||
|
||||
/// Beendet Kind + Enkel (ctty-run-Wächter + ssh teilen die Prozessgruppe).
|
||||
private func killTree() {
|
||||
if let pid = process?.processIdentifier, pid > 0 {
|
||||
Darwin.kill(-pid, SIGTERM)
|
||||
}
|
||||
process?.terminate()
|
||||
}
|
||||
|
||||
/// Synchroner Cleanup auf Main: Source canceln, Master schließen, Pipe abklemmen.
|
||||
/// Laufende ioQueue-Reads bekommen EBADF und beenden sich selbst.
|
||||
private func cleanupSync() {
|
||||
readSource?.cancel()
|
||||
readSource = nil
|
||||
if masterFD >= 0 {
|
||||
close(masterFD)
|
||||
masterFD = -1
|
||||
if case .running = state {
|
||||
state = .done(exitCode: nil, message: "Getrennt.")
|
||||
}
|
||||
if let pipe = errPipe {
|
||||
pipe.fileHandleForReading.readabilityHandler = nil
|
||||
errPipe = nil
|
||||
}
|
||||
process = nil
|
||||
}
|
||||
|
||||
private func finish(message: String, code: Int32?) {
|
||||
guard !finished else { return }
|
||||
finished = true
|
||||
readSource?.cancel()
|
||||
readSource = nil
|
||||
masterFD = -1
|
||||
process = nil
|
||||
cleanupSync()
|
||||
state = .done(exitCode: code, message: message)
|
||||
let note = StyledText(text: "— \(message) —", style: TermStyle(fg: 8))
|
||||
lines.append([note])
|
||||
lines.append([StyledText(text: "— \(message) —", style: TermStyle(fg: 8))])
|
||||
lines.append([])
|
||||
}
|
||||
|
||||
deinit {
|
||||
if let pid = process?.processIdentifier, pid > 0 {
|
||||
Darwin.kill(-pid, SIGTERM)
|
||||
}
|
||||
process?.terminate()
|
||||
readSource?.cancel()
|
||||
if masterFD >= 0 { close(masterFD) }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -207,17 +324,50 @@ final class TerminalManager: ObservableObject {
|
||||
private var sessions: [UUID: PTYSession] = [:]
|
||||
|
||||
func session(for profile: ConnectionProfile, key: StoredSSHKey?) -> PTYSession {
|
||||
if let existing = sessions[profile.id] { return existing }
|
||||
let s = PTYSession()
|
||||
if profile.proto == .sftp {
|
||||
s.configure(executable: "/usr/bin/sftp", arguments: ["-P", "\(profile.port)"] + (key.map { ["-i", $0.privateKeyPath] } ?? []) + ["\(profile.username)@\(profile.host)"])
|
||||
} else {
|
||||
s.configure(executable: "/usr/bin/ssh", arguments: SSHService.sshArguments(for: profile, key: key))
|
||||
// Fingerprint aus allem, was die Verbindung bestimmt (inkl. Secret-Wert!):
|
||||
// Ändert der User Host/Passwort/Key, wird neu konfiguriert statt stale weiterzuwählen.
|
||||
let secret = SSHService.loginSecret(for: profile, key: key)
|
||||
let tag = [profile.proto.rawValue, profile.host, "\(profile.port)", profile.username,
|
||||
profile.extraArgs, key?.privateKeyPath ?? "", secret ?? ""].joined(separator: "|")
|
||||
if let existing = sessions[profile.id] {
|
||||
// Laufende Session niemals unter den Füßen wegkonfigurieren — erst Trennen.
|
||||
if existing.isRunning || existing.configTag == tag { return existing }
|
||||
existing.stop()
|
||||
configure(existing, profile: profile, key: key, secret: secret)
|
||||
existing.configTag = tag
|
||||
return existing
|
||||
}
|
||||
let s = PTYSession()
|
||||
configure(s, profile: profile, key: key, secret: secret)
|
||||
s.configTag = tag
|
||||
sessions[profile.id] = s
|
||||
return s
|
||||
}
|
||||
|
||||
private func configure(_ s: PTYSession, profile: ConnectionProfile, key: StoredSSHKey?, secret: String?) {
|
||||
let baseExe: String
|
||||
let baseArgs: [String]
|
||||
if profile.proto == .sftp {
|
||||
baseExe = "/usr/bin/sftp"
|
||||
baseArgs = ["-P", "\(profile.port)"] + (key.map { ["-i", $0.privateKeyPath] } ?? []) + ["\(profile.username)@\(profile.host)"]
|
||||
} else {
|
||||
baseExe = "/usr/bin/ssh"
|
||||
baseArgs = SSHService.sshArguments(for: profile, key: key)
|
||||
}
|
||||
// Auto-Login nur mit Keychain-Secret + sshpass, sonst interaktiver Prompt im Terminal.
|
||||
// SSH-Agent durchreichen (falls vorhanden): gleiche Keys wie in Terminal.app.
|
||||
let cfg = SSHService.sessionConfig(executable: baseExe, args: baseArgs,
|
||||
password: secret,
|
||||
sshpassPath: SSHService.findSshpass())
|
||||
s.configure(executable: cfg.executable, arguments: cfg.arguments)
|
||||
var env = cfg.extraEnv
|
||||
if let sock = SSHService.agentSocket() {
|
||||
env["SSH_AUTH_SOCK"] = sock
|
||||
}
|
||||
s.customEnv = env
|
||||
s.setAutoLogin(cfg.autoLogin)
|
||||
}
|
||||
|
||||
func close(_ profile: ConnectionProfile) {
|
||||
sessions[profile.id]?.stop()
|
||||
sessions.removeValue(forKey: profile.id)
|
||||
|
||||
@@ -0,0 +1,65 @@
|
||||
import Foundation
|
||||
import Network
|
||||
|
||||
/// Schneller TCP-Vorab-Check, BEVOR ssh gestartet wird.
|
||||
/// Falscher Port / falscher Host / Firewall → sofort klare Meldung
|
||||
/// statt „Sitzung beendet (Code 255)" ohne Erklärung.
|
||||
enum TCPCheck {
|
||||
private final class Flag {
|
||||
var done = false
|
||||
}
|
||||
|
||||
/// - completion: nil bei Erfolg, sonst deutsche Fehlermeldung.
|
||||
static func check(host: String, port: Int, timeout: TimeInterval = 4.0, completion: @escaping (String?) -> Void) {
|
||||
let h = host.trimmingCharacters(in: .whitespacesAndNewlines)
|
||||
guard !h.isEmpty else { completion("Kein Host angegeben — Profil bearbeiten."); return }
|
||||
guard (1...65535).contains(port), let p = NWEndpoint.Port(rawValue: UInt16(port)) else {
|
||||
completion("Ungültiger Port \(port)."); return
|
||||
}
|
||||
let conn = NWConnection(host: NWEndpoint.Host(h), port: p, using: .tcp)
|
||||
let lock = NSLock()
|
||||
let flag = Flag()
|
||||
func finish(_ message: String?) {
|
||||
lock.lock()
|
||||
defer { lock.unlock() }
|
||||
guard !flag.done else { return }
|
||||
flag.done = true
|
||||
conn.cancel()
|
||||
completion(message)
|
||||
}
|
||||
conn.stateUpdateHandler = { state in
|
||||
switch state {
|
||||
case .ready:
|
||||
finish(nil)
|
||||
case .failed(let err):
|
||||
finish(describe(err, host: h, port: port))
|
||||
default:
|
||||
break
|
||||
}
|
||||
}
|
||||
conn.start(queue: .global(qos: .userInitiated))
|
||||
DispatchQueue.global().asyncAfter(deadline: .now() + timeout) {
|
||||
finish("Keine Antwort in \(Int(timeout)) s — Hostname/IP, Netzwerk/VPN oder Firewall prüfen.")
|
||||
}
|
||||
}
|
||||
|
||||
static func describe(_ error: NWError, host: String, port: Int) -> String {
|
||||
switch error {
|
||||
case .posix(let code):
|
||||
switch code.rawValue {
|
||||
case 61:
|
||||
return "Port \(port) auf \(host) verweigert die Verbindung — läuft SSH dort? Stimmt der Port?"
|
||||
case 51, 64, 65:
|
||||
return "Host \(host) nicht erreichbar — Netzwerk/VPN prüfen."
|
||||
case 60:
|
||||
return "Zeitüberschreitung — Host/Port/Firewall prüfen."
|
||||
default:
|
||||
return "Netzwerkfehler (\(code.rawValue)): \(error.localizedDescription)"
|
||||
}
|
||||
case .dns:
|
||||
return "Hostname \(host) kann nicht aufgelöst werden — Tippfehler? DNS/VPN prüfen."
|
||||
default:
|
||||
return error.localizedDescription
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -104,7 +104,7 @@ struct ContentView: View {
|
||||
}
|
||||
}
|
||||
.sheet(item: $editingProfile) { profile in
|
||||
ProfileEditorView(profile: profile) { saved in
|
||||
ProfileEditorView(profile: profile, isNew: !store.profiles.contains(where: { $0.id == profile.id })) { saved in
|
||||
if store.profiles.contains(where: { $0.id == saved.id }) {
|
||||
store.update(saved)
|
||||
} else {
|
||||
|
||||
@@ -2,12 +2,16 @@ import SwiftUI
|
||||
import AppKit
|
||||
|
||||
/// In-App-Terminal im Dracula-Look: Ausgabe (NSTextView, read-only) + Eingabezeile.
|
||||
/// Verbindet erst nach TCP-Vorab-Check (falscher Port/Host -> sofort klare Meldung).
|
||||
/// Zeilenumbruch ist an, Autoscroll ans Ende, Passwort-Modus via Auge-Icon.
|
||||
struct EmbeddedTerminalView: View {
|
||||
@ObservedObject var term: PTYSession
|
||||
let profile: ConnectionProfile
|
||||
var canConnect: Bool
|
||||
@State private var input = ""
|
||||
@State private var secureInput = false
|
||||
@State private var checking = false
|
||||
@State private var hostKeyRequest: HostKeyRequest?
|
||||
|
||||
var body: some View {
|
||||
VStack(spacing: 0) {
|
||||
@@ -18,8 +22,8 @@ struct EmbeddedTerminalView: View {
|
||||
Spacer()
|
||||
if term.isRunning {
|
||||
Button("Trennen") { term.stop() }.buttonStyle(.link).font(.caption)
|
||||
} else if canConnect {
|
||||
Button("Verbinden") { term.start() }.buttonStyle(.link).font(.caption)
|
||||
} else if canConnect && !checking {
|
||||
Button("Verbinden") { connect() }.buttonStyle(.link).font(.caption)
|
||||
}
|
||||
Button("Leeren") { term.clear() }.buttonStyle(.link).font(.caption)
|
||||
}
|
||||
@@ -27,6 +31,34 @@ struct EmbeddedTerminalView: View {
|
||||
.padding(.vertical, 6)
|
||||
.background(Dracula.currentLine.opacity(0.35))
|
||||
|
||||
// Fehler-Banner bei Fehlschlag (statt nur „Sitzung beendet")
|
||||
if failed {
|
||||
HStack(spacing: 8) {
|
||||
Image(systemName: "exclamationmark.triangle.fill")
|
||||
.foregroundStyle(Dracula.red)
|
||||
VStack(alignment: .leading, spacing: 2) {
|
||||
Text("Verbindung fehlgeschlagen\(exitSuffix)")
|
||||
.font(.callout).bold().foregroundStyle(Dracula.red)
|
||||
Text(lastMessage)
|
||||
.font(.caption).foregroundStyle(Dracula.foreground)
|
||||
.lineLimit(3)
|
||||
if lastMessage.localizedCaseInsensitiveContains("permission denied") {
|
||||
Text("Tipp: Passwort im Auge-Modus eingeben, Tastaturlayout prüfen. Falls Terminal.app ohne Passwort einloggt (Agent-Key: ssh-add -l), Key in der App hinterlegen oder Agent nutzen.")
|
||||
.font(.caption).foregroundStyle(Dracula.orange)
|
||||
}
|
||||
}
|
||||
Spacer()
|
||||
Button("Bericht kopieren") { copyReport() }
|
||||
.buttonStyle(.link).font(.caption)
|
||||
.help("Kopiert Profil (ohne Passwort), Status und letzte Ausgabe — hierher schicken zur Fehlersuche")
|
||||
Button("Diagnose") { diagnose() }.buttonStyle(.link).font(.caption)
|
||||
Button("Erneut") { connect() }.buttonStyle(.link).font(.caption)
|
||||
}
|
||||
.padding(8)
|
||||
.background(Dracula.red.opacity(0.12))
|
||||
.overlay(Rectangle().fill(Dracula.red.opacity(0.4)).frame(height: 1), alignment: .bottom)
|
||||
}
|
||||
|
||||
// Ausgabe im Dracula-Theme
|
||||
DraculaTextView(lines: term.lines)
|
||||
.frame(maxWidth: .infinity, maxHeight: .infinity)
|
||||
@@ -34,16 +66,17 @@ struct EmbeddedTerminalView: View {
|
||||
// Eingabezeile
|
||||
HStack(spacing: 6) {
|
||||
Text("❯").font(.system(.body, design: .monospaced)).foregroundStyle(Dracula.green)
|
||||
if secureInput {
|
||||
SecureField("Eingabe (versteckt, z. B. Passwort) …", text: $input, onCommit: submit)
|
||||
.textFieldStyle(.plain)
|
||||
// Gehärtetes Feld: keine macOS-Text-Ersetzungen (Passwort-Sonderzeichen!)
|
||||
ZStack(alignment: .leading) {
|
||||
if input.isEmpty {
|
||||
Text(secureInput ? "Eingabe (versteckt, z. B. Passwort) …" : "Eingabe …")
|
||||
.font(.system(.body, design: .monospaced))
|
||||
.foregroundStyle(Dracula.foreground)
|
||||
} else {
|
||||
TextField("Eingabe …", text: $input, onCommit: submit)
|
||||
.textFieldStyle(.plain)
|
||||
.font(.system(.body, design: .monospaced))
|
||||
.foregroundStyle(Dracula.foreground)
|
||||
.foregroundStyle(Dracula.comment.opacity(0.7))
|
||||
.allowsHitTesting(false)
|
||||
}
|
||||
TerminalInputField(text: $input, isSecure: secureInput, onSubmit: submit)
|
||||
.id(secureInput)
|
||||
.frame(height: 22)
|
||||
}
|
||||
Button(action: { secureInput.toggle() }) {
|
||||
Image(systemName: secureInput ? "eye.slash" : "eye")
|
||||
@@ -62,8 +95,80 @@ struct EmbeddedTerminalView: View {
|
||||
.cornerRadius(10)
|
||||
.overlay(RoundedRectangle(cornerRadius: 10).stroke(Dracula.currentLine, lineWidth: 1))
|
||||
.onAppear {
|
||||
if case .never = term.state, canConnect {
|
||||
term.start() // Auto-Connect beim Öffnen des Tabs (Bugfix: kein externes Terminal mehr nötig)
|
||||
if case .never = term.state {
|
||||
connect() // Auto-Connect beim Öffnen des Tabs
|
||||
}
|
||||
}
|
||||
.sheet(item: $hostKeyRequest) { req in
|
||||
HostKeySheet(info: req.info, isChange: req.isChange,
|
||||
onAccept: { acceptHostKey(req) },
|
||||
onCancel: {
|
||||
hostKeyRequest = nil
|
||||
checking = false
|
||||
term.fail("Host-Key nicht akzeptiert — Verbindung abgebrochen.")
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func connect() {
|
||||
guard canConnect, !term.isRunning, !checking else { return }
|
||||
checking = true
|
||||
TCPCheck.check(host: profile.host, port: profile.port) { message in
|
||||
DispatchQueue.main.async {
|
||||
if let message {
|
||||
checking = false
|
||||
term.fail("Vorab-Check: \(message)")
|
||||
return
|
||||
}
|
||||
// Host-Key vorab per keyscan prüfen (Yes/No-Prompt käme ohne Ctty nicht an).
|
||||
// Läuft im Hintergrund: ssh-keyscan blockiert Sekunden (kein UI-Freeze).
|
||||
let host = profile.host
|
||||
let port = profile.port
|
||||
DispatchQueue.global(qos: .userInitiated).async {
|
||||
let hk = HostKeyService.status(host: host, port: port)
|
||||
DispatchQueue.main.async {
|
||||
switch hk {
|
||||
case .known, .unreachable:
|
||||
checking = false
|
||||
term.start()
|
||||
case .unknown(let info):
|
||||
hostKeyRequest = HostKeyRequest(info: info, isChange: false)
|
||||
case .changed(let info):
|
||||
hostKeyRequest = HostKeyRequest(info: info, isChange: true)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func acceptHostKey(_ req: HostKeyRequest) {
|
||||
hostKeyRequest = nil
|
||||
if req.isChange {
|
||||
_ = HostKeyService.revoke(host: profile.host, port: profile.port)
|
||||
}
|
||||
if HostKeyService.accept(req.info) {
|
||||
checking = false
|
||||
term.note("Host-Key akzeptiert (\(req.info.keyType), \(req.info.fingerprintSHA256.prefix(19))…).")
|
||||
term.start()
|
||||
} else {
|
||||
checking = false
|
||||
term.fail("Host-Key konnte nicht in known_hosts gespeichert werden.")
|
||||
}
|
||||
}
|
||||
|
||||
func diagnose() {
|
||||
guard !checking else { return }
|
||||
checking = true
|
||||
term.note("Diagnose: TCP \(profile.host):\(profile.port) …")
|
||||
TCPCheck.check(host: profile.host, port: profile.port) { message in
|
||||
DispatchQueue.main.async {
|
||||
checking = false
|
||||
if let message {
|
||||
term.note("Diagnose: \(message)")
|
||||
} else {
|
||||
term.note("Diagnose: Port offen — ssh selbst lehnt ab (User/Key/Passwort/Hostkey prüfen).")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -74,18 +179,56 @@ struct EmbeddedTerminalView: View {
|
||||
input = ""
|
||||
}
|
||||
|
||||
/// Fehlerbericht ohne Secrets (Passwort steht weder im Profil noch im Befehl).
|
||||
/// Hinweis: Wer das Passwort sichtbar eingetippt hat (nicht Auge-Modus),
|
||||
/// löscht die Ausgabe vorher per „Leeren".
|
||||
func copyReport() {
|
||||
var r = "RemminaMac Fehlerbericht\n"
|
||||
r += "Profil: \(profile.name) | \(profile.proto.rawValue) | \(profile.username)@\(profile.host):\(profile.port)\n"
|
||||
r += "Auto-Login: \(term.autoLogin ? "ja" : "nein") | sshpass: \(SSHService.findSshpass() ?? "fehlt")\n"
|
||||
r += "Status: \(statusText)\n"
|
||||
let tail = term.lines.suffix(20).map { $0.map(\.text).joined() }.joined(separator: "\n")
|
||||
r += "--- letzte Ausgabe ---\n\(tail)\n"
|
||||
NSPasteboard.general.clearContents()
|
||||
NSPasteboard.general.setString(r, forType: .string)
|
||||
}
|
||||
|
||||
var failed: Bool {
|
||||
if case .done(let code, _) = term.state {
|
||||
return (code ?? 1) != 0
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
var exitSuffix: String {
|
||||
if case .done(let code, _) = term.state, let code {
|
||||
return " (Exit \(code))"
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
var lastMessage: String {
|
||||
for row in term.lines.reversed() {
|
||||
let t = row.map(\.text).joined().trimmingCharacters(in: .whitespacesAndNewlines)
|
||||
if !t.isEmpty && !t.hasPrefix("—") { return t }
|
||||
}
|
||||
if case .done(_, let msg) = term.state { return msg }
|
||||
return "Unbekannter Fehler."
|
||||
}
|
||||
|
||||
var statusDot: some View {
|
||||
Group {
|
||||
if term.isRunning { Image(systemName: "circle.fill").foregroundStyle(Dracula.green) }
|
||||
else if case .done = term.state { Image(systemName: "circle.fill").foregroundStyle(Dracula.red) }
|
||||
if checking || term.isRunning { Image(systemName: "circle.fill").foregroundStyle(Dracula.green) }
|
||||
else if case .done = term.state { Image(systemName: "circle.fill").foregroundStyle(failed ? Dracula.red : Dracula.comment) }
|
||||
else { Image(systemName: "circle.fill").foregroundStyle(Dracula.comment) }
|
||||
}.font(.caption2)
|
||||
}
|
||||
|
||||
var statusText: String {
|
||||
if checking { return "Prüfe \(profile.host):\(profile.port) …" }
|
||||
switch term.state {
|
||||
case .never: return canConnect ? "Bereit — verbindet beim Öffnen." : "Host/Benutzer fehlt."
|
||||
case .running: return "Verbunden (PTY, TERM=xterm-256color)."
|
||||
case .running: return term.autoLogin ? "Verbunden (Auto-Login via Keychain)." : "Verbunden (PTY, TERM=xterm-256color)."
|
||||
case .done(_, let msg): return msg
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,65 @@
|
||||
import SwiftUI
|
||||
|
||||
/// Sheet-Request (Identifiable): .sheet(item:) rendert IMMER mit Wert —
|
||||
/// ein `if let` im Sheet kann den Empty-Zweig nehmen und bleibt dann leer.
|
||||
struct HostKeyRequest: Identifiable {
|
||||
let id = UUID()
|
||||
var info: HostKeyInfo
|
||||
var isChange: Bool
|
||||
}
|
||||
|
||||
/// Popup bei unbekanntem/geändertem Host-Key: Fingerprint prüfen, dann
|
||||
/// akzeptieren (→ known_hosts + verbinden) oder abbrechen.
|
||||
struct HostKeySheet: View {
|
||||
var info: HostKeyInfo
|
||||
var isChange: Bool
|
||||
var onAccept: () -> Void
|
||||
var onCancel: () -> Void
|
||||
|
||||
var body: some View {
|
||||
VStack(alignment: .leading, spacing: 12) {
|
||||
HStack(spacing: 10) {
|
||||
Image(systemName: isChange ? "exclamationmark.octagon.fill" : "key.fill")
|
||||
.font(.title)
|
||||
.foregroundStyle(isChange ? Dracula.red : Dracula.orange)
|
||||
VStack(alignment: .leading) {
|
||||
Text(isChange ? "Host-Key GEÄNDERT" : "Neuer Host-Key")
|
||||
.font(.headline)
|
||||
Text("\(info.host):\(info.port) · \(info.keyType)")
|
||||
.font(.subheadline).foregroundStyle(.secondary)
|
||||
}
|
||||
}
|
||||
|
||||
if isChange {
|
||||
Text("Warnung: Der gespeicherte Schlüssel passt NICHT zum Server. Das kann ein neu aufgesetzter Server sein — oder ein Angriff (MITM). Nur fortfahren, wenn du die Änderung erwartest!")
|
||||
.font(.callout).foregroundStyle(Dracula.red)
|
||||
} else {
|
||||
Text("Erstverbindung: Dieser Server ist noch unbekannt. Fingerprint prüfen (z. B. mit dem Server-Admin oder einer Terminal-Verbindung vergleichen), dann akzeptieren.")
|
||||
.font(.callout).foregroundStyle(.secondary)
|
||||
}
|
||||
|
||||
GroupBox("SHA256-Fingerprint") {
|
||||
Text(info.fingerprintSHA256)
|
||||
.font(.system(.body, design: .monospaced))
|
||||
.textSelection(.enabled)
|
||||
.frame(maxWidth: .infinity, alignment: .leading)
|
||||
}
|
||||
GroupBox("MD5-Fingerprint") {
|
||||
Text(info.fingerprintMD5)
|
||||
.font(.system(.callout, design: .monospaced))
|
||||
.foregroundStyle(.secondary)
|
||||
.textSelection(.enabled)
|
||||
.frame(maxWidth: .infinity, alignment: .leading)
|
||||
}
|
||||
|
||||
HStack {
|
||||
Button("Abbrechen", role: .cancel, action: onCancel)
|
||||
Spacer()
|
||||
Button(isChange ? "Trotzdem ersetzen & verbinden" : "Akzeptieren & verbinden", action: onAccept)
|
||||
.keyboardShortcut(.defaultAction)
|
||||
}
|
||||
}
|
||||
.padding(20)
|
||||
.frame(width: 480)
|
||||
}
|
||||
}
|
||||
@@ -4,18 +4,23 @@ struct ProfileEditorView: View {
|
||||
@Environment(\.dismiss) var dismiss
|
||||
@EnvironmentObject var store: ProfileStore
|
||||
@State var profile: ConnectionProfile
|
||||
var isNew: Bool
|
||||
var onSave: (ConnectionProfile) -> Void
|
||||
@State private var password: String = ""
|
||||
@State private var savePassword: Bool = false
|
||||
@State private var storedPasswordPresent: Bool = false
|
||||
|
||||
init(profile: ConnectionProfile, onSave: @escaping (ConnectionProfile) -> Void) {
|
||||
init(profile: ConnectionProfile, isNew: Bool, onSave: @escaping (ConnectionProfile) -> Void) {
|
||||
_profile = State(initialValue: profile)
|
||||
self.isNew = isNew
|
||||
self.onSave = onSave
|
||||
}
|
||||
|
||||
var liveWarnings: [String] { ProfileValidation.warnings(for: profile) }
|
||||
|
||||
var body: some View {
|
||||
VStack(spacing: 0) {
|
||||
Text(profile.id.uuidString.prefix(8) == ConnectionProfile().id.uuidString.prefix(8) ? "Profil bearbeiten" : "Profil").font(.headline).padding()
|
||||
Text(isNew ? "Neues Profil" : "Profil bearbeiten").font(.headline).padding()
|
||||
Form {
|
||||
Section("Allgemein") {
|
||||
TextField("Name", text: $profile.name)
|
||||
@@ -34,18 +39,38 @@ struct ProfileEditorView: View {
|
||||
}
|
||||
Section("Verbindung") {
|
||||
TextField("Host", text: $profile.host)
|
||||
.autocorrectionDisabled()
|
||||
TextField("Port", value: $profile.port, format: .number)
|
||||
TextField("Benutzername", text: $profile.username)
|
||||
.autocorrectionDisabled()
|
||||
// Passwort direkt unter dem Benutzernamen (Keychain-gespeichert)
|
||||
if storedPasswordPresent && password.isEmpty {
|
||||
HStack {
|
||||
Image(systemName: "checkmark.circle.fill").foregroundStyle(.green)
|
||||
Text("Passwort gespeichert")
|
||||
Spacer()
|
||||
Button("Löschen", role: .destructive) { deleteStoredPassword() }
|
||||
}
|
||||
}
|
||||
SecureField(storedPasswordPresent ? "Neues Passwort …" : "Passwort", text: $password)
|
||||
Toggle("Passwort in Keychain speichern", isOn: $savePassword)
|
||||
TextField("Auflösung (RDP, z. B. 1920x1080 oder Automatisch)", text: $profile.resolution)
|
||||
TextField("Extra-Argumente", text: $profile.extraArgs)
|
||||
if !liveWarnings.isEmpty {
|
||||
ForEach(liveWarnings, id: \.self) { w in
|
||||
HStack(spacing: 6) {
|
||||
Image(systemName: "exclamationmark.triangle").foregroundStyle(.orange)
|
||||
Text(w).font(.caption).foregroundStyle(.orange)
|
||||
}
|
||||
Section("Authentifizierung") {
|
||||
}
|
||||
}
|
||||
}
|
||||
Section("SSH-Key (optional)") {
|
||||
Picker("SSH-Key", selection: $profile.sshKeyID) {
|
||||
Text("Kein Key").tag(UUID?.none)
|
||||
Text("Kein Key (Passwort-Login)").tag(UUID?.none)
|
||||
ForEach(store.sshKeys) { k in Text(k.name).tag(UUID?.some(k.id)) }
|
||||
}
|
||||
SecureField("Passwort (optional, Keychain)", text: $password)
|
||||
Toggle("Passwort in Keychain speichern", isOn: $savePassword)
|
||||
Text(sshpassHint).font(.caption).foregroundStyle(.secondary)
|
||||
}
|
||||
}
|
||||
.formStyle(.grouped)
|
||||
@@ -54,7 +79,7 @@ struct ProfileEditorView: View {
|
||||
Button("Abbrechen", role: .cancel) { dismiss() }
|
||||
Spacer()
|
||||
Button("Speichern") {
|
||||
var toSave = profile
|
||||
var toSave = ProfileValidation.cleaned(profile)
|
||||
if toSave.port == 0 { toSave.port = toSave.proto.defaultPort }
|
||||
if toSave.passwordAccount == nil { toSave.passwordAccount = "profile-\(toSave.id.uuidString)" }
|
||||
if savePassword, !password.isEmpty, let acct = toSave.passwordAccount {
|
||||
@@ -64,16 +89,35 @@ struct ProfileEditorView: View {
|
||||
dismiss()
|
||||
}
|
||||
.keyboardShortcut(.defaultAction)
|
||||
.disabled(profile.host.isEmpty || profile.name.isEmpty)
|
||||
.disabled(profile.name.trimmingCharacters(in: .whitespacesAndNewlines).isEmpty
|
||||
|| profile.host.trimmingCharacters(in: .whitespacesAndNewlines).isEmpty)
|
||||
}
|
||||
.padding()
|
||||
}
|
||||
.frame(width: 520, height: 620)
|
||||
.frame(width: 520, height: 680)
|
||||
.onAppear {
|
||||
if let acct = profile.passwordAccount,
|
||||
let stored = KeychainHelper.load(account: acct), !stored.isEmpty {
|
||||
storedPasswordPresent = true
|
||||
savePassword = true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
var sshpassHint: String {
|
||||
if SSHService.findSshpass() != nil {
|
||||
return "sshpass gefunden → Auto-Login mit Keychain-Passwort aktiv, kein Tippen nötig."
|
||||
} else {
|
||||
return "Ohne sshpass: Passwort wird beim Verbinden im Terminal abgefragt. Für Auto-Login: brew install sshpass."
|
||||
}
|
||||
}
|
||||
|
||||
func deleteStoredPassword() {
|
||||
if let acct = profile.passwordAccount {
|
||||
password = KeychainHelper.load(account: acct) ?? ""
|
||||
savePassword = !password.isEmpty
|
||||
}
|
||||
}
|
||||
KeychainHelper.delete(account: acct)
|
||||
}
|
||||
password = ""
|
||||
savePassword = false
|
||||
storedPasswordPresent = false
|
||||
}
|
||||
}
|
||||
|
||||
@@ -37,7 +37,7 @@ struct SessionView: View {
|
||||
|
||||
if isSSH {
|
||||
// In-App-Terminal (Dracula) — kein externes Fenster mehr nötig
|
||||
EmbeddedTerminalView(term: term, canConnect: canConnect)
|
||||
EmbeddedTerminalView(term: term, profile: profile, canConnect: canConnect)
|
||||
.frame(minHeight: 380)
|
||||
.padding(.horizontal)
|
||||
}
|
||||
|
||||
@@ -0,0 +1,119 @@
|
||||
import SwiftUI
|
||||
import AppKit
|
||||
|
||||
/// Eingabefeld ohne macOS-Text-Ersetzungen (Anführungszeichen, Gedankenstriche,
|
||||
/// Auto-Korrektur, Punkt-Verdopplung, Vervollständigung, Links/Daten-Erkennung).
|
||||
/// Hintergrund: Normale Textfelder ersetzen still z. B. `"` durch „“ und `--`
|
||||
/// durch — (je nach Tastatur-Einstellung). Im Terminal fällt das nicht auf, aber
|
||||
/// ein Passwort mit Sonderzeichen kommt falsch bei ssh an → „Permission denied",
|
||||
/// obwohl das Passwort „stimmt" (docs/ERRORS.md #13).
|
||||
/// NSTextField kann das nicht alles abschalten, daher NSTextView-Basis.
|
||||
/// Secure-Modus nutzt NSSecureTextField (per Design ohne Ersetzungen).
|
||||
struct TerminalInputField: NSViewRepresentable {
|
||||
@Binding var text: String
|
||||
var isSecure: Bool
|
||||
var onSubmit: () -> Void
|
||||
|
||||
func makeCoordinator() -> Coordinator {
|
||||
Coordinator(text: $text, onSubmit: onSubmit)
|
||||
}
|
||||
|
||||
func makeNSView(context: Context) -> NSView {
|
||||
if isSecure {
|
||||
let f = NSSecureTextField()
|
||||
f.font = .monospacedSystemFont(ofSize: 13, weight: .regular)
|
||||
f.textColor = Dracula.nsColor(for: nil)
|
||||
f.backgroundColor = .clear
|
||||
f.isBordered = false
|
||||
f.focusRingType = .none
|
||||
f.delegate = context.coordinator
|
||||
return f
|
||||
} else {
|
||||
let tv = NSTextView()
|
||||
Self.configure(tv)
|
||||
tv.delegate = context.coordinator
|
||||
return tv
|
||||
}
|
||||
}
|
||||
|
||||
func updateNSView(_ view: NSView, context: Context) {
|
||||
context.coordinator.onSubmit = onSubmit
|
||||
// Delegat während Programm-Sets abhängen: sonst feuert textDidChange synchron
|
||||
// zurück ins SwiftUI-State — mitten im Render -> Crash ("Modifying state
|
||||
// during view update"). User-Tippen läuft weiter über den Delegaten.
|
||||
if let f = view as? NSTextField {
|
||||
if f.stringValue != text {
|
||||
f.delegate = nil
|
||||
f.stringValue = text
|
||||
f.delegate = context.coordinator
|
||||
}
|
||||
} else if let tv = view as? NSTextView, tv.string != text {
|
||||
tv.delegate = nil
|
||||
tv.string = text
|
||||
tv.delegate = context.coordinator
|
||||
}
|
||||
}
|
||||
|
||||
/// Alle Ersetzungen aus. Auch als Harness-Test nutzbar (reine Flags, headless).
|
||||
static func configure(_ tv: NSTextView) {
|
||||
tv.isRichText = false
|
||||
tv.importsGraphics = false
|
||||
tv.isAutomaticQuoteSubstitutionEnabled = false
|
||||
tv.isAutomaticDashSubstitutionEnabled = false
|
||||
tv.isAutomaticTextCompletionEnabled = false
|
||||
tv.isAutomaticSpellingCorrectionEnabled = false
|
||||
tv.isContinuousSpellCheckingEnabled = false
|
||||
tv.isAutomaticDataDetectionEnabled = false
|
||||
tv.isAutomaticLinkDetectionEnabled = false
|
||||
tv.isAutomaticTextReplacementEnabled = false
|
||||
tv.font = .monospacedSystemFont(ofSize: 13, weight: .regular)
|
||||
tv.textColor = Dracula.nsColor(for: nil)
|
||||
tv.backgroundColor = .clear
|
||||
tv.drawsBackground = false
|
||||
tv.isVerticallyResizable = false
|
||||
tv.isHorizontallyResizable = true
|
||||
tv.textContainer?.widthTracksTextView = false
|
||||
tv.textContainer?.containerSize = NSSize(width: 100000, height: 24)
|
||||
}
|
||||
|
||||
final class Coordinator: NSObject, NSTextFieldDelegate, NSTextViewDelegate {
|
||||
var text: Binding<String>
|
||||
var onSubmit: () -> Void
|
||||
|
||||
init(text: Binding<String>, onSubmit: @escaping () -> Void) {
|
||||
self.text = text
|
||||
self.onSubmit = onSubmit
|
||||
}
|
||||
|
||||
func controlTextDidChange(_ obj: Notification) {
|
||||
if let f = obj.object as? NSTextField {
|
||||
text.wrappedValue = f.stringValue
|
||||
}
|
||||
}
|
||||
|
||||
func control(_ control: NSControl, textView: NSTextView, doCommandBy commandSelector: Selector) -> Bool {
|
||||
if commandSelector == #selector(NSResponder.insertNewline(_:)) {
|
||||
onSubmit()
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
func textDidChange(_ notification: Notification) {
|
||||
if let tv = notification.object as? NSTextView {
|
||||
// Einzeiler: harte Umbrüche sofort entfernen (Paste mit \n)
|
||||
let single = tv.string.replacingOccurrences(of: "\n", with: "")
|
||||
if single != tv.string { tv.string = single }
|
||||
text.wrappedValue = single
|
||||
}
|
||||
}
|
||||
|
||||
func textView(_ textView: NSTextView, doCommandBy commandSelector: Selector) -> Bool {
|
||||
if commandSelector == #selector(NSResponder.insertNewline(_:)) {
|
||||
onSubmit()
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
// ctty-run: gibt dem Kindprozess ein Controlling-Terminal auf dem PTY-Slave.
|
||||
// Usage: ctty-run <slave-pfad> <programm> [args...]
|
||||
// stdin/stdout zeigen dabei bereits auf den Slave (vom Parent gesetzt),
|
||||
// stderr bleibt unberührt (Eltern-Pipe für garantierte Fehlerausgabe).
|
||||
//
|
||||
// Warum Double-Fork: Apples Process startet Kinder in eigener Prozessgruppe,
|
||||
// daher schlägt setsid() im direkten Kind mit EPERM fehl. Der Wächter forkt
|
||||
// einmal weiter (Enkel = kein Leader mehr), wartet auf ihn und übernimmt
|
||||
// dessen Exit-Code — Lifecycle/Exit-Codes bleiben für den Parent korrekt.
|
||||
// Der Enkel: setsid() -> Slave einmal öffnen (wird dadurch Ctty) -> exec.
|
||||
// Ohne Ctty scheitern ssh-Passwort- und Yes/No-Prompts still (/dev/tty ENXIO).
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
#include <fcntl.h>
|
||||
#include <errno.h>
|
||||
#include <sys/wait.h>
|
||||
|
||||
int
|
||||
main(int argc, char **argv)
|
||||
{
|
||||
if (argc < 3) {
|
||||
dprintf(STDERR_FILENO, "usage: ctty-run <slave> <prog> [args...]\n");
|
||||
return 2;
|
||||
}
|
||||
pid_t pid = fork();
|
||||
if (pid < 0) {
|
||||
dprintf(STDERR_FILENO, "ctty-run: fork: %s\n", strerror(errno));
|
||||
return 1;
|
||||
}
|
||||
if (pid > 0) {
|
||||
/* Wächter: keine FDs offen halten (sonst nie EOF), aufs Kind warten. */
|
||||
close(STDIN_FILENO);
|
||||
close(STDOUT_FILENO);
|
||||
close(STDERR_FILENO);
|
||||
int st = 0;
|
||||
while (waitpid(pid, &st, 0) < 0 && errno == EINTR)
|
||||
;
|
||||
if (WIFEXITED(st))
|
||||
return WEXITSTATUS(st);
|
||||
return 128;
|
||||
}
|
||||
/* Enkel: eigene Session; danach Slave-Open = Ctty. */
|
||||
if (setsid() < 0) {
|
||||
dprintf(STDERR_FILENO, "ctty-run: setsid: %s (weiter ohne Ctty)\n",
|
||||
strerror(errno));
|
||||
}
|
||||
int fd = open(argv[1], O_RDWR);
|
||||
if (fd < 0) {
|
||||
dprintf(STDERR_FILENO, "ctty-run: open slave: %s\n", strerror(errno));
|
||||
_exit(1);
|
||||
}
|
||||
close(fd); /* Ctty bleibt der Session erhalten */
|
||||
execvp(argv[2], &argv[2]);
|
||||
dprintf(STDERR_FILENO, "ctty-run: execvp: %s\n", strerror(errno));
|
||||
_exit(127);
|
||||
}
|
||||
+124
@@ -14,6 +14,18 @@ Stand: 2026-09-21 · Version 0.1.0 · macOS arm64 · Swift 5.9+ · Xcode 15+
|
||||
| 5 | 2026-09-21 | App-Bundle + DMG | keine Fehler: `build-app.sh` (Signatur ok), `build-dmg.sh` (UDZO, 200K), Mount-Verifikation ok (App + Applications/Programme-Links) | Info | ✅ ok |
|
||||
| 6 | 2026-09-21 | SSH verbinden | kein Terminal öffnete sich: `SSHService.openInTerminal` nutzte `NSAppleScript` → scheitert still (keine `NSAppleEventsUsageDescription`, kein Error-Handling) | blockierend | ✅ behoben — In-App-PTY-Terminal (Dracula) + `.command`-Fallback |
|
||||
| 7 | 2026-09-21 | ANSI-Parser (Test) | `feed()` flusht Chunk erst NACH `parseCSI` → Text bekam den neuen statt alten Stil (`rot` mit fg=nil statt 1) | mittel | ✅ behoben — Flush vor Stilwechsel |
|
||||
| 8 | 2026-09-21 | SSH-Session stirbt instant ohne Meldung | stderr hing mit am PTY: macOS verwirft ungelesene Master-Daten bei Slave-Close → „Code 255" ohne Text | blockierend | ✅ behoben — stderr→Pipe, TCP-Vorab-Check, Fehler-Banner |
|
||||
| 9 | 2026-09-21 | `swift build` | `Result<Void, String>`: String conformt nicht zu Error (Folgefehler: DispatchQueue-Overload) | blockierend | ✅ behoben — Completion als `(String?) -> Void` |
|
||||
| 10 | 2026-09-21 | Icon-Generator (`RenderIcon.swift`) | 3 Swift-Fehler: `guard let x = f() ?? g()` (nicht optional), `Int * CGFloat`, falscher Preview-Pfad | klein | ✅ behoben |
|
||||
| 11 | 2026-09-21 | Passwort-Feature | Wunsch: Passwort + Keys speichern UND nutzen (bisher nur gespeichert, nie benutzt) | Feature | ✅ umgesetzt — Auto-Login via sshpass, sonst interaktiv |
|
||||
| 12 | 2026-09-21 | „Immer Verbindung falsch" | User-Report ohne Details (Ziel/Credentials unbekannt) | offen | ⬜ Teils: Editor-Validierung + kopierbarer Fehlerbericht; warte auf Bericht |
|
||||
| 13 | 2026-09-21 | Permission denied trotz richtigem Passwort | Text-Ersetzung im Eingabefeld verfälscht Sonderzeichen | hoch | ✅ behoben — gehärtetes Eingabefeld (alle Ersetzungen aus, 9/9 Tests) |
|
||||
| 14 | 2026-09-21 | Terminal geht, App nicht (gleiches Passwort) | SSH-Agent-Socket fehlt GUI-Prozessen → evtl. Key-Login in Terminal | hoch | ✅ App reicht Agent jetzt durch; Gegenprobe beim User offen |
|
||||
| 15 | 2026-09-21 | Crash bei Tippen + Senden | Ursache unklar (headless nicht reproduzierbar) | kritisch | ⬜ Gehärtet (v0.5.3); Crash-Log angefragt |
|
||||
| 16 | 2026-09-22 | Profil-Änderungen wirkungslos | Session-Cache ignorierte Host-/Passwort-/Key-Korrekturen | hoch | ✅ behoben — Fingerprint-Reconfig (9/9 Tests) |
|
||||
| 17 | 2026-09-22 | rzsv: Vorab-Check Timeout | Port 22 wird serverseitig gedroppt (443 ok) — kein App-Fehler | extern | ⬜ Server-Seite: fail2ban/VPN/Firewall prüfen |
|
||||
| 18 | 2026-09-22 | Host-Key-Yes/No unmöglich | ssh ohne Controlling-Terminal: /dev/tty ENXIO → stummer Abbruch | kritisch | ✅ ctty-run-Helper (Double-Fork) + Fingerprint-Popup |
|
||||
| 19 | 2026-09-22 | Popup leer (s. Screenshot) | `if let` im Sheet nimmt Empty-Zweig ohne Update-Pfad | mittel | ✅ `.sheet(item:)` + Keyscan im Hintergrund |
|
||||
|
||||
---
|
||||
|
||||
@@ -92,6 +104,42 @@ dist/
|
||||
**Verifikation:** `swift build` ok; Parser-Harness 8/8; PTY-Smoke (`/bin/echo` → Output + Exit 0); `ssh -G example.com` durchs PTY ok.
|
||||
**Status:** ✅ behoben.
|
||||
|
||||
## #8 — Terminal verbindet nicht, „direkt gekappt" (User-Bugreport)
|
||||
**Phase:** Laufzeit, SSH-Profil → Tab öffnet, sofort „Sitzung beendet (Code 255)." — ohne jede Meldung
|
||||
**Reproduktion (Harness, exakter App-Pfad `ssh -p 1 nobody@127.0.0.1`):**
|
||||
```
|
||||
STATE: done(exitCode: Optional(255), message: "Sitzung beendet (Code 255).")
|
||||
TEXT: "\n\n— Sitzung beendet (Code 255). —\n" # <- Fehlermeldung fehlt!
|
||||
```
|
||||
**Ground Truth (Python-pty):** Selbst `/bin/echo hello` liefert `b''`, wenn man erst NACH Child-Exit liest; bei sofortigem Lesen kommt `b'hello-py\r\n'`. → macOS verwirft ungelesene PTY-Master-Daten beim Slave-Close (danach EIO). Unser `DispatchSourceRead` verliert dieses Rennen bei Instant-Exit-Kindern — und ssh schreibt ALLES (inkl. „Connection refused") nach stderr, das mit am PTY hing.
|
||||
**Fix (`Services/PTYSession.swift`, `Services/TCPCheck.swift`, `Views/EmbeddedTerminalView.swift`):**
|
||||
- stderr → `Pipe` (gepufferte Daten überleben Child-Exit garantiert), stdin/stdout bleiben am PTY (TTY erhalten für interaktive Prompts)
|
||||
- `finalFlush` (non-blocking Rest-Drain) + Epoch-guarded Lifecycle (kein State-/FD-Durcheinander bei Trennen→Neuverbinden)
|
||||
- TCP-Vorab-Check (Network.framework, 4 s Timeout) mit deutschen Klartext-Meldungen (refused/DNS/Timeout/Port)
|
||||
- Rotes Fehler-Banner mit letzter Meldung + Diagnose- und Erneut-Buttons
|
||||
**Verifikation:** Refused-Harness zeigt jetzt `ssh: connect to host 127.0.0.1 port 1: Connection refused` (PASS); Roundtrip (`cat`) PASS; `ssh -G` PASS; TCP-Harness (closed/open/empty) PASS.
|
||||
**Status:** ✅ behoben.
|
||||
|
||||
## #9 — Build: `Result<Void, String>` ungültig
|
||||
**Log:** `error: type 'String' does not conform to protocol 'Error'` (+ Folgefehler an `DispatchQueue.main.async`)
|
||||
**Fix:** `TCPCheck.check` nutzt `(String?) -> Void` (nil = ok, sonst deutsche Meldung).
|
||||
**Status:** ✅ behoben.
|
||||
|
||||
## #11 — Passwort speichern UND benutzen (User-Wunsch)
|
||||
**Stand:** Passwort/Key-Passphrase wurden in der Keychain gespeichert, aber nie zum Einloggen benutzt (ssh fragte immer interaktiv).
|
||||
**Umsetzung:**
|
||||
- `SSHService.loginSecret()` (Profil-Passwort → Key-Passphrase), `sessionConfig()` (rein, testbar): mit Secret + sshpass → `sshpass -e ssh/sftp …` + `SSHPASS`-Env (nie Befehlszeile/Logs); sonst direkter Aufruf + interaktiver Prompt.
|
||||
- `PTYSession.customEnv` + `autoLogin`-Flag, `TerminalManager` verdrahtet alles; Status zeigt „Auto-Login via Keychain".
|
||||
- Editor: Gespeichert-Anzeige (✓), Löschen-Button, sshpass-Hinweis; Titel-Bug (`UUID`-Vergleich mit neuem Random-Objekt) via `isNew` ersetzt.
|
||||
**Verifikation:** Config-Harness 9/9 (inkl. „Passwort nie in Befehlszeile"); echter Keychain-Roundtrip 7/7 (save/load/delete + Priorität + Fallback).
|
||||
**Hinweis:** Ohne `sshpass` (`brew install sshpass`) bleibt es beim interaktiven Prompt — hier auf dem Build-Mac ebenfalls nicht installiert, getestet wurde der interaktive Pfad + Logik.
|
||||
**Status:** ✅ umgesetzt.
|
||||
|
||||
## #10 — Icon-Generator Buildfehler
|
||||
**Log:** `guard let` auf nicht-optionalem Ausdruck (`??` unwrapt schon); `Int * CGFloat`; Preview lag in `.iconset/` statt `/tmp/`.
|
||||
**Fix:** `??`-Fallback direkt zuweisen; `CGFloat(...)`; Pfad korrigiert.
|
||||
**Status:** ✅ behoben. Icon: `Resources/AppIcon.icns` (per `scripts/generate-icon.sh` reproduzierbar), Vorschau `docs/icon-preview.png`.
|
||||
|
||||
## #7 — ANSI-Parser: Text bekam falschen Stil
|
||||
**Phase:** `swiftc`-Harness während #6
|
||||
**Log:** `text("rot", fg: nil)` statt `fg: 1`
|
||||
@@ -124,3 +172,79 @@ Oder mit Token als Passwort: `git push https://<owner>:<token>@git.sysdaemon.xyz
|
||||
**Lokaler Stand:** Commit `cd834dc` + `dist/RemminaMac-0.1.0-macos-arm64.zip` sind fertig und warteten nur auf den Push.
|
||||
**Nachtrag 2026-09-21:** ✅ behoben — mit korrigierten Credentials: `GET /api/v1/user → 200 (login x3)`, Repo `x3/remmina-mac` erstellt (201), `git push -u origin main` ok, Release `v0.1.0` (id 1) + 2 Assets (ZIP + SHA256) hochgeladen.
|
||||
**Status:** ✅ behoben.
|
||||
|
||||
## #12 — „Immer Verbindung falsch" (User-Report, Details offen)
|
||||
**Stand:** Gemeldet ohne Ziel-Host, Banner-Text oder Credentials — aus der Ferne nicht reproduzierbar. Systematische App-Fehler als Ursache weitgehend ausgeschlossen (PTY/ssh-Pfad, Fehlertext-Anzeige, TCP-Check und Keychain-Fluss sind per Harness verifiziert).
|
||||
**Häufigste reale Ursachen (Checkliste):**
|
||||
1. `user@host` im Host-Feld oder `ssh://`-Präfix → jetzt Live-Warnung im Editor
|
||||
2. Leerzeichen/Vertipper in Host/User → wird jetzt getrimmt + gewarnt
|
||||
3. Falsches Passwort / Key ohne Passphrase-Eintrag → Banner + Diagnose nutzen
|
||||
4. Server blockt (Fail2ban, nur Key-Login erlaubt) → Server-Logs prüfen
|
||||
**Umgesetzt:** `Models/ProfileValidation.swift` (trimmen + Warnungen, Harness 7/7), Passwort direkt unter Benutzername, „Bericht kopieren" im Fehler-Banner (ohne Secrets).
|
||||
**Offen:** Bitte Banner-Text oder kopierten Bericht hierher schicken — dann steht die Ursache in einer Zeile.
|
||||
**Status:** ⬜ wartet auf Fehlerbericht.
|
||||
|
||||
## #13 — Permission denied trotz richtigem Passwort (User-Fehlerbericht)
|
||||
**Bericht:** `administrator@sysdaemon.xyz:22`, ssh fragt 3x Passwort → `Permission denied (publickey,password)`. Gleiches Passwort im Terminal.app funktioniert.
|
||||
**Ursache:** Das Terminal-Eingabefeld war ein Standard-TextField. macOS ersetzt dort je nach Einstellung still Zeichen (`"` → „“, `--` → —, Auto-Korrektur). Ein Passwort mit Sonderzeichen kommt dadurch falsch bei ssh an — im Terminal fällt nichts auf, ssh sagt nur „denied". Verifiziert: Standard-`NSTextField` hat diese Schalter an bzw. `NSTextField` kann Dash-Ersetzung gar nicht abschalten (Compiler-Beweis).
|
||||
**Fix (`Views/TerminalInputField.swift`):** Eigenes Eingabefeld auf `NSTextView`-Basis mit allen Ersetzungen explizit aus (Quotes, Dashes, Completion, Spelling, Data/Link-Erkennung, Text-Replacement, Plain-Text); Secure-Variante via `NSSecureTextField` (per Design ersetzungsfrei); Enter → Senden, Paste-Normalisierung (keine Umbrüche).
|
||||
**Verifikation:** Harness 9/9 (alle Flags aus). Hinweis: Restrisiko Tastaturlayout (Z/Y) bleibt — Banner-Tipp ergänzt.
|
||||
**Status:** ✅ behoben — bitte mit v0.5.1 erneut testen.
|
||||
|
||||
## #14 — Terminal.app loggt ein, RemminaMac nicht (gleiches Passwort)
|
||||
**Stand (User-Antworten):** v0.5.1 installiert, Passwort-Login, Terminal.app funktioniert mit denselben Daten.
|
||||
**Analyse:** App-seitig ist alles verifiziert (PTY, Fehleranzeige, Passwort-Loop mit Sonderzeichen, Eingabe-Ersetzungen aus). Gleiches Binary + gleiche Config → Unterschied muss aus der Umgebung kommen. Hauptkandidat: **SSH-Agent** — Finder-gestartete GUI-Prozesse erben `SSH_AUTH_SOCK` nicht. Nutzt Terminal unbemerkt einen Agent-Key (statt Passwort), scheitert die App mit Passwort. Verifiziert: `launchctl getenv SSH_AUTH_SOCK` liefert den Socket, Shell-Env wäre ohne Abfrage leer für GUI-Apps.
|
||||
**Fix:** `SSHService.agentSocket()` (launchctl + Existenzprüfung) → `TerminalManager` injiziert `SSH_AUTH_SOCK` ins ssh-Env (koexistiert mit SSHPASS). Banner-Tipp ergänzt.
|
||||
**Verifikation:** Harness 4/4 (Auflösung 0.07 s, Pfad existiert, `ssh -G` ok mit echtem + kaputtem Socket).
|
||||
**Gegenprobe beim User (bitte ausführen):**
|
||||
```bash
|
||||
ssh-add -l
|
||||
ssh -o IdentitiesOnly=yes administrator@sysdaemon.xyz
|
||||
```
|
||||
Zweite Zeile erzwingt Passwort-Login ohne Agent — scheitert sie auch im Terminal, war es immer der Agent-Key.
|
||||
**Status:** ✅ App-Seite umgesetzt — warte auf Gegenprobe.
|
||||
|
||||
## #15 — Crash bei Tippen + Senden (User-Report)
|
||||
**Stand:** „Sobald ich was eintippe und absende, crasht das Programm." Headless nicht reproduzierbar — alle Ebenen einzeln grün.
|
||||
**Ausgeschlossen per Test:**
|
||||
- SIGPIPE beim Schreiben (Harness: macOS liefert EIO statt Signal; `send` nach `stop()` überlebt) — Hypothese widerlegt
|
||||
- View-Schicht (echter Coordinator + NSTextView: Tippen mit Umlauten/Quotes/Paste, Enter, 200 Programm-Sets) — grün
|
||||
- PTY-Roundtrip, Refused-, Keychain-, TCP-Harness — grün
|
||||
**Gehärtet (v0.5.3, ohne Beweis dass es DER Crash war):**
|
||||
- `TerminalInputField.updateNSView`: Delegat bei Programm-Sets abgehängt — sonst feuert `textDidChange` synchron zurück ins State während SwiftUI rendert („Modifying state during view update" → Crash-Kandidat Nr. 1, genau beim Senden: Eingabe wird geleert)
|
||||
- `PTYSession.send`: Force-Unwrap `baseAddress!` → Guard, Leer-Check
|
||||
**Weiter nötig bei erneutem Crash:** Console.app → Absturzberichte → neuesten `RemminaMac`-Eintrag öffnen → `Exception Type`, `Termination Reason` und crashed Thread hierher schicken. Damit steht die Stelle fest.
|
||||
**Status:** ⬜ wartet auf Rückmeldung / Crash-Log.
|
||||
|
||||
## #16 — Profil-Änderungen wirkungslos („geht immer noch nicht")
|
||||
**Stand:** Nach mehreren Fixes meldet der User weiterhin pauschal Misserfolg. Code-Review (`TerminalManager.session`, Zeile 291): Eine einmal erstellte Session wurde für immer wiederverwendet — Host-/Passwort-/Key-Korrekturen im Editor erreichten die laufende/stale Session nie. Jede Korrektur lief ins Leere.
|
||||
**Fix:** Konfigurations-Fingerprint (Proto/Host/Port/User/ExtraArgs/Key-Pfad/Secret-Wert) pro Session. Bei Abweichung und nicht-laufender Session: stoppen + neu konfigurieren (gleiches Objekt, Tabs bleiben). Laufende Sessions werden nie unter den Füßen wegkonfiguriert ( erst Trennen).
|
||||
**Verifikation:** Harness 9/9 (Host-Wechsel reconfiguriert, Secret-Wechsel erkannt, laufende ssh-Session an Banner-lesendem Socket unangetastet).
|
||||
**Status:** ✅ behoben — bitte mit v0.5.4 erneut testen (Profil ggf. einmal neu speichern).
|
||||
|
||||
## #17 — rzsv: Vorab-Check Timeout (kein App-Fehler, Screenshot-Beweis)
|
||||
**Bild:** Tab rzsv (`administrator@sysdaemon.xyz:22`), Banner „Vorab-Check: Keine Antwort in 4 s", ssh wird korrekt NICHT gestartet.
|
||||
**Messung (gleiche Maschine, 22.09.):**
|
||||
- `sysdaemon.xyz` → `185.117.250.190` (auch `git.sysdaemon.xyz`)
|
||||
- Port 443: OK in 0.02 s — Port 22: Timeout (DROP, kein Refused)
|
||||
- Fazit: Server erreichbar, aber SSH-Port wird aus diesem Netz gedroppt. Von hier kann ssh in KEINEM Client gehen (Terminal eingeschlossen) — kein Terminal-/App-Problem, der Vorab-Check hatte recht.
|
||||
**Wahrscheinlichste Ursachen (Reihenfolge):**
|
||||
1. **fail2ban-Bann** nach den vielen `Permission denied`-Versuchen (`#13`-Ära): `fail2ban-client status sshd` → `unbanip <eigene-IP>`
|
||||
2. **VPN an/aus:** „Terminal geht" evtl. mit VPN (Split-DNS/Intern), App ohne (oder umgekehrt) — Zustände vergleichen
|
||||
3. Firewall lässt 22 nur aus bestimmten Netzen zu (`ufw status`, `iptables -L`, `ss -tlnp | grep 22` auf dem Server)
|
||||
**Gegenprobe (10 s, Terminal):** `ssh -v -o ConnectTimeout=8 administrator@sysdaemon.xyz` bleibt bei `Connecting...` hängen → bewiesen netzseitig.
|
||||
**Status:** ⬜ Server-/Netz-Seite, warte auf Gegenprobe + VPN-Status.
|
||||
|
||||
## #18 — Host-Key-Yes/No unmöglich (User-Screenshot: Terminal geht, App sagt nur „Host key verification failed.")
|
||||
**Analyse:** Terminal zeigt den `Are you sure...?`-Prompt (mit Fingerprint), App nur den Abbruch ohne Prompt. Beweis per `-v`: `read_passphrase: can't open /dev/tty: Device not configured` — ssh-Prompts brauchen ein Controlling-Terminal, unser PTY-Slave war keins (GUI-App hat keins, Kind erbt keins). Betrifft Passwort- UND Yes/No-Prompts.
|
||||
**Fix:**
|
||||
- `Sources/ctty-run/ctty-run.c` (C-Helper, SPM-Target): Double-Fork (nötig, weil Apples Process Kinder in eigener Prozessgruppe startet → direktes setsid = EPERM) → setsid → Slave-Open (= Ctty) → exec ssh. stderr bleibt auf der Eltern-Pipe (verlustfrei). `stop()` killt die Prozessgruppe (keine Waisen, verifiziert).
|
||||
- `Views/HostKeySheet.swift` + Flow: Vorab per `ssh-keyscan` Fingerprint holen → Popup (SHA256/MD5, Typ) → Akzeptieren (→ `~/.ssh/known_hosts`, geteilt mit Terminal) / Abbrechen; bei GEÄNDERTEM Key rote MITM-Warnung + `ssh-keygen -R`-Pfad.
|
||||
**Verifikation (lokaler paramiko-Server):** Bug reproduziert (kein Prompt, Exit 255) → nach Fix: Ctty per `ps` bewiesen (ttys001), Yes/No sichtbar + beantwortbar, Passwort akzeptiert, Shell aktiv. HostKeyService: unknown/accept/known/changed/revoke/unreachable grün. Regression (stop ohne Waisen) grün.
|
||||
**Status:** ✅ behoben (v0.6.0) — Fingerprint im Popup mit Terminal-Ausgabe vergleichbar.
|
||||
|
||||
## #19 — Fingerprint-Popup erscheint leer (User-Screenshot)
|
||||
**Bild:** Sheet-Fenster da, aber winzig und ohne Inhalt; Status hängt auf „Prüfe …".
|
||||
**Ursache:** `.sheet(isPresented:)` + `if let info` im Content: Nimmt die Auswertung den Empty-Zweig (Timing beim Präsentieren), hat der leere Zweig keine Abhängigkeit auf die State-Variable → Sheet aktualisiert sich nie, bleibt leer. Klassische SwiftUI-Falle.
|
||||
**Fix:** `.sheet(item: $hostKeyRequest)` mit `HostKeyRequest: Identifiable` — Content existiert strukturell immer. Zusätzlich läuft `HostKeyService.status` (ssh-keyscan blockiert Sekunden) jetzt auf Hintergrund-Queue — vorher fror die UI während „Prüfe …" ein.
|
||||
**Status:** ✅ behoben (v0.6.1).
|
||||
|
||||
+2
-1
@@ -3,8 +3,9 @@
|
||||
## Lokal bauen
|
||||
```bash
|
||||
./scripts/build-release.sh [version] # ZIP mit Binary + Docs
|
||||
./scripts/build-app.sh [version] # RemminaMac.app (Bundle, ad-hoc-signiert)
|
||||
./scripts/build-app.sh [version] # RemminaMac.app (Bundle, ad-hoc-signiert, mit Icon)
|
||||
./scripts/build-dmg.sh [version] # DMG mit App + Programme-Link
|
||||
./scripts/generate-icon.sh # AppIcon.icns neu rendern (Dracula-Terminal)
|
||||
# Beispiel:
|
||||
./scripts/build-release.sh 0.1.0
|
||||
./scripts/build-app.sh 0.1.0
|
||||
|
||||
+16
-4
@@ -7,14 +7,15 @@
|
||||
- **Toolbar:** `+` Neu, Stift Bearbeiten, Kopie-Symbol Duplizieren, Schlüssel Keys, `▶` Verbinden, `⚡` Quick-Connect.
|
||||
|
||||
## Profil anlegen
|
||||
1. `+` → Name, Gruppe, Protokoll (SSH/SFTP/RDP/VNC), Host, Port, User ausfüllen.
|
||||
2. SSH-Key wählen (vorher unter Schlüssel-Icon importieren).
|
||||
3. Optional Passwort → Haken „in Keychain speichern“.
|
||||
1. `+` → Name, Gruppe, Protokoll (SSH/SFTP/RDP/VNC), Host, Port, Benutzername, **Passwort direkt darunter** ausfüllen (Keychain-Haken setzen zum Speichern).
|
||||
2. Der Editor warnt live bei typischen Fehlern: `user@host` im Host-Feld, `ssh://`-Präfix, Leerzeichen, leerer Benutzername, ungültiger Port. Beim Speichern wird getrimmt.
|
||||
3. SSH-Key wählen (optional, Bereich darunter — vorher unter Schlüssel-Icon importieren).
|
||||
4. Speichern → liegt sofort in `profiles.json`.
|
||||
5. Schlägt eine Verbindung fehl: rotes Banner → **Bericht kopieren** und zur Fehlersuche mitschicken (enthält kein Passwort).
|
||||
|
||||
## Verbinden
|
||||
- Profil wählen → `▶ Verbinden` oder Doppelklick.
|
||||
- SSH/SFTP: **In-App-Terminal (Dracula-Theme) direkt im Tab** — verbindet automatisch, kein externes Fenster nötig. Eingabezeile unten (Auge-Icon = Passwort-Modus), `^C`/`^D`-Buttons, `Leeren`, `Trennen`/`Verbinden`, `Tab schließen`.
|
||||
- SSH/SFTP: **In-App-Terminal (Dracula-Theme) direkt im Tab** — erst TCP-Vorab-Check (falscher Port/Host → sofort klare Meldung statt kryptischem Exit-Code), dann Auto-Connect. Eingabezeile unten (Auge-Icon = Passwort-Modus), `^C`/`^D`-Buttons, `Leeren`, `Trennen`/`Verbinden`, `Tab schließen`. Bei Fehlschlag: rotes Banner mit letzter Meldung + Diagnose-Button.
|
||||
- Alternativ: `In Terminal.app öffnen` (öffnet eine `.command`-Datei, braucht keine Automation-Berechtigung) oder `Befehl kopieren`.
|
||||
- RDP: startet `xfreerdp` (falls vorhanden) oder öffnet MS Remote Desktop.
|
||||
- VNC: öffnet `vnc://host:port`.
|
||||
@@ -25,6 +26,17 @@
|
||||
- `Neuen Key generieren`: ruft `/usr/bin/ssh-keygen -t ed25519 -f ~/.ssh/remminamac_<timestamp>` auf.
|
||||
- Passphrase → Keychain (`sshkey-<UUID>`).
|
||||
|
||||
## Host-Key prüfen & akzeptieren (Popup)
|
||||
- Bei Erstverbindung zeigt die App ein Popup mit SHA256-/MD5-Fingerprint (per `ssh-keyscan` geholt) — mit Terminal-Ausgabe oder Admin-Angabe vergleichen, dann Akzeptieren & Verbinden (landet in `~/.ssh/known_hosts`, gemeinsam mit Terminal.app).
|
||||
- Bei GEÄNDERTEM Key: rote Warnung (MITM möglich!) — nur ersetzen, wenn erwartet (Server neu aufgesetzt). Zurücksetzen auch manuell: `ssh-keygen -R HOST`.
|
||||
- Technik: `Sources/ctty-run/ctty-run.c` gibt ssh ein Controlling-Terminal (sonst scheitern alle interaktiven Prompts still).
|
||||
|
||||
## Passwort speichern & Auto-Login
|
||||
- Im Profil-Editor: Passwort eingeben + „in Keychain speichern“. Gespeichertes Passwort wird angezeigt (✓) und kann gelöscht werden. In `profiles.json` steht nur die Referenz, nie das Passwort.
|
||||
- Reihenfolge beim Verbinden: Profil-Passwort zuerst, sonst Key-Passphrase.
|
||||
- **Auto-Login ohne Tippen:** braucht `sshpass` (`brew install sshpass`). Dann loggt ssh via Keychain-Secret ein (Passwort nur im Prozess-Env `SSHPASS`, nie in Befehlszeile/Logs). Status zeigt „Auto-Login via Keychain".
|
||||
- **Ohne sshpass:** Passwort/Key-Passphrase wird interaktiv im Terminal abgefragt (Passwort-Modus: Auge-Icon). Bei Sonderzeichen im Passwort immer Auge-Modus nutzen (keine Text-Ersetzung).
|
||||
|
||||
## Quick-Connect
|
||||
- Mit Auswahl: verbindet direkt. Ohne Auswahl: öffnet Editor mit „Quick-Connect“-Vorlage.
|
||||
|
||||
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 336 KiB |
@@ -0,0 +1,100 @@
|
||||
#!/usr/bin/env swift
|
||||
// Generiert das RemminaMac App-Icon (Dracula-Terminal) als PNG-Set + .iconset.
|
||||
// Aufruf: swift scripts/RenderIcon.swift <output-dir>
|
||||
// Braucht nur macOS-Bordmittel (AppKit). Kein Netzwerk, keine Deps.
|
||||
import AppKit
|
||||
import Foundation
|
||||
|
||||
let outDir = CommandLine.arguments.count > 1 ? CommandLine.arguments[1] : "/tmp/RemminaMac.iconset"
|
||||
try? FileManager.default.createDirectory(atPath: outDir, withIntermediateDirectories: true)
|
||||
|
||||
// Dracula-Palette
|
||||
func c(_ hex: String, _ alpha: CGFloat = 1) -> NSColor {
|
||||
var v: UInt64 = 0
|
||||
Scanner(string: hex).scanHexInt64(&v)
|
||||
return NSColor(red: CGFloat((v >> 16) & 0xFF) / 255,
|
||||
green: CGFloat((v >> 8) & 0xFF) / 255,
|
||||
blue: CGFloat(v & 0xFF) / 255, alpha: alpha)
|
||||
}
|
||||
let bg1 = c("3A3D4F"), bg2 = c("23242F"), bar = c("44475A")
|
||||
let green = c("50FA7B"), pink = c("FF79C6"), purple = c("BD93F9")
|
||||
let red = c("FF5555"), yellow = c("F1FA8C")
|
||||
|
||||
func drawIcon(size: CGFloat) -> NSImage {
|
||||
let img = NSImage(size: NSSize(width: size, height: size))
|
||||
img.lockFocus()
|
||||
let s = size / 1024.0 // Skalierung relativ zu 1024er-Master
|
||||
NSGraphicsContext.current?.imageInterpolation = .high
|
||||
|
||||
// Hintergrund: abgerundetes Quadrat mit Verlauf
|
||||
let rect = NSRect(x: 0, y: 0, width: size, height: size)
|
||||
let radius = 232 * s
|
||||
let path = NSBezierPath(roundedRect: rect, xRadius: radius, yRadius: radius)
|
||||
let grad = NSGradient(colors: [bg1, bg2])!
|
||||
grad.draw(in: path, angle: 90)
|
||||
// feine Kontur
|
||||
bar.withAlphaComponent(0.9).setStroke()
|
||||
path.lineWidth = max(2, 6 * s)
|
||||
path.stroke()
|
||||
|
||||
// Dezenter Glow hinter der Glyphe
|
||||
let glow = NSShadow()
|
||||
glow.shadowColor = purple.withAlphaComponent(0.55)
|
||||
glow.shadowBlurRadius = 90 * s
|
||||
glow.shadowOffset = .zero
|
||||
|
||||
// Traffic-Lights (Fenster-Look)
|
||||
for (i, col) in [red, yellow, green].enumerated() {
|
||||
let r = 40 * s
|
||||
let cx = CGFloat(150 + i * 108) * s
|
||||
let cy = size - 158.0 * s
|
||||
col.setFill()
|
||||
NSBezierPath(ovalIn: NSRect(x: cx - r, y: cy - r, width: 2 * r, height: 2 * r)).fill()
|
||||
}
|
||||
|
||||
// Prompt „>" + Block-Cursor (Menlo Bold)
|
||||
let fontSize: CGFloat = 470 * s
|
||||
let font: NSFont = NSFont(name: "Menlo-Bold", size: fontSize)
|
||||
?? NSFont.monospacedSystemFont(ofSize: fontSize, weight: .bold)
|
||||
let attrs: [NSAttributedString.Key: Any] = [.font: font, .foregroundColor: green]
|
||||
let glyph = NSAttributedString(string: ">", attributes: attrs)
|
||||
let gw = glyph.size()
|
||||
|
||||
// Cursor-Block rechts vom „>"
|
||||
let gap = 44 * s
|
||||
let cursorW = 128 * s, cursorH = 96 * s
|
||||
let totalW = gw.width + gap + cursorW
|
||||
let startX = (size - totalW) / 2
|
||||
let baseY = size * 0.30
|
||||
|
||||
NSGraphicsContext.saveGraphicsState()
|
||||
NSGraphicsContext.current?.cgContext.setShadow(offset: .zero, blur: 90 * s, color: purple.withAlphaComponent(0.55).cgColor)
|
||||
glyph.draw(at: NSPoint(x: startX, y: baseY))
|
||||
NSGraphicsContext.restoreGraphicsState()
|
||||
|
||||
let cursor = NSBezierPath(roundedRect: NSRect(x: startX + gw.width + gap, y: baseY + 30 * s, width: cursorW, height: cursorH), xRadius: 14 * s, yRadius: 14 * s)
|
||||
pink.setFill()
|
||||
cursor.fill()
|
||||
|
||||
img.unlockFocus()
|
||||
return img
|
||||
}
|
||||
|
||||
func save(_ img: NSImage, _ name: String) {
|
||||
guard let tiff = img.tiffRepresentation,
|
||||
let rep = NSBitmapImageRep(data: tiff),
|
||||
let png = rep.representation(using: .png, properties: [:]) else {
|
||||
fputs("FEHLER bei \(name)\n", stderr); exit(1)
|
||||
}
|
||||
try! png.write(to: URL(fileURLWithPath: "\(outDir)/\(name)"))
|
||||
}
|
||||
|
||||
// iconset: je Größe 1x + 2x
|
||||
for base in [16, 32, 128, 256, 512] {
|
||||
save(drawIcon(size: CGFloat(base)), "icon_\(base)x\(base).png")
|
||||
save(drawIcon(size: CGFloat(base * 2)), "icon_\(base)x\(base)@2x.png")
|
||||
}
|
||||
// Vorschau in groß
|
||||
try? FileManager.default.createDirectory(atPath: "/tmp", withIntermediateDirectories: true)
|
||||
save(drawIcon(size: 512), "RemminaMac-preview-tmp.png")
|
||||
print("iconset fertig: \(outDir)")
|
||||
@@ -18,6 +18,13 @@ rm -rf "$APP"
|
||||
mkdir -p "$APP/Contents/MacOS" "$APP/Contents/Resources"
|
||||
cp "$BIN" "$APP/Contents/MacOS/RemminaMac"
|
||||
chmod +x "$APP/Contents/MacOS/RemminaMac"
|
||||
# Ctty-Helper (gibt ssh ein Controlling-Terminal für Prompts)
|
||||
if [ -x "$ROOT/.build/release/ctty-run" ]; then
|
||||
cp "$ROOT/.build/release/ctty-run" "$APP/Contents/MacOS/"
|
||||
else
|
||||
echo "[build-app] WARNUNG: ctty-run fehlt (swift build lief ohne C-Target?)"
|
||||
fi
|
||||
cp "$ROOT/Resources/AppIcon.icns" "$APP/Contents/Resources/" 2>/dev/null || echo "[build-app] Hinweis: kein AppIcon.icns (./scripts/generate-icon.sh)"
|
||||
|
||||
# Info.plist mit Version versehen
|
||||
sed "s|<string>0.1.0</string>|<string>$VERSION</string>|" "$ROOT/Resources/Info.plist" > "$APP/Contents/Info.plist"
|
||||
|
||||
Executable
+12
@@ -0,0 +1,12 @@
|
||||
#!/bin/bash
|
||||
# Generiert AppIcon.icns + Doku-Vorschau aus scripts/RenderIcon.swift (nur Bordmittel).
|
||||
# Usage: ./scripts/generate-icon.sh
|
||||
set -euo pipefail
|
||||
ROOT="$(cd "$(dirname "$0")/.." && pwd)"
|
||||
ICONSET="/tmp/RemminaMac.iconset"
|
||||
rm -rf "$ICONSET"
|
||||
swift "$ROOT/scripts/RenderIcon.swift" "$ICONSET"
|
||||
cp "$ICONSET/RemminaMac-preview-tmp.png" "$ROOT/docs/icon-preview.png"
|
||||
iconutil -c icns "$ICONSET" -o "$ROOT/Resources/AppIcon.icns"
|
||||
echo "[icon] Fertig:"
|
||||
ls -lh "$ROOT/Resources/AppIcon.icns" "$ROOT/docs/icon-preview.png"
|
||||
Reference in New Issue
Block a user