1use std::path::PathBuf;
2
3use ratatui::style::{Color, Style};
4
5#[derive(Debug, Clone, Default)]
6pub struct Tunnel {
7 pub name: String,
8 pub config_path: PathBuf,
9 pub is_active: bool,
10 pub interface: Option<InterfaceInfo>,
11}
12
13#[derive(Debug, Clone, Default)]
14pub struct InterfaceInfo {
15 pub public_key: String,
16 pub listen_port: Option<u16>,
17 pub peers: Vec<PeerInfo>,
18}
19
20#[derive(Debug, Clone, Default)]
21pub struct PeerInfo {
22 pub public_key: String,
23 pub endpoint: Option<String>,
24 pub allowed_ips: Vec<String>,
25 pub latest_handshake: Option<String>,
26 pub transfer_rx: u64,
27 pub transfer_tx: u64,
28}
29
30#[derive(Debug, Clone)]
31pub struct NewTunnelDraft {
32 pub name: String,
33 pub private_key: String,
34 pub address: String,
35 pub dns: String,
36 pub peer_public_key: String,
37 pub allowed_ips: String,
38 pub endpoint: String,
39}
40
41#[derive(Debug, Clone)]
42pub struct NewServerDraft {
43 pub name: String,
44 pub private_key: String,
45 pub address: String,
46 pub listen_port: String,
47 pub egress_interface: String,
48}
49
50#[derive(Debug, Clone)]
51pub struct PeerConfig {
52 pub client_config_template: String,
53 pub suggested_filename: String,
54 pub listen_port: u16,
55}
56
57#[derive(Clone)]
58pub enum Message {
59 Info(String),
60 Success(String),
61 Error(String),
62}
63
64impl Message {
65 #[must_use]
66 pub fn style(&self) -> Style {
67 Style::default().fg(match self {
68 Self::Info(_) => Color::Blue,
69 Self::Success(_) => Color::Green,
70 Self::Error(_) => Color::Red,
71 })
72 }
73
74 #[must_use]
75 pub fn text(&self) -> &str {
76 match self {
77 Self::Info(s) | Self::Success(s) | Self::Error(s) => s,
78 }
79 }
80}