feat(bridge): show node ip in pairing
This commit is contained in:
@@ -107,7 +107,7 @@ struct SettingsTab: View {
|
|||||||
|
|
||||||
private func platformString() -> String {
|
private func platformString() -> String {
|
||||||
let v = ProcessInfo.processInfo.operatingSystemVersion
|
let v = ProcessInfo.processInfo.operatingSystemVersion
|
||||||
return "ios \(v.majorVersion).\(v.minorVersion).\(v.patchVersion)"
|
return "iOS \(v.majorVersion).\(v.minorVersion).\(v.patchVersion)"
|
||||||
}
|
}
|
||||||
|
|
||||||
private func appVersion() -> String {
|
private func appVersion() -> String {
|
||||||
|
|||||||
@@ -73,7 +73,14 @@ actor BridgeConnectionHandler {
|
|||||||
case "pair-request":
|
case "pair-request":
|
||||||
let req = try self.decoder.decode(BridgePairRequest.self, from: data)
|
let req = try self.decoder.decode(BridgePairRequest.self, from: data)
|
||||||
self.nodeId = req.nodeId
|
self.nodeId = req.nodeId
|
||||||
let result = await handlePair(req)
|
let enriched = BridgePairRequest(
|
||||||
|
type: req.type,
|
||||||
|
nodeId: req.nodeId,
|
||||||
|
displayName: req.displayName,
|
||||||
|
platform: req.platform,
|
||||||
|
version: req.version,
|
||||||
|
remoteAddress: self.remoteAddressString())
|
||||||
|
let result = await handlePair(enriched)
|
||||||
await self.handlePairResult(
|
await self.handlePairResult(
|
||||||
result,
|
result,
|
||||||
serverName: Host.current().localizedName ?? ProcessInfo.processInfo.hostName)
|
serverName: Host.current().localizedName ?? ProcessInfo.processInfo.hostName)
|
||||||
@@ -114,6 +121,16 @@ actor BridgeConnectionHandler {
|
|||||||
await self.close(with: onDisconnected)
|
await self.close(with: onDisconnected)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private func remoteAddressString() -> String? {
|
||||||
|
switch self.connection.endpoint {
|
||||||
|
case let .hostPort(host: host, port: _):
|
||||||
|
let value = String(describing: host)
|
||||||
|
return value.trimmingCharacters(in: .whitespacesAndNewlines).isEmpty ? nil : value
|
||||||
|
default:
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private func handlePairResult(_ result: PairResult, serverName: String) async {
|
private func handlePairResult(_ result: PairResult, serverName: String) async {
|
||||||
switch result {
|
switch result {
|
||||||
case let .ok(token):
|
case let .ok(token):
|
||||||
|
|||||||
@@ -262,10 +262,12 @@ enum BridgePairingApprover {
|
|||||||
static func approve(request: BridgePairRequest, isRepair: Bool) async -> Bool {
|
static func approve(request: BridgePairRequest, isRepair: Bool) async -> Bool {
|
||||||
await withCheckedContinuation { cont in
|
await withCheckedContinuation { cont in
|
||||||
let name = request.displayName ?? request.nodeId
|
let name = request.displayName ?? request.nodeId
|
||||||
|
let remote = request.remoteAddress?.trimmingCharacters(in: .whitespacesAndNewlines).nonEmpty
|
||||||
let alert = NSAlert()
|
let alert = NSAlert()
|
||||||
alert.messageText = isRepair ? "Re-pair Clawdis Node?" : "Pair Clawdis Node?"
|
alert.messageText = isRepair ? "Re-pair Clawdis Node?" : "Pair Clawdis Node?"
|
||||||
alert.informativeText = """
|
alert.informativeText = """
|
||||||
Node: \(name)
|
Node: \(name)
|
||||||
|
IP: \(remote ?? "unknown")
|
||||||
Platform: \(request.platform ?? "unknown")
|
Platform: \(request.platform ?? "unknown")
|
||||||
Version: \(request.version ?? "unknown")
|
Version: \(request.version ?? "unknown")
|
||||||
"""
|
"""
|
||||||
|
|||||||
@@ -97,19 +97,22 @@ public struct BridgePairRequest: Codable, Sendable {
|
|||||||
public let displayName: String?
|
public let displayName: String?
|
||||||
public let platform: String?
|
public let platform: String?
|
||||||
public let version: String?
|
public let version: String?
|
||||||
|
public let remoteAddress: String?
|
||||||
|
|
||||||
public init(
|
public init(
|
||||||
type: String = "pair-request",
|
type: String = "pair-request",
|
||||||
nodeId: String,
|
nodeId: String,
|
||||||
displayName: String?,
|
displayName: String?,
|
||||||
platform: String?,
|
platform: String?,
|
||||||
version: String?)
|
version: String?,
|
||||||
|
remoteAddress: String? = nil)
|
||||||
{
|
{
|
||||||
self.type = type
|
self.type = type
|
||||||
self.nodeId = nodeId
|
self.nodeId = nodeId
|
||||||
self.displayName = displayName
|
self.displayName = displayName
|
||||||
self.platform = platform
|
self.platform = platform
|
||||||
self.version = version
|
self.version = version
|
||||||
|
self.remoteAddress = remoteAddress
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user