Updated without Vector
This commit is contained in:
@@ -91,6 +91,7 @@ struct ConnectionConfig {
|
||||
tcp_port: String,
|
||||
udp_port: String,
|
||||
log_port: String,
|
||||
auto_ports: bool, // when true, SERVICE_INFO may override udp_port / log_port
|
||||
version: u64,
|
||||
}
|
||||
|
||||
@@ -314,6 +315,7 @@ impl MarteDebugApp {
|
||||
tcp_port: "8080".to_string(),
|
||||
udp_port: "8081".to_string(),
|
||||
log_port: "8082".to_string(),
|
||||
auto_ports: true,
|
||||
version: 0,
|
||||
};
|
||||
let shared_config = Arc::new(Mutex::new(config.clone()));
|
||||
@@ -1102,7 +1104,7 @@ fn udp_worker(
|
||||
thread::sleep(std::time::Duration::from_secs(1));
|
||||
continue;
|
||||
};
|
||||
let mut buf = [0u8; 4096];
|
||||
let mut buf = [0u8; 65535];
|
||||
let mut total_packets = 0u64;
|
||||
loop {
|
||||
if shared_config.lock().unwrap().version != current_version {
|
||||
@@ -1360,23 +1362,25 @@ impl eframe::App for MarteDebugApp {
|
||||
let _ = self.tx_cmd.send("DISCOVER".to_string());
|
||||
}
|
||||
InternalEvent::ServiceConfig { udp_port, log_port } => {
|
||||
let mut changed = false;
|
||||
if !udp_port.is_empty() && self.config.udp_port != udp_port {
|
||||
self.config.udp_port = udp_port;
|
||||
changed = true;
|
||||
}
|
||||
if !log_port.is_empty() && self.config.log_port != log_port {
|
||||
self.config.log_port = log_port;
|
||||
changed = true;
|
||||
}
|
||||
if changed {
|
||||
self.config.version += 1;
|
||||
*self.shared_config.lock().unwrap() = self.config.clone();
|
||||
self.logs.push_back(LogEntry {
|
||||
time: Local::now().format("%H:%M:%S").to_string(),
|
||||
level: "GUI_INFO".to_string(),
|
||||
message: format!("Config updated from server: UDP={}, LOG={}", self.config.udp_port, self.config.log_port),
|
||||
});
|
||||
if self.config.auto_ports {
|
||||
let mut changed = false;
|
||||
if !udp_port.is_empty() && self.config.udp_port != udp_port {
|
||||
self.config.udp_port = udp_port;
|
||||
changed = true;
|
||||
}
|
||||
if !log_port.is_empty() && self.config.log_port != log_port {
|
||||
self.config.log_port = log_port;
|
||||
changed = true;
|
||||
}
|
||||
if changed {
|
||||
self.config.version += 1;
|
||||
*self.shared_config.lock().unwrap() = self.config.clone();
|
||||
self.logs.push_back(LogEntry {
|
||||
time: Local::now().format("%H:%M:%S").to_string(),
|
||||
level: "GUI_INFO".to_string(),
|
||||
message: format!("Ports auto-configured: UDP={}, LOG={}", self.config.udp_port, self.config.log_port),
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
InternalEvent::Disconnected => {
|
||||
@@ -1942,14 +1946,17 @@ impl eframe::App for MarteDebugApp {
|
||||
ui.label("IP:");
|
||||
ui.text_edit_singleline(&mut self.config.ip);
|
||||
ui.end_row();
|
||||
ui.label("Control:");
|
||||
ui.label("Control TCP:");
|
||||
ui.text_edit_singleline(&mut self.config.tcp_port);
|
||||
ui.end_row();
|
||||
ui.label("Telemetry (Auto):");
|
||||
ui.label(&self.config.udp_port);
|
||||
ui.label("Telemetry UDP:");
|
||||
ui.add_enabled(!self.config.auto_ports, egui::TextEdit::singleline(&mut self.config.udp_port));
|
||||
ui.end_row();
|
||||
ui.label("Logs (Auto):");
|
||||
ui.label(&self.config.log_port);
|
||||
ui.label("Log TCP:");
|
||||
ui.add_enabled(!self.config.auto_ports, egui::TextEdit::singleline(&mut self.config.log_port));
|
||||
ui.end_row();
|
||||
ui.label("Auto ports:");
|
||||
ui.checkbox(&mut self.config.auto_ports, "from SERVICE_INFO");
|
||||
ui.end_row();
|
||||
});
|
||||
if ui.button("🔄 Apply").clicked() {
|
||||
|
||||
Reference in New Issue
Block a user