domain-status 0.2.1

Concurrent URL status checker that captures comprehensive metadata in SQLite.
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
//! Record preparation orchestration.

use crate::fetch::dns::{AdditionalDnsData, TlsDnsData};
use crate::fetch::response::{HtmlData, ResponseData};
use crate::storage::PersistedUrlRecord;

use super::builder::{build_persisted_url_record, build_url_record};

/// Parameters for preparing a record for database insertion.
///
/// This struct **owns** the response, HTML, and TLS/DNS data to enable moving
/// large collections (`HashMaps`, Vecs) into the final `PersistedUrlRecord` without cloning.
/// This eliminates ~5-10KB of heap allocations per URL in the hot path.
pub struct RecordPreparationParams<'a> {
    /// Response data (headers, status, body, etc.) - owned to move `HashMaps`
    pub resp_data: ResponseData,
    /// HTML parsing results - owned to move Vecs
    pub html_data: HtmlData,
    /// TLS and DNS data - owned to move `HashSet` and Vec
    pub tls_dns_data: TlsDnsData,
    /// Additional DNS records (NS, TXT, MX)
    pub additional_dns: AdditionalDnsData,
    /// Detected technologies
    pub technologies_vec: Vec<crate::fingerprint::DetectedTechnology>,
    /// Partial failures (DNS/TLS errors that didn't prevent processing)
    pub partial_failures: Vec<(crate::error_handling::ErrorType, String)>,
    /// Redirect chain (URL, HTTP status code) per hop
    pub redirect_chain: Vec<(String, u16)>,
    /// Elapsed time for the request (in seconds)
    pub elapsed: f64,
    /// Timestamp for the record
    pub timestamp: i64,
    /// Processing context (for enrichment lookups) - still borrowed (not owned data)
    pub ctx: &'a crate::fetch::ProcessingContext,
    /// Favicon data (fetched in parallel with tech detection and DNS/TLS)
    pub favicon: Option<crate::fetch::favicon::FaviconData>,
    /// security.txt / robots.txt (fetched in parallel with other enrichments)
    pub well_known: crate::fetch::well_known::WellKnownData,
}

