diff options
| author | Christian Cleberg <[email protected]> | 2026-08-08 15:32:26 -0500 |
|---|---|---|
| committer | Christian Cleberg <[email protected]> | 2026-08-08 15:32:26 -0500 |
| commit | 49a999885fd23e59555429dbc111e3a3d87fd164 (patch) | |
| tree | 7818bbb9f81db35b4de140bb667d02e0dfdca2ab | |
| parent | fe83ff502ffcaa59c7a22471c634d565972e7644 (diff) | |
| download | domain-dig-sonarcloud-cleanup.tar.gz domain-dig-sonarcloud-cleanup.tar.bz2 domain-dig-sonarcloud-cleanup.zip | |
Add CodingKeys for external JSON decodablessonarcloud-cleanup
| -rw-r--r-- | DomainDig/DNSLookupService.swift | 6 | ||||
| -rw-r--r-- | DomainDig/DomainViewModel.swift | 2 | ||||
| -rw-r--r-- | DomainDig/Models.swift | 28 | ||||
| -rw-r--r-- | DomainInspectionService.swift | 4 | ||||
| -rw-r--r-- | DomainReportBuilder.swift | 2 |
5 files changed, 30 insertions, 12 deletions
diff --git a/DomainDig/DNSLookupService.swift b/DomainDig/DNSLookupService.swift index 8c8d53c..00ca13b 100644 --- a/DomainDig/DNSLookupService.swift +++ b/DomainDig/DNSLookupService.swift @@ -87,7 +87,7 @@ struct DNSLookupService { } else { value = answer.data.trimmingCharacters(in: CharacterSet(charactersIn: "\"")) } - return DNSRecord(value: value, ttl: answer.TTL) + return DNSRecord(value: value, ttl: answer.ttl) } } @@ -202,8 +202,8 @@ struct DNSLookupService { let dnsResponse = try JSONDecoder().decode(CloudflareDNSResponse.self, from: data) return DNSLookupResponse( - answers: dnsResponse.Answer ?? [], - authenticatedData: dnsResponse.AD ?? false + answers: dnsResponse.answer ?? [], + authenticatedData: dnsResponse.authenticatedData ?? false ) } diff --git a/DomainDig/DomainViewModel.swift b/DomainDig/DomainViewModel.swift index 7246112..c6ebf4f 100644 --- a/DomainDig/DomainViewModel.swift +++ b/DomainDig/DomainViewModel.swift @@ -3564,7 +3564,7 @@ final class DomainViewModel { if let org = ipGeolocation.org { rows.append(InfoRowViewData(label: "Org / ISP", value: org, tone: .secondary)) } - let location = [ipGeolocation.city, ipGeolocation.region, ipGeolocation.country_name].compactMap { $0 }.joined(separator: ", ") + let location = [ipGeolocation.city, ipGeolocation.region, ipGeolocation.countryName].compactMap { $0 }.joined(separator: ", ") if !location.isEmpty { rows.append(InfoRowViewData(label: "Location", value: location, tone: .secondary)) } diff --git a/DomainDig/Models.swift b/DomainDig/Models.swift index d83dc79..e93fb46 100644 --- a/DomainDig/Models.swift +++ b/DomainDig/Models.swift @@ -2144,10 +2144,16 @@ struct IPGeolocation: Codable { let ip: String let city: String? let region: String? - let country_name: String? + let countryName: String? let org: String? let latitude: Double? let longitude: Double? + + enum CodingKeys: String, CodingKey { + case ip, city, region + case countryName = "country_name" + case org, latitude, longitude + } } // MARK: - Ownership Models @@ -2616,14 +2622,26 @@ struct HistoryEntry: Identifiable, Codable { // MARK: - Cloudflare DNS-over-HTTPS Response struct CloudflareDNSResponse: Decodable { - let Status: Int - let AD: Bool? - let Answer: [CloudflareDNSAnswer]? + let status: Int + let authenticatedData: Bool? + let answer: [CloudflareDNSAnswer]? + + enum CodingKeys: String, CodingKey { + case status = "Status" + case authenticatedData = "AD" + case answer = "Answer" + } struct CloudflareDNSAnswer: Decodable { let name: String let type: Int - let TTL: Int + let ttl: Int let data: String + + enum CodingKeys: String, CodingKey { + case name, type + case ttl = "TTL" + case data + } } } diff --git a/DomainInspectionService.swift b/DomainInspectionService.swift index 3ebfe09..730d172 100644 --- a/DomainInspectionService.swift +++ b/DomainInspectionService.swift @@ -609,10 +609,10 @@ struct DomainInspectionService { private func confidenceForGeolocation(result: IPGeolocation?) -> ConfidenceLevel { guard let result else { return .low } - if result.city != nil && result.country_name != nil && result.latitude != nil && result.longitude != nil { + if result.city != nil && result.countryName != nil && result.latitude != nil && result.longitude != nil { return .high } - if result.country_name != nil || result.org != nil { + if result.countryName != nil || result.org != nil { return .medium } return .low diff --git a/DomainReportBuilder.swift b/DomainReportBuilder.swift index 4068c0a..7887fc6 100644 --- a/DomainReportBuilder.swift +++ b/DomainReportBuilder.swift @@ -440,7 +440,7 @@ struct DomainReportBuilder { return snapshot.ipGeolocationError ?? "Unavailable" } - let parts = [geolocation.city, geolocation.region, geolocation.country_name] + let parts = [geolocation.city, geolocation.region, geolocation.countryName] .compactMap { $0?.trimmingCharacters(in: .whitespacesAndNewlines) } .filter { !$0.isEmpty } |
