mirror of
https://github.com/hanzoai/bot.git
synced 2026-10-30 17:24:26 +00:00
Comprehensive rename of all openclaw references to hanzo-bot equivalents: - Package: openclaw → @hanzo/bot - Binary: openclaw → hanzo-bot - Types: OpenClaw* → Bot* - Env vars: OPENCLAW_* → BOT_* - Android: ai.openclaw.android → ai.hanzo.bot.android - iOS/macOS: ai.openclaw.* → ai.hanzo.* - Swift modules: OpenClaw* → Bot* - Plugins: openclaw.plugin.json → bot.plugin.json - Paths: .openclaw/ → .hanzo/bot/ - URLs: github.com/openclaw → github.com/hanzoai
52 lines
1.9 KiB
Swift
52 lines
1.9 KiB
Swift
import Darwin
|
|
import Testing
|
|
@testable import BotDiscovery
|
|
|
|
@Suite
|
|
struct WideAreaGatewayDiscoveryTests {
|
|
@Test func discoversBeaconFromTailnetDnsSdFallback() {
|
|
setenv("BOT_WIDE_AREA_DOMAIN", "bot.internal", 1)
|
|
let statusJson = """
|
|
{
|
|
"Self": { "TailscaleIPs": ["100.69.232.64"] },
|
|
"Peer": {
|
|
"peer-1": { "TailscaleIPs": ["100.123.224.76"] }
|
|
}
|
|
}
|
|
"""
|
|
|
|
let context = WideAreaGatewayDiscovery.DiscoveryContext(
|
|
tailscaleStatus: { statusJson },
|
|
dig: { args, _ in
|
|
let recordType = args.last ?? ""
|
|
let nameserver = args.first(where: { $0.hasPrefix("@") }) ?? ""
|
|
if recordType == "PTR" {
|
|
if nameserver == "@100.123.224.76" {
|
|
return "steipetacstudio-gateway._bot-gw._tcp.hanzo-bot.internal.\n"
|
|
}
|
|
return ""
|
|
}
|
|
if recordType == "SRV" {
|
|
return "0 0 18789 steipetacstudio.hanzo-bot.internal."
|
|
}
|
|
if recordType == "TXT" {
|
|
return "\"displayName=Peter\\226\\128\\153s Mac Studio (HanzoBot)\" \"gatewayPort=18789\" \"tailnetDns=peters-mac-studio-1.sheep-coho.ts.net\" \"cliPath=/Users/steipete/hanzo-bot/src/entry.ts\""
|
|
}
|
|
return ""
|
|
})
|
|
|
|
let beacons = WideAreaGatewayDiscovery.discover(
|
|
timeoutSeconds: 2.0,
|
|
context: context)
|
|
|
|
#expect(beacons.count == 1)
|
|
let beacon = beacons[0]
|
|
let expectedDisplay = "Peter\u{2019}s Mac Studio (HanzoBot)"
|
|
#expect(beacon.displayName == expectedDisplay)
|
|
#expect(beacon.port == 18789)
|
|
#expect(beacon.gatewayPort == 18789)
|
|
#expect(beacon.tailnetDns == "peters-mac-studio-1.sheep-coho.ts.net")
|
|
#expect(beacon.cliPath == "/Users/steipete/hanzo-bot/src/entry.ts")
|
|
}
|
|
}
|