/// Prepares a complete record for database insertion.
///
/// Orchestrates enrichment lookups and persistence-record building.
/// Technology detection is now done in parallel with DNS/TLS fetching.
/// Returns the persisted record and timing metrics in microseconds:
/// (`geoip_lookup_us`, `whois_lookup_us`).
///
/// This function takes **ownership** of the response, HTML, and TLS/DNS data
/// to enable moving large collections (`HashMaps`, Vecs) into the final `PersistedUrlRecord`
/// without cloning, saving ~5-10KB of allocations per URL.
///
/// # Arguments
///
/// * `params` - Parameters for record preparation (ownership transferred)
#[allow(clippy::too_many_lines)] // Assembles PersistedUrlRecord from response data, DNS, TLS, fingerprints, and enrichment data
pub async fn prepare_record_for_insertion(
    params: RecordPreparationParams<'_>,
) -> (PersistedUrlRecord, (u64, u64)) {
    use crate::utils::duration_to_us;
    use std::time::Instant;

    // Build URL record (borrows data, clones ~15 small strings - unavoidable)
    let record = build_url_record(
        &params.resp_data,
        &params.html_data,
        &params.tls_dns_data,
        &params.additional_dns,
        params.elapsed,
        params.timestamp,
        params.ctx.runtime.run_id.as_ref(),
    );

    // Perform enrichment lookups in parallel where possible
    // GeoIP is synchronous and fast, WHOIS is async
    // Both can run in parallel since they're independent
    // Note: These borrow specific fields from params, which is still valid here
    let (geoip_data, whois_data) = tokio::join!(
        // GeoIP lookup (synchronous, very fast)
        async {
            let geoip_start = Instant::now();
            let geoip_data = params
                .tls_dns_data
                .ip_address
                .as_ref()
                .and_then(|ip_address| {
                    let ip_addr = std::hint::black_box(ip_address.as_str());
                    crate::geoip::lookup_ip(ip_addr).map(|result| (ip_address.clone(), result))
                });
            let geoip_elapsed = geoip_start.elapsed();
            let geoip_lookup_us = duration_to_us(geoip_elapsed);
            // Debug: Log if GeoIP lookup is suspiciously fast (might indicate measurement issue)
            if geoip_lookup_us == 0 && geoip_data.is_some() {
                log::debug!(
                    "GeoIP lookup returned data but timing is 0ms (elapsed: {:?}, micros: {}, nanos: {})",
                    geoip_elapsed,
                    geoip_elapsed.as_micros(),
                    geoip_elapsed.as_nanos()
                );
            }
            (geoip_data, geoip_lookup_us)
        },
        // WHOIS lookup (async, can be slow)
        async {
            if params.ctx.runtime.enable_whois {
                let whois_start = Instant::now();
                log::debug!(
                    "Performing WHOIS lookup for domain: {}",
                    params.resp_data.final_domain
                );

                let result = match crate::whois::lookup_whois_with_client(
                    &params.resp_data.final_domain,
                    Some(params.ctx.runtime.whois_cache_dir.as_path()),
                    params.ctx.runtime.whois_client.as_deref(),
                )
                .await
                {
                    Ok(Some(whois_result)) => {
                        log::debug!(
                            "WHOIS lookup successful for {}: registrar={:?}, creation={:?}, expiration={:?}",
                            params.resp_data.final_domain,
                            whois_result.registrar,
                            whois_result.creation_date,
                            whois_result.expiration_date
                        );
                        Some(whois_result)
                    }
                    Ok(None) => {
                        log::debug!(
                            "WHOIS lookup returned no data for {}",
                            params.resp_data.final_domain
                        );
                        None
                    }
                    Err(e) => {
                        log::warn!(
                            "WHOIS lookup failed for {}: {}",
                            params.resp_data.final_domain,
                            e
                        );
                        None
                    }
                };
                let whois_lookup_us = duration_to_us(whois_start.elapsed());
                (result, whois_lookup_us)
            } else {
                (None, 0)
            }
        }
    );

    let (geoip_data, geoip_lookup_us) = geoip_data;
    let (whois_data, whois_lookup_us) = whois_data;

    // Build the persisted record by moving large collections instead of cloning.
    // This eliminates ~5-10KB of heap allocations per URL (HashMaps, Vecs)
    let persisted_record = build_persisted_url_record(super::builder::PersistedUrlRecordParams {
        record,
        resp_data: params.resp_data,
        html_data: params.html_data,
        tls_dns_data: params.tls_dns_data,
        technologies_vec: params.technologies_vec,
        redirect_chain: params.redirect_chain,
        partial_failures: params.partial_failures,
        geoip_data,
        whois_data,
        timestamp: params.timestamp,
        run_id: params.ctx.runtime.run_id.clone(),
        favicon: params.favicon,
        additional_dns: params.additional_dns,
        well_known: params.well_known,
    });

    (persisted_record, (geoip_lookup_us, whois_lookup_us))
}

#[cfg(test)]
mod tests {
    use super::*;
    use crate::error_handling::ProcessingStats;
    use crate::fetch::dns::{AdditionalDnsData, TlsDnsData};
    use crate::fetch::response::{HtmlData, ResponseData};
    use crate::fetch::{NetworkContext, ProcessingContext, RuntimeContext};
    use crate::initialization::test_resolver;
    use crate::utils::TimingStats;
    use std::sync::Arc;

    /// Max `GeoIP` lookup time (µs) allowed in tests. 8s, lenient for CI.
    /// `prepare_record_for_insertion` returns microseconds via `duration_to_us`.
    const GEOIP_TEST_TIMEOUT_US: u64 = 8_000_000;

    async fn create_test_context() -> ProcessingContext {
        let client = Arc::new(
            reqwest::Client::builder()
                .build()
                .expect("Failed to create HTTP client"),
        );
        let redirect_client = Arc::new(
            reqwest::Client::builder()
                .redirect(reqwest::redirect::Policy::none())
                .build()
                .expect("Failed to create redirect client"),
        );
        let resolver = test_resolver();
        let error_stats = Arc::new(ProcessingStats::new());
        let timing_stats = Arc::new(TimingStats::new());
        let run_id = Some("test-run".to_string());
        let enable_whois = false; // Disable WHOIS for faster tests
        let pool = Arc::new(
            sqlx::SqlitePool::connect("sqlite::memory:")
                .await
                .expect("Failed to create test pool"),
        );

        ProcessingContext::new(
            NetworkContext::new(client, redirect_client, resolver),
            pool,
            RuntimeContext::new(
                error_stats,
                timing_stats,
                run_id,
                enable_whois,
                std::path::PathBuf::from("/tmp/domain_status_whois_test"),
                false,
                Arc::new(crate::runtime_metrics::RuntimeMetrics::default()),
                true,
            ),
            Arc::new(crate::fingerprint::FingerprintRuleset::empty_for_tests()),
        )
    }

