fix: escape the source title in markup; capture peer comes from the source config

This commit is contained in:
Martino Ferrari committed 2026-10-31 20:27:47 +01:00
1 parent 4d859d6a37
commit dd4aed8dec
2 files changed
+11 -5

No files matched your search

+8 -2
View File
@@ -97,11 +97,17 @@ void Acquisition::set_capture_want(bool want, std::uint32_t slots) {
g_mkdir_with_parents(dir.c_str(), 0700); g_mkdir_with_parents(dir.c_str(), 0700);
capture_path_ = dir + "/capture.bin"; capture_path_ = dir + "/capture.bin";
std::uint32_t addr = 0; std::uint32_t addr = 0;
std::uint16_t peer_port = 0;
if (cfg_.source_kind == "udps") {
// The source config, not cfg_.server/port: --source-opt overrides only the former.
const SourceConfig sc = cfg_.source_config();
struct ::in_addr a; struct ::in_addr a;
if (cfg_.source_kind == "udps" && ::inet_pton(AF_INET, cfg_.server.c_str(), &a) == 1) { if (::inet_pton(AF_INET, sc.get("server", "127.0.0.1").c_str(), &a) == 1) {
addr = a.s_addr; // already network order, which is what the header wants addr = a.s_addr; // already network order, which is what the header wants
} }
capture_.set_peer(addr, cfg_.source_kind == "udps" ? cfg_.port : 0); peer_port = static_cast<std::uint16_t>(sc.get_int("port", 8000));
}
capture_.set_peer(addr, peer_port);
} }
} }
capture_want_.store(want, std::memory_order_release); capture_want_.store(want, std::memory_order_release);
+3 -3
View File
@@ -100,9 +100,9 @@ void open_configurations(App& app) {
GtkWidget* box = gtk_window_get_child(GTK_WINDOW(window)); GtkWidget* box = gtk_window_get_child(GTK_WINDOW(window));
GtkWidget* title = gtk_label_new(nullptr); GtkWidget* title = gtk_label_new(nullptr);
gtk_label_set_markup(GTK_LABEL(title), char* escaped_title = g_markup_escape_text(app.source_title.c_str(), -1);
("<b>" + app.source_title + "</b>") gtk_label_set_markup(GTK_LABEL(title), (std::string("<b>") + escaped_title + "</b>").c_str());
.c_str()); g_free(escaped_title);
gtk_widget_set_halign(title, GTK_ALIGN_START); gtk_widget_set_halign(title, GTK_ALIGN_START);
gtk_box_append(GTK_BOX(box), title); gtk_box_append(GTK_BOX(box), title);