Commit 49a999885f
49a999885fd23e59555429dbc111e3a3d87fd164
parent: fe83ff502f
Unsigned
cmc <hello@cleberg.net> · 2026-08-08 20:32 UTC
Add CodingKeys for external JSON decodables
Layout: unified · split
DomainDig/DNSLookupService.swift
+3 −3
| @@ -87,7 +87,7 @@ struct DNSLookupService { |
| 87 | 87 | } else { |
| 88 | 88 | value = answer.data.trimmingCharacters(in: CharacterSet(charactersIn: "\"")) |
| 89 | 89 | } |
| 90 | | return DNSRecord(value: value, ttl: answer.TTL) |
| 90 | return DNSRecord(value: value, ttl: answer.ttl) |
| 91 | 91 | } |
| 92 | 92 | } |
| 93 | 93 | |
| @@ -202,8 +202,8 @@ struct DNSLookupService { |
| 202 | 202 | let dnsResponse = try JSONDecoder().decode(CloudflareDNSResponse.self, from: data) |
| 203 | 203 | |
| 204 | 204 | return DNSLookupResponse( |
| 205 | | answers: dnsResponse.Answer ?? [], |
| 206 | | authenticatedData: dnsResponse.AD ?? false |
| 205 | answers: dnsResponse.answer ?? [], |
| 206 | authenticatedData: dnsResponse.authenticatedData ?? false |
| 207 | 207 | ) |
| 208 | 208 | } |
| 209 | 209 | |
DomainDig/DomainViewModel.swift
+1 −1
| @@ -3564,7 +3564,7 @@ final class DomainViewModel { |
| 3564 | 3564 | if let org = ipGeolocation.org { |
| 3565 | 3565 | rows.append(InfoRowViewData(label: "Org / ISP", value: org, tone: .secondary)) |
| 3566 | 3566 | } |
| 3567 | | let location = [ipGeolocation.city, ipGeolocation.region, ipGeolocation.country_name].compactMap { $0 }.joined(separator: ", ") |
| 3567 | let location = [ipGeolocation.city, ipGeolocation.region, ipGeolocation.countryName].compactMap { $0 }.joined(separator: ", ") |
| 3568 | 3568 | if !location.isEmpty { |
| 3569 | 3569 | rows.append(InfoRowViewData(label: "Location", value: location, tone: .secondary)) |
| 3570 | 3570 | } |
DomainDig/Models.swift
+23 −5
| @@ -2144,10 +2144,16 @@ struct IPGeolocation: Codable { |
| 2144 | 2144 | let ip: String |
| 2145 | 2145 | let city: String? |
| 2146 | 2146 | let region: String? |
| 2147 | | let country_name: String? |
| 2147 | let countryName: String? |
| 2148 | 2148 | let org: String? |
| 2149 | 2149 | let latitude: Double? |
| 2150 | 2150 | let longitude: Double? |
| 2151 | |
| 2152 | enum CodingKeys: String, CodingKey { |
| 2153 | case ip, city, region |
| 2154 | case countryName = "country_name" |
| 2155 | case org, latitude, longitude |
| 2156 | } |
| 2151 | 2157 | } |
| 2152 | 2158 | |
| 2153 | 2159 | // MARK: - Ownership Models |
| @@ -2616,14 +2622,26 @@ struct HistoryEntry: Identifiable, Codable { |
| 2616 | 2622 | // MARK: - Cloudflare DNS-over-HTTPS Response |
| 2617 | 2623 | |
| 2618 | 2624 | struct CloudflareDNSResponse: Decodable { |
| 2619 | | let Status: Int |
| 2620 | | let AD: Bool? |
| 2621 | | let Answer: [CloudflareDNSAnswer]? |
| 2625 | let status: Int |
| 2626 | let authenticatedData: Bool? |
| 2627 | let answer: [CloudflareDNSAnswer]? |
| 2628 | |
| 2629 | enum CodingKeys: String, CodingKey { |
| 2630 | case status = "Status" |
| 2631 | case authenticatedData = "AD" |
| 2632 | case answer = "Answer" |
| 2633 | } |
| 2622 | 2634 | |
| 2623 | 2635 | struct CloudflareDNSAnswer: Decodable { |
| 2624 | 2636 | let name: String |
| 2625 | 2637 | let type: Int |
| 2626 | | let TTL: Int |
| 2638 | let ttl: Int |
| 2627 | 2639 | let data: String |
| 2640 | |
| 2641 | enum CodingKeys: String, CodingKey { |
| 2642 | case name, type |
| 2643 | case ttl = "TTL" |
| 2644 | case data |
| 2645 | } |
| 2628 | 2646 | } |
| 2629 | 2647 | } |
DomainInspectionService.swift
+2 −2
| @@ -609,10 +609,10 @@ struct DomainInspectionService { |
| 609 | 609 | |
| 610 | 610 | private func confidenceForGeolocation(result: IPGeolocation?) -> ConfidenceLevel { |
| 611 | 611 | guard let result else { return .low } |
| 612 | | if result.city != nil && result.country_name != nil && result.latitude != nil && result.longitude != nil { |
| 612 | if result.city != nil && result.countryName != nil && result.latitude != nil && result.longitude != nil { |
| 613 | 613 | return .high |
| 614 | 614 | } |
| 615 | | if result.country_name != nil || result.org != nil { |
| 615 | if result.countryName != nil || result.org != nil { |
| 616 | 616 | return .medium |
| 617 | 617 | } |
| 618 | 618 | return .low |
DomainReportBuilder.swift
+1 −1
| @@ -440,7 +440,7 @@ struct DomainReportBuilder { |
| 440 | 440 | return snapshot.ipGeolocationError ?? "Unavailable" |
| 441 | 441 | } |
| 442 | 442 | |
| 443 | | let parts = [geolocation.city, geolocation.region, geolocation.country_name] |
| 443 | let parts = [geolocation.city, geolocation.region, geolocation.countryName] |
| 444 | 444 | .compactMap { $0?.trimmingCharacters(in: .whitespacesAndNewlines) } |
| 445 | 445 | .filter { !$0.isEmpty } |
| 446 | 446 | |