    fn create_minimal_resp_data() -> ResponseData {
        ResponseData {
            initial_url: "https://example.com".to_string(),
            final_url: "https://example.com".to_string(),
            initial_domain: "example.com".to_string(),
            final_domain: "example.com".to_string(),
            host: "example.com".to_string(),
            status: 200,
            status_desc: "OK".to_string(),
            headers: reqwest::header::HeaderMap::new(),
            security_headers: std::collections::HashMap::new(),
            http_headers: std::collections::HashMap::new(),
            body: std::sync::Arc::<str>::from("<html><body>Test</body></html>"),
            body_sha256: None,
            body_truncated: false,
            content_length: None,
            http_version: None,
            content_type: None,
        }
    }

    fn create_minimal_html_data() -> HtmlData {
        HtmlData {
            title: "Test".to_string(),
            description: None,
            structured_data: crate::parse::StructuredData::default(),
            social_media_links: Vec::new(),
            contact_links: Vec::new(),
            exposed_secrets: Vec::new(),
            analytics_ids: Vec::new(),
            meta_tags: std::collections::HashMap::new(),
            script_sources: Vec::new(),
            script_tag_ids: std::collections::HashSet::new(),
            inline_script_text: String::new(),
            external_scripts_eligible: 0,
            external_scripts_scanned: 0,
            favicon_url: None,
            canonical_url: None,
            meta_refresh_url: None,
            meta_robots: None,
            resource_hints: Vec::new(),
        }
    }

    fn create_minimal_tls_dns_data() -> TlsDnsData {
        TlsDnsData {
            ip_address: Some("8.8.8.8".to_string()),
            tls_version: None,
            subject: None,
            issuer: None,
            valid_from: None,
            valid_to: None,
            oids: None,
            cipher_suite: None,
            key_algorithm: None,
            subject_alternative_names: None,
            reverse_dns_name: None,
            cert_fingerprint_sha256: None,
            cert_serial_number: None,
            cert_is_self_signed: None,
            cert_is_wildcard: None,
        }
    }

    fn create_minimal_additional_dns_data() -> AdditionalDnsData {
        AdditionalDnsData {
            nameservers: None,
            txt_records: None,
            mx_records: None,
            spf_record: None,
            dmarc_record: None,
            mta_sts_record: None,
            tls_rpt_record: None,
            bimi_record: None,
            cname_chain: None,
            aaaa_records: None,
            caa_records: None,
        }
    }

    #[tokio::test]
    async fn test_prepare_record_for_insertion_basic_success() {
        // Test that prepare_record_for_insertion works with minimal valid data
        // This is critical - verifies the orchestration doesn't panic
        let ctx = create_test_context().await;
        let resp_data = create_minimal_resp_data();
        let html_data = create_minimal_html_data();
        let tls_dns_data = create_minimal_tls_dns_data();
        let additional_dns = create_minimal_additional_dns_data();

        let (persisted_record, (geoip_us, whois_us)) =
            prepare_record_for_insertion(RecordPreparationParams {
                resp_data,
                html_data,
                tls_dns_data,
                additional_dns,
                technologies_vec: Vec::new(),
                partial_failures: Vec::new(),
                redirect_chain: Vec::new(),
                elapsed: 1.0,
                timestamp: chrono::Utc::now().timestamp_millis(),
                ctx: &ctx,
                favicon: None,
                well_known: crate::fetch::well_known::WellKnownData::default(),
            })
            .await;

        // Should succeed without panicking (create_minimal_resp_data sets final_domain to "example.com")
        assert_eq!(persisted_record.url_record.final_domain, "example.com");
        // Timing metrics should be reasonable
        // Note: GeoIP lookup can be slower in CI environments due to network latency and cold cache
        assert!(
            geoip_us < GEOIP_TEST_TIMEOUT_US,
            "GeoIP lookup took {geoip_us}us, expected < {GEOIP_TEST_TIMEOUT_US}us"
        );
        assert_eq!(whois_us, 0); // WHOIS disabled in test context
    }

