LookupSnapshot.swift

cc69cbd7e589ec4b065ce74d8c5e7714a040cfc5
domain-dig/LookupSnapshot.swift history · blame · raw

145 lines · 5482 bytes

  1import Foundation
  2
  3struct LookupSnapshot {
  4    let historyEntryID: UUID?
  5    let domain: String
  6    let timestamp: Date
  7    let trackedDomainID: UUID?
  8    let note: String?
  9    let appVersion: String
 10    let resolverDisplayName: String
 11    let resolverURLString: String
 12    let dataSources: [String]
 13    let provenanceBySection: [LookupSectionKind: SectionProvenance]
 14    let availabilityConfidence: ConfidenceLevel?
 15    let ownershipConfidence: ConfidenceLevel?
 16    let subdomainConfidence: ConfidenceLevel?
 17    let emailSecurityConfidence: ConfidenceLevel?
 18    let geolocationConfidence: ConfidenceLevel?
 19    let errorDetails: [LookupSectionKind: InspectionFailure]
 20    let isPartialSnapshot: Bool
 21    let validationIssues: [String]
 22    let totalLookupDurationMs: Int?
 23    let snapshotIndex: Int?
 24    let previousSnapshotID: UUID?
 25    let changeCount: Int
 26    let severitySummary: ChangeSeverity?
 27    let dnsSections: [DNSSection]
 28    let dnsError: String?
 29    let availabilityResult: DomainAvailabilityResult?
 30    let suggestions: [DomainSuggestionResult]
 31    let sslInfo: SSLCertificateInfo?
 32    let sslError: String?
 33    let hstsPreloaded: Bool?
 34    let httpHeaders: [HTTPHeader]
 35    let httpSecurityGrade: String?
 36    let httpStatusCode: Int?
 37    let httpResponseTimeMs: Int?
 38    let httpProtocol: String?
 39    let http3Advertised: Bool
 40    let httpHeadersError: String?
 41    let reachabilityResults: [PortReachability]
 42    let reachabilityError: String?
 43    let ipGeolocation: IPGeolocation?
 44    let ipGeolocationError: String?
 45    let emailSecurity: EmailSecurityResult?
 46    let emailSecurityError: String?
 47    let ownership: DomainOwnership?
 48    let ownershipError: String?
 49    let ownershipHistory: [DomainOwnershipHistoryEvent]
 50    let ownershipHistoryError: String?
 51    let ptrRecord: String?
 52    let ptrError: String?
 53    let redirectChain: [RedirectHop]
 54    let redirectChainError: String?
 55    let subdomains: [DiscoveredSubdomain]
 56    let subdomainsError: String?
 57    let extendedSubdomains: [DiscoveredSubdomain]
 58    let extendedSubdomainsError: String?
 59    let dnsHistory: [DNSHistoryEvent]
 60    let dnsHistoryError: String?
 61    let domainPricing: DomainPricingInsight?
 62    let domainPricingError: String?
 63    let portScanResults: [PortScanResult]
 64    let portScanError: String?
 65    let changeSummary: DomainChangeSummary?
 66    let resultSource: LookupResultSource
 67    let cachedSections: [LookupSectionKind]
 68    let statusMessage: String?
 69
 70    var isLive: Bool {
 71        resultSource == .live
 72    }
 73}
 74
 75extension HistoryEntry {
 76    var snapshot: LookupSnapshot {
 77        LookupSnapshot(
 78            historyEntryID: id,
 79            domain: domain,
 80            timestamp: timestamp,
 81            trackedDomainID: trackedDomainID,
 82            note: note,
 83            appVersion: appVersion,
 84            resolverDisplayName: resolverDisplayName,
 85            resolverURLString: resolverURLString,
 86            dataSources: dataSources,
 87            provenanceBySection: provenanceBySection,
 88            availabilityConfidence: availabilityConfidence,
 89            ownershipConfidence: ownershipConfidence,
 90            subdomainConfidence: subdomainConfidence,
 91            emailSecurityConfidence: emailSecurityConfidence,
 92            geolocationConfidence: geolocationConfidence,
 93            errorDetails: errorDetails,
 94            isPartialSnapshot: isPartialSnapshot,
 95            validationIssues: validationIssues,
 96            totalLookupDurationMs: totalLookupDurationMs,
 97            snapshotIndex: snapshotIndex,
 98            previousSnapshotID: previousSnapshotID,
 99            changeCount: changeCount,
100            severitySummary: severitySummary,
101            dnsSections: dnsSections,
102            dnsError: nil,
103            availabilityResult: availabilityResult,
104            suggestions: suggestions,
105            sslInfo: sslInfo,
106            sslError: sslError,
107            hstsPreloaded: hstsPreloaded,
108            httpHeaders: httpHeaders,
109            httpSecurityGrade: HTTPSecurityGrade.grade(for: httpHeaders).rawValue,
110            httpStatusCode: nil,
111            httpResponseTimeMs: nil,
112            httpProtocol: nil,
113            http3Advertised: false,
114            httpHeadersError: httpHeadersError,
115            reachabilityResults: reachabilityResults,
116            reachabilityError: reachabilityError,
117            ipGeolocation: ipGeolocation,
118            ipGeolocationError: ipGeolocationError,
119            emailSecurity: emailSecurity,
120            emailSecurityError: emailSecurityError,
121            ownership: ownership,
122            ownershipError: ownershipError,
123            ownershipHistory: ownershipHistory,
124            ownershipHistoryError: ownershipHistoryError,
125            ptrRecord: ptrRecord,
126            ptrError: ptrError,
127            redirectChain: redirectChain,
128            redirectChainError: redirectChainError,
129            subdomains: subdomains,
130            subdomainsError: subdomainsError,
131            extendedSubdomains: extendedSubdomains,
132            extendedSubdomainsError: extendedSubdomainsError,
133            dnsHistory: dnsHistory,
134            dnsHistoryError: dnsHistoryError,
135            domainPricing: domainPricing,
136            domainPricingError: domainPricingError,
137            portScanResults: portScanResults,
138            portScanError: portScanError,
139            changeSummary: changeSummary,
140            resultSource: resultSource,
141            cachedSections: [],
142            statusMessage: nil
143        )
144    }
145}