Skip to content

Force Proxy to any Windows/MacOS/Linux Application TCP and UDP traffic

test(linux): zoom, auto-clear, filter, boot service and start-up update scenarios; boot unit test; profile and settings tests

anof-cyberd2ad4badbd27
diff --git a/Linux/README.md b/Linux/README.md
index 0744687..f1044d5 100644
--- a/Linux/README.md
+++ b/Linux/README.md
@@ -89,6 +89,7 @@ sudo ProxyBridgeGUI
The GTK3-based GUI provides:
- Proxy configuration (SOCKS5/HTTP with authentication)
- Visual rule management with process selection
+- Font zoom, auto-clear logs, connection-log filters, *Start at Boot* and an update check on startup (see [Appearance, logs and start-up](#appearance-logs-and-start-up))
- Real-time connection monitoring, a **Live Connections** tab (every proxied TCP connection and UDP flow with its process, destination, proxy, age and bytes), and *Log Every Connection* / *Enable ProxyBridge* switches in the Proxy menu
- Profiles: create, switch, duplicate, rename, delete, **import and export** `.pbprofile` files (the Windows/macOS format, see [Profiles](#profiles))
- Import/Export rules (JSON format compatible with Windows/macOS)
@@ -350,6 +351,14 @@ Cost: DNS from covered processes takes one extra loopback hop (about +90 µs per
- **Enable ProxyBridge** (Proxy menu, `ProxyBridge_SetEnabled()`): the main switch. Off pauses every rule for *new* connections; connections already relayed keep running.
- **Testing a proxy.** The Test button in the proxy settings and `--test-proxy host[:port]` run the same five steps: reach the proxy, open a tunnel and log in, load a page (port 80), time three more tunnels, and probe UDP ASSOCIATE. Only the first two decide success; a page, latency or UDP problem is a warning. The exit code is 0 only when every configured proxy works.
+## Appearance, logs and start-up
+
+- **Font zoom** (View menu, `Ctrl` + `+` / `-` / `0`): 60-300 % in steps of 10, saved in the profile (`FontZoom`).
+- **Auto-clear Logs** (Proxy menu, on by default, saved in the profile as `AutoClearConnectionLogs`): a log is wiped once it grows past 500 lines. Switched off, each log keeps its recent history (1000 lines for activity, 2000 for connections).
+- **Log Filters...** (Proxy menu): rules for what the connection log shows, saved in the profile as `LogFilters`. A filter has a mode (*Include* or *Exclude*) and optional patterns for process, IP address, port, protocol (*All*/*TCP*/*UDP*) and action (*All*/*Direct*/*Proxy*/*Blocked*); patterns are case-insensitive globs (`*`, `?`), empty or `All` matches anything. Excludes run first (any match hides a line); if there are Include filters, a line must match one of them. Filters apply to new connections as they happen; the traffic itself is not affected.
+- **Start at Boot** (Proxy menu): writes `/etc/systemd/system/proxybridge.service`, which runs the command line program next to the GUI (or `/usr/local/bin/ProxyBridge`) with the **active profile**, and enables it; unchecking disables the service and removes the file. The unit follows the active profile when you switch or rename it. Needs systemd and root (the GUI already runs as root); a failure is reported and the box stays unchecked.
+- **Check for Updates on Startup** (About menu, on by default, stored in `settings.json`): asks the update feed in the background when the GUI starts. It stays quiet unless a newer version exists, then offers *Open in Browser*, *Close* or *Don't Check at Startup*. Only an `https` page is ever opened.
+
## Compared with the Windows app (4.3.0)
| Feature | Linux |
@@ -364,7 +373,10 @@ Cost: DNS from covered processes takes one extra loopback hop (about +90 µs per
| Detailed proxy check (reach, login, page, latency, UDP) | yes (GUI Test button, `--test-proxy`) |
| Live connections | yes (GUI tab, `ProxyBridge_GetFlows`) |
| Log Every Connection, main on/off switch | yes |
-| Hide/Show log filters (`LogFilters`), auto-clear logs, font zoom, language, close to tray, start with the OS, update check on start-up | not implemented (a `LogFilters` list in an imported profile is ignored) |
+| Connection-log filters (`LogFilters`), auto-clear logs (`AutoClearConnectionLogs`), font zoom (`FontZoom`) | yes, per profile |
+| Start with the OS | yes, as a systemd service that runs `ProxyBridge --profile <active profile>` (Proxy menu, *Start at Boot*) |
+| Update check on start-up | yes (*Check for Updates on Startup*, on by default, quiet unless a newer version exists) |
+| Language selection, close to tray | not implemented |
## Multiple proxies
diff --git a/Linux/gui/tests/boot_test.c b/Linux/gui/tests/boot_test.c
new file mode 100644
index 0000000..a5cb770
--- /dev/null
+++ b/Linux/gui/tests/boot_test.c
@@ -0,0 +1,119 @@
+// Unit test of gui_boot.c: the systemd unit "Start at boot" writes, with a fake systemctl. Needs no root.
+#include "../gui_boot.h"
+#include <glib/gstdio.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <sys/stat.h>
+#include <unistd.h>
+
+static int checks, fails;
+#define CHECK(c) do { checks++; if (!(c)) { fails++; printf("FAIL line %d: %s\n", __LINE__, #c); } } while (0)
+
+static char *slurp(const char *path)
+{
+ char *s = NULL;
+ if (!g_file_get_contents(path, &s, NULL, NULL)) s = g_strdup("");
+ return s;
+}
+
+int main(void)
+{
+ char *dir = g_dir_make_tmp("pbboot-XXXXXX", NULL);
+ char *units = g_build_filename(dir, "units", NULL), *calls = g_build_filename(dir, "calls.log", NULL), *fake = g_build_filename(dir, "systemctl", NULL);
+ g_mkdir_with_parents(units, 0755);
+ char *script = g_strdup_printf("#!/bin/sh\necho \"$@\" >> %s\n[ \"$FAKE_FAIL\" = \"$1\" ] && { echo \"boom: $1\" >&2; exit 1; }\nexit 0\n", calls);
+ g_file_set_contents(fake, script, -1, NULL);
+ chmod(fake, 0755);
+ setenv("PROXYBRIDGE_SYSTEMD_DIR", units, 1);
+ setenv("PROXYBRIDGE_SYSTEMCTL", fake, 1);
+ setenv("PROXYBRIDGE_CLI", "/opt/pb dir/ProxyBridge", 1);
+ char *unit = g_build_filename(units, "proxybridge.service", NULL);
+ char *err = NULL;
+
+ // unit text
+ char *t = boot_unit_text("/usr/local/bin/ProxyBridge", "Work", &err);
+ CHECK(t && strstr(t, "ExecStart=\"/usr/local/bin/ProxyBridge\" --profile \"Work\"\n") && strstr(t, "WantedBy=multi-user.target") &&
+ strstr(t, "After=network-online.target") && strstr(t, "Restart=on-failure"));
+ g_free(t);
+ t = boot_unit_text("/x/ProxyBridge", "a \"b\" \\c %h $HOME", &err);
+ CHECK(t && strstr(t, "--profile \"a \\\"b\\\" \\\\c %%h $$HOME\"\n")); // quoting that systemd understands
+ g_free(t);
+ t = boot_unit_text("/x/ProxyBridge", "line\nbreak", &err);
+ CHECK(t == NULL && err && strstr(err, "control characters"));
+ g_free(err); err = NULL;
+ t = boot_unit_text("/x/ProxyBridge", "tab\there", &err);
+ CHECK(t == NULL);
+ g_free(err); err = NULL;
+ t = boot_unit_text("/x/Proxy\nBridge", "ok", &err);
+ CHECK(t == NULL && err);
+ g_free(err); err = NULL;
+
+ // enable
+ CHECK(!boot_is_enabled());
+ CHECK(boot_set(true, "Work", &err) && err == NULL);
+ CHECK(boot_is_enabled());
+ char *content = slurp(unit);
+ CHECK(strstr(content, "ExecStart=\"/opt/pb dir/ProxyBridge\" --profile \"Work\"\n")); // a path with a space is quoted
+ struct stat st;
+ CHECK(stat(unit, &st) == 0 && (st.st_mode & 0777) == 0644);
+ char *log = slurp(calls);
+ CHECK(strstr(log, "daemon-reload") && strstr(log, "enable proxybridge.service"));
+ g_free(content); g_free(log);
+
+ // another active profile rewrites the unit
+ CHECK(boot_refresh("Home", &err));
+ content = slurp(unit);
+ CHECK(strstr(content, "--profile \"Home\"") && !strstr(content, "Work"));
+ g_free(content);
+
+ // disable
+ g_unlink(calls);
+ CHECK(boot_set(false, "Home", &err));
+ CHECK(!boot_is_enabled());
+ log = slurp(calls);
+ CHECK(strstr(log, "disable proxybridge.service") && strstr(log, "daemon-reload"));
+ g_free(log);
+ g_unlink(calls);
+ CHECK(boot_refresh("Work", &err) && !boot_is_enabled()); // refresh does not enable anything
+ CHECK(boot_set(false, "Work", &err)); // disabling twice is fine and runs nothing
+ log = slurp(calls);
+ CHECK(strlen(log) == 0);
+ g_free(log);
+
+ // a failing systemctl: report it and leave no unit behind
+ setenv("FAKE_FAIL", "enable", 1);
+ CHECK(!boot_set(true, "Work", &err) && err && strstr(err, "systemctl enable") && strstr(err, "boom"));
+ CHECK(!boot_is_enabled());
+ g_free(err); err = NULL;
+ setenv("FAKE_FAIL", "daemon-reload", 1);
+ CHECK(!boot_set(true, "Work", &err) && err && strstr(err, "daemon-reload"));
+ CHECK(!boot_is_enabled());
+ g_free(err); err = NULL;
+ unsetenv("FAKE_FAIL");
+ CHECK(boot_set(true, "Work", &err));
+ setenv("FAKE_FAIL", "disable", 1);
+ CHECK(!boot_set(false, "Work", &err) && err && strstr(err, "disable"));
+ CHECK(boot_is_enabled()); // still enabled: the disable failed
+ g_free(err); err = NULL;
+ unsetenv("FAKE_FAIL");
+ CHECK(boot_set(false, "Work", &err));
+
+ // systemctl missing, and a directory that cannot be written
+ setenv("PROXYBRIDGE_SYSTEMCTL", "/nonexistent/systemctl", 1);
+ CHECK(!boot_set(true, "Work", &err) && err && strstr(err, "could not run"));
+ CHECK(!boot_is_enabled());
+ g_free(err); err = NULL;
+ setenv("PROXYBRIDGE_SYSTEMCTL", fake, 1);
+ setenv("PROXYBRIDGE_SYSTEMD_DIR", "/nonexistent/dir", 1);
+ CHECK(!boot_set(true, "Work", &err) && err && strstr(err, "cannot write"));
+ g_free(err); err = NULL;
+ CHECK(!boot_set(true, "bad\nname", &err) && err && strstr(err, "control characters"));
+ g_free(err);
+
+ char *cmd = g_strdup_printf("rm -rf %s", dir);
+ CHECK(system(cmd) == 0);
+ g_free(cmd); g_free(dir); g_free(units); g_free(calls); g_free(fake); g_free(script); g_free(unit);
+ printf("boot_test: %d checks, %d failed\n", checks, fails);
+ return fails != 0;
+}
diff --git a/Linux/gui/tests/config_test.c b/Linux/gui/tests/config_test.c
index d27a4ee..b18da5d 100644
--- a/Linux/gui/tests/config_test.c
+++ b/Linux/gui/tests/config_test.c
@@ -11,6 +11,13 @@ GList *g_rules_list = NULL;
bool g_chk_logging = true;
bool g_chk_dns = true;
bool g_chk_log_every = false;
+bool g_chk_auto_clear = true;
+int g_zoom = 100;
+bool g_chk_updates = true;
+
+// the log view lives in gui_logs.c; the test only records what the config code tells it
+static size_t g_filters_seen;
+void gui_logs_set_filters(const struct pbp_filter *f, size_t n) { (void)f; g_filters_seen = n; }
void free_proxy_data(ProxyData *p) {
g_free(p->name); g_free(p->host); g_free(p->username); g_free(p->password); g_free(p);
@@ -197,6 +204,18 @@ int main() {
g_chk_dns = false;
g_chk_logging = false;
g_chk_log_every = true;
+ g_chk_auto_clear = false;
+ g_zoom = 140;
+ g_chk_updates = false;
+ {
+ struct pbp_filter *fl = calloc(2, sizeof *fl);
+ struct pbp_filter a = { true, (char *)"chrome*", (char *)"10.*", (char *)"443", (char *)"TCP", (char *)"Proxy" };
+ struct pbp_filter b = { false, (char *)"", (char *)"", (char *)"", (char *)"All", (char *)"All" };
+ fl[0] = pbp_filter_dup(&a);
+ fl[1] = pbp_filter_dup(&b);
+ gui_filters_replace(fl, 2);
+ CHECK(g_filters_seen == 2);
+ }
save_config();
check_storage(dir);
@@ -210,13 +229,22 @@ int main() {
CHECK(!((ProxyData *)g_proxies_list->data)->send_domain); // per-proxy "DNS via proxy" survives a restart
CHECK(strcmp(((RuleData *)g_rules_list->data)->name, "Burp \"intercept\"") == 0 && ((RuleData *)g_rules_list->data)->localhost);
CHECK(!g_chk_dns && !g_chk_logging && g_chk_log_every); // restored from the Work profile file itself
+ CHECK(!g_chk_auto_clear && g_zoom == 140 && !g_chk_updates); // zoom and auto-clear belong to the profile, the update check to settings.json
+ {
+ size_t n = 0;
+ struct pbp_filter *fl = gui_filters(&n);
+ CHECK(n == 2 && fl && fl[0].exclude && strcmp(fl[0].process, "chrome*") == 0 && strcmp(fl[0].port, "443") == 0 &&
+ strcmp(fl[0].protocol, "TCP") == 0 && strcmp(fl[0].action, "Proxy") == 0 && !fl[1].exclude);
+ CHECK(g_filters_seen == 2); // the log view got the filters when the profile was loaded
+ }
CHECK(profile_find("Home") && !profile_find("Home")->logging && profile_find("Home")->dns); // migrated values of the old file, per profile
CHECK(profile_find("Home") && g_list_length(profile_find("Home")->rules) == 1);
CHECK(profile_activate("Home")); // switching profiles switches the values too
CHECK(!g_chk_logging && g_chk_dns && !g_chk_log_every);
+ CHECK(g_chk_auto_clear && g_zoom == 100 && g_filters_seen == 0); // the migrated profile has the defaults
CHECK(profile_activate("Work"));
- CHECK(!g_chk_logging && !g_chk_dns && g_chk_log_every);
+ CHECK(!g_chk_logging && !g_chk_dns && g_chk_log_every && g_zoom == 140 && g_filters_seen == 2);
CHECK(profile_activate("Home"));
CHECK(profile_activate("Work"));
CHECK(profile_delete(profile_find("Work")));
diff --git a/Linux/gui/tests/run_tests.sh b/Linux/gui/tests/run_tests.sh
index 3ccad92..48c7fe2 100755
--- a/Linux/gui/tests/run_tests.sh
+++ b/Linux/gui/tests/run_tests.sh
@@ -7,11 +7,13 @@ CF="-Wall -Wextra -Wno-unused-parameter -g -fsanitize=address,undefined -I../src
LF="$(pkg-config --libs gtk+-3.0)"
gcc $CF tests/config_test.c gui_config.c ../profile/pb_profile.c -o "$OUT/config_test" $LF
gcc $CF tests/json_test.c gui_json.c -o "$OUT/json_test" $LF
+gcc -g -Wall -Wextra -fsanitize=address,undefined -DPB_TEST_HOOKS -D_GNU_SOURCE -I. $(pkg-config --cflags glib-2.0) tests/boot_test.c gui_boot.c -o "$OUT/boot_test" $(pkg-config --libs glib-2.0)
gcc $CF tests/list_test.c gui_list.c -o "$OUT/list_test" $LF
gcc -O1 -I../src -I../profile -I. -D_GNU_SOURCE $(pkg-config --cflags gtk+-3.0) tests/config_test.c gui_config.c ../profile/pb_profile.c -o "$OUT/config_plain" $LF
"$OUT/config_plain"
ASAN_OPTIONS=detect_leaks=1 "$OUT/config_test"
ASAN_OPTIONS=detect_leaks=1 "$OUT/json_test"
+ASAN_OPTIONS=detect_leaks=1 "$OUT/boot_test"
ASAN_OPTIONS=detect_leaks=1 "$OUT/list_test"
gcc -O2 -Wall -Wextra -I. tests/events_test.c gui_events.c -o "$OUT/events_plain" -pthread
time "$OUT/events_plain"
diff --git a/Linux/gui/tests/ui_test.c b/Linux/gui/tests/ui_test.c
index cbef674..c12ee0d 100644
--- a/Linux/gui/tests/ui_test.c
+++ b/Linux/gui/tests/ui_test.c
@@ -808,6 +808,375 @@ static void logs_scenario(void) {
ProxyBridge_DeleteRule(rule);
}
+
+// ================================================================================================================================
+// Font zoom, auto-clear, log filters, start at boot, update check on start-up
+// ================================================================================================================================
+static int buffer_lines(const char *view_name)
+{
+ GtkWidget *v = find_named(view_name);
+ return v ? gtk_text_buffer_get_line_count(gtk_text_view_get_buffer(GTK_TEXT_VIEW(v))) - 1 : -1;
+}
+
+static void fire_logs(int n)
+{
+ for (int i = 0; i < n; i++) gui_log("filler line %d", i);
+ pump(900);
+}
+
+static void zoom_scenario(void)
+{
+ STEP("font zoom");
+ struct pbp_profile disk;
+ CHECK(g_zoom == 100);
+ activate("Zoom In"); activate("Zoom In");
+ CHECK(g_zoom == 120 && strstr(gui_zoom_css(), "120%") != NULL);
+ CHECK(load_disk("Default", &disk) && disk.font_zoom == 120);
+ pbp_free(&disk);
+ activate("Zoom Out");
+ CHECK(g_zoom == 110 && strstr(gui_zoom_css(), "110%") != NULL);
+ activate("Reset Zoom");
+ CHECK(g_zoom == 100 && strstr(gui_zoom_css(), "100%") != NULL);
+
+ gui_set_zoom(1000); CHECK(g_zoom == 300);
+ activate("Zoom In"); CHECK(g_zoom == 300); // clamped at both ends
+ gui_set_zoom(5); CHECK(g_zoom == 60);
+ activate("Zoom Out"); CHECK(g_zoom == 60);
+ gui_set_zoom(-40); CHECK(g_zoom == 60);
+
+ // the zoom belongs to the profile
+ gui_set_zoom(130);
+ CHECK(profile_create("Zoomed", false) != NULL);
+ CHECK(profile_activate("Zoomed"));
+ gui_sync_switches();
+ CHECK(g_zoom == 100 && strstr(gui_zoom_css(), "100%") != NULL);
+ gui_set_zoom(180);
+ CHECK(profile_activate("Default"));
+ gui_sync_switches();
+ CHECK(g_zoom == 130 && strstr(gui_zoom_css(), "130%") != NULL);
+ CHECK(profile_activate("Zoomed"));
+ gui_sync_switches();
+ CHECK(g_zoom == 180);
+ CHECK(profile_activate("Default"));
+ gui_sync_switches();
+ gui_set_zoom(100);
+ save_config();
+}
+
+static void autoclear_scenario(void)
+{
+ STEP("auto-clear logs");
+ GtkWidget *item = menu_item("Auto-clear Logs");
+ CHECK(item && gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(item)) && g_chk_auto_clear);
+ click("log_clear");
+ fire_logs(600); // past 500 lines the log is wiped
+ int n = buffer_lines("log_view");
+ CHECK(n >= 0 && n < 500);
+ gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(item), FALSE);
+ CHECK(!g_chk_auto_clear);
+ struct pbp_profile disk;
+ CHECK(load_disk("Default", &disk) && !disk.auto_clear);
+ pbp_free(&disk);
+ click("log_clear");
+ fire_logs(700); // switched off: the log keeps its history
+ n = buffer_lines("log_view");
+ CHECK(n >= 700);
+ gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(item), TRUE);
+ CHECK(g_chk_auto_clear && load_disk("Default", &disk) && disk.auto_clear);
+ pbp_free(&disk);
+ click("log_clear");
+}
+
+typedef struct { const char *mode, *proc, *ip, *port, *proto, *action; } FltForm;
+
+static void fill_flt(GtkWidget *d, gpointer arg)
+{
+ FltForm *f = arg;
+ set_combo(d, "flt_mode", !strcmp(f->mode, "Exclude") ? 1 : 0);
+ set_text(d, "flt_process", f->proc); set_text(d, "flt_ip", f->ip); set_text(d, "flt_port", f->port);
+ set_combo(d, "flt_proto", !strcmp(f->proto, "TCP") ? 1 : !strcmp(f->proto, "UDP") ? 2 : 0);
+ set_combo(d, "flt_action", !strcmp(f->action, "Direct") ? 1 : !strcmp(f->action, "Proxy") ? 2 : !strcmp(f->action, "Blocked") ? 3 : 0);
+}
+
+static FltForm *ff(const char *mode, const char *proc, const char *ip, const char *port, const char *proto, const char *action)
+{
+ FltForm *f = g_malloc0(sizeof *f);
+ f->mode = mode; f->proc = proc; f->ip = ip; f->port = port; f->proto = proto; f->action = action;
+ return f;
+}
+
+static char *flt_error;
+static void see_flt_error(GtkWidget *d, gpointer arg) { (void)arg; g_free(flt_error); flt_error = get_text(d, "flt_error"); }
+static void submit_bad_flt(GtkWidget *d, gpointer arg)
+{
+ fill_flt(d, arg);
+ arm("dlg_filter", see_flt_error, NULL, GTK_RESPONSE_CANCEL);
+}
+
+static void filters_add_exclude(GtkWidget *dlg, gpointer arg)
+{
+ (void)arg;
+ CHECK(model_rows("filter_tree") == 0);
+ arm("dlg_filter", fill_flt, ff("Exclude", "python3*", "", "", "All", "All"), GTK_RESPONSE_ACCEPT);
+ click("flt_add");
+ CHECK(model_rows("filter_tree") == 1);
+ size_t n = 0;
+ struct pbp_filter *fl = gui_filters(&n);
+ CHECK(n == 1 && fl[0].exclude && !strcmp(fl[0].process, "python3*") && !strcmp(fl[0].protocol, "All"));
+ gtk_dialog_response(GTK_DIALOG(dlg), GTK_RESPONSE_CLOSE);
+}
+
+static void filters_manage(GtkWidget *dlg, gpointer arg)
+{
+ (void)arg;
+ size_t n = 0;
+ CHECK(model_rows("filter_tree") == 1); // the filter added earlier is listed
+
+ g_free(flt_error); flt_error = NULL;
+ arm("dlg_filter", submit_bad_flt, ff("Include", "x", "", "80x", "All", "All"), GTK_RESPONSE_ACCEPT);
+ click("flt_add");
+ CHECK_HAS(flt_error, "Port must be digits");
+ CHECK(model_rows("filter_tree") == 1);
+
+ arm("dlg_filter", fill_flt, ff("Include", "ignored", "", "", "All", "All"), GTK_RESPONSE_CANCEL); // cancel changes nothing
+ click("flt_add");
+ CHECK(model_rows("filter_tree") == 1);
+
+ unselect_all("filter_tree");
+ arm_msg(GTK_RESPONSE_OK); click("flt_edit"); CHECK_HAS(last_msg, "Select a filter first");
+ arm_msg(GTK_RESPONSE_OK); click("flt_delete"); CHECK_HAS(last_msg, "Select a filter first");
+
+ select_row("filter_tree", 0);
+ arm("dlg_filter", fill_flt, ff("Include", "curl", "192.0.2.4*", "80", "TCP", "Proxy"), GTK_RESPONSE_ACCEPT);
+ click("flt_edit");
+ struct pbp_filter *fl = gui_filters(&n);
+ CHECK(n == 1 && !fl[0].exclude && !strcmp(fl[0].process, "curl") && !strcmp(fl[0].ip, "192.0.2.4*") && !strcmp(fl[0].port, "80") &&
+ !strcmp(fl[0].protocol, "TCP") && !strcmp(fl[0].action, "Proxy"));
+ struct pbp_profile disk;
+ CHECK(load_disk("Default", &disk) && disk.nfilters == 1 && !disk.filters[0].exclude && !strcmp(disk.filters[0].ip, "192.0.2.4*"));
+ pbp_free(&disk);
+
+ arm("dlg_filter", fill_flt, ff("Exclude", "*", "", "53", "UDP", "Blocked"), GTK_RESPONSE_ACCEPT);
+ click("flt_add");
+ CHECK(model_rows("filter_tree") == 2);
+ select_row("filter_tree", 0);
+ click("flt_delete");
+ fl = gui_filters(&n);
+ CHECK(n == 1 && fl[0].exclude && !strcmp(fl[0].port, "53"));
+ select_row("filter_tree", 0);
+ click("flt_delete");
+ gui_filters(&n);
+ CHECK(n == 0 && model_rows("filter_tree") == 0);
+ CHECK(load_disk("Default", &disk) && disk.nfilters == 0);
+ pbp_free(&disk);
+ gtk_dialog_response(GTK_DIALOG(dlg), GTK_RESPONSE_CLOSE);
+}
+
+static void filters_delete_all(GtkWidget *dlg, gpointer arg)
+{
+ (void)arg;
+ while (model_rows("filter_tree") > 0) { select_row("filter_tree", 0); click("flt_delete"); }
+ gtk_dialog_response(GTK_DIALOG(dlg), GTK_RESPONSE_CLOSE);
+}
+
+static void filters_scenario(void)
+{
+ STEP("log filters");
+ ProxyData *p = proxy_named("p1x");
+ char err[200];
+ uint32_t rule = p ? ProxyBridge_AddRule("python3*", "192.0.2.40-192.0.2.60", "80", RULE_PROTOCOL_TCP, RULE_ACTION_PROXY, p->id, err, sizeof err) : 0;
+ CHECK(rule != 0);
+ GtkWidget *log_item = menu_item("Enable Traffic Logging");
+ if (log_item) gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(log_item), TRUE);
+ click("conn_clear");
+
+ // an Exclude filter hides new connections of that process
+ arm("dlg_filters", filters_add_exclude, NULL, 0);
+ activate("Log Filters...");
+ connect_once("192.0.2.43");
+ pump(900);
+ char *conns = buffer_of("conn_view");
+ CHECK(strstr(conns, "192.0.2.43") == NULL);
+ g_free(conns);
+
+ // the dialog edits, validates and deletes
+ arm("dlg_filters", filters_manage, NULL, 0);
+ activate("Log Filters...");
+
+ // Include filters show only what matches
+ arm("dlg_filters", filters_delete_all, NULL, 0);
+ activate("Log Filters...");
+ connect_once("192.0.2.44");
+ pump(900);
+ conns = buffer_of("conn_view");
+ CHECK_HAS(conns, "192.0.2.44:80"); // with the filter gone the connection shows again
+ g_free(conns);
+ click("conn_clear");
+
+ size_t n = 0;
+ struct pbp_filter inc = { false, strdup(""), strdup("192.0.2.45"), strdup(""), strdup("All"), strdup("All") };
+ struct pbp_filter *fl = calloc(1, sizeof *fl);
+ fl[0] = pbp_filter_dup(&inc);
+ pbp_filter_clear(&inc);
+ gui_filters_replace(fl, 1);
+ connect_once("192.0.2.45");
+ connect_once("192.0.2.46");
+ pump(900);
+ conns = buffer_of("conn_view");
+ CHECK(strstr(conns, "192.0.2.45:80") != NULL && strstr(conns, "192.0.2.46") == NULL);
+ g_free(conns);
+ gui_filters_replace(NULL, 0);
+ gui_filters(&n);
+ CHECK(n == 0);
+
+ // the filters follow the profile
+ fl = calloc(1, sizeof *fl);
+ struct pbp_filter ex = { true, strdup("python3*"), strdup(""), strdup(""), strdup("All"), strdup("All") };
+ fl[0] = pbp_filter_dup(&ex);
+ pbp_filter_clear(&ex);
+ gui_filters_replace(fl, 1);
+ CHECK(profile_activate("Zoomed"));
+ gui_filters(&n);
+ CHECK(n == 0);
+ CHECK(profile_activate("Default"));
+ gui_filters(&n);
+ CHECK(n == 1);
+ gui_filters_replace(NULL, 0);
+ save_config();
+ ProxyBridge_DeleteRule(rule);
+ click("conn_clear");
+}
+
+static void make_fake_systemctl(const char *path, const char *log)
+{
+ char *script = g_strdup_printf("#!/bin/sh\necho \"$@\" >> %s\n[ \"$FAKE_FAIL\" = \"$1\" ] && { echo \"boom: $1\" >&2; exit 1; }\nexit 0\n", log);
+ g_file_set_contents(path, script, -1, NULL);
+ chmod(path, 0755);
+ g_free(script);
+}
+
+static void switch_to(GtkWidget *dlg, gpointer arg)
+{
+ select_by_first_column("profile_tree", arg);
+ click("pf_switch");
+ gtk_dialog_response(GTK_DIALOG(dlg), GTK_RESPONSE_CLOSE);
+}
+
+static void boot_scenario(void)
+{
+ STEP("start at boot");
+ char *units = tmp_path("units"), *fake = tmp_path("systemctl"), *calls = tmp_path("systemctl.log");
+ g_mkdir_with_parents(units, 0755);
+ make_fake_systemctl(fake, calls);
+ setenv("PROXYBRIDGE_SYSTEMD_DIR", units, 1);
+ setenv("PROXYBRIDGE_SYSTEMCTL", fake, 1);
+ setenv("PROXYBRIDGE_CLI", "/usr/local/bin/ProxyBridge", 1);
+ char *unit = g_build_filename(units, "proxybridge.service", NULL);
+
+ GtkWidget *item = menu_item("Start at Boot (systemd service)");
+ CHECK(item != NULL && !gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(item)));
+ gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(item), TRUE);
+ char *text = NULL;
+ CHECK(g_file_get_contents(unit, &text, NULL, NULL));
+ CHECK_HAS(text, "ExecStart=\"/usr/local/bin/ProxyBridge\" --profile \"Default\"");
+ g_free(text);
+ char *log = NULL;
+ g_file_get_contents(calls, &log, NULL, NULL);
+ CHECK_HAS(log, "enable proxybridge.service");
+ g_free(log);
+
+ // another active profile is what the service runs after the next boot
+ arm("dlg_profiles", switch_to, (gpointer)"Zoomed", 0);
+ activate("Profiles...");
+ CHECK_STR(g_active_profile, "Zoomed");
+ CHECK(g_file_get_contents(unit, &text, NULL, NULL));
+ CHECK_HAS(text, "--profile \"Zoomed\"");
+ g_free(text);
+ arm("dlg_profiles", switch_to, (gpointer)"Default", 0);
+ activate("Profiles...");
+ CHECK(g_file_get_contents(unit, &text, NULL, NULL));
+ CHECK_HAS(text, "--profile \"Default\"");
+ g_free(text);
+
+ gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(item), FALSE);
+ CHECK(!g_file_test(unit, G_FILE_TEST_EXISTS));
+
+ // a failing systemctl: say so and leave the box unchecked
+ setenv("FAKE_FAIL", "enable", 1);
+ arm_msg(GTK_RESPONSE_OK);
+ gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(item), TRUE);
+ CHECK_HAS(last_msg, "Could not enable starting at boot");
+ CHECK(!gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(item)) && !g_file_test(unit, G_FILE_TEST_EXISTS));
+ unsetenv("FAKE_FAIL");
+ unsetenv("PROXYBRIDGE_SYSTEMD_DIR"); unsetenv("PROXYBRIDGE_SYSTEMCTL"); unsetenv("PROXYBRIDGE_CLI");
+ g_free(units); g_free(fake); g_free(calls); g_free(unit);
+}
+
+static bool any_message_dialog(void) { return visible_dialog("msg") != NULL; }
+
+static void startup_update_scenario(void)
+{
+ STEP("update check on start-up");
+ GtkWidget *item = menu_item("Check for Updates on Startup");
+ CHECK(item && gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(item)) && g_chk_updates);
+ gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(item), FALSE);
+ CHECK(!g_chk_updates);
+ char *settings = tmp_path("settings.json"), *text = NULL;
+ CHECK(g_file_get_contents(settings, &text, NULL, NULL));
+ CHECK_HAS(text, "\"CheckForUpdatesOnStartup\": false");
+ g_free(text);
+ gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(item), TRUE);
+ CHECK(g_chk_updates && g_file_get_contents(settings, &text, NULL, NULL));
+ CHECK_HAS(text, "\"CheckForUpdatesOnStartup\": true");
+ g_free(text); g_free(settings);
+
+ // a start-up check says nothing unless there is a newer version
+ const char *quiet[][2] = {
+ { "su_same.json", "{\"linux\": {\"version\": \"" PROXYBRIDGE_VERSION "\"}}" },
+ { "su_older.json", "{\"linux\": {\"version\": \"1.0.0\"}}" },
+ { "su_broken.json", "not json at all" },
+ { "su_nolinux.json", "{\"windows\": {}}" },
+ };
+ for (size_t i = 0; i < sizeof quiet / sizeof *quiet; i++) {
+ char *path = tmp_path(quiet[i][0]);
+ g_file_set_contents(path, quiet[i][1], -1, NULL);
+ char *url = g_strdup_printf("file://%s", path);
+ setenv("PB_UPDATE_FEED", url, 1);
+ gui_check_updates_on_startup();
+ pump(1500);
+ CHECK(!any_message_dialog());
+ g_free(path); g_free(url);
+ }
+ setenv("PB_UPDATE_FEED", "file:///nonexistent/feed.json", 1);
+ gui_check_updates_on_startup();
+ pump(1500);
+ CHECK(!any_message_dialog());
+
+ // news: the user is asked, and can turn the start-up check off for good
+ char *path = tmp_path("su_newer.json");
+ g_file_set_contents(path, "{\"linux\": {\"version\": \"9.9.9\", \"download\": \"https://example.test/d\", \"release_notes\": \"https://example.test/n\"}}", -1, NULL);
+ char *url = g_strdup_printf("file://%s", path);
+ setenv("PB_UPDATE_FEED", url, 1);
+ g_free(last_msg); last_msg = NULL;
+ arm_msg(GTK_RESPONSE_CANCEL);
+ gui_check_updates_on_startup();
+ for (int i = 0; i < 60 && !last_msg; i++) pump(100);
+ CHECK_HAS(last_msg, "Version 9.9.9 is available");
+ CHECK(g_chk_updates); // Close leaves the setting alone
+ g_free(last_msg); last_msg = NULL;
+ arm_msg(GTK_RESPONSE_REJECT); // "Don't Check at Startup"
+ gui_check_updates_on_startup();
+ for (int i = 0; i < 60 && !last_msg; i++) pump(100);
+ CHECK_HAS(last_msg, "Version 9.9.9 is available");
+ pump(300);
+ CHECK(!g_chk_updates);
+ GtkWidget *it2 = menu_item("Check for Updates on Startup");
+ CHECK(it2 && !gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(it2)));
+ gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(it2), TRUE);
+ g_free(path); g_free(url);
+ unsetenv("PB_UPDATE_FEED");
+}
+
// ================================================================================================================================
static void ui_main(void) {
pump(300);
@@ -837,6 +1206,15 @@ static void ui_main(void) {
printf("== logs\n");
logs_scenario();
+ printf("== zoom, auto-clear, filters, boot, start-up update check\n");
+ zoom_scenario();
+ autoclear_scenario();
+ filters_scenario();
+ boot_scenario();
+ startup_update_scenario();
+ CHECK(profile_delete(profile_find("Zoomed"))); // the scenarios made it; the end state below expects only Default
+ save_config();
+
printf("== menus and engine\n");
GtkWidget *start = menu_item("Start Engine"), *stop = menu_item("Stop Engine");
CHECK(start && stop);
diff --git a/Linux/profile/tests/profile_test.c b/Linux/profile/tests/profile_test.c
index fdc240e..dedea27 100644
--- a/Linux/profile/tests/profile_test.c
+++ b/Linux/profile/tests/profile_test.c
@@ -87,6 +87,118 @@ static void test_parity_fields(void)
pbp_free(&q);
}
+
+static void expect_error(const char *json, const char *needle);
+
+static struct pbp_filter flt(bool exclude, const char *proc, const char *ip, const char *port, const char *proto, const char *action)
+{
+ struct pbp_filter f = { exclude, (char *)proc, (char *)ip, (char *)port, (char *)proto, (char *)action };
+ return f;
+}
+
+static void test_gui_fields(void)
+{
+ struct pbp_profile p, q;
+ char err[256];
+ CHECK(parse("{}", &p, err) == 0 && p.auto_clear && p.font_zoom == 100 && p.nfilters == 0);
+ pbp_free(&p);
+
+ CHECK(parse("{ \"AutoClearConnectionLogs\": false, \"FontZoom\": 150, \"LogFilters\": ["
+ "{ \"Mode\": \"Exclude\", \"ProcessName\": \"chrome*\", \"Ip\": \"10.*\", \"Port\": \"443\", \"Protocol\": \"tcp\", \"Action\": \"proxy\" },"
+ "{ \"Mode\": \"Include\" },"
+ "{ \"Mode\": \"Bogus\", \"Protocol\": \"ICMP\", \"Action\": \"Maybe\", \"ProcessName\": \"x\" } ] }", &p, err) == 0);
+ CHECK(!p.auto_clear && p.font_zoom == 150 && p.nfilters == 3);
+ CHECK(p.filters[0].exclude && !strcmp(p.filters[0].process, "chrome*") && !strcmp(p.filters[0].protocol, "TCP") && !strcmp(p.filters[0].action, "Proxy"));
+ CHECK(!p.filters[1].exclude && !strcmp(p.filters[1].process, "") && !strcmp(p.filters[1].protocol, "All") && !strcmp(p.filters[1].action, "All"));
+ CHECK(!p.filters[2].exclude && !strcmp(p.filters[2].protocol, "All") && !strcmp(p.filters[2].action, "All")); // unknown values fall back to All / Include
+ char *json = pbp_serialize(&p);
+ CHECK(json && strstr(json, "\"FontZoom\": 150") && strstr(json, "\"AutoClearConnectionLogs\": false") && strstr(json, "\"Mode\": \"Exclude\""));
+ CHECK(pbp_parse(json, strlen(json), &q, err, sizeof err) == 0 && q.nfilters == 3 && q.font_zoom == 150 && !q.auto_clear && q.filters[0].exclude);
+ free(json);
+ pbp_free(&p);
+ pbp_free(&q);
+
+ // the zoom must stay in range, whatever the file says
+ const char *zooms[] = { "59", "301", "0", "-5", "\"abc\"", "99999999999", "true" };
+ for (size_t i = 0; i < sizeof zooms / sizeof *zooms; i++) {
+ char doc[80];
+ snprintf(doc, sizeof doc, "{ \"FontZoom\": %s }", zooms[i]);
+ CHECK(parse(doc, &p, err) == 0 && p.font_zoom == 100);
+ pbp_free(&p);
+ }
+ CHECK(parse("{ \"FontZoom\": 60 }", &p, err) == 0 && p.font_zoom == 60); pbp_free(&p);
+ CHECK(parse("{ \"FontZoom\": \"300\" }", &p, err) == 0 && p.font_zoom == 300); pbp_free(&p);
+
+ expect_error("{ \"LogFilters\": 5 }", "LogFilters must be an array");
+ expect_error("{ \"LogFilters\": [ 5 ] }", "not an object");
+ {
+ char many[4096] = "{ \"LogFilters\": [";
+ for (int i = 0; i < PBP_MAX_FILTERS + 1; i++) strcat(many, i ? ",{}" : "{}");
+ strcat(many, "] }");
+ expect_error(many, "too many log filters");
+ }
+}
+
+static void test_filters(void)
+{
+ struct pbp_filter none[1] = { { 0 } };
+ CHECK(pbp_filters_pass(none, 0, "curl", "1.2.3.4", "80", "TCP", "Proxy")); // no filters: everything shows
+
+ struct pbp_filter ex[] = { flt(true, "chrome*", "", "", "All", "All") };
+ CHECK(!pbp_filters_pass(ex, 1, "chrome", "1.2.3.4", "80", "TCP", "Proxy"));
+ CHECK(!pbp_filters_pass(ex, 1, "CHROME-sandbox", "1.2.3.4", "80", "TCP", "Proxy")); // case-insensitive
+ CHECK(pbp_filters_pass(ex, 1, "curl", "1.2.3.4", "80", "TCP", "Proxy")); // exclude-only: everything else shows
+
+ struct pbp_filter in[] = { flt(false, "curl", "", "", "All", "All"), flt(false, "", "10.0.*", "", "All", "All") };
+ CHECK(pbp_filters_pass(in, 2, "curl", "1.2.3.4", "80", "TCP", "Direct"));
+ CHECK(pbp_filters_pass(in, 2, "wget", "10.0.5.6", "80", "TCP", "Direct"));
+ CHECK(!pbp_filters_pass(in, 2, "wget", "1.2.3.4", "80", "TCP", "Direct")); // include filters: one must match
+
+ struct pbp_filter both[] = { flt(false, "", "10.*", "", "All", "All"), flt(true, "", "", "22", "All", "All") };
+ CHECK(pbp_filters_pass(both, 2, "ssh", "10.1.1.1", "443", "TCP", "Proxy"));
+ CHECK(!pbp_filters_pass(both, 2, "ssh", "10.1.1.1", "22", "TCP", "Proxy")); // exclude wins over include
+ CHECK(!pbp_filters_pass(both, 2, "ssh", "192.168.1.1", "443", "TCP", "Proxy"));
+
+ struct pbp_filter pa[] = { flt(true, "*", "*", "44?", "UDP", "Blocked") };
+ CHECK(!pbp_filters_pass(pa, 1, "x", "1.1.1.1", "443", "UDP", "Blocked")); // '?' and "*" patterns, protocol and action
+ CHECK(pbp_filters_pass(pa, 1, "x", "1.1.1.1", "443", "TCP", "Blocked"));
+ CHECK(pbp_filters_pass(pa, 1, "x", "1.1.1.1", "443", "UDP", "Direct"));
+ CHECK(pbp_filters_pass(pa, 1, "x", "1.1.1.1", "4433", "UDP", "Blocked"));
+ struct pbp_filter all[] = { flt(true, "All", "all", "ALL", "all", "ALL") };
+ CHECK(!pbp_filters_pass(all, 1, "anything", "9.9.9.9", "1", "UDP", "Direct")); // the literal word All matches anything
+ CHECK(pbp_filters_pass(ex, 1, NULL, NULL, NULL, NULL, NULL)); // missing fields do not crash
+ struct pbp_filter ip6[] = { flt(true, "", "2001:db8:*", "", "All", "All") };
+ CHECK(!pbp_filters_pass(ip6, 1, "x", "2001:db8::7", "80", "TCP", "Proxy"));
+}
+
+static void test_settings(void)
+{
+ char dir[] = "/tmp/pbp_settings_XXXXXX", path[300], err[200];
+ CHECK(mkdtemp(dir) != NULL);
+ snprintf(path, sizeof path, "%s/settings.json", dir);
+ char *active = NULL;
+ bool upd = false;
+ CHECK(pbp_settings_load(path, &active, &upd) == -1); // no file yet
+ CHECK(pbp_settings_save(path, "Work", true, err, sizeof err) == 0);
+ CHECK(pbp_settings_load(path, &active, &upd) == 0 && active && !strcmp(active, "Work") && upd);
+ CHECK(pbp_settings_save(path, "Home \"x\"", false, err, sizeof err) == 0);
+ upd = true;
+ CHECK(pbp_settings_load(path, &active, &upd) == 0 && !strcmp(active, "Home \"x\"") && !upd);
+ FILE *f = fopen(path, "w");
+ fputs("{ \"ActiveProfileName\": \"Only\" }", f); // an older file without the switch
+ fclose(f);
+ upd = false;
+ CHECK(pbp_settings_load(path, &active, &upd) == 0 && !strcmp(active, "Only") && upd); // defaults to on
+ f = fopen(path, "w");
+ fputs("not json", f);
+ fclose(f);
+ CHECK(pbp_settings_load(path, &active, &upd) == -1);
+ free(active);
+ char cmd[400];
+ snprintf(cmd, sizeof cmd, "rm -rf %s", dir);
+ CHECK(system(cmd) == 0);
+}
+
static void test_roundtrip(void)
{
struct pbp_profile a, b;
@@ -307,6 +419,9 @@ int main(void)
test_windows_sample();
test_roundtrip();
test_parity_fields();
+ test_gui_fields();
+ test_filters();
+ test_settings();
test_errors();
test_leniency();
test_hosts();
diff --git a/Linux/tests/api_live_test.c b/Linux/tests/api_live_test.c
index 9664721..c08c432 100644
--- a/Linux/tests/api_live_test.c
+++ b/Linux/tests/api_live_test.c
@@ -10,6 +10,13 @@
static int pass, fail;
static int events;
+static char ex_seen[4096];
+static void on_conn_ex(const char *p, uint32_t pid, const char *ip, uint16_t port, const char *proto, const char *info)
+{
+ (void)p; (void)pid;
+ size_t n = strlen(ex_seen);
+ if (n < sizeof ex_seen - 160) snprintf(ex_seen + n, sizeof ex_seen - n, "%s %s:%u via %s\n", proto, ip, port, info);
+}
static void on_conn(const char *p, uint32_t pid, const char *ip, uint16_t port, const char *info) { (void)p; (void)pid; (void)ip; (void)port; (void)info; events++; }
static void on_log(const char *m) { if (getenv("PB_VERBOSE")) fprintf(stderr, "[log] %s\n", m); }
@@ -33,7 +40,7 @@ static void check(const char *what, int cond) { printf(" %s %s\n", cond ? "PAS
int main(void)
{
char err[256] = "";
- ProxyBridge_SetLogCallback(on_log); ProxyBridge_SetConnectionCallback(on_conn); ProxyBridge_SetTrafficLoggingEnabled(true);
+ ProxyBridge_SetLogCallback(on_log); ProxyBridge_SetConnectionCallback(on_conn); ProxyBridge_SetConnectionCallbackEx(on_conn_ex); ProxyBridge_SetTrafficLoggingEnabled(true);
printf("== validation\n");
check("invalid host rejected with a reason", !ProxyBridge_ValidateRule("curl", "999.1.1.1", "80", err, sizeof err) && err[0]);
@@ -153,6 +160,7 @@ int main(void)
for (uint32_t k = 0; k < n; k++) if (!fl[k].is_udp && strncmp(fl[k].name, "python3", 7) == 0) left++;
}
check("closed connections leave the list", left == 0);
+ check("the extended connection callback names the protocol", strstr(ex_seen, "TCP 192.0.2.30:8888 via ") != NULL && strstr(ex_seen, "UDP 192.0.2.32:5300 via ") != NULL);
ProxyBridge_DeleteRule(fr1);
ProxyBridge_DeleteRule(fr2);
unlink("/tmp/pb_api_live_hold.py");
diff --git a/Linux/tests/coverage.sh b/Linux/tests/coverage.sh
index 53e0e7a..d30eef9 100755
--- a/Linux/tests/coverage.sh
+++ b/Linux/tests/coverage.sh
@@ -32,6 +32,7 @@ unit_tests() {
( cd "$ROOT/gui" &&
gcc $cf -I../src -I../profile -I. tests/config_test.c gui_config.c ../profile/pb_profile.c -o "$UNIT/config_test" $gtk && "$UNIT/config_test" &&
gcc $cf -I../src -I. tests/json_test.c gui_json.c -o "$UNIT/json_test" $gtk && "$UNIT/json_test" &&
+ gcc $cf -I. $(pkg-config --cflags glib-2.0) -DPB_TEST_HOOKS tests/boot_test.c gui_boot.c -o "$UNIT/boot_test" $(pkg-config --libs glib-2.0) && "$UNIT/boot_test" &&
gcc $cf -I. tests/events_test.c gui_events.c -o "$UNIT/events_test" -pthread && "$UNIT/events_test" ) 2>&1 | grep -E "FAIL|passed" || true
fi
}
@@ -52,7 +53,7 @@ for t in e2e e2e_rules e2e_domains e2e_security e2e_profile e2e_parity e2e_fault
echo "== $t"
timeout 900 bash "$HERE/$t.sh" 2>&1 | grep -E "FAIL|passed=|RESULT" || true
done
-echo "== churn"; timeout 900 bash "$HERE/churn.sh" 1500 2>&1 | grep -E "PASS|FAIL" || true
+echo "== churn"; timeout 900 bash "$HERE/churn.sh" 1500 2>&1 | grep -E "PASS|FAIL" || echo "FAIL churn produced no result (timed out?)"
if [ -x "$OUT/ProxyBridgeGUI" ] && command -v broadwayd > /dev/null; then
echo "== gui_headless"; timeout 300 bash "$HERE/gui_headless.sh" "$OUT/ProxyBridgeGUI" "$OUT" 2>&1 | grep -E "FAIL|passed=" || true
fi
diff --git a/Linux/tests/e2e_logging.sh b/Linux/tests/e2e_logging.sh
index a1bb5f2..2639a81 100755
--- a/Linux/tests/e2e_logging.sh
+++ b/Linux/tests/e2e_logging.sh
@@ -49,7 +49,7 @@ connects 198.51.100.50 80 6; connects 198.51.100.51 80 4; connects 198.51.100.52
[ "$(lines '198.51.100.51:80 via BLOCK')" = 1 ] && ok "4 blocked connections: one line" || bad "blocked: $(lines '198.51.100.51:80 via')"
[ "$(lines '198.51.100.52:80 via DIRECT')" = 1 ] && ok "4 direct connections: one line" || bad "direct: $(lines '198.51.100.52:80 via')"
connects 198.51.100.61 80 5; sleep 1.5
-[ "$(lines '198.51.100.61:80 via')" = 1 ] && ok "decided by the relay (long host list): one line" || bad "slow path: $(grep '198.51.100.61' "$WORK/pb.out")"
+[ "$(lines '198.51.100.61:80 via SOCKS5')" = 1 ] && ok "decided by the relay (long host list), process already gone: one proxied line" || bad "slow path: $(grep '198.51.100.61' "$WORK/pb.out")"
udp_sends 198.51.100.80 5300 8; sleep 1
[ "$(lines '198.51.100.80:5300 via')" = 1 ] && ok "a UDP flow of 8 datagrams: one line" || bad "udp: $(lines '198.51.100.80:5300 via')"
stop_pb
@@ -61,7 +61,7 @@ connects 198.51.100.50 80 6; connects 198.51.100.51 80 4; connects 198.51.100.52
[ "$(lines '198.51.100.51:80 via BLOCK')" = 4 ] && ok "every blocked connection is listed" || bad "blocked: $(lines '198.51.100.51:80 via')"
[ "$(lines '198.51.100.52:80 via DIRECT')" = 4 ] && ok "every direct connection is listed" || bad "direct: $(lines '198.51.100.52:80 via')"
connects 198.51.100.61 80 5; sleep 2
-[ "$(lines '198.51.100.61:80 via')" = 5 ] && ok "decided by the relay: every connection, once" || bad "slow path: $(lines '198.51.100.61:80 via')"
+[ "$(lines '198.51.100.61:80 via SOCKS5')" = 5 ] && ok "decided by the relay: every connection, once" || bad "slow path: $(lines '198.51.100.61:80 via')"
udp_sends 198.51.100.80 5300 8; sleep 1
[ "$(lines '198.51.100.80:5300 via')" = 1 ] && ok "a busy UDP flow is still one line" || bad "udp: $(lines '198.51.100.80:5300 via')"
if [ "${PB_SLOW:-0}" = 1 ]; then
diff --git a/Linux/tests/gui_ui.sh b/Linux/tests/gui_ui.sh
index 6f8eeb3..aa44912 100755
--- a/Linux/tests/gui_ui.sh
+++ b/Linux/tests/gui_ui.sh
@@ -17,7 +17,7 @@ G="$ROOT/gui"
SRC=$(ls "$G"/*.c | grep -v "/main.c$")
gcc -O1 -g -w -D_GNU_SOURCE ${EXTRA_CFLAGS:-} -I"$ROOT/src" -I"$ROOT/profile" -I"$G" $(pkg-config --cflags gtk+-3.0) \
-DPB_TEST_HOOKS -Dmain=pb_gui_main -c "$G/main.c" -o "$BUILD/gui_main.o" || exit 1
-gcc -O1 -g -w -D_GNU_SOURCE ${EXTRA_CFLAGS:-} -I"$ROOT/src" -I"$ROOT/profile" -I"$G" $(pkg-config --cflags gtk+-3.0) \
+gcc -O1 -g -w -D_GNU_SOURCE -DPB_TEST_HOOKS ${EXTRA_CFLAGS:-} -I"$ROOT/src" -I"$ROOT/profile" -I"$G" $(pkg-config --cflags gtk+-3.0) \
-o "$BUILD/ui_test" "$G/tests/ui_test.c" "$BUILD/gui_main.o" $SRC "$ROOT/profile/pb_profile.c" \
-L"$LIBDIR" -Wl,-rpath,"$LIBDIR" -lproxybridge -lpthread $(pkg-config --libs gtk+-3.0) ${EXTRA_LDFLAGS:-} || exit 1