    #[tokio::test]
    async fn test_prepare_record_for_insertion_geoip_lookup_failure_handled() {
        // Test that GeoIP lookup failures don't prevent record creation
        // This is critical - GeoIP is optional, failures shouldn't break the flow
        let ctx = create_test_context().await;
        let resp_data = create_minimal_resp_data();
        let html_data = create_minimal_html_data();
        let mut tls_dns_data = create_minimal_tls_dns_data();
        // Use invalid IP to trigger GeoIP lookup failure
        tls_dns_data.ip_address = Some("invalid.ip.address".to_string());
        let additional_dns = create_minimal_additional_dns_data();

        let (persisted_record, (geoip_us, _whois_us)) =
            prepare_record_for_insertion(RecordPreparationParams {
                resp_data,
                html_data,
                tls_dns_data,
                additional_dns,
                technologies_vec: Vec::new(),
                partial_failures: Vec::new(),
                redirect_chain: Vec::new(),
                elapsed: 1.0,
                timestamp: chrono::Utc::now().timestamp_millis(),
                ctx: &ctx,
                favicon: None,
                well_known: crate::fetch::well_known::WellKnownData::default(),
            })
            .await;

        // Should succeed even with invalid IP (GeoIP lookup returns None)
        assert_eq!(persisted_record.url_record.final_domain, "example.com");
        // GeoIP lookup should complete quickly (returns None for invalid IP)
        // Note: Using lenient threshold for CI environments
        assert!(
            geoip_us < GEOIP_TEST_TIMEOUT_US,
            "GeoIP lookup took {geoip_us}us, expected < {GEOIP_TEST_TIMEOUT_US}us"
        );
    }

    #[tokio::test]
    async fn test_prepare_record_for_insertion_parallel_tasks_complete() {
        // Test that parallel tasks (GeoIP, WHOIS) complete correctly
        // This is critical - tokio::join! should handle all tasks even if some fail
        let ctx = create_test_context().await;
        let resp_data = create_minimal_resp_data();
        let html_data = create_minimal_html_data();
        let tls_dns_data = create_minimal_tls_dns_data();
        let additional_dns = create_minimal_additional_dns_data();

        let start = std::time::Instant::now();
        let (persisted_record, (geoip_us, whois_us)) =
            prepare_record_for_insertion(RecordPreparationParams {
                resp_data,
                html_data,
                tls_dns_data,
                additional_dns,
                technologies_vec: Vec::new(),
                partial_failures: Vec::new(),
                redirect_chain: Vec::new(),
                elapsed: 1.0,
                timestamp: chrono::Utc::now().timestamp_millis(),
                ctx: &ctx,
                favicon: None,
                well_known: crate::fetch::well_known::WellKnownData::default(),
            })
            .await;
        let elapsed = start.elapsed();

        // All tasks should complete
        assert_eq!(persisted_record.url_record.final_domain, "example.com");
        // Timing should be reasonable (parallel execution)
        // Note: Using lenient thresholds for CI environments where network latency can be higher
        assert!(
            elapsed.as_millis() < 10000,
            "Total elapsed time {}ms, expected < 10000ms",
            elapsed.as_millis()
        ); // Should complete reasonably quickly
        assert!(
            geoip_us < GEOIP_TEST_TIMEOUT_US,
            "GeoIP lookup took {geoip_us}us, expected < {GEOIP_TEST_TIMEOUT_US}us"
        );
        assert_eq!(whois_us, 0); // WHOIS disabled
    }

    #[tokio::test]
    async fn test_prepare_record_for_insertion_with_technologies() {
        // Test that technologies are correctly passed through
        // This is critical - technology detection results must be preserved
        let ctx = create_test_context().await;
        let resp_data = create_minimal_resp_data();
        let html_data = create_minimal_html_data();
        let tls_dns_data = create_minimal_tls_dns_data();
        let additional_dns = create_minimal_additional_dns_data();
        let technologies = vec![
            crate::fingerprint::DetectedTechnology {
                name: "WordPress".to_string(),
                version: None,
                category: None,
                is_implied: false,
                detection_source: None,
            },
            crate::fingerprint::DetectedTechnology {
                name: "PHP".to_string(),
                version: None,
                category: None,
                is_implied: false,
                detection_source: None,
            },
        ];

        let technologies_count = technologies.len();
        let (persisted_record, _) = prepare_record_for_insertion(RecordPreparationParams {
            resp_data,
            html_data,
            tls_dns_data,
            additional_dns,
            technologies_vec: technologies,
            partial_failures: Vec::new(),
            redirect_chain: Vec::new(),
            elapsed: 1.0,
            timestamp: chrono::Utc::now().timestamp_millis(),
            ctx: &ctx,
            favicon: None,
            well_known: crate::fetch::well_known::WellKnownData::default(),
        })
        .await;

        // Technologies should be preserved
        assert_eq!(persisted_record.technologies.len(), technologies_count);
    }

