Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
4fd711474c | ||
|
|
7dc6ff75d2 | ||
|
|
1828a96a2b | ||
|
|
8fe8c4925e | ||
|
|
c5ecb273c2 |
@@ -1,5 +1,7 @@
|
|||||||
# RemminaMac — SSH / RDP Client für macOS
|
# RemminaMac — SSH / RDP Client für macOS
|
||||||
|
|
||||||
|

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

|

|
||||||
@@ -102,7 +104,10 @@ open Package.swift
|
|||||||
Fertige Binaries liegen unter Git-Releases (`dist/` wird lokal gebaut, nicht committet):
|
Fertige Binaries liegen unter Git-Releases (`dist/` wird lokal gebaut, nicht committet):
|
||||||
```bash
|
```bash
|
||||||
./scripts/build-release.sh
|
./scripts/build-release.sh
|
||||||
|
./scripts/build-app.sh # RemminaMac.app für /Applications
|
||||||
|
./scripts/build-dmg.sh # DMG mit Drag-and-drop auf Programme
|
||||||
# → dist/RemminaMac-<version>-macos-arm64.zip + .sha256
|
# → dist/RemminaMac-<version>-macos-arm64.zip + .sha256
|
||||||
|
# → dist/RemminaMac-<version>-macos-arm64.dmg + .sha256
|
||||||
ls dist/
|
ls dist/
|
||||||
```
|
```
|
||||||
Details: [docs/INSTALL.md](docs/INSTALL.md), [docs/RELEASING.md](docs/RELEASING.md).
|
Details: [docs/INSTALL.md](docs/INSTALL.md), [docs/RELEASING.md](docs/RELEASING.md).
|
||||||
|
|||||||
Binary file not shown.
@@ -0,0 +1,34 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||||
|
<plist version="1.0">
|
||||||
|
<dict>
|
||||||
|
<key>CFBundleDevelopmentRegion</key>
|
||||||
|
<string>de</string>
|
||||||
|
<key>CFBundleDisplayName</key>
|
||||||
|
<string>RemminaMac</string>
|
||||||
|
<key>CFBundleExecutable</key>
|
||||||
|
<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>
|
||||||
|
<string>RemminaMac</string>
|
||||||
|
<key>CFBundlePackageType</key>
|
||||||
|
<string>APPL</string>
|
||||||
|
<key>CFBundleShortVersionString</key>
|
||||||
|
<string>0.1.0</string>
|
||||||
|
<key>CFBundleVersion</key>
|
||||||
|
<string>1</string>
|
||||||
|
<key>LSMinimumSystemVersion</key>
|
||||||
|
<string>14.0</string>
|
||||||
|
<key>NSHighResolutionCapable</key>
|
||||||
|
<true/>
|
||||||
|
<key>NSHumanReadableCopyright</key>
|
||||||
|
<string>MIT — RemminaMac Contributors</string>
|
||||||
|
<key>LSApplicationCategoryType</key>
|
||||||
|
<string>public.app-category.utilities</string>
|
||||||
|
</dict>
|
||||||
|
</plist>
|
||||||
@@ -0,0 +1,188 @@
|
|||||||
|
import Foundation
|
||||||
|
|
||||||
|
/// Reine ANSI/SGR-Logik ohne UI-Abhängigkeiten (unit-testbar).
|
||||||
|
/// Versteht: SGR-Farben (30-37, 90-97, 38;5;n, 38;2;r;g;b + BG-Varianten),
|
||||||
|
/// Clear Screen (ESC[2J), Clear Line (ESC[K]), CR/LF/Tab/Backspace/Bell.
|
||||||
|
/// Alles andere (Cursor-Moves etc.) wird ignoriert.
|
||||||
|
|
||||||
|
/// Vorder-/Hintergrund als Dracula-Index 0-15, nil = Standard.
|
||||||
|
struct TermStyle: Equatable {
|
||||||
|
var fg: Int? = nil
|
||||||
|
var bg: Int? = nil
|
||||||
|
var bold: Bool = false
|
||||||
|
}
|
||||||
|
|
||||||
|
struct StyledText: Equatable {
|
||||||
|
var text: String
|
||||||
|
var style: TermStyle
|
||||||
|
}
|
||||||
|
|
||||||
|
enum TerminalEvent: Equatable {
|
||||||
|
case text(StyledText)
|
||||||
|
case newline
|
||||||
|
case carriageReturn
|
||||||
|
case backspace
|
||||||
|
case clearScreen
|
||||||
|
case clearLine
|
||||||
|
case bell
|
||||||
|
}
|
||||||
|
|
||||||
|
struct AnsiParser {
|
||||||
|
private(set) var style = TermStyle()
|
||||||
|
|
||||||
|
mutating func feed(_ data: Data) -> [TerminalEvent] {
|
||||||
|
var events: [TerminalEvent] = []
|
||||||
|
var chunk = ""
|
||||||
|
func flush() {
|
||||||
|
if !chunk.isEmpty {
|
||||||
|
events.append(.text(StyledText(text: chunk, style: style)))
|
||||||
|
chunk = ""
|
||||||
|
}
|
||||||
|
}
|
||||||
|
let bytes = [UInt8](data)
|
||||||
|
var i = 0
|
||||||
|
while i < bytes.count {
|
||||||
|
let b = bytes[i]
|
||||||
|
switch b {
|
||||||
|
case 0x07: // BEL
|
||||||
|
flush(); events.append(.bell); i += 1
|
||||||
|
case 0x08: // BS
|
||||||
|
flush(); events.append(.backspace); i += 1
|
||||||
|
case 0x09: // TAB -> 8er-Stopp angenähert mit Spaces
|
||||||
|
chunk += " "; i += 1
|
||||||
|
case 0x0A: // LF
|
||||||
|
flush(); events.append(.newline); i += 1
|
||||||
|
case 0x0D: // CR (+ LF folgt -> nur Newline, sonst Overwrite)
|
||||||
|
if i + 1 < bytes.count && bytes[i + 1] == 0x0A {
|
||||||
|
i += 1 // CR vor LF schlucken, LF handled es
|
||||||
|
} else {
|
||||||
|
flush(); events.append(.carriageReturn)
|
||||||
|
i += 1
|
||||||
|
}
|
||||||
|
case 0x1B: // ESC
|
||||||
|
if i + 1 < bytes.count && bytes[i + 1] == UInt8(ascii: "[") {
|
||||||
|
flush() // pending Text gehört noch zum alten Stil
|
||||||
|
let (consumed, evs) = parseCSI(bytes: bytes, from: i, chunk: &chunk)
|
||||||
|
events.append(contentsOf: evs)
|
||||||
|
i += consumed
|
||||||
|
} else if i + 1 < bytes.count && bytes[i + 1] == UInt8(ascii: "]") {
|
||||||
|
// OSC (z. B. Fenstertitel) bis BEL oder ESC\ skippen
|
||||||
|
flush()
|
||||||
|
i += 2
|
||||||
|
while i < bytes.count {
|
||||||
|
if bytes[i] == 0x07 { i += 1; break }
|
||||||
|
if bytes[i] == 0x1B && i + 1 < bytes.count && bytes[i + 1] == UInt8(ascii: "\\") { i += 2; break }
|
||||||
|
i += 1
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
i += 2 // sonstige ESC-Sequenz ignorieren
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
if b < 0x20 {
|
||||||
|
i += 1 // übrige Steuerzeichen ignorieren
|
||||||
|
} else {
|
||||||
|
// UTF-8: Folgebytes mitnehmen
|
||||||
|
let len: Int
|
||||||
|
if b & 0x80 == 0 { len = 1 }
|
||||||
|
else if b & 0xE0 == 0xC0 { len = 2 }
|
||||||
|
else if b & 0xF0 == 0xE0 { len = 3 }
|
||||||
|
else { len = 4 }
|
||||||
|
let slice = bytes[i..<min(i + len, bytes.count)]
|
||||||
|
chunk += String(decoding: slice, as: UTF8.self)
|
||||||
|
i += slice.count
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
flush()
|
||||||
|
return events
|
||||||
|
}
|
||||||
|
|
||||||
|
private mutating func parseCSI(bytes: [UInt8], from start: Int, chunk: inout String) -> (Int, [TerminalEvent]) {
|
||||||
|
var i = start + 2 // hinter ESC[
|
||||||
|
var params = ""
|
||||||
|
while i < bytes.count && !(bytes[i] >= 0x40 && bytes[i] <= 0x7E) {
|
||||||
|
params.append(Character(UnicodeScalar(bytes[i])))
|
||||||
|
i += 1
|
||||||
|
}
|
||||||
|
guard i < bytes.count else { return (bytes.count - start, []) }
|
||||||
|
let final = bytes[i]
|
||||||
|
i += 1
|
||||||
|
switch final {
|
||||||
|
case UInt8(ascii: "m"):
|
||||||
|
applySGR(params)
|
||||||
|
return (i - start, [])
|
||||||
|
case UInt8(ascii: "J"):
|
||||||
|
if params == "2" || params == "3" { return (i - start, [.clearScreen]) }
|
||||||
|
return (i - start, [])
|
||||||
|
case UInt8(ascii: "K"):
|
||||||
|
return (i - start, [.clearLine])
|
||||||
|
case UInt8(ascii: "H"), UInt8(ascii: "f"):
|
||||||
|
return (i - start, [.carriageReturn])
|
||||||
|
default:
|
||||||
|
return (i - start, []) // Cursor-Moves etc. ignorieren
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private mutating func applySGR(_ params: String) {
|
||||||
|
let codes = params.isEmpty ? [0] : params.split(separator: ";").compactMap { Int($0) }
|
||||||
|
var i = 0
|
||||||
|
while i < codes.count {
|
||||||
|
let c = codes[i]
|
||||||
|
switch c {
|
||||||
|
case 0: style = TermStyle()
|
||||||
|
case 1: style.bold = true
|
||||||
|
case 22: style.bold = false
|
||||||
|
case 30...37: style.fg = c - 30
|
||||||
|
case 39: style.fg = nil
|
||||||
|
case 40...47: style.bg = c - 40
|
||||||
|
case 49: style.bg = nil
|
||||||
|
case 90...97: style.fg = c - 90 + 8
|
||||||
|
case 100...107: style.bg = c - 100 + 8
|
||||||
|
case 38, 48:
|
||||||
|
let isFg = (c == 38)
|
||||||
|
if i + 1 < codes.count && codes[i + 1] == 5 && i + 2 < codes.count {
|
||||||
|
let mapped = Self.map256(codes[i + 2])
|
||||||
|
if isFg { style.fg = mapped } else { style.bg = mapped }
|
||||||
|
i += 2
|
||||||
|
} else if i + 1 < codes.count && codes[i + 1] == 2 && i + 4 < codes.count {
|
||||||
|
let mapped = Self.nearestDracula(r: codes[i + 2], g: codes[i + 3], b: codes[i + 4])
|
||||||
|
if isFg { style.fg = mapped } else { style.bg = mapped }
|
||||||
|
i += 4
|
||||||
|
}
|
||||||
|
default: break
|
||||||
|
}
|
||||||
|
i += 1
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// 256-Farben grob auf Dracula 0-15 mappen.
|
||||||
|
static func map256(_ n: Int) -> Int {
|
||||||
|
if n < 16 { return n }
|
||||||
|
if n >= 232 {
|
||||||
|
if n < 238 { return 0 }
|
||||||
|
if n < 248 { return 8 }
|
||||||
|
return 15
|
||||||
|
}
|
||||||
|
let x = n - 16
|
||||||
|
let r = (x / 36) % 6, g = (x / 6) % 6, b = x % 6
|
||||||
|
let bright = (r > 2 || g > 2 || b > 2) ? 8 : 0
|
||||||
|
if r >= g && r >= b { return 1 + bright }
|
||||||
|
if g >= b { return 2 + bright }
|
||||||
|
if b == g && b > r { return 6 + bright }
|
||||||
|
return 4 + bright
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Truecolor -> nächstliegende Dracula-Farbe (vereinfachte Distanz).
|
||||||
|
static func nearestDracula(r: Int, g: Int, b: Int) -> Int {
|
||||||
|
let palette = [(33, 34, 44), (255, 85, 85), (80, 250, 123), (241, 250, 140),
|
||||||
|
(189, 147, 249), (255, 121, 198), (139, 233, 253), (248, 248, 242),
|
||||||
|
(98, 114, 164), (255, 110, 110), (105, 255, 148), (255, 255, 165),
|
||||||
|
(214, 172, 255), (255, 146, 223), (164, 255, 255), (255, 255, 255)]
|
||||||
|
var best = 7, bestDist = Int.max
|
||||||
|
for (idx, (pr, pg, pb)) in palette.enumerated() {
|
||||||
|
let d = (r - pr) * (r - pr) + (g - pg) * (g - pg) + (b - pb) * (b - pb)
|
||||||
|
if d < bestDist { bestDist = d; best = idx }
|
||||||
|
}
|
||||||
|
return best
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -20,14 +20,18 @@ enum SSHService {
|
|||||||
return "ssh " + escaped.joined(separator: " ")
|
return "ssh " + escaped.joined(separator: " ")
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Öffnet die SSH-Session in Terminal.app
|
/// Öffnet die SSH-Session in Terminal.app — ohne AppleScript (das scheiterte
|
||||||
|
/// still an fehlender Automation-Berechtigung), sondern über eine .command-Datei.
|
||||||
static func openInTerminal(profile: ConnectionProfile, key: StoredSSHKey?) {
|
static func openInTerminal(profile: ConnectionProfile, key: StoredSSHKey?) {
|
||||||
let cmd = sshCommandString(for: profile, key: key)
|
let cmd = sshCommandString(for: profile, key: key)
|
||||||
let script = "tell application \"Terminal\" to do script \"\(cmd.replacingOccurrences(of: "\"", with: "\\\""))\""
|
let dir = FileManager.default.urls(for: .applicationSupportDirectory, in: .userDomainMask).first!
|
||||||
var err: NSDictionary?
|
.appendingPathComponent("RemminaMac", isDirectory: true)
|
||||||
if let appleScript = NSAppleScript(source: script) {
|
try? FileManager.default.createDirectory(at: dir, withIntermediateDirectories: true)
|
||||||
appleScript.executeAndReturnError(&err)
|
let url = dir.appendingPathComponent("launch-\(profile.id.uuidString).command")
|
||||||
}
|
// exec bash hält das Fenster nach Sitzungsende offen
|
||||||
|
try? "#!/bin/bash\n\(cmd)\nexec bash\n".write(to: url, atomically: true, encoding: .utf8)
|
||||||
|
try? FileManager.default.setAttributes([.posixPermissions: 0o755], ofItemAtPath: url.path)
|
||||||
|
NSWorkspace.shared.open(url)
|
||||||
}
|
}
|
||||||
|
|
||||||
static func copyCommandToClipboard(profile: ConnectionProfile, key: StoredSSHKey?) {
|
static func copyCommandToClipboard(profile: ConnectionProfile, key: StoredSSHKey?) {
|
||||||
@@ -35,6 +39,43 @@ enum SSHService {
|
|||||||
NSPasteboard.general.clearContents()
|
NSPasteboard.general.clearContents()
|
||||||
NSPasteboard.general.setString(cmd, forType: .string)
|
NSPasteboard.general.setString(cmd, forType: .string)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// MARK: - Passwort / Auto-Login
|
||||||
|
|
||||||
|
/// 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 {
|
enum RDPService {
|
||||||
|
|||||||
@@ -0,0 +1,316 @@
|
|||||||
|
import Foundation
|
||||||
|
import Combine
|
||||||
|
import Darwin
|
||||||
|
import AppKit
|
||||||
|
|
||||||
|
enum PTYState: Equatable {
|
||||||
|
case never
|
||||||
|
case running
|
||||||
|
case done(exitCode: Int32?, message: String)
|
||||||
|
}
|
||||||
|
|
||||||
|
/// 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] = [:]
|
||||||
|
|
||||||
|
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 {
|
||||||
|
if case .running = state { return true }
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
var plainText: String {
|
||||||
|
lines.map { $0.map(\.text).joined() }.joined(separator: "\n")
|
||||||
|
}
|
||||||
|
|
||||||
|
func configure(executable: String, arguments: [String]) {
|
||||||
|
self.executable = executable
|
||||||
|
self.arguments = arguments
|
||||||
|
}
|
||||||
|
|
||||||
|
func setAutoLogin(_ value: Bool) {
|
||||||
|
autoLogin = value
|
||||||
|
}
|
||||||
|
|
||||||
|
func start() {
|
||||||
|
cleanupSync()
|
||||||
|
epoch += 1
|
||||||
|
finished = false
|
||||||
|
parser = AnsiParser()
|
||||||
|
state = .running
|
||||||
|
lines = [[]]
|
||||||
|
|
||||||
|
let master = posix_openpt(O_RDWR | O_NOCTTY)
|
||||||
|
guard master >= 0, grantpt(master) == 0, unlockpt(master) == 0,
|
||||||
|
let cName = ptsname(master),
|
||||||
|
!String(cString: cName).isEmpty else {
|
||||||
|
finish(message: "PTY konnte nicht geöffnet werden (errno \(errno)).", code: nil)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
let slavePath = String(cString: cName)
|
||||||
|
let slave = open(slavePath, O_RDWR | O_NOCTTY)
|
||||||
|
guard slave >= 0 else {
|
||||||
|
close(master)
|
||||||
|
finish(message: "PTY-Slave \(slavePath) ließ sich nicht öffnen.", code: nil)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
masterFD = master
|
||||||
|
|
||||||
|
let pipe = Pipe()
|
||||||
|
let p = Process()
|
||||||
|
p.executableURL = URL(fileURLWithPath: executable)
|
||||||
|
p.arguments = arguments
|
||||||
|
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 = pipe.fileHandleForWriting
|
||||||
|
let myEpoch = epoch
|
||||||
|
p.terminationHandler = { [weak self] proc in
|
||||||
|
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() }
|
||||||
|
// Kein Close hier (Eigentum: Main-Thread) — nur Cancel.
|
||||||
|
readSource = source
|
||||||
|
source.resume()
|
||||||
|
}
|
||||||
|
|
||||||
|
private func drain() {
|
||||||
|
let fd = masterFD
|
||||||
|
guard fd >= 0 else { return }
|
||||||
|
var buf = [UInt8](repeating: 0, count: 8192)
|
||||||
|
let n = read(fd, &buf, buf.count)
|
||||||
|
if n > 0 {
|
||||||
|
let events = parser.feed(Data(buf[..<n]))
|
||||||
|
DispatchQueue.main.async { [weak self] in self?.apply(events) }
|
||||||
|
} else {
|
||||||
|
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)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private func apply(_ events: [TerminalEvent]) {
|
||||||
|
for ev in events {
|
||||||
|
switch ev {
|
||||||
|
case .text(let seg):
|
||||||
|
if lines.isEmpty { lines.append([]) }
|
||||||
|
if var last = lines[lines.count - 1].last, last.style == seg.style {
|
||||||
|
last.text += seg.text
|
||||||
|
lines[lines.count - 1][lines[lines.count - 1].count - 1] = last
|
||||||
|
} else {
|
||||||
|
lines[lines.count - 1].append(seg)
|
||||||
|
}
|
||||||
|
case .newline:
|
||||||
|
lines.append([])
|
||||||
|
case .carriageReturn:
|
||||||
|
// Overwrite-Modus (Fortschrittsbalken): aktuelle Zeile leeren
|
||||||
|
if !lines.isEmpty { lines[lines.count - 1] = [] }
|
||||||
|
case .backspace:
|
||||||
|
guard !lines.isEmpty, !lines[lines.count - 1].isEmpty else { break }
|
||||||
|
var row = lines[lines.count - 1]
|
||||||
|
if var last = row.last, !last.text.isEmpty {
|
||||||
|
last.text.removeLast()
|
||||||
|
if last.text.isEmpty { row.removeLast() } else { row[row.count - 1] = last }
|
||||||
|
lines[lines.count - 1] = row
|
||||||
|
}
|
||||||
|
case .clearScreen:
|
||||||
|
lines = [[]]
|
||||||
|
case .clearLine:
|
||||||
|
if !lines.isEmpty { lines[lines.count - 1] = [] }
|
||||||
|
case .bell:
|
||||||
|
NSSound.beep()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if lines.count > maxLines {
|
||||||
|
lines.removeFirst(lines.count - maxLines)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func send(_ string: String) {
|
||||||
|
let fd = masterFD
|
||||||
|
guard fd >= 0 else { return }
|
||||||
|
guard let data = string.data(using: .utf8) else { return }
|
||||||
|
ioQueue.async {
|
||||||
|
data.withUnsafeBytes { ptr in
|
||||||
|
var written = 0
|
||||||
|
while written < data.count {
|
||||||
|
let n = write(fd, ptr.baseAddress!.advanced(by: written), data.count - written)
|
||||||
|
if n <= 0 { break }
|
||||||
|
written += n
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func clear() {
|
||||||
|
lines = [[]]
|
||||||
|
}
|
||||||
|
|
||||||
|
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
|
||||||
|
process?.terminate()
|
||||||
|
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([])
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// 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 let pipe = errPipe {
|
||||||
|
pipe.fileHandleForReading.readabilityHandler = nil
|
||||||
|
errPipe = nil
|
||||||
|
}
|
||||||
|
process = nil
|
||||||
|
}
|
||||||
|
|
||||||
|
private func finish(message: String, code: Int32?) {
|
||||||
|
guard !finished else { return }
|
||||||
|
finished = true
|
||||||
|
cleanupSync()
|
||||||
|
state = .done(exitCode: code, message: message)
|
||||||
|
lines.append([StyledText(text: "— \(message) —", style: TermStyle(fg: 8))])
|
||||||
|
lines.append([])
|
||||||
|
}
|
||||||
|
|
||||||
|
deinit {
|
||||||
|
process?.terminate()
|
||||||
|
readSource?.cancel()
|
||||||
|
if masterFD >= 0 { close(masterFD) }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Hält pro Profil genau eine PTYSession, damit Tab-Wechsel die Session nicht killen.
|
||||||
|
@MainActor
|
||||||
|
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()
|
||||||
|
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
|
||||||
|
let cfg = SSHService.sessionConfig(executable: baseExe, args: baseArgs,
|
||||||
|
password: SSHService.loginSecret(for: profile, key: key),
|
||||||
|
sshpassPath: SSHService.findSshpass())
|
||||||
|
s.configure(executable: cfg.executable, arguments: cfg.arguments)
|
||||||
|
s.customEnv = cfg.extraEnv
|
||||||
|
s.setAutoLogin(cfg.autoLogin)
|
||||||
|
sessions[profile.id] = s
|
||||||
|
return s
|
||||||
|
}
|
||||||
|
|
||||||
|
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
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,59 @@
|
|||||||
|
import SwiftUI
|
||||||
|
import AppKit
|
||||||
|
|
||||||
|
/// Offizielle Dracula-Palette (https://draculatheme.com/contribute).
|
||||||
|
enum Dracula {
|
||||||
|
static let background = Color(hex: "282A36")
|
||||||
|
static let currentLine = Color(hex: "44475A")
|
||||||
|
static let foreground = Color(hex: "F8F8F2")
|
||||||
|
static let comment = Color(hex: "6272A4")
|
||||||
|
static let cyan = Color(hex: "8BE9FD")
|
||||||
|
static let green = Color(hex: "50FA7B")
|
||||||
|
static let orange = Color(hex: "FFB86C")
|
||||||
|
static let pink = Color(hex: "FF79C6")
|
||||||
|
static let purple = Color(hex: "BD93F9")
|
||||||
|
static let red = Color(hex: "FF5555")
|
||||||
|
static let yellow = Color(hex: "F1FA8C")
|
||||||
|
|
||||||
|
/// ANSI-Index 0-15 -> Dracula-Farbe.
|
||||||
|
static func color(for index: Int?) -> Color {
|
||||||
|
guard let index else { return foreground }
|
||||||
|
switch index {
|
||||||
|
case 0: return Color(hex: "21222C")
|
||||||
|
case 1: return red
|
||||||
|
case 2: return green
|
||||||
|
case 3: return yellow
|
||||||
|
case 4: return purple
|
||||||
|
case 5: return pink
|
||||||
|
case 6: return cyan
|
||||||
|
case 7: return foreground
|
||||||
|
case 8: return comment
|
||||||
|
case 9: return Color(hex: "FF6E6E")
|
||||||
|
case 10: return Color(hex: "69FF94")
|
||||||
|
case 11: return Color(hex: "FFFFA5")
|
||||||
|
case 12: return Color(hex: "D6ACFF")
|
||||||
|
case 13: return Color(hex: "FF92DF")
|
||||||
|
case 14: return Color(hex: "A4FFFF")
|
||||||
|
default: return Color(hex: "FFFFFF")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static func nsColor(for index: Int?) -> NSColor {
|
||||||
|
NSColor(color(for: index))
|
||||||
|
}
|
||||||
|
|
||||||
|
static let nsBackground = NSColor(Color(hex: "282A36"))
|
||||||
|
static let nsSelection = NSColor(Color(hex: "44475A"))
|
||||||
|
}
|
||||||
|
|
||||||
|
extension Color {
|
||||||
|
init(hex: String) {
|
||||||
|
let clean = hex.trimmingCharacters(in: CharacterSet.alphanumerics.inverted)
|
||||||
|
var value: UInt64 = 0
|
||||||
|
Scanner(string: clean).scanHexInt64(&value)
|
||||||
|
let r = Double((value >> 16) & 0xFF) / 255
|
||||||
|
let g = Double((value >> 8) & 0xFF) / 255
|
||||||
|
let b = Double(value & 0xFF) / 255
|
||||||
|
self.init(red: r, green: g, blue: b)
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -3,6 +3,7 @@ import AppKit
|
|||||||
|
|
||||||
struct ContentView: View {
|
struct ContentView: View {
|
||||||
@EnvironmentObject var store: ProfileStore
|
@EnvironmentObject var store: ProfileStore
|
||||||
|
@StateObject private var terminals = TerminalManager()
|
||||||
@State private var selection: ConnectionProfile.ID?
|
@State private var selection: ConnectionProfile.ID?
|
||||||
@State private var openSessions: [ConnectionProfile] = []
|
@State private var openSessions: [ConnectionProfile] = []
|
||||||
@State private var activeSessionID: ConnectionProfile.ID?
|
@State private var activeSessionID: ConnectionProfile.ID?
|
||||||
@@ -68,7 +69,12 @@ struct ContentView: View {
|
|||||||
} else {
|
} else {
|
||||||
TabView(selection: $activeSessionID) {
|
TabView(selection: $activeSessionID) {
|
||||||
ForEach(openSessions) { session in
|
ForEach(openSessions) { session in
|
||||||
SessionView(profile: session, statusMessage: $statusMessage)
|
SessionView(
|
||||||
|
profile: session,
|
||||||
|
statusMessage: $statusMessage,
|
||||||
|
term: terminals.session(for: session, key: store.key(for: session)),
|
||||||
|
onClose: { closeSession(session) }
|
||||||
|
)
|
||||||
.tag(Optional(session.id))
|
.tag(Optional(session.id))
|
||||||
.tabItem { Text(session.name) }
|
.tabItem { Text(session.name) }
|
||||||
}
|
}
|
||||||
@@ -98,7 +104,7 @@ struct ContentView: View {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
.sheet(item: $editingProfile) { profile in
|
.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 }) {
|
if store.profiles.contains(where: { $0.id == saved.id }) {
|
||||||
store.update(saved)
|
store.update(saved)
|
||||||
} else {
|
} else {
|
||||||
@@ -143,11 +149,10 @@ struct ContentView: View {
|
|||||||
openSessions.append(updated)
|
openSessions.append(updated)
|
||||||
}
|
}
|
||||||
activeSessionID = p.id
|
activeSessionID = p.id
|
||||||
let key = store.key(for: p)
|
|
||||||
switch p.proto {
|
switch p.proto {
|
||||||
case .ssh, .sftp:
|
case .ssh, .sftp:
|
||||||
SSHService.openInTerminal(profile: p, key: key)
|
// In-App-Terminal verbindet automatisch (onAppear) — kein externes Fenster nötig
|
||||||
statusMessage = "SSH: \(SSHService.sshCommandString(for: p, key: key))"
|
statusMessage = "SSH-Terminal zu \(p.username)@\(p.host) …"
|
||||||
case .rdp:
|
case .rdp:
|
||||||
RDPService.connect(profile: p)
|
RDPService.connect(profile: p)
|
||||||
statusMessage = "RDP zu \(p.host):\(p.port) gestartet."
|
statusMessage = "RDP zu \(p.host):\(p.port) gestartet."
|
||||||
@@ -157,6 +162,13 @@ struct ContentView: View {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func closeSession(_ p: ConnectionProfile) {
|
||||||
|
terminals.close(p)
|
||||||
|
openSessions.removeAll { $0.id == p.id }
|
||||||
|
if activeSessionID == p.id { activeSessionID = openSessions.last?.id }
|
||||||
|
statusMessage = "Sitzung '\(p.name)' geschlossen."
|
||||||
|
}
|
||||||
|
|
||||||
func quickConnect() {
|
func quickConnect() {
|
||||||
// Simple Quick-Connect: nimmt Auswahl oder leeres SSH-Profil
|
// Simple Quick-Connect: nimmt Auswahl oder leeres SSH-Profil
|
||||||
if let p = selectedProfile { connect(p) }
|
if let p = selectedProfile { connect(p) }
|
||||||
|
|||||||
@@ -0,0 +1,236 @@
|
|||||||
|
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
|
||||||
|
|
||||||
|
var body: some View {
|
||||||
|
VStack(spacing: 0) {
|
||||||
|
// Statuszeile
|
||||||
|
HStack(spacing: 8) {
|
||||||
|
statusDot
|
||||||
|
Text(statusText).font(.caption).foregroundStyle(.secondary)
|
||||||
|
Spacer()
|
||||||
|
if term.isRunning {
|
||||||
|
Button("Trennen") { term.stop() }.buttonStyle(.link).font(.caption)
|
||||||
|
} else if canConnect && !checking {
|
||||||
|
Button("Verbinden") { connect() }.buttonStyle(.link).font(.caption)
|
||||||
|
}
|
||||||
|
Button("Leeren") { term.clear() }.buttonStyle(.link).font(.caption)
|
||||||
|
}
|
||||||
|
.padding(.horizontal, 10)
|
||||||
|
.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)
|
||||||
|
}
|
||||||
|
Spacer()
|
||||||
|
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)
|
||||||
|
|
||||||
|
// 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)
|
||||||
|
.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)
|
||||||
|
}
|
||||||
|
Button(action: { secureInput.toggle() }) {
|
||||||
|
Image(systemName: secureInput ? "eye.slash" : "eye")
|
||||||
|
}
|
||||||
|
.buttonStyle(.plain).foregroundStyle(Dracula.comment)
|
||||||
|
.help("Passwort-Modus (versteckte Eingabe)")
|
||||||
|
Button("Senden") { submit() }
|
||||||
|
.disabled(input.isEmpty || !term.isRunning)
|
||||||
|
ControlButton(label: "^C", tip: "SIGINT (Strg+C)") { term.send("\u{03}") }
|
||||||
|
ControlButton(label: "^D", tip: "EOF (Strg+D)") { term.send("\u{04}") }
|
||||||
|
}
|
||||||
|
.padding(8)
|
||||||
|
.background(Dracula.background)
|
||||||
|
}
|
||||||
|
.background(Dracula.background)
|
||||||
|
.cornerRadius(10)
|
||||||
|
.overlay(RoundedRectangle(cornerRadius: 10).stroke(Dracula.currentLine, lineWidth: 1))
|
||||||
|
.onAppear {
|
||||||
|
if case .never = term.state {
|
||||||
|
connect() // Auto-Connect beim Öffnen des Tabs
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func connect() {
|
||||||
|
guard canConnect, !term.isRunning, !checking else { return }
|
||||||
|
checking = true
|
||||||
|
TCPCheck.check(host: profile.host, port: profile.port) { message in
|
||||||
|
DispatchQueue.main.async {
|
||||||
|
checking = false
|
||||||
|
if let message {
|
||||||
|
term.fail("Vorab-Check: \(message)")
|
||||||
|
} else {
|
||||||
|
term.start()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
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).")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func submit() {
|
||||||
|
guard term.isRunning, !input.isEmpty else { return }
|
||||||
|
term.send(input + "\n")
|
||||||
|
input = ""
|
||||||
|
}
|
||||||
|
|
||||||
|
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 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 term.autoLogin ? "Verbunden (Auto-Login via Keychain)." : "Verbunden (PTY, TERM=xterm-256color)."
|
||||||
|
case .done(_, let msg): return msg
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
struct ControlButton: View {
|
||||||
|
var label: String
|
||||||
|
var tip: String
|
||||||
|
var action: () -> Void
|
||||||
|
var body: some View {
|
||||||
|
Button(label, action: action)
|
||||||
|
.font(.system(.caption, design: .monospaced))
|
||||||
|
.foregroundStyle(Dracula.orange)
|
||||||
|
.buttonStyle(.plain)
|
||||||
|
.padding(.horizontal, 6)
|
||||||
|
.padding(.vertical, 2)
|
||||||
|
.background(Dracula.currentLine.opacity(0.6), in: RoundedRectangle(cornerRadius: 5))
|
||||||
|
.help(tip)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Read-only NSTextView mit Dracula-Farben, baut NSAttributedString aus StyledText-Zeilen.
|
||||||
|
struct DraculaTextView: NSViewRepresentable {
|
||||||
|
var lines: [[StyledText]]
|
||||||
|
|
||||||
|
func makeNSView(context: Context) -> NSScrollView {
|
||||||
|
let scroll = NSScrollView()
|
||||||
|
scroll.hasVerticalScroller = true
|
||||||
|
scroll.drawsBackground = true
|
||||||
|
scroll.backgroundColor = Dracula.nsBackground
|
||||||
|
let tv = NSTextView()
|
||||||
|
tv.isEditable = false
|
||||||
|
tv.isSelectable = true
|
||||||
|
tv.backgroundColor = Dracula.nsBackground
|
||||||
|
tv.textColor = Dracula.nsColor(for: nil)
|
||||||
|
tv.font = .monospacedSystemFont(ofSize: 12, weight: .regular)
|
||||||
|
tv.textContainerInset = NSSize(width: 8, height: 8)
|
||||||
|
tv.isAutomaticQuoteSubstitutionEnabled = false
|
||||||
|
scroll.documentView = tv
|
||||||
|
return scroll
|
||||||
|
}
|
||||||
|
|
||||||
|
func updateNSView(_ scroll: NSScrollView, context: Context) {
|
||||||
|
guard let tv = scroll.documentView as? NSTextView else { return }
|
||||||
|
let attr = NSMutableAttributedString()
|
||||||
|
let font = NSFont.monospacedSystemFont(ofSize: 12, weight: .regular)
|
||||||
|
let boldFont = NSFontManager.shared.convert(font, toHaveTrait: .boldFontMask)
|
||||||
|
for (idx, row) in lines.enumerated() {
|
||||||
|
if row.isEmpty {
|
||||||
|
attr.append(NSAttributedString(string: idx < lines.count - 1 ? "\n" : ""))
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
for seg in row {
|
||||||
|
let attrs: [NSAttributedString.Key: Any] = [
|
||||||
|
.font: seg.style.bold ? boldFont : font,
|
||||||
|
.foregroundColor: Dracula.nsColor(for: seg.style.fg),
|
||||||
|
.backgroundColor: seg.style.bg.map { Dracula.nsColor(for: $0) } ?? Dracula.nsBackground
|
||||||
|
]
|
||||||
|
attr.append(NSAttributedString(string: seg.text, attributes: attrs))
|
||||||
|
}
|
||||||
|
if idx < lines.count - 1 { attr.append(NSAttributedString(string: "\n")) }
|
||||||
|
}
|
||||||
|
// Nur neu setzen wenn geändert (Performance bei viel Output)
|
||||||
|
if tv.textStorage?.string != attr.string {
|
||||||
|
tv.textStorage?.setAttributedString(attr)
|
||||||
|
}
|
||||||
|
tv.scrollToEndOfDocument(nil)
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -4,18 +4,21 @@ struct ProfileEditorView: View {
|
|||||||
@Environment(\.dismiss) var dismiss
|
@Environment(\.dismiss) var dismiss
|
||||||
@EnvironmentObject var store: ProfileStore
|
@EnvironmentObject var store: ProfileStore
|
||||||
@State var profile: ConnectionProfile
|
@State var profile: ConnectionProfile
|
||||||
|
var isNew: Bool
|
||||||
var onSave: (ConnectionProfile) -> Void
|
var onSave: (ConnectionProfile) -> Void
|
||||||
@State private var password: String = ""
|
@State private var password: String = ""
|
||||||
@State private var savePassword: Bool = false
|
@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)
|
_profile = State(initialValue: profile)
|
||||||
|
self.isNew = isNew
|
||||||
self.onSave = onSave
|
self.onSave = onSave
|
||||||
}
|
}
|
||||||
|
|
||||||
var body: some View {
|
var body: some View {
|
||||||
VStack(spacing: 0) {
|
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 {
|
Form {
|
||||||
Section("Allgemein") {
|
Section("Allgemein") {
|
||||||
TextField("Name", text: $profile.name)
|
TextField("Name", text: $profile.name)
|
||||||
@@ -44,8 +47,17 @@ struct ProfileEditorView: View {
|
|||||||
Text("Kein Key").tag(UUID?.none)
|
Text("Kein Key").tag(UUID?.none)
|
||||||
ForEach(store.sshKeys) { k in Text(k.name).tag(UUID?.some(k.id)) }
|
ForEach(store.sshKeys) { k in Text(k.name).tag(UUID?.some(k.id)) }
|
||||||
}
|
}
|
||||||
SecureField("Passwort (optional, Keychain)", text: $password)
|
if storedPasswordPresent && password.isEmpty {
|
||||||
|
HStack {
|
||||||
|
Image(systemName: "checkmark.circle.fill").foregroundStyle(.green)
|
||||||
|
Text("Passwort in Keychain gespeichert")
|
||||||
|
Spacer()
|
||||||
|
Button("Löschen", role: .destructive) { deleteStoredPassword() }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
SecureField(storedPasswordPresent ? "Neues Passwort …" : "Passwort (optional, Keychain)", text: $password)
|
||||||
Toggle("Passwort in Keychain speichern", isOn: $savePassword)
|
Toggle("Passwort in Keychain speichern", isOn: $savePassword)
|
||||||
|
Text(sshpassHint).font(.caption).foregroundStyle(.secondary)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
.formStyle(.grouped)
|
.formStyle(.grouped)
|
||||||
@@ -68,12 +80,30 @@ struct ProfileEditorView: View {
|
|||||||
}
|
}
|
||||||
.padding()
|
.padding()
|
||||||
}
|
}
|
||||||
.frame(width: 520, height: 620)
|
.frame(width: 520, height: 640)
|
||||||
.onAppear {
|
.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 {
|
if let acct = profile.passwordAccount {
|
||||||
password = KeychainHelper.load(account: acct) ?? ""
|
KeychainHelper.delete(account: acct)
|
||||||
savePassword = !password.isEmpty
|
}
|
||||||
}
|
password = ""
|
||||||
}
|
savePassword = false
|
||||||
|
storedPasswordPresent = false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,7 +4,11 @@ struct SessionView: View {
|
|||||||
let profile: ConnectionProfile
|
let profile: ConnectionProfile
|
||||||
@Binding var statusMessage: String
|
@Binding var statusMessage: String
|
||||||
@EnvironmentObject var store: ProfileStore
|
@EnvironmentObject var store: ProfileStore
|
||||||
@State private var log: String = ""
|
@ObservedObject var term: PTYSession
|
||||||
|
var onClose: () -> Void
|
||||||
|
|
||||||
|
var isSSH: Bool { profile.proto == .ssh || profile.proto == .sftp }
|
||||||
|
var canConnect: Bool { !profile.host.isEmpty && !profile.username.isEmpty }
|
||||||
|
|
||||||
var body: some View {
|
var body: some View {
|
||||||
VStack(alignment: .leading, spacing: 8) {
|
VStack(alignment: .leading, spacing: 8) {
|
||||||
@@ -16,8 +20,8 @@ struct SessionView: View {
|
|||||||
.font(.subheadline).foregroundStyle(.secondary)
|
.font(.subheadline).foregroundStyle(.secondary)
|
||||||
}
|
}
|
||||||
Spacer()
|
Spacer()
|
||||||
if profile.proto == .ssh || profile.proto == .sftp {
|
if isSSH {
|
||||||
Button("In Terminal öffnen") {
|
Button("In Terminal.app öffnen") {
|
||||||
SSHService.openInTerminal(profile: profile, key: store.key(for: profile))
|
SSHService.openInTerminal(profile: profile, key: store.key(for: profile))
|
||||||
}
|
}
|
||||||
Button("Befehl kopieren") {
|
Button("Befehl kopieren") {
|
||||||
@@ -27,12 +31,20 @@ struct SessionView: View {
|
|||||||
} else if profile.proto == .rdp {
|
} else if profile.proto == .rdp {
|
||||||
Button("RDP erneut verbinden") { RDPService.connect(profile: profile) }
|
Button("RDP erneut verbinden") { RDPService.connect(profile: profile) }
|
||||||
}
|
}
|
||||||
|
Button("Tab schließen") { onClose() }
|
||||||
|
}
|
||||||
|
.padding(.horizontal)
|
||||||
|
|
||||||
|
if isSSH {
|
||||||
|
// In-App-Terminal (Dracula) — kein externes Fenster mehr nötig
|
||||||
|
EmbeddedTerminalView(term: term, profile: profile, canConnect: canConnect)
|
||||||
|
.frame(minHeight: 380)
|
||||||
|
.padding(.horizontal)
|
||||||
}
|
}
|
||||||
.padding()
|
|
||||||
|
|
||||||
GroupBox("Verbindungsdetails") {
|
GroupBox("Verbindungsdetails") {
|
||||||
let key = store.key(for: profile)
|
let key = store.key(for: profile)
|
||||||
let cmd = profile.proto == .ssh || profile.proto == .sftp
|
let cmd = isSSH
|
||||||
? SSHService.sshCommandString(for: profile, key: key)
|
? SSHService.sshCommandString(for: profile, key: key)
|
||||||
: "\(profile.proto.rawValue) \(profile.host):\(profile.port)"
|
: "\(profile.proto.rawValue) \(profile.host):\(profile.port)"
|
||||||
Text(cmd)
|
Text(cmd)
|
||||||
@@ -54,14 +66,15 @@ struct SessionView: View {
|
|||||||
Spacer()
|
Spacer()
|
||||||
}
|
}
|
||||||
.frame(maxWidth: .infinity, maxHeight: .infinity)
|
.frame(maxWidth: .infinity, maxHeight: .infinity)
|
||||||
|
.padding(.top, 8)
|
||||||
}
|
}
|
||||||
|
|
||||||
var hintText: String {
|
var hintText: String {
|
||||||
switch profile.proto {
|
switch profile.proto {
|
||||||
case .ssh:
|
case .ssh:
|
||||||
return "SSH wird in Terminal.app geöffnet (System-ssh). Für ein eingebettetes Terminal als nächsten Schritt SwiftTerm + swift-nio-ssh einbinden."
|
return "In-App-Terminal (Dracula-Theme) — läuft direkt in diesem Tab über ein PTY. Alternativ: In Terminal.app öffnen."
|
||||||
case .sftp:
|
case .sftp:
|
||||||
return "SFTP nutzt denselben SSH-Zugang. Befehl kopieren und z. B. mit Cyberduck / Transmit / sftp im Terminal nutzen: sftp -P \(profile.port) \(profile.username)@\(profile.host)."
|
return "SFTP-Sitzung läuft im Terminal oben. Alternativ extern nutzen: sftp -P \(profile.port) \(profile.username)@\(profile.host)."
|
||||||
case .rdp:
|
case .rdp:
|
||||||
return RDPService.freeRDPPath != nil
|
return RDPService.freeRDPPath != nil
|
||||||
? "Verbunden über xfreerdp (\(RDPService.freeRDPPath!))."
|
? "Verbunden über xfreerdp (\(RDPService.freeRDPPath!))."
|
||||||
|
|||||||
+66
-2
@@ -10,7 +10,14 @@ Stand: 2026-09-21 · Version 0.1.0 · macOS arm64 · Swift 5.9+ · Xcode 15+
|
|||||||
| 1 | 2026-09-21 | `swift build` (debug) | `WindowGroup<some View> has no member 'windowTitle'` | blockierend | ✅ behoben |
|
| 1 | 2026-09-21 | `swift build` (debug) | `WindowGroup<some View> has no member 'windowTitle'` | blockierend | ✅ behoben |
|
||||||
| 2 | 2026-09-21 | `swift build -c release` | keine Fehler, nur lange Link-Zeit (~40 s) | Info | ✅ ok |
|
| 2 | 2026-09-21 | `swift build -c release` | keine Fehler, nur lange Link-Zeit (~40 s) | Info | ✅ ok |
|
||||||
| 3 | 2026-09-21 | Release-Skript | `dist/` war nicht in `.gitignore` → Binary drohte committet zu werden | mittel | ✅ behoben (ignoriert) |
|
| 3 | 2026-09-21 | Release-Skript | `dist/` war nicht in `.gitignore` → Binary drohte committet zu werden | mittel | ✅ behoben (ignoriert) |
|
||||||
| 4 | 2026-09-21 | Gitea-Upload | `GET /api/v1/user` → `401 invalid username, password or token` (Host `git.sysdaemon.xyz`, v1.27.3 erreichbar) | blockierend (Push/Release) | ⬜ offen — Credentials prüfen |
|
| 4 | 2026-09-21 | Gitea-Upload | `GET /api/v1/user` → `401 invalid username, password or token` mit alten Credentials | blockierend (Push/Release) | ✅ behoben — neue Credentials ok, Push + Release v0.1.0 hochgeladen |
|
||||||
|
| 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 |
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
@@ -76,6 +83,62 @@ dist/
|
|||||||
## Wie Fehler hierher kommen
|
## Wie Fehler hierher kommen
|
||||||
- Jeder `swift build` / `swift build -c release` / Skript-Lauf mit Fehler → Log-Ausschnitt + Exit-Code hier eintragen.
|
- Jeder `swift build` / `swift build -c release` / Skript-Lauf mit Fehler → Log-Ausschnitt + Exit-Code hier eintragen.
|
||||||
- Gitea-Push/Release-Fehler (z. B. 401, Repo existiert schon, Asset-Upload schlägt fehl) ebenfalls hier dokumentieren.
|
- Gitea-Push/Release-Fehler (z. B. 401, Repo existiert schon, Asset-Upload schlägt fehl) ebenfalls hier dokumentieren.
|
||||||
|
- Neue Tests: `AnsiParser` per `swiftc`-Harness (`/tmp`, SGR/CRLF/Clear/Map), `PTYSession` per Smoke-Test (`/bin/echo` + `ssh -G` durchs echte PTY).
|
||||||
|
|
||||||
|
## #6 — SSH-Klick öffnet kein Terminal (User-Bugreport)
|
||||||
|
**Phase:** Laufzeit, SSH-Profil → Verbinden
|
||||||
|
**Ursache:** `Services/ConnectionServices.swift` nutzte `NSAppleScript(tell application "Terminal" to do script …)`. Ohne `NSAppleEventsUsageDescription` und ohne Error-Auswertung scheitert das still — es passiert schlicht nichts.
|
||||||
|
**Fix:**
|
||||||
|
- Neu: `Services/PTYSession.swift` — echte PTY-Session (`posix_openpt`, `ssh` mit TTY), `TerminalManager` pro Profil (überlebt Tab-Wechsel).
|
||||||
|
- Neu: `Views/EmbeddedTerminalView.swift` — In-App-Terminal im Dracula-Theme (`Services/TerminalTheme.swift`, `Services/AnsiParser.swift`), Auto-Connect per `onAppear`, Eingabezeile + Passwort-Modus + `^C`/`^D`.
|
||||||
|
- `SessionView` bettet das Terminal ein (min. 380 pt), `ContentView.connect()` öffnet nur noch den Tab.
|
||||||
|
- Extern-Fallback umgebaut auf `.command`-Datei via `NSWorkspace` (keine Automation-Rechte nötig).
|
||||||
|
**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`
|
||||||
|
**Ursache:** Chunk wurde erst nach dem SGR-Wechsel geflusht.
|
||||||
|
**Fix:** `Services/AnsiParser.swift` — `flush()` vor `parseCSI`.
|
||||||
|
**Verifikation:** Harness 8/8 grün.
|
||||||
|
**Status:** ✅ behoben.
|
||||||
|
|
||||||
## #4 — Gitea-Upload: 401 trotz erreichbarem Server
|
## #4 — Gitea-Upload: 401 trotz erreichbarem Server
|
||||||
**Phase:** `POST /api/v1/user/repos` + `GET /api/v1/user` auf `https://git.sysdaemon.xyz` (Version 1.27.3, per `/api/v1/version` bestätigt)
|
**Phase:** `POST /api/v1/user/repos` + `GET /api/v1/user` auf `https://git.sysdaemon.xyz` (Version 1.27.3, per `/api/v1/version` bestätigt)
|
||||||
@@ -99,4 +162,5 @@ export GITEA_HOST="https://git.sysdaemon.xyz" GITEA_OWNER="<owner>" GITEA_REPO="
|
|||||||
```
|
```
|
||||||
Oder mit Token als Passwort: `git push https://<owner>:<token>@git.sysdaemon.xyz/<owner>/remmina-mac.git main`.
|
Oder mit Token als Passwort: `git push https://<owner>:<token>@git.sysdaemon.xyz/<owner>/remmina-mac.git main`.
|
||||||
**Lokaler Stand:** Commit `cd834dc` + `dist/RemminaMac-0.1.0-macos-arm64.zip` sind fertig und warteten nur auf den Push.
|
**Lokaler Stand:** Commit `cd834dc` + `dist/RemminaMac-0.1.0-macos-arm64.zip` sind fertig und warteten nur auf den Push.
|
||||||
**Status:** ⬜ offen — bitte gültige Credentials / Token liefern, dann pushe ich erneut.
|
**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.
|
||||||
|
|||||||
@@ -26,6 +26,17 @@ unzip dist/RemminaMac-*-macos-arm64.zip -d /tmp/rmm
|
|||||||
/tmp/rmm/RemminaMac
|
/tmp/rmm/RemminaMac
|
||||||
```
|
```
|
||||||
|
|
||||||
|
## Variante D: Installer-DMG (Empfohlen für Endnutzer)
|
||||||
|
1. `RemminaMac-0.1.0-macos-arm64.dmg` aus dem Gitea-Release laden (oder lokal: `./scripts/build-app.sh 0.1.0 && ./scripts/build-dmg.sh 0.1.0`)
|
||||||
|
2. DMG doppelklicken → Finder-Fenster mit `RemminaMac.app` + `Programme`-Link
|
||||||
|
3. `RemminaMac.app` auf `Programme` ziehen → liegt in `/Applications/RemminaMac.app`
|
||||||
|
4. Auswerfen, aus Programme starten. Beim ersten Start: Rechtsklick → Öffnen (ad-hoc-Signatur, kein Apple-Notarization).
|
||||||
|
```bash
|
||||||
|
# Prüfen:
|
||||||
|
spctl -a -vv dist/RemminaMac.app
|
||||||
|
hdiutil verify dist/RemminaMac-0.1.0-macos-arm64.dmg
|
||||||
|
```
|
||||||
|
|
||||||
## RDP-Voraussetzungen
|
## RDP-Voraussetzungen
|
||||||
```bash
|
```bash
|
||||||
# Für volle RDP-Unterstützung:
|
# Für volle RDP-Unterstützung:
|
||||||
|
|||||||
+9
-4
@@ -2,13 +2,18 @@
|
|||||||
|
|
||||||
## Lokal bauen
|
## Lokal bauen
|
||||||
```bash
|
```bash
|
||||||
./scripts/build-release.sh [version]
|
./scripts/build-release.sh [version] # ZIP mit Binary + Docs
|
||||||
|
./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:
|
# Beispiel:
|
||||||
./scripts/build-release.sh 0.1.0
|
./scripts/build-release.sh 0.1.0
|
||||||
|
./scripts/build-app.sh 0.1.0
|
||||||
|
./scripts/build-dmg.sh 0.1.0
|
||||||
# Output:
|
# Output:
|
||||||
# dist/RemminaMac-0.1.0-macos-arm64.zip
|
# dist/RemminaMac-0.1.0-macos-arm64.zip (+ .sha256)
|
||||||
# dist/RemminaMac-0.1.0-macos-arm64.zip.sha256
|
# dist/RemminaMac.app/
|
||||||
# dist/RemminaMac-0.1.0-macos-arm64/RemminaMac (Binary)
|
# dist/RemminaMac-0.1.0-macos-arm64.dmg (+ .sha256)
|
||||||
```
|
```
|
||||||
|
|
||||||
## Was das Skript macht
|
## Was das Skript macht
|
||||||
|
|||||||
+8
-1
@@ -14,7 +14,8 @@
|
|||||||
|
|
||||||
## Verbinden
|
## Verbinden
|
||||||
- Profil wählen → `▶ Verbinden` oder Doppelklick.
|
- Profil wählen → `▶ Verbinden` oder Doppelklick.
|
||||||
- SSH/SFTP: öffnet Terminal.app mit `ssh -p PORT -i KEY user@host`. Befehl steht zusätzlich kopierbar in der Detailansicht.
|
- 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.
|
- RDP: startet `xfreerdp` (falls vorhanden) oder öffnet MS Remote Desktop.
|
||||||
- VNC: öffnet `vnc://host:port`.
|
- VNC: öffnet `vnc://host:port`.
|
||||||
|
|
||||||
@@ -24,6 +25,12 @@
|
|||||||
- `Neuen Key generieren`: ruft `/usr/bin/ssh-keygen -t ed25519 -f ~/.ssh/remminamac_<timestamp>` auf.
|
- `Neuen Key generieren`: ruft `/usr/bin/ssh-keygen -t ed25519 -f ~/.ssh/remminamac_<timestamp>` auf.
|
||||||
- Passphrase → Keychain (`sshkey-<UUID>`).
|
- Passphrase → Keychain (`sshkey-<UUID>`).
|
||||||
|
|
||||||
|
## 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).
|
||||||
|
|
||||||
## Quick-Connect
|
## Quick-Connect
|
||||||
- Mit Auswahl: verbindet direkt. Ohne Auswahl: öffnet Editor mit „Quick-Connect“-Vorlage.
|
- 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)")
|
||||||
Executable
+33
@@ -0,0 +1,33 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
# Baut RemminaMac.app (Drag-and-drop-fähiges Bundle) aus dem Release-Binary.
|
||||||
|
# Usage: ./scripts/build-app.sh [version]
|
||||||
|
set -euo pipefail
|
||||||
|
VERSION="${1:-0.1.0}"
|
||||||
|
ROOT="$(cd "$(dirname "$0")/.." && pwd)"
|
||||||
|
DIST="$ROOT/dist"
|
||||||
|
BIN="$ROOT/.build/release/RemminaMac"
|
||||||
|
APP="$DIST/RemminaMac.app"
|
||||||
|
|
||||||
|
echo "[build-app] Version: $VERSION"
|
||||||
|
if [ ! -x "$BIN" ]; then
|
||||||
|
echo "[build-app] Kein Release-Binary, baue..."
|
||||||
|
swift build -c release --package-path "$ROOT"
|
||||||
|
fi
|
||||||
|
|
||||||
|
rm -rf "$APP"
|
||||||
|
mkdir -p "$APP/Contents/MacOS" "$APP/Contents/Resources"
|
||||||
|
cp "$BIN" "$APP/Contents/MacOS/RemminaMac"
|
||||||
|
chmod +x "$APP/Contents/MacOS/RemminaMac"
|
||||||
|
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"
|
||||||
|
echo -n "APPL????" > "$APP/Contents/PkgInfo"
|
||||||
|
|
||||||
|
# Ad-hoc-Signatur (nötig für Apple Silicon / Gatekeeper-Basis)
|
||||||
|
codesign --force --deep --sign - "$APP" 2>&1 | tail -n 3 || true
|
||||||
|
codesign --verify --verbose=2 "$APP" 2>&1 | tail -n 5 || true
|
||||||
|
|
||||||
|
echo "[build-app] Fertig:"
|
||||||
|
ls -ld "$APP"
|
||||||
|
du -sh "$APP"
|
||||||
Executable
+44
@@ -0,0 +1,44 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
# Baut ein Drag-and-drop-DMG: RemminaMac.app + Programme-Symlink.
|
||||||
|
# Nur Bordmittel (hdiutil). Usage: ./scripts/build-dmg.sh [version]
|
||||||
|
set -euo pipefail
|
||||||
|
VERSION="${1:-0.1.0}"
|
||||||
|
ROOT="$(cd "$(dirname "$0")/.." && pwd)"
|
||||||
|
DIST="$ROOT/dist"
|
||||||
|
APP="$DIST/RemminaMac.app"
|
||||||
|
VOL="RemminaMac $VERSION"
|
||||||
|
RW_DMG="$DIST/.rw.RemminaMac-$VERSION.dmg"
|
||||||
|
FINAL_DMG="$DIST/RemminaMac-$VERSION-macos-arm64.dmg"
|
||||||
|
|
||||||
|
echo "[build-dmg] Version: $VERSION"
|
||||||
|
[ -d "$APP" ] || { echo "[build-dmg] $APP fehlt — erst ./scripts/build-app.sh $VERSION"; exit 1; }
|
||||||
|
|
||||||
|
rm -f "$RW_DMG" "$FINAL_DMG"
|
||||||
|
# 1. Beschreibbares DMG mit App + Programme-Link erzeugen
|
||||||
|
hdiutil create -volname "$VOL" -srcfolder "$APP" -ov -format UDRW "$RW_DMG" > /dev/null
|
||||||
|
MOUNT="$(hdiutil attach -readwrite -nobrowse "$RW_DMG" | grep -E '/Volumes/' | sed 's/.*\/Volumes\//\/Volumes\//')"
|
||||||
|
echo "[build-dmg] Gemountet: $MOUNT"
|
||||||
|
ln -s /Applications "$MOUNT/Programme" || true
|
||||||
|
ln -s /Applications "$MOUNT/Applications" || true
|
||||||
|
# Optionales Fenster-Layout (schlägt headless ggf. fehl — nicht fatal)
|
||||||
|
osascript <<OSA || true
|
||||||
|
tell application "Finder"
|
||||||
|
tell disk "$VOL"
|
||||||
|
open
|
||||||
|
set current view of container window to icon view
|
||||||
|
set toolbar visible of container window to false
|
||||||
|
set the bounds of container window to {100, 100, 640, 420}
|
||||||
|
delay 1
|
||||||
|
end tell
|
||||||
|
end tell
|
||||||
|
OSA
|
||||||
|
hdiutil detach "$MOUNT" > /dev/null
|
||||||
|
# 2. Komprimieren + Checksumme
|
||||||
|
hdiutil convert "$RW_DMG" -format UDZO -imagekey zlib-level=9 -o "$FINAL_DMG" > /dev/null
|
||||||
|
rm -f "$RW_DMG"
|
||||||
|
shasum -a 256 "$FINAL_DMG" > "$FINAL_DMG.sha256"
|
||||||
|
|
||||||
|
echo "[build-dmg] Fertig:"
|
||||||
|
ls -lh "$FINAL_DMG" "$FINAL_DMG.sha256"
|
||||||
|
cat "$FINAL_DMG.sha256"
|
||||||
|
hdiutil imageinfo "$FINAL_DMG" 2>/dev/null | grep -E 'Format|Size' | head -n 4 || true
|
||||||
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