summaryrefslogtreecommitdiff
path: root/DomainDig/DNSLookupService.swift
diff options
context:
space:
mode:
authorChristian Cleberg <[email protected]>2026-04-20 15:28:12 -0500
committerChristian Cleberg <[email protected]>2026-04-20 15:28:12 -0500
commitee2520f2c0c2d806fd284c3d6b8a81a3822f5270 (patch)
tree0680550a1071e01546ba074c2f20b1bf5a452238 /DomainDig/DNSLookupService.swift
parent4e94ee723cd19c964b1cf37792931e0c7c4614f4 (diff)
downloaddomain-dig-ee2520f2c0c2d806fd284c3d6b8a81a3822f5270.tar.gz
domain-dig-ee2520f2c0c2d806fd284c3d6b8a81a3822f5270.tar.bz2
domain-dig-ee2520f2c0c2d806fd284c3d6b8a81a3822f5270.zip
feat(v1.8): improve result structure, history, and consistency
- normalize sections and add summary card - fix resolver usage in reverse DNS - include custom port scans in history/export - standardize error handling - decompose ContentView into smaller views
Diffstat (limited to 'DomainDig/DNSLookupService.swift')
-rw-r--r--DomainDig/DNSLookupService.swift23
1 files changed, 18 insertions, 5 deletions
diff --git a/DomainDig/DNSLookupService.swift b/DomainDig/DNSLookupService.swift
index a59126f..8c8d53c 100644
--- a/DomainDig/DNSLookupService.swift
+++ b/DomainDig/DNSLookupService.swift
@@ -57,8 +57,6 @@ enum DNSResolverOption: String, CaseIterable, Identifiable {
}
struct DNSLookupService {
- private static let rrsigQueryType = 46
- private static let dnskeyQueryType = 48
private static let internetClass = 1
static func lookup(domain: String, recordType: DNSRecordType) async throws -> [DNSRecord] {
@@ -93,7 +91,7 @@ struct DNSLookupService {
}
}
- static func lookupAll(domain: String) async -> [DNSSection] {
+ static func lookupAll(domain: String) async -> ServiceResult<[DNSSection]> {
typealias Result = (
type: DNSRecordType,
records: [DNSRecord],
@@ -109,8 +107,11 @@ struct DNSLookupService {
resolverURLString: resolverURLString
)
- return await withTaskGroup(of: Result.self, returning: [DNSSection].self) { group in
+ let sections = await withTaskGroup(of: Result.self, returning: [DNSSection].self) { group in
for recordType in DNSRecordType.allCases {
+ guard recordType != .PTR else {
+ continue
+ }
let shouldQueryWildcard = wildcardTypes.contains(recordType)
group.addTask {
var apexRecords: [DNSRecord] = []
@@ -159,6 +160,12 @@ struct DNSLookupService {
(order.firstIndex(of: a.recordType) ?? 0) < (order.firstIndex(of: b.recordType) ?? 0)
}
}
+
+ if sections.contains(where: { !$0.records.isEmpty || !$0.wildcardRecords.isEmpty || $0.error != nil }) {
+ return .success(sections)
+ }
+
+ return .empty("No DNS records found")
}
private static func lookupResponse(
@@ -218,11 +225,17 @@ struct DNSLookupService {
return response.authenticatedData
}
- private static func currentResolverURLString() -> String {
+ static func currentResolverURLString() -> String {
let storedValue = UserDefaults.standard.string(forKey: DNSResolverOption.userDefaultsKey)
return DNSResolverOption.resolvedURLString(from: storedValue)
}
+ static func currentResolverDisplayName() -> String {
+ let resolverURLString = currentResolverURLString()
+ let option = DNSResolverOption.option(for: resolverURLString)
+ return option == .custom ? resolverURLString : option.title
+ }
+
private static func validatedResolverURL(from urlString: String) throws -> URL {
guard let url = URL(string: urlString) else {
throw URLError(.badURL)