essh 0.3.2

Enhanced SSH client with concurrent sessions, real-time host diagnostics, and a Netwatch-inspired TUI
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
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
use std::collections::HashMap;
use std::fs;
use std::path::PathBuf;

use serde::{Deserialize, Serialize};
use thiserror::Error;

// ---------------------------------------------------------------------------
// Error
// ---------------------------------------------------------------------------

#[derive(Debug, Error)]
pub enum ConfigError {
    #[error("I/O error: {0}")]
    Io(#[from] std::io::Error),

    #[error("TOML parse error: {0}")]
    Parse(#[from] toml::de::Error),

    #[error("TOML serialization error: {0}")]
    Serialize(#[from] toml::ser::Error),
}

// ---------------------------------------------------------------------------
// Enums
// ---------------------------------------------------------------------------

#[derive(Clone, Debug, Default, Serialize, Deserialize, PartialEq, Eq)]
#[serde(rename_all = "snake_case")]
pub enum TofuPolicy {
    Strict,
    #[default]
    Prompt,
    Auto,
}

#[derive(Clone, Debug, Default, Serialize, Deserialize, PartialEq, Eq)]
#[serde(rename_all = "snake_case")]
pub enum DiagnosticsDisplay {
    #[default]
    StatusBar,
    Overlay,
    Hidden,
}

// ---------------------------------------------------------------------------
// Sub-configs
// ---------------------------------------------------------------------------

#[derive(Clone, Debug, Serialize, Deserialize)]
#[serde(default)]
pub struct GeneralConfig {
    pub default_user: Option<String>,
    pub default_key: Option<String>,
    pub tofu_policy: TofuPolicy,
    pub cache_ttl: String,
    pub log_level: String,
    /// Open the launcher on start rather than the dashboard.
    pub launcher: bool,
    /// Seconds to wait for a connection before giving up.
    ///
    /// Without a bound, connecting to an address that silently drops packets
    /// — a typo'd `192.168.x.x`, a host behind a firewall that DROPs rather
    /// than REJECTs — waits on the OS TCP timeout, which is ~75s on macOS and
    /// can be far longer. The UI has nothing to show during that, so it reads
    /// as a freeze.
    pub connect_timeout: u64,
}

impl Default for GeneralConfig {
    fn default() -> Self {
        Self {
            default_user: None,
            default_key: None,
            tofu_policy: TofuPolicy::default(),
            cache_ttl: "30d".to_string(),
            log_level: "info".to_string(),
            launcher: true,
            connect_timeout: 12,
        }
    }
}

#[derive(Clone, Debug, Serialize, Deserialize)]
#[serde(default)]
pub struct DiagnosticsConfig {
    pub enabled: bool,
    pub display: DiagnosticsDisplay,
    pub export_format: String,
    pub keepalive_interval: u64,
}

impl Default for DiagnosticsConfig {
    fn default() -> Self {
        Self {
            enabled: true,
            display: DiagnosticsDisplay::default(),
            export_format: "jsonl".to_string(),
            keepalive_interval: 15,
        }
    }
}

#[derive(Clone, Debug, Serialize, Deserialize)]
#[serde(default)]
pub struct SessionConfig {
    pub auto_reconnect: bool,
    pub reconnect_max_retries: u32,
    pub multiplex: bool,
    pub recording: bool,
    pub max_concurrent: usize,
    pub scrollback_lines: usize,
    pub notification_patterns: Vec<String>,
    /// Key that puts ESSH into command mode while a shell has focus.
    /// Press it twice to send the literal key to the remote.
    pub prefix_key: String,
}

impl Default for SessionConfig {
    fn default() -> Self {
        Self {
            auto_reconnect: true,
            reconnect_max_retries: 5,
            multiplex: true,
            recording: false,
            max_concurrent: 9,
            scrollback_lines: 10000,
            notification_patterns: Vec::new(),
            prefix_key: "ctrl-a".to_string(),
        }
    }
}

#[derive(Clone, Debug, Serialize, Deserialize)]
#[serde(default)]
pub struct SecurityConfig {
    pub min_key_bits: u32,
    pub allowed_ciphers: Vec<String>,
    pub allowed_kex: Vec<String>,
    pub allowed_macs: Vec<String>,
    pub require_mfa_groups: Vec<String>,
}

impl Default for SecurityConfig {
    fn default() -> Self {
        Self {
            min_key_bits: 3072,
            allowed_ciphers: vec![
                "chacha20-poly1305@openssh.com".to_string(),
                "aes256-gcm@openssh.com".to_string(),
                "aes128-gcm@openssh.com".to_string(),
            ],
            allowed_kex: vec![
                "curve25519-sha256".to_string(),
                "curve25519-sha256@libssh.org".to_string(),
            ],
            allowed_macs: vec![
                "hmac-sha2-256-etm@openssh.com".to_string(),
                "hmac-sha2-512-etm@openssh.com".to_string(),
            ],
            require_mfa_groups: Vec::new(),
        }
    }
}

#[derive(Clone, Debug, Serialize, Deserialize)]
#[serde(default)]
pub struct AuditConfig {
    pub enabled: bool,
    pub syslog_target: Option<String>,
}

impl Default for AuditConfig {
    fn default() -> Self {
        Self {
            enabled: true,
            syslog_target: None,
        }
    }
}

#[derive(Clone, Debug, Serialize, Deserialize)]
#[serde(default)]
pub struct HostMonitorConfig {
    pub enabled: bool,
    pub cpu_interval: u64,
    pub memory_interval: u64,
    pub process_count: usize,
    pub history_samples: usize,
}

impl Default for HostMonitorConfig {
    fn default() -> Self {
        Self {
            enabled: true,
            cpu_interval: 1,
            memory_interval: 2,
            process_count: 15,
            history_samples: 60,
        }
    }
}

impl AppConfig {
    /// The connect timeout, as a `Duration`.
    ///
    /// Clamped to at least a second: a zero here would make every connection
    /// fail instantly and look like a broken network rather than a bad
    /// setting.
    pub fn connect_timeout(&self) -> std::time::Duration {
        std::time::Duration::from_secs(self.general.connect_timeout.max(1))
    }
}

#[derive(Clone, Debug, Serialize, Deserialize)]
#[serde(default)]
pub struct FleetConfig {
    pub probe_enabled: bool,
    pub probe_interval: u64,
    pub probe_timeout: u64,
    pub latency_history_samples: usize,
}

impl Default for FleetConfig {
    fn default() -> Self {
        Self {
            probe_enabled: true,
            probe_interval: 60,
            probe_timeout: 5,
            latency_history_samples: 30,
        }
    }
}

/// Which extra facets to compare across peers.
///
/// Config-file hashes and package versions are the two facets that cannot have
/// a universal default — every fleet runs different things — so they are
/// opinionated-but-overridable. The defaults cover the services people
/// actually ask "are these the same?" about.
#[derive(Clone, Debug, Serialize, Deserialize)]
#[serde(default)]
pub struct DivergenceConfig {
    pub enabled: bool,
    /// Files whose content hash is compared. Unreadable ones report why
    /// rather than being dropped.
    pub config_paths: Vec<String>,
    /// Packages whose version is compared.
    pub packages: Vec<String>,
}

impl Default for DivergenceConfig {
    fn default() -> Self {
        Self {
            enabled: true,
            config_paths: vec![
                "/etc/nginx/nginx.conf".to_string(),
                "/etc/ssh/sshd_config".to_string(),
                "/etc/resolv.conf".to_string(),
            ],
            packages: vec![
                "openssh-server".to_string(),
                "nginx".to_string(),
                "docker.io".to_string(),
            ],
        }
    }
}

// ---------------------------------------------------------------------------
// Host / group structs
// ---------------------------------------------------------------------------

#[derive(Clone, Debug, Serialize, Deserialize)]
pub struct PortForwardConfig {
    pub direction: String,
    pub bind_host: String,
    pub bind_port: u16,
    pub target_host: String,
    pub target_port: u16,
}

#[derive(Clone, Debug, Serialize, Deserialize)]
pub struct HostEntry {
    pub name: String,
    pub hostname: String,
    #[serde(default = "default_port")]
    pub port: u16,
    pub user: Option<String>,
    pub key: Option<String>,
    #[serde(default)]
    pub tags: HashMap<String, String>,
    pub jump_host: Option<String>,
    #[serde(default)]
    pub port_forwards: Vec<PortForwardConfig>,
}

fn default_port() -> u16 {
    22
}

#[derive(Clone, Debug, Serialize, Deserialize, Default)]
#[serde(default)]
pub struct GroupDefaults {
    pub user: Option<String>,
    pub key: Option<String>,
}

#[derive(Clone, Debug, Serialize, Deserialize)]
pub struct HostGroup {
    pub name: String,
    #[serde(default)]
    pub match_tags: HashMap<String, String>,
    #[serde(default)]
    pub defaults: GroupDefaults,
}

// ---------------------------------------------------------------------------
// AppConfig
// ---------------------------------------------------------------------------

fn default_theme() -> String {
    "dark".to_string()
}

#[derive(Clone, Debug, Serialize, Deserialize)]
#[serde(default)]
pub struct AppConfig {
    #[serde(default = "default_theme")]
    pub theme: String,
    pub general: GeneralConfig,
    pub diagnostics: DiagnosticsConfig,
    pub session: SessionConfig,
    pub security: SecurityConfig,
    pub audit: AuditConfig,
    #[serde(default)]
    pub host_monitor: HostMonitorConfig,
    #[serde(default)]
    pub fleet: FleetConfig,
    #[serde(default)]
    pub divergence: DivergenceConfig,
    #[serde(default)]
    pub hosts: Vec<HostEntry>,
    #[serde(default)]
    pub host_groups: Vec<HostGroup>,
}

impl Default for AppConfig {
    fn default() -> Self {
        Self {
            theme: default_theme(),
            general: GeneralConfig::default(),
            diagnostics: DiagnosticsConfig::default(),
            session: SessionConfig::default(),
            security: SecurityConfig::default(),
            audit: AuditConfig::default(),
            host_monitor: HostMonitorConfig::default(),
            fleet: FleetConfig::default(),
            divergence: DivergenceConfig::default(),
            hosts: Vec::new(),
            host_groups: Vec::new(),
        }
    }
}

impl AppConfig {
    pub fn data_dir() -> PathBuf {
        dirs::home_dir()
            .expect("could not determine home directory")
            .join(".essh")
    }

    pub fn ensure_dirs() -> Result<(), ConfigError> {
        let base = Self::data_dir();
        for sub in ["", "sessions", "recordings", "known_cas", "plugins"] {
            fs::create_dir_all(base.join(sub))?;
        }
        Ok(())
    }

    pub fn load() -> Result<Self, ConfigError> {
        let path = Self::data_dir().join("config.toml");
        if !path.exists() {
            return Ok(Self::default());
        }
        let contents = fs::read_to_string(&path)?;
        let config: AppConfig = toml::from_str(&contents)?;
        Ok(config)
    }

    pub fn save(&self) -> Result<(), ConfigError> {
        Self::ensure_dirs()?;
        let path = Self::data_dir().join("config.toml");
        let contents = toml::to_string_pretty(self)?;
        fs::write(&path, contents)?;
        Ok(())
    }
}

#[cfg(test)]
mod tests {
    use super::*;

    #[test]
    fn test_default_config() {
        let cfg = AppConfig::default();
        assert_eq!(cfg.theme, "dark");
        assert_eq!(cfg.general.tofu_policy, TofuPolicy::Prompt);
        assert_eq!(cfg.general.cache_ttl, "30d");
        assert_eq!(cfg.general.log_level, "info");
        assert_eq!(cfg.general.default_user, None);
        assert_eq!(cfg.general.default_key, None);
        assert!(cfg.diagnostics.enabled);
        assert_eq!(cfg.diagnostics.display, DiagnosticsDisplay::StatusBar);
        assert_eq!(cfg.diagnostics.export_format, "jsonl");
        assert_eq!(cfg.diagnostics.keepalive_interval, 15);
        assert!(cfg.session.auto_reconnect);
        assert_eq!(cfg.session.reconnect_max_retries, 5);
        assert!(cfg.session.multiplex);
        assert!(!cfg.session.recording);
        assert_eq!(cfg.security.min_key_bits, 3072);
        assert!(cfg.audit.enabled);
        assert_eq!(cfg.audit.syslog_target, None);
        assert!(cfg.hosts.is_empty());
        assert!(cfg.host_groups.is_empty());
    }

    #[test]
    fn test_serialize_deserialize_roundtrip() {
        let cfg = AppConfig::default();
        let toml_str = toml::to_string_pretty(&cfg).expect("serialize");
        let cfg2: AppConfig = toml::from_str(&toml_str).expect("deserialize");

        assert_eq!(cfg2.theme, cfg.theme);
        assert_eq!(cfg2.general.tofu_policy, cfg.general.tofu_policy);
        assert_eq!(cfg2.general.cache_ttl, cfg.general.cache_ttl);
        assert_eq!(cfg2.general.log_level, cfg.general.log_level);
        assert_eq!(cfg2.diagnostics.enabled, cfg.diagnostics.enabled);
        assert_eq!(cfg2.diagnostics.display, cfg.diagnostics.display);
        assert_eq!(cfg2.session.auto_reconnect, cfg.session.auto_reconnect);
        assert_eq!(cfg2.session.multiplex, cfg.session.multiplex);
        assert_eq!(cfg2.security.min_key_bits, cfg.security.min_key_bits);
        assert_eq!(cfg2.security.allowed_ciphers, cfg.security.allowed_ciphers);
        assert_eq!(cfg2.security.allowed_kex, cfg.security.allowed_kex);
        assert_eq!(cfg2.security.allowed_macs, cfg.security.allowed_macs);
        assert_eq!(cfg2.audit.enabled, cfg.audit.enabled);
    }

    #[test]
    fn test_load_nonexistent_returns_default() {
        let cfg: AppConfig = toml::from_str("").expect("deserialize empty string");
        let default_cfg = AppConfig::default();

        assert_eq!(cfg.general.tofu_policy, default_cfg.general.tofu_policy);
        assert_eq!(cfg.general.cache_ttl, default_cfg.general.cache_ttl);
        assert_eq!(cfg.general.log_level, default_cfg.general.log_level);
        assert_eq!(cfg.diagnostics.enabled, default_cfg.diagnostics.enabled);
        assert_eq!(
            cfg.session.auto_reconnect,
            default_cfg.session.auto_reconnect
        );
        assert_eq!(cfg.security.min_key_bits, default_cfg.security.min_key_bits);
        assert_eq!(cfg.audit.enabled, default_cfg.audit.enabled);
        assert!(cfg.hosts.is_empty());
    }

    #[test]
    fn test_parse_toml_with_hosts() {
        let toml_str = r#"
            [[hosts]]
            name = "web1"
            hostname = "192.168.1.10"
            port = 2222
            user = "deploy"

            [[hosts]]
            name = "db1"
            hostname = "192.168.1.20"
        "#;

        let cfg: AppConfig = toml::from_str(toml_str).expect("parse hosts");
        assert_eq!(cfg.hosts.len(), 2);

        assert_eq!(cfg.hosts[0].name, "web1");
        assert_eq!(cfg.hosts[0].hostname, "192.168.1.10");
        assert_eq!(cfg.hosts[0].port, 2222);
        assert_eq!(cfg.hosts[0].user, Some("deploy".to_string()));

        assert_eq!(cfg.hosts[1].name, "db1");
        assert_eq!(cfg.hosts[1].hostname, "192.168.1.20");
        assert_eq!(cfg.hosts[1].port, 22);
        assert_eq!(cfg.hosts[1].user, None);
    }

    #[test]
    fn test_parse_toml_with_security() {
        let toml_str = r#"
            [security]
            min_key_bits = 4096
            allowed_ciphers = ["aes256-gcm@openssh.com"]
            allowed_kex = ["curve25519-sha256"]
            allowed_macs = ["hmac-sha2-512-etm@openssh.com"]
        "#;

        let cfg: AppConfig = toml::from_str(toml_str).expect("parse security");
        assert_eq!(cfg.security.min_key_bits, 4096);
        assert_eq!(cfg.security.allowed_ciphers, vec!["aes256-gcm@openssh.com"]);
        assert_eq!(cfg.security.allowed_kex, vec!["curve25519-sha256"]);
        assert_eq!(
            cfg.security.allowed_macs,
            vec!["hmac-sha2-512-etm@openssh.com"]
        );
    }

    #[test]
    fn test_tofu_policy_serde() {
        #[derive(Deserialize)]
        struct Wrapper {
            policy: TofuPolicy,
        }

        let strict: Wrapper = toml::from_str(r#"policy = "strict""#).unwrap();
        assert_eq!(strict.policy, TofuPolicy::Strict);

        let prompt: Wrapper = toml::from_str(r#"policy = "prompt""#).unwrap();
        assert_eq!(prompt.policy, TofuPolicy::Prompt);

        let auto: Wrapper = toml::from_str(r#"policy = "auto""#).unwrap();
        assert_eq!(auto.policy, TofuPolicy::Auto);
    }

    #[test]
    fn test_diagnostics_display_serde() {
        #[derive(Deserialize)]
        struct Wrapper {
            display: DiagnosticsDisplay,
        }

        let sb: Wrapper = toml::from_str(r#"display = "status_bar""#).unwrap();
        assert_eq!(sb.display, DiagnosticsDisplay::StatusBar);

        let ov: Wrapper = toml::from_str(r#"display = "overlay""#).unwrap();
        assert_eq!(ov.display, DiagnosticsDisplay::Overlay);

        let hid: Wrapper = toml::from_str(r#"display = "hidden""#).unwrap();
        assert_eq!(hid.display, DiagnosticsDisplay::Hidden);
    }

    #[test]
    fn test_host_entry_default_port() {
        let toml_str = r#"
            [[hosts]]
            name = "myhost"
            hostname = "10.0.0.1"
        "#;

        let cfg: AppConfig = toml::from_str(toml_str).expect("parse host without port");
        assert_eq!(cfg.hosts.len(), 1);
        assert_eq!(cfg.hosts[0].port, 22);
    }

    #[test]
    fn test_host_monitor_config_defaults() {
        let cfg = AppConfig::default();
        assert!(cfg.host_monitor.enabled);
        assert_eq!(cfg.host_monitor.cpu_interval, 1);
        assert_eq!(cfg.host_monitor.memory_interval, 2);
        assert_eq!(cfg.host_monitor.process_count, 15);
        assert_eq!(cfg.host_monitor.history_samples, 60);
        assert_eq!(cfg.session.max_concurrent, 9);
        assert_eq!(cfg.session.scrollback_lines, 10000);
    }

    #[test]
    fn test_fleet_config_defaults() {
        let cfg = AppConfig::default();
        assert!(cfg.fleet.probe_enabled);
        assert_eq!(cfg.fleet.probe_interval, 60);
        assert_eq!(cfg.fleet.probe_timeout, 5);
        assert_eq!(cfg.fleet.latency_history_samples, 30);
    }

    #[test]
    fn test_fleet_config_parse() {
        let toml_str = r#"
            [fleet]
            probe_enabled = false
            probe_interval = 120
            probe_timeout = 10
            latency_history_samples = 50
        "#;
        let cfg: AppConfig = toml::from_str(toml_str).expect("parse fleet config");
        assert!(!cfg.fleet.probe_enabled);
        assert_eq!(cfg.fleet.probe_interval, 120);
        assert_eq!(cfg.fleet.probe_timeout, 10);
        assert_eq!(cfg.fleet.latency_history_samples, 50);
    }

    #[test]
    fn test_data_dir() {
        let dir = AppConfig::data_dir();
        assert!(dir.ends_with(".essh"));
    }

    #[test]
    fn test_notification_patterns_serde() {
        let toml_str = r#"
            [session]
            notification_patterns = ["ERROR", "build complete", "OOM"]
        "#;
        let cfg: AppConfig = toml::from_str(toml_str).expect("parse notification_patterns");
        assert_eq!(
            cfg.session.notification_patterns,
            vec![
                "ERROR".to_string(),
                "build complete".to_string(),
                "OOM".to_string(),
            ]
        );

        // Round-trip
        let serialized = toml::to_string_pretty(&cfg).expect("serialize");
        let cfg2: AppConfig = toml::from_str(&serialized).expect("deserialize");
        assert_eq!(
            cfg2.session.notification_patterns,
            cfg.session.notification_patterns
        );

        // Default is empty
        let default_cfg = AppConfig::default();
        assert!(default_cfg.session.notification_patterns.is_empty());
    }

    #[test]
    fn test_parse_port_forward_config() {
        let toml_str = r#"
            [[hosts]]
            name = "web1"
            hostname = "192.168.1.10"

            [[hosts.port_forwards]]
            direction = "local"
            bind_host = "127.0.0.1"
            bind_port = 8080
            target_host = "localhost"
            target_port = 80

            [[hosts.port_forwards]]
            direction = "remote"
            bind_host = "0.0.0.0"
            bind_port = 3306
            target_host = "localhost"
            target_port = 3306
        "#;

        let cfg: AppConfig = toml::from_str(toml_str).expect("parse port forwards");
        assert_eq!(cfg.hosts.len(), 1);
        assert_eq!(cfg.hosts[0].port_forwards.len(), 2);

        let pf0 = &cfg.hosts[0].port_forwards[0];
        assert_eq!(pf0.direction, "local");
        assert_eq!(pf0.bind_host, "127.0.0.1");
        assert_eq!(pf0.bind_port, 8080);
        assert_eq!(pf0.target_host, "localhost");
        assert_eq!(pf0.target_port, 80);

        let pf1 = &cfg.hosts[0].port_forwards[1];
        assert_eq!(pf1.direction, "remote");
        assert_eq!(pf1.bind_port, 3306);
        assert_eq!(pf1.target_port, 3306);
    }
}