Commit be76f79456
Unsigned
Layout: unified · split
DomainDig/ContentView.swift +2 −34
| @@ -102,22 +102,7 @@ struct ContentView: View { | ||
| 102 | 102 | .padding(.top, appDensity.metrics.sectionSpacing) |
| 103 | 103 | WebSectionView( |
| 104 | 104 | isCollapsed: sectionCollapsedBinding(.web), |
| 105 | certificateRows: viewModel.webCertificateRows, | |
| 106 | sslInfo: viewModel.sslInfo, | |
| 107 | tlsSummary: viewModel.currentTLSSummary, | |
| 108 | sslLoading: viewModel.sslLoading || viewModel.hstsLoading, | |
| 109 | sslError: viewModel.sslError, | |
| 110 | tlsProvenance: viewModel.currentSnapshot.provenanceBySection[.ssl], | |
| 111 | responseRows: viewModel.webResponseRows, | |
| 112 | headers: viewModel.httpHeaders, | |
| 113 | headersLoading: viewModel.httpHeadersLoading, | |
| 114 | headersError: viewModel.httpHeadersError, | |
| 115 | httpProvenance: viewModel.currentSnapshot.provenanceBySection[.httpHeaders], | |
| 116 | redirects: viewModel.redirectRows, | |
| 117 | redirectLoading: viewModel.redirectChainLoading, | |
| 118 | redirectError: viewModel.redirectChainError, | |
| 119 | redirectProvenance: viewModel.currentSnapshot.provenanceBySection[.redirectChain], | |
| 120 | finalURL: viewModel.currentSnapshot.redirectChain.last?.url | |
| 105 | data: viewModel.webSectionData | |
| 121 | 106 | ) |
| 122 | 107 | .padding(.top, appDensity.metrics.sectionSpacing) |
| 123 | 108 | EmailSectionView( |
| @@ -132,26 +117,9 @@ struct ContentView: View { | ||
| 132 | 117 | .padding(.top, appDensity.metrics.sectionSpacing) |
| 133 | 118 | NetworkSectionView( |
| 134 | 119 | isCollapsed: sectionCollapsedBinding(.network), |
| 135 | reachabilityRows: viewModel.reachabilityRows, | |
| 136 | reachabilityLoading: viewModel.reachabilityLoading, | |
| 137 | reachabilityError: viewModel.reachabilityError, | |
| 138 | reachabilityProvenance: viewModel.currentSnapshot.provenanceBySection[.reachability], | |
| 139 | locationRows: viewModel.locationRows, | |
| 140 | geolocation: viewModel.ipGeolocation, | |
| 141 | geolocationLoading: viewModel.ipGeolocationLoading, | |
| 142 | geolocationError: viewModel.ipGeolocationError, | |
| 143 | geolocationProvenance: viewModel.currentSnapshot.provenanceBySection[.ipGeolocation], | |
| 144 | geolocationConfidence: viewModel.currentSnapshot.geolocationConfidence, | |
| 145 | standardPortRows: viewModel.standardPortRows, | |
| 146 | customPortRows: viewModel.customPortRows, | |
| 147 | portScanLoading: viewModel.portScanLoading, | |
| 148 | portScanError: viewModel.portScanError, | |
| 149 | portScanProvenance: viewModel.currentSnapshot.provenanceBySection[.portScan], | |
| 150 | customPortScanLoading: viewModel.customPortScanLoading, | |
| 151 | customPortScanError: viewModel.customPortScanError, | |
| 152 | isCloudflareProxied: viewModel.isCloudflareProxied, | |
| 153 | 120 | customPortsExpanded: $customPortsExpanded, |
| 154 | 121 | customPortInput: $customPortInput, |
| 122 | data: viewModel.networkSectionData, | |
| 155 | 123 | onScanCustomPorts: runCustomPortScan |
| 156 | 124 | ) |
| 157 | 125 | .padding(.top, appDensity.metrics.sectionSpacing) |
DomainDig/DomainViewModel.swift +112
| @@ -747,6 +747,118 @@ final class DomainViewModel { | ||
| 747 | 747 | Self.ptrMessage(from: currentSnapshot) |
| 748 | 748 | } |
| 749 | 749 | |
| 750 | /// The same two slices built from a stored snapshot, for the history | |
| 751 | /// detail view. Nothing is in flight there, so every panel is settled. | |
| 752 | static func webSectionData(from snapshot: LookupSnapshot, report: DomainReport) -> WebSectionViewData { | |
| 753 | WebSectionViewData( | |
| 754 | tls: SectionPanelViewData( | |
| 755 | error: snapshot.sslError, | |
| 756 | provenance: snapshot.provenanceBySection[.ssl] | |
| 757 | ), | |
| 758 | certificateRows: webCertificateRows(from: snapshot), | |
| 759 | sslInfo: snapshot.sslInfo, | |
| 760 | tlsSummary: report.web, | |
| 761 | http: SectionPanelViewData( | |
| 762 | error: snapshot.httpHeadersError, | |
| 763 | provenance: snapshot.provenanceBySection[.httpHeaders] | |
| 764 | ), | |
| 765 | responseRows: webResponseRows(from: snapshot), | |
| 766 | headers: snapshot.httpHeaders, | |
| 767 | redirect: SectionPanelViewData( | |
| 768 | error: snapshot.redirectChainError, | |
| 769 | provenance: snapshot.provenanceBySection[.redirectChain] | |
| 770 | ), | |
| 771 | redirectRows: redirectRows(from: snapshot), | |
| 772 | finalURL: snapshot.redirectChain.last?.url | |
| 773 | ) | |
| 774 | } | |
| 775 | ||
| 776 | static func networkSectionData(from snapshot: LookupSnapshot) -> NetworkSectionViewData { | |
| 777 | NetworkSectionViewData( | |
| 778 | reachability: SectionPanelViewData( | |
| 779 | error: snapshot.reachabilityError, | |
| 780 | provenance: snapshot.provenanceBySection[.reachability] | |
| 781 | ), | |
| 782 | reachabilityRows: reachabilityRows(from: snapshot), | |
| 783 | location: SectionPanelViewData( | |
| 784 | error: snapshot.ipGeolocationError, | |
| 785 | provenance: snapshot.provenanceBySection[.ipGeolocation], | |
| 786 | confidence: snapshot.geolocationConfidence | |
| 787 | ), | |
| 788 | locationRows: locationRows(from: snapshot), | |
| 789 | geolocation: snapshot.ipGeolocation, | |
| 790 | portScan: SectionPanelViewData( | |
| 791 | error: snapshot.portScanError, | |
| 792 | provenance: snapshot.provenanceBySection[.portScan] | |
| 793 | ), | |
| 794 | standardPortRows: portRows(from: snapshot, kind: .standard), | |
| 795 | customPortRows: portRows(from: snapshot, kind: .custom), | |
| 796 | isCloudflareProxied: snapshot.httpHeaders.contains { $0.name.lowercased() == "cf-ray" } | |
| 797 | ) | |
| 798 | } | |
| 799 | ||
| 800 | /// Everything the Web section draws, assembled in one place. The call | |
| 801 | /// site used to name seventeen arguments and had to keep their order | |
| 802 | /// straight; this groups them by the card they belong to (A10). | |
| 803 | var webSectionData: WebSectionViewData { | |
| 804 | WebSectionViewData( | |
| 805 | tls: SectionPanelViewData( | |
| 806 | isLoading: sslLoading || hstsLoading, | |
| 807 | error: sslError, | |
| 808 | provenance: currentSnapshot.provenanceBySection[.ssl] | |
| 809 | ), | |
| 810 | certificateRows: webCertificateRows, | |
| 811 | sslInfo: sslInfo, | |
| 812 | tlsSummary: currentTLSSummary, | |
| 813 | http: SectionPanelViewData( | |
| 814 | isLoading: httpHeadersLoading, | |
| 815 | error: httpHeadersError, | |
| 816 | provenance: currentSnapshot.provenanceBySection[.httpHeaders] | |
| 817 | ), | |
| 818 | responseRows: webResponseRows, | |
| 819 | headers: httpHeaders, | |
| 820 | redirect: SectionPanelViewData( | |
| 821 | isLoading: redirectChainLoading, | |
| 822 | error: redirectChainError, | |
| 823 | provenance: currentSnapshot.provenanceBySection[.redirectChain] | |
| 824 | ), | |
| 825 | redirectRows: redirectRows, | |
| 826 | finalURL: currentSnapshot.redirectChain.last?.url | |
| 827 | ) | |
| 828 | } | |
| 829 | ||
| 830 | /// Everything the Network section draws. Twenty-two arguments before. | |
| 831 | var networkSectionData: NetworkSectionViewData { | |
| 832 | NetworkSectionViewData( | |
| 833 | reachability: SectionPanelViewData( | |
| 834 | isLoading: reachabilityLoading, | |
| 835 | error: reachabilityError, | |
| 836 | provenance: currentSnapshot.provenanceBySection[.reachability] | |
| 837 | ), | |
| 838 | reachabilityRows: reachabilityRows, | |
| 839 | location: SectionPanelViewData( | |
| 840 | isLoading: ipGeolocationLoading, | |
| 841 | error: ipGeolocationError, | |
| 842 | provenance: currentSnapshot.provenanceBySection[.ipGeolocation], | |
| 843 | confidence: currentSnapshot.geolocationConfidence | |
| 844 | ), | |
| 845 | locationRows: locationRows, | |
| 846 | geolocation: ipGeolocation, | |
| 847 | portScan: SectionPanelViewData( | |
| 848 | isLoading: portScanLoading, | |
| 849 | error: portScanError, | |
| 850 | provenance: currentSnapshot.provenanceBySection[.portScan] | |
| 851 | ), | |
| 852 | standardPortRows: standardPortRows, | |
| 853 | customPortRows: customPortRows, | |
| 854 | customPortScan: SectionPanelViewData( | |
| 855 | isLoading: customPortScanLoading, | |
| 856 | error: customPortScanError | |
| 857 | ), | |
| 858 | isCloudflareProxied: isCloudflareProxied | |
| 859 | ) | |
| 860 | } | |
| 861 | ||
| 750 | 862 | var webCertificateRows: [InfoRowViewData] { |
| 751 | 863 | Self.webCertificateRows(from: currentSnapshot) |
| 752 | 864 | } |
DomainDig/HistoryView.swift +2 −34
| @@ -260,22 +260,7 @@ struct HistoryDetailView: View { | ||
| 260 | 260 | .padding(.top, appDensity.metrics.sectionSpacing) |
| 261 | 261 | WebSectionView( |
| 262 | 262 | isCollapsed: .constant(false), |
| 263 | certificateRows: DomainViewModel.webCertificateRows(from: snapshot), | |
| 264 | sslInfo: snapshot.sslInfo, | |
| 265 | tlsSummary: report.web, | |
| 266 | sslLoading: false, | |
| 267 | sslError: snapshot.sslError, | |
| 268 | tlsProvenance: snapshot.provenanceBySection[.ssl], | |
| 269 | responseRows: DomainViewModel.webResponseRows(from: snapshot), | |
| 270 | headers: snapshot.httpHeaders, | |
| 271 | headersLoading: false, | |
| 272 | headersError: snapshot.httpHeadersError, | |
| 273 | httpProvenance: snapshot.provenanceBySection[.httpHeaders], | |
| 274 | redirects: DomainViewModel.redirectRows(from: snapshot), | |
| 275 | redirectLoading: false, | |
| 276 | redirectError: snapshot.redirectChainError, | |
| 277 | redirectProvenance: snapshot.provenanceBySection[.redirectChain], | |
| 278 | finalURL: snapshot.redirectChain.last?.url | |
| 263 | data: DomainViewModel.webSectionData(from: snapshot, report: report) | |
| 279 | 264 | ) |
| 280 | 265 | .padding(.top, appDensity.metrics.sectionSpacing) |
| 281 | 266 | EmailSectionView( |
| @@ -290,26 +275,9 @@ struct HistoryDetailView: View { | ||
| 290 | 275 | .padding(.top, appDensity.metrics.sectionSpacing) |
| 291 | 276 | NetworkSectionView( |
| 292 | 277 | isCollapsed: .constant(false), |
| 293 | reachabilityRows: DomainViewModel.reachabilityRows(from: snapshot), | |
| 294 | reachabilityLoading: false, | |
| 295 | reachabilityError: snapshot.reachabilityError, | |
| 296 | reachabilityProvenance: snapshot.provenanceBySection[.reachability], | |
| 297 | locationRows: DomainViewModel.locationRows(from: snapshot), | |
| 298 | geolocation: snapshot.ipGeolocation, | |
| 299 | geolocationLoading: false, | |
| 300 | geolocationError: snapshot.ipGeolocationError, | |
| 301 | geolocationProvenance: snapshot.provenanceBySection[.ipGeolocation], | |
| 302 | geolocationConfidence: snapshot.geolocationConfidence, | |
| 303 | standardPortRows: DomainViewModel.portRows(from: snapshot, kind: .standard), | |
| 304 | customPortRows: DomainViewModel.portRows(from: snapshot, kind: .custom), | |
| 305 | portScanLoading: false, | |
| 306 | portScanError: snapshot.portScanError, | |
| 307 | portScanProvenance: snapshot.provenanceBySection[.portScan], | |
| 308 | customPortScanLoading: false, | |
| 309 | customPortScanError: nil, | |
| 310 | isCloudflareProxied: snapshot.httpHeaders.contains(where: { $0.name.lowercased() == "cf-ray" }), | |
| 311 | 278 | customPortsExpanded: .constant(false), |
| 312 | 279 | customPortInput: .constant(""), |
| 280 | data: DomainViewModel.networkSectionData(from: snapshot), | |
| 313 | 281 | onScanCustomPorts: { /* Historical snapshot; re-scanning is not offered here. */ } |
| 314 | 282 | ) |
| 315 | 283 | .padding(.top, appDensity.metrics.sectionSpacing) |
DomainDig/ResultSectionViews.swift +140 −34
| @@ -677,22 +677,43 @@ struct DNSSectionView: View { | ||
| 677 | 677 | struct WebSectionView: View { |
| 678 | 678 | @Environment(\.appDensity) private var appDensity |
| 679 | 679 | @Binding var isCollapsed: Bool |
| 680 | let certificateRows: [InfoRowViewData] | |
| 681 | let sslInfo: SSLCertificateInfo? | |
| 682 | let tlsSummary: WebResultSummary? | |
| 683 | let sslLoading: Bool | |
| 684 | let sslError: String? | |
| 685 | let tlsProvenance: SectionProvenance? | |
| 686 | let responseRows: [InfoRowViewData] | |
| 687 | let headers: [HTTPHeader] | |
| 688 | let headersLoading: Bool | |
| 689 | let headersError: String? | |
| 690 | let httpProvenance: SectionProvenance? | |
| 691 | let redirects: [RedirectHopViewData] | |
| 692 | let redirectLoading: Bool | |
| 693 | let redirectError: String? | |
| 694 | let redirectProvenance: SectionProvenance? | |
| 695 | let finalURL: String? | |
| 680 | ||
| 681 | private let certificateRows: [InfoRowViewData] | |
| 682 | private let sslInfo: SSLCertificateInfo? | |
| 683 | private let tlsSummary: WebResultSummary? | |
| 684 | private let sslLoading: Bool | |
| 685 | private let sslError: String? | |
| 686 | private let tlsProvenance: SectionProvenance? | |
| 687 | private let responseRows: [InfoRowViewData] | |
| 688 | private let headers: [HTTPHeader] | |
| 689 | private let headersLoading: Bool | |
| 690 | private let headersError: String? | |
| 691 | private let httpProvenance: SectionProvenance? | |
| 692 | private let redirects: [RedirectHopViewData] | |
| 693 | private let redirectLoading: Bool | |
| 694 | private let redirectError: String? | |
| 695 | private let redirectProvenance: SectionProvenance? | |
| 696 | private let finalURL: String? | |
| 697 | ||
| 698 | init(isCollapsed: Binding<Bool>, data: WebSectionViewData) { | |
| 699 | _isCollapsed = isCollapsed | |
| 700 | certificateRows = data.certificateRows | |
| 701 | sslInfo = data.sslInfo | |
| 702 | tlsSummary = data.tlsSummary | |
| 703 | sslLoading = data.tls.isLoading | |
| 704 | sslError = data.tls.error | |
| 705 | tlsProvenance = data.tls.provenance | |
| 706 | responseRows = data.responseRows | |
| 707 | headers = data.headers | |
| 708 | headersLoading = data.http.isLoading | |
| 709 | headersError = data.http.error | |
| 710 | httpProvenance = data.http.provenance | |
| 711 | redirects = data.redirectRows | |
| 712 | redirectLoading = data.redirect.isLoading | |
| 713 | redirectError = data.redirect.error | |
| 714 | redirectProvenance = data.redirect.provenance | |
| 715 | finalURL = data.finalURL | |
| 716 | } | |
| 696 | 717 | |
| 697 | 718 | var body: some View { |
| 698 | 719 | CollapsibleSectionView(title: "Web", isCollapsed: $isCollapsed) { |
| @@ -911,28 +932,60 @@ struct EmailSectionView: View { | ||
| 911 | 932 | struct NetworkSectionView: View { |
| 912 | 933 | @Environment(\.appDensity) private var appDensity |
| 913 | 934 | @Binding var isCollapsed: Bool |
| 914 | let reachabilityRows: [ReachabilityRowViewData] | |
| 915 | let reachabilityLoading: Bool | |
| 916 | let reachabilityError: String? | |
| 917 | let reachabilityProvenance: SectionProvenance? | |
| 918 | let locationRows: [InfoRowViewData] | |
| 919 | let geolocation: IPGeolocation? | |
| 920 | let geolocationLoading: Bool | |
| 921 | let geolocationError: String? | |
| 922 | let geolocationProvenance: SectionProvenance? | |
| 923 | let geolocationConfidence: ConfidenceLevel? | |
| 924 | let standardPortRows: [PortScanRowViewData] | |
| 925 | let customPortRows: [PortScanRowViewData] | |
| 926 | let portScanLoading: Bool | |
| 927 | let portScanError: String? | |
| 928 | let portScanProvenance: SectionProvenance? | |
| 929 | let customPortScanLoading: Bool | |
| 930 | let customPortScanError: String? | |
| 931 | let isCloudflareProxied: Bool | |
| 932 | 935 | @Binding var customPortsExpanded: Bool |
| 933 | 936 | @Binding var customPortInput: String |
| 934 | 937 | let onScanCustomPorts: () -> Void |
| 935 | 938 | |
| 939 | private let reachabilityRows: [ReachabilityRowViewData] | |
| 940 | private let reachabilityLoading: Bool | |
| 941 | private let reachabilityError: String? | |
| 942 | private let reachabilityProvenance: SectionProvenance? | |
| 943 | private let locationRows: [InfoRowViewData] | |
| 944 | private let geolocation: IPGeolocation? | |
| 945 | private let geolocationLoading: Bool | |
| 946 | private let geolocationError: String? | |
| 947 | private let geolocationProvenance: SectionProvenance? | |
| 948 | private let geolocationConfidence: ConfidenceLevel? | |
| 949 | private let standardPortRows: [PortScanRowViewData] | |
| 950 | private let customPortRows: [PortScanRowViewData] | |
| 951 | private let portScanLoading: Bool | |
| 952 | private let portScanError: String? | |
| 953 | private let portScanProvenance: SectionProvenance? | |
| 954 | private let customPortScanLoading: Bool | |
| 955 | private let customPortScanError: String? | |
| 956 | private let isCloudflareProxied: Bool | |
| 957 | ||
| 958 | init( | |
| 959 | isCollapsed: Binding<Bool>, | |
| 960 | customPortsExpanded: Binding<Bool>, | |
| 961 | customPortInput: Binding<String>, | |
| 962 | data: NetworkSectionViewData, | |
| 963 | onScanCustomPorts: @escaping () -> Void | |
| 964 | ) { | |
| 965 | _isCollapsed = isCollapsed | |
| 966 | _customPortsExpanded = customPortsExpanded | |
| 967 | _customPortInput = customPortInput | |
| 968 | self.onScanCustomPorts = onScanCustomPorts | |
| 969 | reachabilityRows = data.reachabilityRows | |
| 970 | reachabilityLoading = data.reachability.isLoading | |
| 971 | reachabilityError = data.reachability.error | |
| 972 | reachabilityProvenance = data.reachability.provenance | |
| 973 | locationRows = data.locationRows | |
| 974 | geolocation = data.geolocation | |
| 975 | geolocationLoading = data.location.isLoading | |
| 976 | geolocationError = data.location.error | |
| 977 | geolocationProvenance = data.location.provenance | |
| 978 | geolocationConfidence = data.location.confidence | |
| 979 | standardPortRows = data.standardPortRows | |
| 980 | customPortRows = data.customPortRows | |
| 981 | portScanLoading = data.portScan.isLoading | |
| 982 | portScanError = data.portScan.error | |
| 983 | portScanProvenance = data.portScan.provenance | |
| 984 | customPortScanLoading = data.customPortScan.isLoading | |
| 985 | customPortScanError = data.customPortScan.error | |
| 986 | isCloudflareProxied = data.isCloudflareProxied | |
| 987 | } | |
| 988 | ||
| 936 | 989 | var body: some View { |
| 937 | 990 | CollapsibleSectionView(title: "Network", isCollapsed: $isCollapsed) { |
| 938 | 991 | CardView { |
| @@ -1117,3 +1170,56 @@ struct PortRowsView: View { | ||
| 1117 | 1170 | } |
| 1118 | 1171 | } |
| 1119 | 1172 | } |
| 1173 | ||
| 1174 | // MARK: - Section view data | |
| 1175 | ||
| 1176 | /// What one card inside a result section needs to know about its own state: | |
| 1177 | /// whether the data is still arriving, what failed, where it came from and how | |
| 1178 | /// much to trust it. | |
| 1179 | /// | |
| 1180 | /// These four travelled as a positional group repeated once per card, which is | |
| 1181 | /// how `NetworkSectionView` came to declare 22 init parameters and | |
| 1182 | /// `WebSectionView` 17 (A10). The views keep their own stored properties — | |
| 1183 | /// unpacking happens in the init, so the bodies are unchanged — but a caller | |
| 1184 | /// now names three groups instead of counting out twenty-two arguments. | |
| 1185 | struct SectionPanelViewData { | |
| 1186 | var isLoading = false | |
| 1187 | var error: String? | |
| 1188 | var provenance: SectionProvenance? | |
| 1189 | var confidence: ConfidenceLevel? | |
| 1190 | } | |
| 1191 | ||
| 1192 | /// The Web section's three cards: TLS, headers, redirects. | |
| 1193 | struct WebSectionViewData { | |
| 1194 | var tls = SectionPanelViewData() | |
| 1195 | var certificateRows: [InfoRowViewData] = [] | |
| 1196 | var sslInfo: SSLCertificateInfo? | |
| 1197 | var tlsSummary: WebResultSummary? | |
| 1198 | ||
| 1199 | var http = SectionPanelViewData() | |
| 1200 | var responseRows: [InfoRowViewData] = [] | |
| 1201 | var headers: [HTTPHeader] = [] | |
| 1202 | ||
| 1203 | var redirect = SectionPanelViewData() | |
| 1204 | var redirectRows: [RedirectHopViewData] = [] | |
| 1205 | var finalURL: String? | |
| 1206 | } | |
| 1207 | ||
| 1208 | /// The Network section's cards: reachability, location, ports. Custom port | |
| 1209 | /// scanning carries its own state because it runs separately, after the user | |
| 1210 | /// asks for it. | |
| 1211 | struct NetworkSectionViewData { | |
| 1212 | var reachability = SectionPanelViewData() | |
| 1213 | var reachabilityRows: [ReachabilityRowViewData] = [] | |
| 1214 | ||
| 1215 | var location = SectionPanelViewData() | |
| 1216 | var locationRows: [InfoRowViewData] = [] | |
| 1217 | var geolocation: IPGeolocation? | |
| 1218 | ||
| 1219 | var portScan = SectionPanelViewData() | |
| 1220 | var standardPortRows: [PortScanRowViewData] = [] | |
| 1221 | var customPortRows: [PortScanRowViewData] = [] | |
| 1222 | var customPortScan = SectionPanelViewData() | |
| 1223 | ||
| 1224 | var isCloudflareProxied = false | |
| 1225 | } | |