rush_sync_server/proxy/
types.rs

1use serde::{Deserialize, Serialize};
2use std::collections::HashMap;
3
4#[derive(Debug, Clone, Serialize, Deserialize)]
5pub struct ProxyConfig {
6    pub enabled: bool,
7    pub port: u16,              // HTTP Proxy Port (3000)
8    pub https_port_offset: u16, // NEU: HTTPS Offset (443)
9    pub bind_address: String,
10    pub health_check_interval: u64,
11    pub timeout_ms: u64,
12}
13
14impl Default for ProxyConfig {
15    fn default() -> Self {
16        Self {
17            enabled: true,
18            port: 3000,             // HTTP Proxy
19            https_port_offset: 443, // HTTPS = 3000 + 443 = 3443
20            bind_address: "127.0.0.1".to_string(),
21            health_check_interval: 30,
22            timeout_ms: 5000,
23        }
24    }
25}
26
27// NEU: TOML-spezifische Struktur für Serialisierung
28#[derive(Debug, Serialize, Deserialize)]
29pub struct ProxyConfigToml {
30    pub enabled: bool,
31    pub port: u16,
32    pub bind_address: String,
33    pub health_check_interval: u64,
34    pub timeout_ms: u64,
35    pub https_port_offset: u16,
36}
37
38// FEHLEND: Default für ProxyConfigToml
39impl Default for ProxyConfigToml {
40    fn default() -> Self {
41        Self {
42            enabled: true,
43            port: 3000,
44            https_port_offset: 443,
45            bind_address: "127.0.0.1".to_string(),
46            health_check_interval: 30,
47            timeout_ms: 5000,
48        }
49    }
50}
51
52impl From<ProxyConfig> for ProxyConfigToml {
53    fn from(config: ProxyConfig) -> Self {
54        Self {
55            enabled: config.enabled,
56            port: config.port,
57            https_port_offset: config.https_port_offset,
58            bind_address: config.bind_address,
59            health_check_interval: config.health_check_interval,
60            timeout_ms: config.timeout_ms,
61        }
62    }
63}
64
65impl From<ProxyConfigToml> for ProxyConfig {
66    fn from(config: ProxyConfigToml) -> Self {
67        Self {
68            enabled: config.enabled,
69            port: config.port,
70            https_port_offset: config.https_port_offset,
71            bind_address: config.bind_address,
72            health_check_interval: config.health_check_interval,
73            timeout_ms: config.timeout_ms,
74        }
75    }
76}
77
78#[derive(Debug, Clone)]
79pub struct ProxyTarget {
80    pub name: String,
81    pub port: u16,
82    pub healthy: bool,
83    pub last_check: std::time::SystemTime,
84}
85
86#[derive(Debug, Clone)]
87pub struct ProxyRoute {
88    pub subdomain: String,
89    pub target_port: u16,
90    pub server_id: String,
91}
92
93pub type RouteMap = HashMap<String, ProxyRoute>;