fix(macos): hide local bridge discovery
parent
4abaf62783
commit
a88e5968ae
|
|
@ -85,6 +85,7 @@ final class GatewayDiscoveryModel {
|
||||||
lanHost: lanHost,
|
lanHost: lanHost,
|
||||||
tailnetDns: tailnetDns,
|
tailnetDns: tailnetDns,
|
||||||
displayName: prettyName,
|
displayName: prettyName,
|
||||||
|
serviceName: decodedName,
|
||||||
local: self.localIdentity)
|
local: self.localIdentity)
|
||||||
return DiscoveredGateway(
|
return DiscoveredGateway(
|
||||||
displayName: prettyName,
|
displayName: prettyName,
|
||||||
|
|
@ -180,6 +181,7 @@ final class GatewayDiscoveryModel {
|
||||||
lanHost: String?,
|
lanHost: String?,
|
||||||
tailnetDns: String?,
|
tailnetDns: String?,
|
||||||
displayName: String?,
|
displayName: String?,
|
||||||
|
serviceName: String?,
|
||||||
local: LocalIdentity) -> Bool
|
local: LocalIdentity) -> Bool
|
||||||
{
|
{
|
||||||
if let host = normalizeHostToken(lanHost),
|
if let host = normalizeHostToken(lanHost),
|
||||||
|
|
@ -197,6 +199,13 @@ final class GatewayDiscoveryModel {
|
||||||
{
|
{
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
if let service = normalizeServiceToken(serviceName) {
|
||||||
|
for token in local.hostTokens {
|
||||||
|
if service.contains(token) {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -250,4 +259,11 @@ final class GatewayDiscoveryModel {
|
||||||
if trimmed.isEmpty { return nil }
|
if trimmed.isEmpty { return nil }
|
||||||
return trimmed.lowercased()
|
return trimmed.lowercased()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static func normalizeServiceToken(_ raw: String?) -> String? {
|
||||||
|
guard let raw else { return nil }
|
||||||
|
let trimmed = raw.trimmingCharacters(in: .whitespacesAndNewlines)
|
||||||
|
if trimmed.isEmpty { return nil }
|
||||||
|
return trimmed.lowercased()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1335,8 +1335,12 @@ struct OnboardingView: View {
|
||||||
let shouldMonitor = isConnectionPage
|
let shouldMonitor = isConnectionPage
|
||||||
if shouldMonitor, !self.monitoringDiscovery {
|
if shouldMonitor, !self.monitoringDiscovery {
|
||||||
self.monitoringDiscovery = true
|
self.monitoringDiscovery = true
|
||||||
self.gatewayDiscovery.start()
|
Task { @MainActor in
|
||||||
Task { await self.refreshLocalGatewayProbe() }
|
try? await Task.sleep(nanoseconds: 250_000_000)
|
||||||
|
guard self.monitoringDiscovery else { return }
|
||||||
|
self.gatewayDiscovery.start()
|
||||||
|
await self.refreshLocalGatewayProbe()
|
||||||
|
}
|
||||||
} else if !shouldMonitor, self.monitoringDiscovery {
|
} else if !shouldMonitor, self.monitoringDiscovery {
|
||||||
self.monitoringDiscovery = false
|
self.monitoringDiscovery = false
|
||||||
self.gatewayDiscovery.stop()
|
self.gatewayDiscovery.stop()
|
||||||
|
|
|
||||||
|
|
@ -10,6 +10,7 @@ import Testing
|
||||||
lanHost: "studio.local",
|
lanHost: "studio.local",
|
||||||
tailnetDns: nil,
|
tailnetDns: nil,
|
||||||
displayName: nil,
|
displayName: nil,
|
||||||
|
serviceName: nil,
|
||||||
local: local))
|
local: local))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -21,6 +22,7 @@ import Testing
|
||||||
lanHost: nil,
|
lanHost: nil,
|
||||||
tailnetDns: "studio.tailnet.example",
|
tailnetDns: "studio.tailnet.example",
|
||||||
displayName: nil,
|
displayName: nil,
|
||||||
|
serviceName: nil,
|
||||||
local: local))
|
local: local))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -32,6 +34,7 @@ import Testing
|
||||||
lanHost: nil,
|
lanHost: nil,
|
||||||
tailnetDns: nil,
|
tailnetDns: nil,
|
||||||
displayName: "Peter's Mac Studio (Clawdis)",
|
displayName: "Peter's Mac Studio (Clawdis)",
|
||||||
|
serviceName: nil,
|
||||||
local: local))
|
local: local))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -43,6 +46,19 @@ import Testing
|
||||||
lanHost: "other.local",
|
lanHost: "other.local",
|
||||||
tailnetDns: "other.tailnet.example",
|
tailnetDns: "other.tailnet.example",
|
||||||
displayName: "Other Mac",
|
displayName: "Other Mac",
|
||||||
|
serviceName: "other-bridge",
|
||||||
|
local: local))
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test func localGatewayMatchesServiceName() {
|
||||||
|
let local = GatewayDiscoveryModel.LocalIdentity(
|
||||||
|
hostTokens: ["studio"],
|
||||||
|
displayTokens: [])
|
||||||
|
#expect(GatewayDiscoveryModel.isLocalGateway(
|
||||||
|
lanHost: nil,
|
||||||
|
tailnetDns: nil,
|
||||||
|
displayName: nil,
|
||||||
|
serviceName: "studio-bridge",
|
||||||
local: local))
|
local: local))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue