Skip to content

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

feat(linux/gui): menu bar like the Windows app (Proxy, Profile, Settings, Help) with Documentation

anof-cyberc77538db4ade
diff --git a/Linux/README.md b/Linux/README.md
index 6c87b3b..3859154 100644
--- a/Linux/README.md
+++ b/Linux/README.md
@@ -90,7 +90,8 @@ 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 (UDP flows are marked `(UDP)`), 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
+- The same four menus as the Windows app: **Proxy** (Enable ProxyBridge, Proxy Settings, Proxy Rules, Log Filters, and the Linux-only Start/Stop Engine and Exit), **Profile**, **Settings** (traffic logging, start at boot, auto-clear, log every connection, update check on startup, zoom) and **Help** (Documentation, Check for Updates, About)
+- Real-time connection monitoring (UDP flows are marked `(UDP)`), a **Live Connections** tab (every proxied TCP connection and UDP flow with its process, destination, proxy, age and bytes), a *Log Every Connection* switch in the Settings menu and the *Enable ProxyBridge* switch 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)
- DNS via proxy is chosen per proxy in the proxy settings (no global switch), like the Windows app
@@ -208,11 +209,11 @@ Cost: DNS from covered processes takes one extra loopback hop (about +90 µs per
## 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).
+- **Font zoom** (Settings menu, `Ctrl` + `+` / `-` / `0`): 60-300 % in steps of 10, saved in the profile (`FontZoom`).
+- **Auto-clear Logs** (Settings 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.
+- **Start at Boot** (Settings 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** (Settings 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)
@@ -229,7 +230,7 @@ Cost: DNS from covered processes takes one extra loopback hop (about +90 µs per
| Live connections | yes (GUI tab, `ProxyBridge_GetFlows`) |
| Log Every Connection, main on/off switch | yes |
| 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*) |
+| Start with the OS | yes, as a systemd service that runs `ProxyBridge --profile <active profile>` (Settings 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 |
diff --git a/Linux/gui/main.c b/Linux/gui/main.c
index 80afc6a..abc464f 100644
--- a/Linux/gui/main.c
+++ b/Linux/gui/main.c
@@ -258,6 +258,23 @@ static UpdateInfo *update_lookup(void) {
return u;
}
+// Opens an address in the default browser. The tests build records the address in a file instead (no browser in a test display).
+static void open_in_browser(const char *url) {
+#ifdef PB_TEST_HOOKS
+ const char *log = getenv("PB_OPEN_URL_LOG");
+ if (log && *log) {
+ FILE *f = fopen(log, "a");
+ if (f) { fprintf(f, "%s\n", url); fclose(f); }
+ return;
+ }
+#endif
+ GError *uri_err = NULL;
+ if (!gtk_show_uri_on_window(GTK_WINDOW(window), url, GDK_CURRENT_TIME, &uri_err)) {
+ show_message(GTK_WINDOW(window), GTK_MESSAGE_ERROR, "Could not open browser: %s", uri_err ? uri_err->message : "unknown");
+ if (uri_err) g_error_free(uri_err);
+ }
+}
+
// Main thread. A user-started check reports everything; a start-up check only speaks up when a newer version exists.
static void update_show(UpdateInfo *u) {
if (u->problem) {
@@ -288,15 +305,18 @@ static void update_show(UpdateInfo *u) {
if (!url) {
show_message(GTK_WINDOW(window), GTK_MESSAGE_ERROR, "No safe https url in update feed.");
} else {
- GError *uri_err = NULL;
- if (!gtk_show_uri_on_window(GTK_WINDOW(window), url, GDK_CURRENT_TIME, &uri_err)) {
- show_message(GTK_WINDOW(window), GTK_MESSAGE_ERROR, "Could not open browser: %s", uri_err ? uri_err->message : "unknown");
- if (uri_err) g_error_free(uri_err);
- }
+ open_in_browser(url);
}
}
}
+// same address as the Windows app's Help > Documentation
+#define DOCS_URL "https://proxybridge.interceptsuite.com/docs/"
+
+static void on_documentation(GtkWidget *widget, gpointer data) {
+ open_in_browser(DOCS_URL);
+}
+
static void on_check_update(GtkWidget *widget, gpointer data) {
UpdateInfo *u = update_lookup();
update_show(u);
@@ -598,19 +618,16 @@ int main(int argc, char *argv[]) {
// never gets pointer events from) the menu would stay on top of it: close it as soon as this window loses focus.
g_signal_connect(window, "notify::is-active", G_CALLBACK(on_active_changed), menubar);
g_signal_connect(window, "focus-out-event", G_CALLBACK(on_focus_out), menubar);
+ // The same four menus as the Windows app: Proxy, Profile, Settings, Help
GtkWidget *proxy_menu = add_submenu(menubar, "Proxy");
+ enable_item = add_check_item(proxy_menu, "Enable ProxyBridge", true, G_CALLBACK(on_enable_toggled)); // the main on/off switch
+ start_item = add_menu_item(proxy_menu, "Start Engine", G_CALLBACK(on_start_engine));
+ stop_item = add_menu_item(proxy_menu, "Stop Engine", G_CALLBACK(on_stop_engine));
+ add_separator(proxy_menu);
add_menu_item(proxy_menu, "Proxy Settings...", G_CALLBACK(on_proxy_configure));
add_menu_item(proxy_menu, "Proxy Rules...", G_CALLBACK(on_proxy_rules_clicked));
- add_separator(proxy_menu);
- log_item = add_check_item(proxy_menu, "Enable Traffic Logging", g_chk_logging, G_CALLBACK(on_log_traffic_toggled));
- every_item = add_check_item(proxy_menu, "Log Every Connection", g_chk_log_every, G_CALLBACK(on_log_every_toggled));
- clear_item = add_check_item(proxy_menu, "Auto-clear Logs", g_chk_auto_clear, G_CALLBACK(on_auto_clear_toggled));
add_menu_item(proxy_menu, "Log Filters...", G_CALLBACK(on_log_filters_clicked));
- enable_item = add_check_item(proxy_menu, "Enable ProxyBridge", true, G_CALLBACK(on_enable_toggled));
add_separator(proxy_menu);
- boot_item = add_check_item(proxy_menu, "Start at Boot (systemd service)", boot_is_enabled(), G_CALLBACK(on_boot_toggled));
- start_item = add_menu_item(proxy_menu, "Start Engine", G_CALLBACK(on_start_engine));
- stop_item = add_menu_item(proxy_menu, "Stop Engine", G_CALLBACK(on_stop_engine));
add_menu_item(proxy_menu, "Exit", G_CALLBACK(on_window_destroy));
// like the Windows app: Profile is a menu of its own and every item acts at once on the active profile
GtkWidget *profile_menu = add_submenu(menubar, "Profile");
@@ -627,20 +644,27 @@ int main(int argc, char *argv[]) {
gtk_menu_item_set_submenu(GTK_MENU_ITEM(switch_item), switch_menu);
gtk_menu_shell_append(GTK_MENU_SHELL(profile_menu), switch_item);
rebuild_switch_menu(NULL);
- GtkWidget *view_menu = add_submenu(menubar, "View");
+ GtkWidget *settings_menu = add_submenu(menubar, "Settings");
+ log_item = add_check_item(settings_menu, "Enable Traffic Logging", g_chk_logging, G_CALLBACK(on_log_traffic_toggled));
+ boot_item = add_check_item(settings_menu, "Start at Boot (systemd service)", boot_is_enabled(), G_CALLBACK(on_boot_toggled));
+ clear_item = add_check_item(settings_menu, "Auto-clear Logs", g_chk_auto_clear, G_CALLBACK(on_auto_clear_toggled));
+ every_item = add_check_item(settings_menu, "Log Every Connection", g_chk_log_every, G_CALLBACK(on_log_every_toggled));
+ update_item = add_check_item(settings_menu, "Check for Updates on Startup", g_chk_updates, G_CALLBACK(on_update_startup_toggled));
+ add_separator(settings_menu);
GtkAccelGroup *accel = gtk_accel_group_new();
gtk_window_add_accel_group(GTK_WINDOW(window), accel);
- GtkWidget *zin = add_menu_item(view_menu, "Zoom In", G_CALLBACK(on_zoom_in));
- GtkWidget *zout = add_menu_item(view_menu, "Zoom Out", G_CALLBACK(on_zoom_out));
- GtkWidget *zreset = add_menu_item(view_menu, "Reset Zoom", G_CALLBACK(on_zoom_reset));
+ GtkWidget *zin = add_menu_item(settings_menu, "Zoom In", G_CALLBACK(on_zoom_in));
+ GtkWidget *zout = add_menu_item(settings_menu, "Zoom Out", G_CALLBACK(on_zoom_out));
+ GtkWidget *zreset = add_menu_item(settings_menu, "Reset Zoom", G_CALLBACK(on_zoom_reset));
gtk_widget_add_accelerator(zin, "activate", accel, GDK_KEY_plus, GDK_CONTROL_MASK, GTK_ACCEL_VISIBLE);
gtk_widget_add_accelerator(zin, "activate", accel, GDK_KEY_equal, GDK_CONTROL_MASK, GTK_ACCEL_MASK);
gtk_widget_add_accelerator(zout, "activate", accel, GDK_KEY_minus, GDK_CONTROL_MASK, GTK_ACCEL_VISIBLE);
gtk_widget_add_accelerator(zreset, "activate", accel, GDK_KEY_0, GDK_CONTROL_MASK, GTK_ACCEL_VISIBLE);
- GtkWidget *about_menu = add_submenu(menubar, "About");
- add_menu_item(about_menu, "About", G_CALLBACK(on_about));
- add_menu_item(about_menu, "Check for Updates", G_CALLBACK(on_check_update));
- update_item = add_check_item(about_menu, "Check for Updates on Startup", g_chk_updates, G_CALLBACK(on_update_startup_toggled));
+ GtkWidget *help_menu = add_submenu(menubar, "Help");
+ add_menu_item(help_menu, "Documentation", G_CALLBACK(on_documentation));
+ add_menu_item(help_menu, "Check for Updates...", G_CALLBACK(on_check_update));
+ add_separator(help_menu);
+ add_menu_item(help_menu, "About", G_CALLBACK(on_about));
gtk_box_pack_start(GTK_BOX(vbox), menubar, FALSE, FALSE, 0);
GtkWidget *notebook = gtk_notebook_new();
diff --git a/Linux/gui/tests/ui_test.c b/Linux/gui/tests/ui_test.c
index 278b200..c6019c1 100644
--- a/Linux/gui/tests/ui_test.c
+++ b/Linux/gui/tests/ui_test.c
@@ -766,11 +766,78 @@ static void feed_case(const char *name, const char *content, int first_response,
g_free(last_msg); last_msg = NULL;
if (second_ok) arm("msg", msg_then_ok, NULL, first_response);
else arm_msg(first_response);
- activate("Check for Updates");
+ activate("Check for Updates...");
CHECK_HAS(second_ok ? first_msg : last_msg, want);
g_free(path); g_free(url);
}
+static GtkWidget *find_menubar(GtkWidget *w) {
+ if (GTK_IS_MENU_BAR(w)) return w;
+ if (!GTK_IS_CONTAINER(w)) return NULL;
+ GList *kids = gtk_container_get_children(GTK_CONTAINER(w));
+ GtkWidget *hit = NULL;
+ for (GList *k = kids; k && !hit; k = k->next) hit = find_menubar(k->data);
+ g_list_free(kids);
+ return hit;
+}
+
+// labels of a menu's items joined with ";" (separators as "-"), or of the menu bar's menus
+static char *menu_labels(GtkWidget *shell) {
+ GString *out = g_string_new("");
+ GList *kids = gtk_container_get_children(GTK_CONTAINER(shell));
+ for (GList *k = kids; k; k = k->next) {
+ if (GTK_IS_SEPARATOR_MENU_ITEM(k->data)) g_string_append(out, "-;");
+ else g_string_append_printf(out, "%s;", gtk_menu_item_get_label(GTK_MENU_ITEM(k->data)));
+ }
+ g_list_free(kids);
+ return g_string_free(out, FALSE);
+}
+
+static char *submenu_labels(const char *top) {
+ GtkWidget *bar = find_menubar(window);
+ char *res = NULL;
+ GList *kids = bar ? gtk_container_get_children(GTK_CONTAINER(bar)) : NULL;
+ for (GList *k = kids; k && !res; k = k->next)
+ if (strcmp(gtk_menu_item_get_label(GTK_MENU_ITEM(k->data)), top) == 0)
+ res = menu_labels(gtk_menu_item_get_submenu(GTK_MENU_ITEM(k->data)));
+ g_list_free(kids);
+ return res ? res : g_strdup("(missing)");
+}
+
+// the menu bar is laid out like the Windows app's: Proxy, Profile, Settings, Help
+static void menus_scenario(void) {
+ STEP("menu bar");
+ GtkWidget *bar = find_menubar(window);
+ CHECK(bar != NULL);
+ char *top = bar ? menu_labels(bar) : g_strdup("");
+ CHECK_STR(top, "Proxy;Profile;Settings;Help;");
+ g_free(top);
+ char *m = submenu_labels("Proxy");
+ CHECK_STR(m, "Enable ProxyBridge;Start Engine;Stop Engine;-;Proxy Settings...;Proxy Rules...;Log Filters...;-;Exit;");
+ g_free(m);
+ m = submenu_labels("Profile");
+ CHECK_STR(m, "New Profile...;Duplicate Profile...;Rename Profile...;Delete Profile...;-;Import Profile...;Export Profile...;-;Switch Profile;");
+ g_free(m);
+ m = submenu_labels("Settings");
+ CHECK_STR(m, "Enable Traffic Logging;Start at Boot (systemd service);Auto-clear Logs;Log Every Connection;Check for Updates on Startup;-;Zoom In;Zoom Out;Reset Zoom;");
+ g_free(m);
+ m = submenu_labels("Help");
+ CHECK_STR(m, "Documentation;Check for Updates...;-;About;");
+ g_free(m);
+
+ // Help > Documentation opens the same page as the Windows app (the test build records the address instead of starting a browser)
+ char *log = tmp_path("opened_urls.txt");
+ unlink(log);
+ setenv("PB_OPEN_URL_LOG", log, 1);
+ activate("Documentation");
+ char *seen = NULL;
+ CHECK(g_file_get_contents(log, &seen, NULL, NULL));
+ CHECK_STR(seen, "https://proxybridge.interceptsuite.com/docs/\n");
+ g_free(seen);
+ g_free(log);
+ unsetenv("PB_OPEN_URL_LOG");
+}
+
static void updates_scenario(void) {
STEP("update check");
feed_case("feed_missing.json", NULL, GTK_RESPONSE_OK, "Update check failed", false);
@@ -788,6 +855,21 @@ static void updates_scenario(void) {
feed_case("feed_unsafe.json", "{\"linux\": {\"version\": \"9.9.9\", \"download\": \"http://insecure.test/x\", \"release_notes\": \"javascript:alert(1)\"}}",
GTK_RESPONSE_ACCEPT, "Version 9.9.9 is available", true);
CHECK_HAS(last_msg, "No safe https url");
+ // a feed that points at the project's release page: "Open in Browser" opens exactly that page
+ {
+ char *log = tmp_path("opened_release.txt");
+ unlink(log);
+ setenv("PB_OPEN_URL_LOG", log, 1);
+ feed_case("feed_project.json", "{\"linux\": {\"version\": \"9.9.9\", \"download\": \"https://github.com/InterceptSuite/ProxyBridge/releases/download/v9.9.9/x.tar.gz\", \"release_notes\": \"https://github.com/InterceptSuite/ProxyBridge/releases/tag/v9.9.9\"}}",
+ GTK_RESPONSE_ACCEPT, "Version 9.9.9 is available", false);
+ pump(100);
+ char *seen = NULL;
+ CHECK(g_file_get_contents(log, &seen, NULL, NULL));
+ CHECK_STR(seen, "https://github.com/InterceptSuite/ProxyBridge/releases/tag/v9.9.9\n");
+ g_free(seen);
+ g_free(log);
+ unsetenv("PB_OPEN_URL_LOG");
+ }
// ...and, since the browser runs as root, only the project's own pages: a feed pointing elsewhere is not opened
feed_case("feed_foreign.json", "{\"linux\": {\"version\": \"9.9.9\", \"download\": \"https://evil.example/x\", \"release_notes\": \"https://evil.example/n\"}}",
GTK_RESPONSE_ACCEPT, "Version 9.9.9 is available", true);
@@ -1278,6 +1360,8 @@ static void ui_main(void) {
CHECK_HAS(gtk_window_get_title(GTK_WINDOW(window)), "ProxyBridge - Default");
CHECK(menu_item("Proxy Settings...") && menu_item("Proxy Rules..."));
+ menus_scenario();
+
printf("== proxy settings\n");
arm("dlg_proxies", proxies_body, NULL, 0);
activate("Proxy Settings...");