LookupSnapshot.swift
121 lines · 4442 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 dnsSections: [DNSSection]
24 let dnsError: String?
25 let availabilityResult: DomainAvailabilityResult?
26 let suggestions: [DomainSuggestionResult]
27 let sslInfo: SSLCertificateInfo?
28 let sslError: String?
29 let hstsPreloaded: Bool?
30 let httpHeaders: [HTTPHeader]
31 let httpSecurityGrade: String?
32 let httpStatusCode: Int?
33 let httpResponseTimeMs: Int?
34 let httpProtocol: String?
35 let http3Advertised: Bool
36 let httpHeadersError: String?
37 let reachabilityResults: [PortReachability]
38 let reachabilityError: String?
39 let ipGeolocation: IPGeolocation?
40 let ipGeolocationError: String?
41 let emailSecurity: EmailSecurityResult?
42 let emailSecurityError: String?
43 let ownership: DomainOwnership?
44 let ownershipError: String?
45 let ptrRecord: String?
46 let ptrError: String?
47 let redirectChain: [RedirectHop]
48 let redirectChainError: String?
49 let subdomains: [DiscoveredSubdomain]
50 let subdomainsError: String?
51 let portScanResults: [PortScanResult]
52 let portScanError: String?
53 let changeSummary: DomainChangeSummary?
54 let resultSource: LookupResultSource
55 let cachedSections: [LookupSectionKind]
56 let statusMessage: String?
57
58 var isLive: Bool {
59 resultSource == .live
60 }
61}
62
63extension HistoryEntry {
64 var snapshot: LookupSnapshot {
65 LookupSnapshot(
66 historyEntryID: id,
67 domain: domain,
68 timestamp: timestamp,
69 trackedDomainID: trackedDomainID,
70 note: note,
71 appVersion: appVersion,
72 resolverDisplayName: resolverDisplayName,
73 resolverURLString: resolverURLString,
74 dataSources: dataSources,
75 provenanceBySection: provenanceBySection,
76 availabilityConfidence: availabilityConfidence,
77 ownershipConfidence: ownershipConfidence,
78 subdomainConfidence: subdomainConfidence,
79 emailSecurityConfidence: emailSecurityConfidence,
80 geolocationConfidence: geolocationConfidence,
81 errorDetails: errorDetails,
82 isPartialSnapshot: isPartialSnapshot,
83 validationIssues: validationIssues,
84 totalLookupDurationMs: totalLookupDurationMs,
85 dnsSections: dnsSections,
86 dnsError: nil,
87 availabilityResult: availabilityResult,
88 suggestions: suggestions,
89 sslInfo: sslInfo,
90 sslError: sslError,
91 hstsPreloaded: hstsPreloaded,
92 httpHeaders: httpHeaders,
93 httpSecurityGrade: HTTPSecurityGrade.grade(for: httpHeaders).rawValue,
94 httpStatusCode: nil,
95 httpResponseTimeMs: nil,
96 httpProtocol: nil,
97 http3Advertised: false,
98 httpHeadersError: httpHeadersError,
99 reachabilityResults: reachabilityResults,
100 reachabilityError: reachabilityError,
101 ipGeolocation: ipGeolocation,
102 ipGeolocationError: ipGeolocationError,
103 emailSecurity: emailSecurity,
104 emailSecurityError: emailSecurityError,
105 ownership: ownership,
106 ownershipError: ownershipError,
107 ptrRecord: ptrRecord,
108 ptrError: ptrError,
109 redirectChain: redirectChain,
110 redirectChainError: redirectChainError,
111 subdomains: subdomains,
112 subdomainsError: subdomainsError,
113 portScanResults: portScanResults,
114 portScanError: portScanError,
115 changeSummary: changeSummary,
116 resultSource: resultSource,
117 cachedSections: [],
118 statusMessage: nil
119 )
120 }
121}