    #[tokio::test]
    async fn test_prepare_record_for_insertion_with_partial_failures() {
        // Test that partial failures are correctly passed through
        // This is critical - DNS/TLS failures shouldn't prevent record creation
        let ctx = create_test_context().await;
        let resp_data = create_minimal_resp_data();
        let html_data = create_minimal_html_data();
        let tls_dns_data = create_minimal_tls_dns_data();
        let additional_dns = create_minimal_additional_dns_data();
        let partial_failures = vec![(
            crate::error_handling::ErrorType::HttpRequestOtherError,
            "DNS lookup failed".to_string(),
        )];
        let partial_failures_count = partial_failures.len();

        let (persisted_record, _) = prepare_record_for_insertion(RecordPreparationParams {
            resp_data,
            html_data,
            tls_dns_data,
            additional_dns,
            technologies_vec: Vec::new(),
            partial_failures,
            redirect_chain: Vec::new(),
            elapsed: 1.0,
            timestamp: chrono::Utc::now().timestamp_millis(),
            ctx: &ctx,
            favicon: None,
            well_known: crate::fetch::well_known::WellKnownData::default(),
        })
        .await;

        // Partial failures should be preserved
        assert_eq!(
            persisted_record.partial_failures.len(),
            partial_failures_count
        );
    }

    #[tokio::test]
    async fn test_prepare_record_for_insertion_whois_when_enabled() {
        let cache_dir = tempfile::TempDir::new().expect("whois cache");
        crate::whois::seed_whois_cache(
            cache_dir.path(),
            "example.com",
            &crate::whois::WhoisResult {
                registrar: Some("Fixture Registrar".to_string()),
                registrant_org: Some("Fixture Org".to_string()),
                raw_text: Some("seeded".to_string()),
                ..crate::whois::WhoisResult::default()
            },
        )
        .await
        .expect("seed whois cache");

        let mut ctx = create_test_context().await;
        ctx.runtime.enable_whois = true;
        ctx.runtime.whois_cache_dir = cache_dir.path().to_path_buf();
        let resp_data = create_minimal_resp_data();
        let html_data = create_minimal_html_data();
        let tls_dns_data = create_minimal_tls_dns_data();
        let additional_dns = create_minimal_additional_dns_data();

        let (persisted_record, (_geoip_us, _whois_us)) =
            prepare_record_for_insertion(RecordPreparationParams {
                resp_data,
                html_data,
                tls_dns_data,
                additional_dns,
                technologies_vec: Vec::new(),
                partial_failures: Vec::new(),
                redirect_chain: Vec::new(),
                elapsed: 1.0,
                timestamp: chrono::Utc::now().timestamp_millis(),
                ctx: &ctx,
                favicon: None,
                well_known: crate::fetch::well_known::WellKnownData::default(),
            })
            .await;

        assert_eq!(persisted_record.url_record.final_domain, "example.com");
        let whois = persisted_record
            .whois
            .expect("WHOIS cache hit must populate");
        assert_eq!(whois.registrar.as_deref(), Some("Fixture Registrar"));
    }

    #[tokio::test]
    async fn test_prepare_record_for_insertion_enrichment_failures_handled_gracefully() {
        // Test that enrichment lookup failures don't prevent record creation
        // This is critical - GeoIP/WHOIS failures should be handled gracefully
        let ctx = create_test_context().await;
        let resp_data = create_minimal_resp_data();
        let html_data = create_minimal_html_data();
        let mut tls_dns_data = create_minimal_tls_dns_data();
        // Use invalid IP to trigger GeoIP lookup failure
        tls_dns_data.ip_address = Some("999.999.999.999".to_string());
        let additional_dns = create_minimal_additional_dns_data();

        let (persisted_record, (geoip_us, whois_us)) =
            prepare_record_for_insertion(RecordPreparationParams {
                resp_data,
                html_data,
                tls_dns_data,
                additional_dns,
                technologies_vec: Vec::new(),
                partial_failures: Vec::new(),
                redirect_chain: Vec::new(),
                elapsed: 1.0,
                timestamp: chrono::Utc::now().timestamp_millis(),
                ctx: &ctx,
                favicon: None,
                well_known: crate::fetch::well_known::WellKnownData::default(),
            })
            .await;

        // Should succeed even with invalid IP (GeoIP returns None)
        assert_eq!(persisted_record.url_record.final_domain, "example.com");
        // GeoIP lookup should complete quickly (returns None for invalid IP)
        // Note: Using lenient threshold for CI environments
        assert!(
            geoip_us < GEOIP_TEST_TIMEOUT_US,
            "GeoIP lookup took {geoip_us}us, expected < {GEOIP_TEST_TIMEOUT_US}us"
        );
        assert_eq!(whois_us, 0); // WHOIS disabled
                                 // GeoIP data should be None (invalid IP)
        assert!(persisted_record.geoip.is_none());
    }
}