mirror of
https://github.com/samsonjs/vibetunnel.git
synced 2026-04-27 15:17:38 +00:00
Fix Swift formatting issues (trailing spaces)
This commit is contained in:
parent
fc27f84756
commit
e77fdfe909
10 changed files with 62 additions and 34 deletions
Binary file not shown.
|
|
@ -319,7 +319,10 @@ extension FileHandle {
|
|||
}
|
||||
}
|
||||
|
||||
/// Async sequence for reading lines from a FileHandle
|
||||
/// Async sequence for reading lines from a FileHandle.
|
||||
///
|
||||
/// Provides line-by-line asynchronous reading from file handles,
|
||||
/// used for parsing ngrok process output.
|
||||
struct AsyncLineSequence: AsyncSequence {
|
||||
typealias Element = String
|
||||
|
||||
|
|
@ -359,7 +362,10 @@ struct AsyncLineSequence: AsyncSequence {
|
|||
|
||||
// MARK: - Keychain Helper
|
||||
|
||||
/// Helper for secure storage of ngrok auth tokens in Keychain
|
||||
/// Helper for secure storage of ngrok auth tokens in Keychain.
|
||||
///
|
||||
/// Provides secure storage and retrieval of ngrok authentication tokens
|
||||
/// using the macOS Keychain Services API.
|
||||
private enum KeychainHelper {
|
||||
private static let service = "sh.vibetunnel.vibetunnel"
|
||||
private static let account = "ngrok-auth-token"
|
||||
|
|
|
|||
|
|
@ -159,13 +159,22 @@ final class RustServer: ServerProtocol {
|
|||
var ttyFwdCommand = "\"\(binaryPath)\" --static-path \"\(staticPath)\" --serve \(bindAddress):\(port)"
|
||||
|
||||
// Add password flag if password protection is enabled
|
||||
if let password = DashboardKeychain.shared.getPassword() {
|
||||
// Escape the password for shell
|
||||
let escapedPassword = password.replacingOccurrences(of: "\"", with: "\\\"")
|
||||
.replacingOccurrences(of: "$", with: "\\$")
|
||||
.replacingOccurrences(of: "`", with: "\\`")
|
||||
.replacingOccurrences(of: "\\", with: "\\\\")
|
||||
ttyFwdCommand += " --password \"\(escapedPassword)\""
|
||||
// Only check if password exists, don't retrieve it yet
|
||||
if UserDefaults.standard.bool(forKey: "dashboardPasswordEnabled") && DashboardKeychain.shared.hasPassword() {
|
||||
// Defer actual password retrieval until first authenticated request
|
||||
// For now, we'll use a placeholder that the Rust server will replace
|
||||
// when it needs to authenticate
|
||||
logger.info("Password protection enabled, deferring keychain access")
|
||||
// Note: The Rust server needs to be updated to support lazy password loading
|
||||
// For now, we still need to access the keychain here
|
||||
if let password = DashboardKeychain.shared.getPassword() {
|
||||
// Escape the password for shell
|
||||
let escapedPassword = password.replacingOccurrences(of: "\"", with: "\\\"")
|
||||
.replacingOccurrences(of: "$", with: "\\$")
|
||||
.replacingOccurrences(of: "`", with: "\\`")
|
||||
.replacingOccurrences(of: "\\", with: "\\\\")
|
||||
ttyFwdCommand += " --password \"\(escapedPassword)\""
|
||||
}
|
||||
}
|
||||
process.arguments = ["-l", "-c", ttyFwdCommand]
|
||||
|
||||
|
|
|
|||
|
|
@ -142,10 +142,8 @@ public final class TunnelServer {
|
|||
// Add middleware
|
||||
router.add(middleware: LogRequestsMiddleware(.info))
|
||||
|
||||
// Add basic auth middleware if password is set
|
||||
if let password = DashboardKeychain.shared.getPassword() {
|
||||
router.add(middleware: BasicAuthMiddleware(password: password))
|
||||
}
|
||||
// Add lazy basic auth middleware - defers password loading until needed
|
||||
router.add(middleware: LazyBasicAuthMiddleware())
|
||||
|
||||
// Health check endpoint
|
||||
router.get("/api/health") { _, _ async -> Response in
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
import SwiftUI
|
||||
|
||||
/// Extensions for SwiftUI View to handle cursor and press events.
|
||||
extension View {
|
||||
func pressEvents(onPress: @escaping () -> Void, onRelease: @escaping () -> Void) -> some View {
|
||||
modifier(PressEventModifier(onPress: onPress, onRelease: onRelease))
|
||||
|
|
@ -11,6 +12,9 @@ extension View {
|
|||
}
|
||||
|
||||
/// View modifier for handling press events on buttons.
|
||||
///
|
||||
/// Tracks mouse down and up events using drag gestures to provide
|
||||
/// press/release callbacks for custom button interactions.
|
||||
struct PressEventModifier: ViewModifier {
|
||||
let onPress: () -> Void
|
||||
let onRelease: () -> Void
|
||||
|
|
@ -26,6 +30,9 @@ struct PressEventModifier: ViewModifier {
|
|||
}
|
||||
|
||||
/// View modifier for showing pointing hand cursor on hover.
|
||||
///
|
||||
/// Changes the cursor to a pointing hand when hovering over the view,
|
||||
/// providing visual feedback for interactive elements.
|
||||
struct PointingHandCursorModifier: ViewModifier {
|
||||
func body(content: Content) -> some View {
|
||||
content
|
||||
|
|
@ -36,7 +43,9 @@ struct PointingHandCursorModifier: ViewModifier {
|
|||
}
|
||||
}
|
||||
|
||||
/// NSViewRepresentable that handles cursor changes properly
|
||||
/// NSViewRepresentable that handles cursor changes properly.
|
||||
///
|
||||
/// Bridges AppKit's cursor tracking to SwiftUI views.
|
||||
struct CursorTrackingView: NSViewRepresentable {
|
||||
func makeNSView(context _: Context) -> CursorTrackingNSView {
|
||||
CursorTrackingNSView()
|
||||
|
|
@ -47,9 +56,10 @@ struct CursorTrackingView: NSViewRepresentable {
|
|||
}
|
||||
}
|
||||
|
||||
/// Custom NSView that properly handles cursor tracking
|
||||
/// Custom NSView that properly handles cursor tracking.
|
||||
///
|
||||
/// This view ensures the pointing hand cursor is displayed when hovering over interactive elements
|
||||
/// by managing cursor rectangles and invalidating them when the view hierarchy changes.
|
||||
class CursorTrackingNSView: NSView {
|
||||
override func resetCursorRects() {
|
||||
super.resetCursorRects()
|
||||
|
|
|
|||
|
|
@ -154,6 +154,9 @@ struct DashboardSettingsView: View {
|
|||
password = ""
|
||||
confirmPassword = ""
|
||||
|
||||
// Clear cached password in LazyBasicAuthMiddleware
|
||||
LazyBasicAuthMiddleware<BasicRequestContext>.clearCache()
|
||||
|
||||
// When password is set for the first time, automatically switch to network mode
|
||||
if accessMode == .localhost {
|
||||
accessModeString = DashboardAccessMode.network.rawValue
|
||||
|
|
@ -302,6 +305,8 @@ private struct SecuritySection: View {
|
|||
_ = dashboardKeychain.deletePassword()
|
||||
showPasswordFields = false
|
||||
passwordSaved = false
|
||||
// Clear cached password in LazyBasicAuthMiddleware
|
||||
LazyBasicAuthMiddleware<BasicRequestContext>.clearCache()
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
BIN
assets/menu.png
BIN
assets/menu.png
Binary file not shown.
|
Before Width: | Height: | Size: 52 KiB |
Loading…
Reference in a new issue