Commit f667d4e49f
Unsigned
Layout: unified · split
DomainDig/DomainViewModel.swift −196
| @@ -1477,202 +1477,6 @@ final class DomainViewModel { | |||
| 1477 | customPortScanLoading = false | 1477 | customPortScanLoading = false |
| 1478 | } | 1478 | } |
| 1479 | 1479 | ||
| 1480 | private func runDNS(domain: String, lookupID: UUID) async { | ||
| 1481 | let result = await DNSLookupService.lookupAll(domain: domain) | ||
| 1482 | guard !Task.isCancelled, isCurrentLookup(lookupID) else { return } | ||
| 1483 | switch result { | ||
| 1484 | case let .success(sections): | ||
| 1485 | dnsSections = sections | ||
| 1486 | dnsError = nil | ||
| 1487 | case let .empty(message), let .error(message): | ||
| 1488 | dnsSections = [] | ||
| 1489 | dnsError = message | ||
| 1490 | } | ||
| 1491 | dnsLoading = false | ||
| 1492 | } | ||
| 1493 | |||
| 1494 | private func runAvailability(domain: String, lookupID: UUID) async { | ||
| 1495 | let result = await DomainAvailabilityService.check(domain: domain) | ||
| 1496 | guard !Task.isCancelled, isCurrentLookup(lookupID) else { return } | ||
| 1497 | availabilityResult = result | ||
| 1498 | availabilityLoading = false | ||
| 1499 | updateTrackedDomainAvailability(for: result.domain, status: result.status) | ||
| 1500 | } | ||
| 1501 | |||
| 1502 | private func runSSL(domain: String, lookupID: UUID) async { | ||
| 1503 | let result = await SSLCheckService.check(domain: domain) | ||
| 1504 | guard !Task.isCancelled, isCurrentLookup(lookupID) else { return } | ||
| 1505 | switch result { | ||
| 1506 | case let .success(info): | ||
| 1507 | sslInfo = info | ||
| 1508 | sslError = nil | ||
| 1509 | case let .empty(message), let .error(message): | ||
| 1510 | sslInfo = nil | ||
| 1511 | sslError = message | ||
| 1512 | } | ||
| 1513 | sslLoading = false | ||
| 1514 | } | ||
| 1515 | |||
| 1516 | private func runHSTSPreload(domain: String, lookupID: UUID) async { | ||
| 1517 | let result = await SSLCheckService.checkHSTSPreload(domain: domain) | ||
| 1518 | guard !Task.isCancelled, isCurrentLookup(lookupID) else { return } | ||
| 1519 | hstsPreloaded = result | ||
| 1520 | hstsLoading = false | ||
| 1521 | } | ||
| 1522 | |||
| 1523 | private func runHTTPHeaders(domain: String, lookupID: UUID) async { | ||
| 1524 | let result = await HTTPHeadersService.fetch(domain: domain) | ||
| 1525 | guard !Task.isCancelled, isCurrentLookup(lookupID) else { return } | ||
| 1526 | switch result { | ||
| 1527 | case let .success(headersResult): | ||
| 1528 | httpHeaders = headersResult.headers | ||
| 1529 | httpSecurityGrade = HTTPSecurityGrade.grade(for: headersResult.headers).rawValue | ||
| 1530 | httpStatusCode = headersResult.statusCode | ||
| 1531 | httpResponseTimeMs = headersResult.responseTimeMs | ||
| 1532 | httpProtocol = headersResult.httpProtocol | ||
| 1533 | http3Advertised = headersResult.http3Advertised | ||
| 1534 | httpHeadersError = nil | ||
| 1535 | case let .empty(message), let .error(message): | ||
| 1536 | httpHeaders = [] | ||
| 1537 | httpSecurityGrade = nil | ||
| 1538 | httpStatusCode = nil | ||
| 1539 | httpResponseTimeMs = nil | ||
| 1540 | httpProtocol = nil | ||
| 1541 | http3Advertised = false | ||
| 1542 | httpHeadersError = message | ||
| 1543 | } | ||
| 1544 | httpHeadersLoading = false | ||
| 1545 | } | ||
| 1546 | |||
| 1547 | private func runReachability(domain: String, lookupID: UUID) async { | ||
| 1548 | let result = await ReachabilityService.checkAll(domain: domain) | ||
| 1549 | guard !Task.isCancelled, isCurrentLookup(lookupID) else { return } | ||
| 1550 | switch result { | ||
| 1551 | case let .success(results): | ||
| 1552 | reachabilityResults = results | ||
| 1553 | reachabilityError = nil | ||
| 1554 | case let .empty(message), let .error(message): | ||
| 1555 | reachabilityResults = [] | ||
| 1556 | reachabilityError = message | ||
| 1557 | } | ||
| 1558 | reachabilityLoading = false | ||
| 1559 | } | ||
| 1560 | |||
| 1561 | private func runEmailSecurity(domain: String, txtRecords: [DNSRecord], lookupID: UUID) async { | ||
| 1562 | let result = await EmailSecurityService.analyze(domain: domain, txtRecords: txtRecords) | ||
| 1563 | guard !Task.isCancelled, isCurrentLookup(lookupID) else { return } | ||
| 1564 | switch result { | ||
| 1565 | case let .success(emailResult): | ||
| 1566 | emailSecurity = emailResult | ||
| 1567 | emailSecurityError = nil | ||
| 1568 | case let .empty(message), let .error(message): | ||
| 1569 | emailSecurity = nil | ||
| 1570 | emailSecurityError = message | ||
| 1571 | } | ||
| 1572 | emailSecurityLoading = false | ||
| 1573 | } | ||
| 1574 | |||
| 1575 | private func runOwnership(domain: String, lookupID: UUID) async { | ||
| 1576 | let result = await DomainOwnershipService.lookup(domain: domain) | ||
| 1577 | guard !Task.isCancelled, isCurrentLookup(lookupID) else { return } | ||
| 1578 | switch result { | ||
| 1579 | case let .success(ownership): | ||
| 1580 | ownershipResult = ownership | ||
| 1581 | ownershipError = nil | ||
| 1582 | case let .empty(message), let .error(message): | ||
| 1583 | ownershipResult = nil | ||
| 1584 | ownershipError = message | ||
| 1585 | } | ||
| 1586 | ownershipLoading = false | ||
| 1587 | } | ||
| 1588 | |||
| 1589 | private func runReverseDNS(ip: String, lookupID: UUID) async { | ||
| 1590 | let result = await ReverseDNSService.lookup(ip: ip, resolverURLString: resolverURLString) | ||
| 1591 | guard !Task.isCancelled, isCurrentLookup(lookupID) else { return } | ||
| 1592 | switch result { | ||
| 1593 | case let .success(record): | ||
| 1594 | ptrRecord = record | ||
| 1595 | ptrError = nil | ||
| 1596 | case let .empty(message), let .error(message): | ||
| 1597 | ptrRecord = nil | ||
| 1598 | ptrError = message | ||
| 1599 | } | ||
| 1600 | ptrLoading = false | ||
| 1601 | } | ||
| 1602 | |||
| 1603 | private func runRedirectChain(domain: String, lookupID: UUID) async { | ||
| 1604 | let result = await RedirectChainService.trace(domain: domain) | ||
| 1605 | guard !Task.isCancelled, isCurrentLookup(lookupID) else { return } | ||
| 1606 | switch result { | ||
| 1607 | case let .success(hops): | ||
| 1608 | redirectChain = hops | ||
| 1609 | redirectChainError = nil | ||
| 1610 | case let .empty(message), let .error(message): | ||
| 1611 | redirectChain = [] | ||
| 1612 | redirectChainError = message | ||
| 1613 | } | ||
| 1614 | redirectChainLoading = false | ||
| 1615 | } | ||
| 1616 | |||
| 1617 | private func runSubdomains(domain: String, lookupID: UUID) async { | ||
| 1618 | let result = await SubdomainDiscoveryService.discover(for: domain) | ||
| 1619 | guard !Task.isCancelled, isCurrentLookup(lookupID) else { return } | ||
| 1620 | switch result { | ||
| 1621 | case let .success(results): | ||
| 1622 | subdomains = results | ||
| 1623 | subdomainsError = nil | ||
| 1624 | case let .empty(message), let .error(message): | ||
| 1625 | subdomains = [] | ||
| 1626 | subdomainsError = message | ||
| 1627 | } | ||
| 1628 | subdomainsLoading = false | ||
| 1629 | } | ||
| 1630 | |||
| 1631 | private func runPortScan(domain: String, lookupID: UUID) async { | ||
| 1632 | let result = await PortScanService.scanAll(domain: domain) | ||
| 1633 | switch result { | ||
| 1634 | case let .success(results): | ||
| 1635 | let enrichedResults = await PortScanService.withBanners(results, host: domain) | ||
| 1636 | guard !Task.isCancelled, isCurrentLookup(lookupID) else { return } | ||
| 1637 | portScanResults = enrichedResults | ||
| 1638 | portScanError = nil | ||
| 1639 | case let .empty(message), let .error(message): | ||
| 1640 | guard !Task.isCancelled, isCurrentLookup(lookupID) else { return } | ||
| 1641 | portScanResults = [] | ||
| 1642 | portScanError = message | ||
| 1643 | } | ||
| 1644 | portScanLoading = false | ||
| 1645 | } | ||
| 1646 | |||
| 1647 | private func runIPGeolocation(ip: String, lookupID: UUID) async { | ||
| 1648 | let result = await IPGeolocationService.lookup(ip: ip) | ||
| 1649 | guard !Task.isCancelled, isCurrentLookup(lookupID) else { return } | ||
| 1650 | switch result { | ||
| 1651 | case let .success(geolocation): | ||
| 1652 | ipGeolocation = geolocation | ||
| 1653 | ipGeolocationError = nil | ||
| 1654 | case let .empty(message), let .error(message): | ||
| 1655 | ipGeolocation = nil | ||
| 1656 | ipGeolocationError = message | ||
| 1657 | } | ||
| 1658 | ipGeolocationLoading = false | ||
| 1659 | } | ||
| 1660 | |||
| 1661 | private func finishDependentWithoutPrimaryIP(lookupID: UUID) async { | ||
| 1662 | guard !Task.isCancelled, isCurrentLookup(lookupID) else { return } | ||
| 1663 | ptrLoading = false | ||
| 1664 | ptrError = "No A record available" | ||
| 1665 | ipGeolocationLoading = false | ||
| 1666 | ipGeolocationError = "No A record available" | ||
| 1667 | } | ||
| 1668 | |||
| 1669 | private func runSuggestions(domain: String, lookupID: UUID) async { | ||
| 1670 | let results = await DomainAvailabilityService.suggestions(for: domain) | ||
| 1671 | guard !Task.isCancelled, isCurrentLookup(lookupID) else { return } | ||
| 1672 | suggestions = results | ||
| 1673 | suggestionsLoading = false | ||
| 1674 | } | ||
| 1675 | |||
| 1676 | private func applyCustomPortResult(_ result: ServiceResult<[PortScanResult]>) { | 1480 | private func applyCustomPortResult(_ result: ServiceResult<[PortScanResult]>) { |
| 1677 | switch result { | 1481 | switch result { |
| 1678 | case let .success(results): | 1482 | case let .success(results): |