mirror of
https://github.com/hanzoai/bot.git
synced 2026-10-30 17:24:26 +00:00
The big rebrand left a residue of HanzoBot* identifiers inside camelCase compounds (resolveHanzoBotAgentDir, HanzoBotPackageRoot, hanzoBotRoot, HanzoBotTmpDir, …) that the canonical bot-root.ts / tmp-bot-dir.ts had always exported as Bot* / bot*. The earlier \b-anchored sweep missed them because the H is mid-identifier with no word boundary. Replace HanzoBot(?=[A-Z][a-z]) → Bot (and hanzoBot equivalent) everywhere, plus HanzoBotKit → BotKit (the on-disk module is apps/shared/BotKit). Also one stray pi-tools.ts type narrowing (senderId is string|null but the target wants string|undefined) — coerce with ?? undefined. pnpm build → ✔ Build complete in 7s.
22 lines
655 B
Swift
22 lines
655 B
Swift
import Foundation
|
|
import BotKit
|
|
|
|
public enum TailscaleNetwork {
|
|
public static func isTailnetIPv4(_ address: String) -> Bool {
|
|
let parts = address.split(separator: ".")
|
|
guard parts.count == 4 else { return false }
|
|
let octets = parts.compactMap { Int($0) }
|
|
guard octets.count == 4 else { return false }
|
|
let a = octets[0]
|
|
let b = octets[1]
|
|
return a == 100 && b >= 64 && b <= 127
|
|
}
|
|
|
|
public static func detectTailnetIPv4() -> String? {
|
|
for entry in NetworkInterfaceIPv4.addresses() where self.isTailnetIPv4(entry.ip) {
|
|
return entry.ip
|
|
}
|
|
return nil
|
|
}
|
|
}
|