Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 16 additions & 17 deletions .github/workflows/ios.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,25 +9,24 @@ on:
jobs:
build:
name: Build and Test default scheme using any available iPhone simulator
runs-on: macos-latest
runs-on: macos-26

steps:
- name: Checkout
uses: actions/checkout@v3
- name: Set Default Scheme
uses: actions/checkout@v4
# The app uses iOS 27 APIs (iPhone Duo): it needs the newest Xcode on the runner, not the image default.
- name: Select newest Xcode
run: |
scheme_list=$(xcodebuild -list -json | tr -d "\n")
default=$(echo $scheme_list | ruby -e "require 'json'; puts JSON.parse(STDIN.gets)['project']['targets'][0]")
echo $default | cat >default
echo Using default scheme: $default
- name: Build
env:
scheme: ${{ 'default' }}
platform: ${{ 'iOS Simulator' }}
xcode=$(ls -d /Applications/Xcode_*.app | sort -V | tail -1)
echo "Using $xcode"
sudo xcode-select -s "$xcode"
xcodebuild -version
# A generic destination needs no particular simulator model to be installed.
- name: Build iOS app
run: |
# xcrun xctrace returns via stderr, not the expected stdout (see https://developer.apple.com/forums/thread/663959)
device=`xcrun xctrace list devices 2>&1 | grep -oE 'iPhone.*?[^\(]+' | head -1 | awk '{$1=$1;print}' | sed -e "s/ Simulator$//"`
if [ $scheme = default ]; then scheme=$(cat default); fi
if [ "`ls -A | grep -i \\.xcworkspace\$`" ]; then filetype_parameter="workspace" && file_to_build="`ls -A | grep -i \\.xcworkspace\$`"; else filetype_parameter="project" && file_to_build="`ls -A | grep -i \\.xcodeproj\$`"; fi
file_to_build=`echo $file_to_build | awk '{$1=$1;print}'`
xcodebuild build-for-testing -scheme "$scheme" -"$filetype_parameter" "$file_to_build" -destination "platform=$platform,name=$device"
xcodebuild build -project IPv64.xcodeproj -scheme IPv64.net \
-destination "generic/platform=iOS Simulator" CODE_SIGNING_ALLOWED=NO
- name: Build Apple TV app
run: |
xcodebuild build -project IPv64.xcodeproj -scheme IPv64TV \
-destination "generic/platform=tvOS Simulator" CODE_SIGNING_ALLOWED=NO
511 changes: 330 additions & 181 deletions IPv64.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

9 changes: 9 additions & 0 deletions IPv64/Helpers/Adaptive.swift
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,12 @@ extension View {
/// iPhone Duo: keeps this screen's bars horizontal (sheet with a single text control Skip/Done).
@ViewBuilder
func appHorizontalBars() -> some View {
// compiler(>=6.4) = Xcode 27 with the iOS 27 SDK; older toolchains (CI runner) skip the iPhone Duo API.
#if compiler(>=6.4)
if #available(iOS 27.1, *) { toolbarVerticalBehavior(.disabled) } else { self }
#else
self
#endif
}

/// Caps the content at a readable width on wide windows and centres it.
Expand Down Expand Up @@ -41,6 +46,10 @@ extension ToolbarContent {
/// instead of staying horizontal next to the status bar.
@ToolbarContentBuilder
func appVerticalPreferred() -> some ToolbarContent {
#if compiler(>=6.4)
if #available(iOS 27.1, *) { axisBehavior(.verticalPreferred) } else { self }
#else
self
#endif
}
}
6 changes: 6 additions & 0 deletions IPv64/Helpers/AppConfig.swift
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import IPv64
/// Shared by the app and the widget extension (target membership exception).
nonisolated enum AppConfig {
static let appGroup = "group.ipv64.net"
/// CloudKit container of the node list the Apple TV app reads (`NodeCloudStore`).
static let cloudContainer = "iCloud.de.rpicloud.IPv64"
/// Debug only: `MOCK_API=http://localhost:8064` (environment or launch argument `-MOCK_API …`)
/// sends every cloud call to `<mock>/api/v2` and SecNtfy to `<mock>/secntfy`. Release builds ignore it.
static let mockBase: String? = {
Expand All @@ -26,7 +28,11 @@ nonisolated enum AppConfig {
return IPv64(configuration: .init(apiKey: apiKey, baseURL: URL(string: base)!, timeoutInterval: timeout))
}
/// Name in a node's audit log for changes made from this app (`Node64.Configuration.agentActor`).
#if os(tvOS)
static let nodeAgentActor = "IPv64 tvOS"
#else
static let nodeAgentActor = "IPv64 iOS"
#endif
/// WidgetKit kinds of the DNS64 widget and Control (reloaded by the app after pause/resume).
static let dns64WidgetKind = "DNS64Widget"
static let dns64ControlKind = "DNS64BlockingControl"
Expand Down
3 changes: 2 additions & 1 deletion IPv64/Helpers/DNS64/DNS64Logic.swift
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,8 @@ nonisolated func dns64StatusTag(_ raw: String?) -> ProxyLogic.Tag {
switch raw {
case "blocked": .init(text: String(localized: "Blocked"), tone: .red)
case "error": .init(text: String(localized: "Error"), tone: .orange)
case "allowed", "cached": .init(text: raw!.capitalized, tone: .green)
case "allowed": .init(text: String(localized: "Allowed"), tone: .green)
case "cached": .init(text: String(localized: "Cached"), tone: .green)
case let other: .init(text: other?.nonBlank?.capitalized ?? "–", tone: .gray)
}
}
Expand Down
48 changes: 27 additions & 21 deletions IPv64/Helpers/DynDNS/DynDNSLogic.swift
Original file line number Diff line number Diff line change
Expand Up @@ -37,22 +37,30 @@ nonisolated enum DynDNSLogic {

enum IpStatus: Sendable { case checking, noIp, unknown, differs, matches }

/// A/AAAA records that can hold this device's IP. CDN records hold CDN addresses, failover records a stand-in,
/// inactive ones are not served; none of them may count for the IP check.
static func ownRecords(_ detail: DomainDetail?, _ type: RecordType) -> [Record] {
(detail?.records ?? []).filter {
$0.type == type && ![.cdnRecord, .failoverRecord, .inactive].contains($0.state ?? .active)
}
}

static func hasIp(_ detail: DomainDetail?) -> Bool {
(detail?.records ?? []).contains { $0.type == .a || $0.type == .aaaa }
!ownRecords(detail, .a).isEmpty || !ownRecords(detail, .aaaa).isEmpty
}

/// An A record exists, none holds the current IPv4, and IPv4 is not ignored for this domain.
static func mismatchV4(_ detail: DomainDetail?, myV4: String) -> Bool {
guard let detail, myV4 != noIPv4, detail.ignore != .ipv4 else { return false }
let records = (detail.records ?? []).filter { $0.type == .a }
let records = ownRecords(detail, .a)
return !records.isEmpty && !records.contains { $0.content == myV4 }
}

/// Like `mismatchV4`; a fixed IPv6 prefix means the AAAA records are not the device address.
static func mismatchV6(_ detail: DomainDetail?, myV6: String) -> Bool {
guard let detail, myV6 != noIPv6, detail.ignore != .ipv6,
(detail.ipv6Prefix ?? "").trimmingCharacters(in: .whitespaces).isEmpty else { return false }
let records = (detail.records ?? []).filter { $0.type == .aaaa }
let records = ownRecords(detail, .aaaa)
return !records.isEmpty && !records.contains { $0.content == myV6 }
}

Expand All @@ -67,16 +75,16 @@ nonisolated enum DynDNSLogic {
static func kindLabel(_ kind: DomainKind?) -> String {
switch kind {
case .dyndns: "DynDNS"
case .own: "Own domain"
case .own: String(localized: "Own domain")
default: "–"
}
}

static func ignoreLabel(_ ignore: DomainIgnore?) -> String {
switch ignore {
case .ipv4: "Ignore IPv4"
case .ipv6: "Ignore IPv6"
default: "None"
case .ipv4: String(localized: "Ignore IPv4")
case .ipv6: String(localized: "Ignore IPv6")
default: String(localized: "None")
}
}

Expand All @@ -89,21 +97,21 @@ nonisolated enum DynDNSLogic {

static func lockReason(_ state: RecordState?) -> String? {
switch state {
case .cdnRecord, .cdnProxied, .cdnPartial: "Managed by the CDN. Change it in the CDN settings."
case .failoverRecord, .failoverReplaced: "Managed by DNS failover. Change it in the failover policy."
case .cdnRecord, .cdnProxied, .cdnPartial: String(localized: "Managed by the CDN. Change it in the CDN settings.")
case .failoverRecord, .failoverReplaced: String(localized: "Managed by DNS failover. Change it in the failover policy.")
default: nil
}
}

static func stateLabel(_ state: RecordState?) -> String? {
switch state {
case .active: "Active"
case .inactive: "Inactive"
case .active: String(localized: "Active")
case .inactive: String(localized: "Inactive")
case .cdnRecord: "CDN"
case .cdnProxied: "CDN proxied"
case .cdnPartial: "CDN partial"
case .failoverRecord: "Failover"
case .failoverReplaced: "Replaced by failover"
case .cdnProxied: String(localized: "CDN proxied")
case .cdnPartial: String(localized: "CDN partial")
case .failoverRecord: String(localized: "Failover")
case .failoverReplaced: String(localized: "Replaced by failover")
default: state?.rawValue
}
}
Expand Down Expand Up @@ -208,9 +216,9 @@ nonisolated enum DomainKindFilter: String, CaseIterable, Identifiable, Sendable

var title: String {
switch self {
case .all: "All"
case .all: String(localized: "All")
case .dyndns: "DynDNS"
case .own: "Own"
case .own: String(localized: "Own")
}
}

Expand All @@ -224,11 +232,9 @@ nonisolated enum DomainKindFilter: String, CaseIterable, Identifiable, Sendable
}

nonisolated extension DynDNSLogic {
/// Android `formatGermanTime`: dd.MM.yyyy HH:mm:ss.
/// Numeric date + time in the user's locale (name kept from the Android port).
static func germanTime(_ date: Date?, fallback: String = "–") -> String {
guard let date else { return fallback }
let formatter = DateFormatter()
formatter.dateFormat = "dd.MM.yyyy HH:mm:ss"
return formatter.string(from: date)
return date.formatted(date: .numeric, time: .standard)
}
}
4 changes: 2 additions & 2 deletions IPv64/Helpers/Healthchecks/HealthcheckFormState.swift
Original file line number Diff line number Diff line change
Expand Up @@ -238,9 +238,9 @@ nonisolated extension HC2CheckType {
switch self {
case .http, .keyword, .json: "https://example.com/health"
case .dns, .whois: "example.com"
case .icmp: "example.com or IP address"
case .icmp: String(localized: "example.com or IP address")
case .tcp, .port: "host:port"
case .cert: "example.com or host:port"
case .cert: String(localized: "example.com or host:port")
default: ""
}
}
Expand Down
40 changes: 20 additions & 20 deletions IPv64/Helpers/Healthchecks/HealthcheckLogic.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,16 @@ nonisolated extension HC2CheckType {
var label: String {
switch self {
case .http: "HTTP(S)"
case .keyword: "Keyword"
case .keyword: String(localized: "Keyword")
case .json: "JSON"
case .dns: "DNS"
case .icmp: "Ping (ICMP)"
case .tcp: "TCP"
case .port: "Port"
case .cert: "Certificate"
case .push: "Push"
case .port: String(localized: "Port")
case .cert: String(localized: "Certificate")
case .push: String(localized: "Push")
case .whois: "WHOIS"
default: "Unknown"
default: String(localized: "Unknown")
}
}
}
Expand All @@ -30,12 +30,12 @@ nonisolated enum Hc2StateUi: Sendable {

var label: String {
switch self {
case .up: "Up"
case .down: "Down"
case .degraded: "Degraded"
case .flapping: "Flapping"
case .paused: "Paused"
case .pending: "Pending"
case .up: String(localized: "Up")
case .down: String(localized: "Down")
case .degraded: String(localized: "Degraded")
case .flapping: String(localized: "Flapping")
case .paused: String(localized: "Paused")
case .pending: String(localized: "Pending")
}
}

Expand All @@ -55,11 +55,11 @@ nonisolated enum HcStatusFilter: CaseIterable, Hashable, Sendable {

var label: String {
switch self {
case .all: "All"
case .up: "Up"
case .degraded: "Degraded"
case .down: "Down"
case .paused: "Paused"
case .all: String(localized: "All")
case .up: String(localized: "Up")
case .degraded: String(localized: "Degraded")
case .down: String(localized: "Down")
case .paused: String(localized: "Paused")
}
}

Expand All @@ -79,10 +79,10 @@ nonisolated enum HcExecFilter: CaseIterable, Hashable, Sendable {

var label: String {
switch self {
case .all: "All"
case .online: "Online"
case .node: "Node"
case .both: "Both"
case .all: String(localized: "All")
case .online: String(localized: "Online")
case .node: String(localized: "Node")
case .both: String(localized: "Both")
}
}

Expand Down
34 changes: 15 additions & 19 deletions IPv64/Helpers/Healthchecks/Monitor64Logic.swift
Original file line number Diff line number Diff line change
Expand Up @@ -37,37 +37,33 @@ nonisolated func isNodeNotFound(_ error: any Error) -> Bool {
nonisolated struct Monitor64Display: Sendable {
let label: String
let color: Color
/// Status-filter bucket; `nil` = only in "All". Not derived from `label`, which is localized.
var bucket: HcStatusFilter?

static func host(view: String?, paused: Bool?) -> Monitor64Display {
if paused == true { return Monitor64Display(label: "Paused", color: .gray) }
if paused == true { return Monitor64Display(label: String(localized: "Paused"), color: .gray, bucket: .paused) }
switch view {
case "ok": return Monitor64Display(label: "OK", color: .green)
case "warn": return Monitor64Display(label: "Warning", color: .orange)
case "crit": return Monitor64Display(label: "Critical", color: .red)
case "unreachable": return Monitor64Display(label: "Unreachable", color: .red)
case "maintenance": return Monitor64Display(label: "Maintenance", color: .gray)
default: return Monitor64Display(label: "Unknown", color: .gray)
case "ok": return Monitor64Display(label: String(localized: "OK"), color: .green, bucket: .up)
case "warn": return Monitor64Display(label: String(localized: "Warning"), color: .orange, bucket: .degraded)
case "crit": return Monitor64Display(label: String(localized: "Critical"), color: .red, bucket: .down)
case "unreachable": return Monitor64Display(label: String(localized: "Unreachable"), color: .red, bucket: .down)
case "maintenance": return Monitor64Display(label: String(localized: "Maintenance"), color: .gray, bucket: .paused)
default: return Monitor64Display(label: String(localized: "Unknown"), color: .gray)
}
}

static func service(_ state: String?) -> Monitor64Display {
switch state {
case "ok": Monitor64Display(label: "OK", color: .green)
case "warn": Monitor64Display(label: "Warning", color: .orange)
case "crit": Monitor64Display(label: "Critical", color: .red)
default: Monitor64Display(label: "Unknown", color: .gray)
case "ok": Monitor64Display(label: String(localized: "OK"), color: .green, bucket: .up)
case "warn": Monitor64Display(label: String(localized: "Warning"), color: .orange, bucket: .degraded)
case "crit": Monitor64Display(label: String(localized: "Critical"), color: .red, bucket: .down)
default: Monitor64Display(label: String(localized: "Unknown"), color: .gray)
}
}

/// ok = Up, warn = Degraded, crit/unreachable = Down, paused/maintenance = Paused.
func matches(_ filter: HcStatusFilter) -> Bool {
switch filter {
case .all: true
case .up: label == "OK"
case .degraded: label == "Warning"
case .down: label == "Critical" || label == "Unreachable"
case .paused: label == "Paused" || label == "Maintenance"
}
filter == .all || bucket == filter
}
}

Expand Down Expand Up @@ -105,7 +101,7 @@ nonisolated let monitor64AccessTypes: [Node64.Monitor64AccessType] = [
]

nonisolated extension Node64.Monitor64HostKind {
var label: String { self == .unspecified ? "None" : rawValue }
var label: String { self == .unspecified ? String(localized: "None") : rawValue }
}

/// Access form fields. The server checks strictly "only fields of the access type", so only non-empty fields are sent.
Expand Down
Loading
Loading