Skip to content

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

Memory and bound fix:

AnoF-Cyberfdd1b64042a3
diff --git a/.github/workflows/build-mac.yml b/.github/workflows/build-mac.yml
index 1005a1a..6500223 100644
--- a/.github/workflows/build-mac.yml
+++ b/.github/workflows/build-mac.yml
@@ -150,7 +150,7 @@ jobs:
PKG_ENV_CONTENT: ${{ secrets.PKG_ENV }}
run: |
# Write PKG_ENV to .env but strip SIGNING_IDENTITY so build.sh skips signing
- # (productsign inside build.sh cannot access build.keychain — we do it below)
+ # (productsign inside build.sh cannot access build.keychain - we do it below)
printf '%s' "$PKG_ENV_CONTENT" | grep -v "^SIGNING_IDENTITY" > MacOS/ProxyBridge/.env
# Copy notarized .app into output/ where build.sh expects it
@@ -158,7 +158,7 @@ jobs:
cp -R MacOS/ProxyBridge/build/DerivedData/Build/Products/Release/ProxyBridge.app \
MacOS/ProxyBridge/output/ProxyBridge.app
- # Run build script — creates the unsigned .pkg only
+ # Run build script - creates the unsigned .pkg only
cd MacOS/ProxyBridge
chmod +x build.sh
bash build.sh
@@ -167,7 +167,7 @@ jobs:
PKG_UNSIGNED="output/ProxyBridge-v${PKG_VERSION}-Universal-Installer.pkg"
PKG_SIGNED="output/ProxyBridge-v${PKG_VERSION}-Universal-Installer-signed.pkg"
- # Sign pkg with explicit keychain — no prompting
+ # Sign pkg with explicit keychain - no prompting
echo "Signing installer..."
KEYCHAIN_PATH=$(security list-keychains -d user | grep build | tr -d ' "')
echo "Using keychain: $KEYCHAIN_PATH"
diff --git a/.github/workflows/build-windows.yml b/.github/workflows/build-windows.yml
index 7fc7cad..0770428 100644
--- a/.github/workflows/build-windows.yml
+++ b/.github/workflows/build-windows.yml
@@ -26,7 +26,7 @@ jobs:
with:
dotnet-version: '10.0.x'
- # No MSVC setup action needed — compile.ps1 auto-detects cl.exe via vswhere.exe,
+ # No MSVC setup action needed - compile.ps1 auto-detects cl.exe via vswhere.exe,
# which is pre-installed on every windows-latest runner.
- name: Install NSIS
diff --git a/.github/workflows/release-mac.yml b/.github/workflows/release-mac.yml
index 97ae860..481973a 100644
--- a/.github/workflows/release-mac.yml
+++ b/.github/workflows/release-mac.yml
@@ -149,7 +149,7 @@ jobs:
PKG_ENV_CONTENT: ${{ secrets.PKG_ENV }}
run: |
# Write PKG_ENV to .env but strip SIGNING_IDENTITY so build.sh skips signing
- # (productsign inside build.sh cannot access build.keychain — we do it below)
+ # (productsign inside build.sh cannot access build.keychain - we do it below)
printf '%s' "$PKG_ENV_CONTENT" | grep -v "^SIGNING_IDENTITY" > MacOS/ProxyBridge/.env
# Copy notarized .app into output/ where build.sh expects it
@@ -157,7 +157,7 @@ jobs:
cp -R MacOS/ProxyBridge/build/DerivedData/Build/Products/Release/ProxyBridge.app \
MacOS/ProxyBridge/output/ProxyBridge.app
- # Run build script — creates the unsigned .pkg only
+ # Run build script - creates the unsigned .pkg only
cd MacOS/ProxyBridge
chmod +x build.sh
bash build.sh
@@ -166,7 +166,7 @@ jobs:
PKG_UNSIGNED="output/ProxyBridge-v${PKG_VERSION}-Universal-Installer.pkg"
PKG_SIGNED="output/ProxyBridge-v${PKG_VERSION}-Universal-Installer-signed.pkg"
- # Sign pkg with explicit keychain — no prompting
+ # Sign pkg with explicit keychain - no prompting
echo "Signing installer..."
KEYCHAIN_PATH=$(security list-keychains -d user | grep build | tr -d ' "')
echo "Using keychain: $KEYCHAIN_PATH"
diff --git a/Linux/src/ProxyBridge.c b/Linux/src/ProxyBridge.c
index b9bc9c4..55872d3 100644
--- a/Linux/src/ProxyBridge.c
+++ b/Linux/src/ProxyBridge.c
@@ -1676,7 +1676,7 @@ static void* udp_relay_server(void *arg)
ssize_t peek_len = recv(socks5_udp_control_socket, peek_buf, 1, MSG_PEEK | MSG_DONTWAIT);
if (peek_len == 0 || (peek_len < 0 && errno != EAGAIN && errno != EWOULDBLOCK))
{
- // tcp died — tear down and reconnect immediately so real-time streams
+ // tcp died - tear down and reconnect immediately so real-time streams
// lose as few packets as possible.
teardown_udp_associate();
udp_associate_connected = establish_udp_associate();
@@ -1726,7 +1726,7 @@ static void* udp_relay_server(void *arg)
if (sent < 0)
{
- // sendto failed — proxy likely died. Tear down, reconnect immediately
+ // sendto failed - proxy likely died. Tear down, reconnect immediately
// and retry the current packet so real-time streams lose at most one packet.
teardown_udp_associate();
if (establish_udp_associate())
diff --git a/MacOS/ProxyBridge/ProxyBridge/ProxyRulesView.swift b/MacOS/ProxyBridge/ProxyBridge/ProxyRulesView.swift
index 212bd41..bf1cf79 100644
--- a/MacOS/ProxyBridge/ProxyBridge/ProxyRulesView.swift
+++ b/MacOS/ProxyBridge/ProxyBridge/ProxyRulesView.swift
@@ -469,7 +469,7 @@ struct RuleEditorView: View {
if viewModel.proxyConfigs.isEmpty {
HStack(spacing: 4) {
Image(systemName: "info.circle").foregroundColor(.secondary)
- Text("No proxy servers configured — add one in Proxy Settings.")
+ Text("No proxy servers configured - add one in Proxy Settings.")
.font(.caption).foregroundColor(.secondary)
}
}
diff --git a/MacOS/ProxyBridge/ProxyBridge/ProxySettingsView.swift b/MacOS/ProxyBridge/ProxyBridge/ProxySettingsView.swift
index 94734e7..633e24c 100644
--- a/MacOS/ProxyBridge/ProxyBridge/ProxySettingsView.swift
+++ b/MacOS/ProxyBridge/ProxyBridge/ProxySettingsView.swift
@@ -102,7 +102,7 @@ struct ProxySettingsView: View {
if config.username != nil {
Image(systemName: "lock.fill").foregroundColor(.secondary)
} else {
- Text("—").foregroundColor(.secondary)
+ Text("-").foregroundColor(.secondary)
}
}
.width(40)
diff --git a/MacOS/ProxyBridge/extension/AppProxyProvider.swift b/MacOS/ProxyBridge/extension/AppProxyProvider.swift
index dd32010..84ed86c 100644
--- a/MacOS/ProxyBridge/extension/AppProxyProvider.swift
+++ b/MacOS/ProxyBridge/extension/AppProxyProvider.swift
@@ -267,7 +267,7 @@ class AppProxyProvider: NETransparentProxyProvider {
let fullPath = String(cString: pathBuffer)
let processName = (fullPath as NSString).lastPathComponent
- // store in cache, evict everything if full — processes rarely hit this
+ // store in cache, evict everything if full - processes rarely hit this
pidCacheLock.lock()
if pidCache.count >= AppProxyProvider.pidCacheMaxSize {
pidCache.removeAll(keepingCapacity: true)
@@ -1314,7 +1314,7 @@ class AppProxyProvider: NETransparentProxyProvider {
continue
}
- // pure wildcard, save it for later — only the first one
+ // pure wildcard, save it for later - only the first one
if wildcardRule == nil {
wildcardRule = rule
}
diff --git a/Windows/compile.ps1 b/Windows/compile.ps1
index a12306b..c95d561 100644
--- a/Windows/compile.ps1
+++ b/Windows/compile.ps1
@@ -202,7 +202,7 @@ if ($success) {
Write-Host "`nBuilding C GUI (MSVC)..." -ForegroundColor Green
if ($script:foundVcvarsPath -and (Test-Path $script:foundVcvarsPath)) {
# Production build. Compiler: size-optimized static-CRT release with the security
- # hardening set — /GS (stack cookies), /guard:cf (Control Flow Guard), /sdl (extra
+ # hardening set - /GS (stack cookies), /guard:cf (Control Flow Guard), /sdl (extra
# security diagnostics), /GL + /Gy for whole-program opt & COMDAT folding.
# Linker: /DYNAMICBASE + /HIGHENTROPYVA (64-bit ASLR), /NXCOMPAT (DEP),
# /guard:cf (CFG), /CETCOMPAT (shadow-stack), /LTCG, dead-code strip.
diff --git a/Windows/gui/main.c b/Windows/gui/main.c
index 5925c4f..df73c99 100644
--- a/Windows/gui/main.c
+++ b/Windows/gui/main.c
@@ -94,13 +94,19 @@ static int g_tbHot = -1; // hovered menu-bar icon: 0 = settings
// Per-log line store so the search box can filter without losing lines. New lines append to
// the edit only when they match the active filter; changing the filter re-renders from here.
#define LOG_MAX_LINES 4000
+#define LOG_PEND_MAX 8000
typedef struct {
HWND edit;
wchar_t* lines[LOG_MAX_LINES];
int count;
wchar_t filter[128];
+ wchar_t* pend[LOG_PEND_MAX]; // queued by native callback threads, drained by the UI timer
+ int pendCount;
+ CRITICAL_SECTION lock;
} LogStore;
static LogStore g_connStore, g_actStore;
+#define TIMER_LOG 1 // batched log-flush timer
+static int g_idleTicks = 0; // consecutive idle flushes (for working-set trim)
static HFONT g_hMono, g_hUi;
static HINSTANCE g_hInst;
static NOTIFYICONDATAW g_tray;
@@ -174,7 +180,7 @@ static void PBLogCb(const char* message)
wchar_t ts[16]; GetTimePrefix(ts, 16);
size_t n = wcslen(ts) + wcslen(body) + 3;
wchar_t* line = (wchar_t*)malloc(n * sizeof(wchar_t));
- if (line) { _snwprintf_s(line, n, _TRUNCATE, L"%s%s\r\n", ts, body); PostMessageW(g_hMain, WM_APP_LOG, 0, (LPARAM)line); }
+ if (line) { _snwprintf_s(line, n, _TRUNCATE, L"%s%s\r\n", ts, body); LogStoreQueue(&g_actStore, line); }
free(body);
}
@@ -199,7 +205,7 @@ static void PBConnCb(const char* proc, DWORD pid, const char* ip, unsigned short
{
_snwprintf_s(line, n, _TRUNCATE, L"%s%s (PID:%lu) -> %s:%u via %s\r\n",
ts, wp ? wp : L"?", pid, wi ? wi : L"?", port, wf ? wf : L"?");
- PostMessageW(g_hMain, WM_APP_CONN, 0, (LPARAM)line);
+ LogStoreQueue(&g_connStore, line);
}
free(wp); free(wi); free(wf);
}
@@ -558,8 +564,9 @@ static LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wp, LPARAM lp)
SendMessageW(g_hActClear, WM_SETFONT, (WPARAM)g_hUi, TRUE);
SendMessageW(g_hConnSearch, EM_SETCUEBANNER, TRUE, (LPARAM)T(S_SEARCH_CUE));
SendMessageW(g_hActSearch, EM_SETCUEBANNER, TRUE, (LPARAM)T(S_SEARCH_CUE));
- g_connStore.edit = g_hConnLog;
- g_actStore.edit = g_hActLog;
+ LogStoreInit(&g_connStore, g_hConnLog);
+ LogStoreInit(&g_actStore, g_hActLog);
+ SetTimer(hwnd, TIMER_LOG, 200, NULL); // batch log updates ~5x/sec
// Menu-bar quick-access icons are drawn on the (non-client) menu bar in WM_NCPAINT;
// this is their glyph font. The menu-bar font is used to owner-draw the top-level
@@ -713,8 +720,16 @@ static LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wp, LPARAM lp)
if (nh->hwndFrom == g_hTab && nh->code == TCN_SELCHANGE) SelectTab(TabCtrl_GetCurSel(g_hTab));
return 0;
}
- case WM_APP_LOG: { wchar_t* s = (wchar_t*)lp; if (s) { LogStoreAdd(&g_actStore, s); free(s); } return 0; }
- case WM_APP_CONN: { wchar_t* s = (wchar_t*)lp; if (s) { LogStoreAdd(&g_connStore, s); free(s); } return 0; }
+ case WM_TIMER:
+ if (wp == TIMER_LOG)
+ {
+ int processed = LogStoreFlush(&g_connStore) + LogStoreFlush(&g_actStore);
+ // When traffic has been idle for a couple of seconds, hand freed pages back to the
+ // OS so memory drops after a burst instead of staying pinned in the working set.
+ if (processed == 0) { if (++g_idleTicks == 10) SetProcessWorkingSetSize(GetCurrentProcess(), (SIZE_T)-1, (SIZE_T)-1); }
+ else g_idleTicks = 0;
+ }
+ return 0;
case WM_APP_UPDATE:
{
UpdInfo* info = (UpdInfo*)lp;
@@ -868,8 +883,9 @@ static LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wp, LPARAM lp)
case WM_DESTROY:
if (g_api.Stop) g_api.Stop();
TrayRemove();
- LogStoreClear(&g_connStore); // release the buffered log lines
- LogStoreClear(&g_actStore);
+ KillTimer(hwnd, TIMER_LOG);
+ LogStoreFree(&g_connStore); // release buffered + pending log lines + the lock
+ LogStoreFree(&g_actStore);
if (g_hMono) DeleteObject(g_hMono);
if (g_hUi) DeleteObject(g_hUi);
if (g_hIcon) DeleteObject(g_hIcon);
diff --git a/Windows/gui/ui/logview.h b/Windows/gui/ui/logview.h
index eb762ce..6e4d21d 100644
--- a/Windows/gui/ui/logview.h
+++ b/Windows/gui/ui/logview.h
@@ -130,7 +130,81 @@ static void LogStoreClear(LogStore* s)
{
for (int i = 0; i < s->count; i++) free(s->lines[i]);
s->count = 0;
+ EnterCriticalSection(&s->lock);
+ for (int i = 0; i < s->pendCount; i++) free(s->pend[i]);
+ s->pendCount = 0;
+ LeaveCriticalSection(&s->lock);
SetWindowTextW(s->edit, L"");
}
+// logs add approx 40 60% memory usage on load as proxybridge use pacekt not connections, too much overload
+// thanks to claude 4.8 ops flagging and fixing it - memory usage reduced:
+// On load memroy goes 70 to 120mb and keept increasing, now it is 20 to 30mb max (max in my test)
+// Memory goes down once load is reduced and come back at 10 to 2mb
+// approx 97% memory usage reduced, thanks to claude 4.8 ops
+// CPU usage is now based on usage instead of constantly increasing on load
+// batched pipeline: callbacks queue lines; the UI timer flushes them in one go
+static void LogStoreInit(LogStore* s, HWND edit)
+{
+ s->edit = edit;
+ InitializeCriticalSection(&s->lock);
+}
+// Native callback thread: takes ownership of `line`. Bounded - drops on overload so a burst
+// of connections (e.g. a speed test) can't balloon memory or back up a message queue.
+static void LogStoreQueue(LogStore* s, wchar_t* line)
+{
+ if (!line) return;
+ EnterCriticalSection(&s->lock);
+ if (s->pendCount < LOG_PEND_MAX) { s->pend[s->pendCount++] = line; line = NULL; }
+ LeaveCriticalSection(&s->lock);
+ if (line) free(line); // queue full → drop
+}
+// UI thread (timer): drain the queue, store the lines, and append the matching ones to the
+// edit in a SINGLE operation. Returns how many lines were processed.
+static int LogStoreFlush(LogStore* s)
+{
+ static wchar_t* local[LOG_PEND_MAX]; // UI-thread only
+ EnterCriticalSection(&s->lock);
+ int n = s->pendCount;
+ for (int i = 0; i < n; i++) local[i] = s->pend[i];
+ s->pendCount = 0;
+ LeaveCriticalSection(&s->lock);
+ if (n == 0) return 0;
+
+ size_t total = 0;
+ for (int i = 0; i < n; i++) if (LogLineMatches(s, local[i])) total += wcslen(local[i]);
+ wchar_t* batch = total ? (wchar_t*)malloc((total + 1) * sizeof(wchar_t)) : NULL;
+ size_t off = 0;
+ for (int i = 0; i < n; i++)
+ {
+ wchar_t* line = local[i];
+ if (s->count >= LOG_MAX_LINES)
+ {
+ free(s->lines[0]);
+ memmove(&s->lines[0], &s->lines[1], (LOG_MAX_LINES - 1) * sizeof(wchar_t*));
+ s->count--;
+ }
+ s->lines[s->count++] = line; // store takes ownership
+ if (batch && LogLineMatches(s, line)) { size_t l = wcslen(line); memcpy(batch + off, line, l * sizeof(wchar_t)); off += l; }
+ }
+ if (batch) { batch[off] = 0; AppendToEdit(s->edit, batch); free(batch); }
+
+ if (g_autoClear && s->count > AUTO_CLEAR_LINES)
+ {
+ for (int i = 0; i < s->count; i++) free(s->lines[i]);
+ s->count = 0;
+ SetWindowTextW(s->edit, L"");
+ }
+ return n;
+}
+static void LogStoreFree(LogStore* s)
+{
+ for (int i = 0; i < s->count; i++) free(s->lines[i]);
+ s->count = 0;
+ EnterCriticalSection(&s->lock);
+ for (int i = 0; i < s->pendCount; i++) free(s->pend[i]);
+ s->pendCount = 0;
+ LeaveCriticalSection(&s->lock);
+ DeleteCriticalSection(&s->lock);
+}
#endif // PB_UI_LOGVIEW_H
diff --git a/Windows/src/ProxyBridge.c b/Windows/src/ProxyBridge.c
index 7a78ecb..929efa0 100644
--- a/Windows/src/ProxyBridge.c
+++ b/Windows/src/ProxyBridge.c
@@ -289,7 +289,7 @@ static BOOL parse_token_list(const char *list, const char *delimiters, token_mat
return TRUE;
// strtok_s needs a writable copy. Use a stack buffer for the common (short) case and
- // only fall back to malloc for unusually long lists — avoids a heap alloc on the
+ // only fall back to malloc for unusually long lists - avoids a heap alloc on the
// packet thread for every rule that has a specific host/port filter.
char stackbuf[256];
size_t len = strnlen_s(list, MAX_LIST_SIZE) + 1;
@@ -339,7 +339,7 @@ static void configure_tcp_socket(SOCKET sock, int bufsize, DWORD timeout)
}
// connect() with a bounded timeout. A blocking connect() to an unreachable host stalls
-// for the OS SYN timeout (~21s on Windows), and the UDP relay runs on a single thread —
+// for the OS SYN timeout (~21s on Windows), and the UDP relay runs on a single thread -
// so one dead/unreachable proxy config would freeze the whole relay (and delay real
// packets) while it waits. This does a non-blocking connect + select so a dead proxy
// fails in `timeout_ms` instead. Returns 0 on success, SOCKET_ERROR otherwise.
@@ -622,7 +622,7 @@ static DWORD WINAPI packet_processor(LPVOID arg)
PROXY_CONFIG *pc6u = find_proxy_config(pcid6u);
if (pc6u == NULL || pc6u->type != PROXY_TYPE_SOCKS5)
{
- // HTTP proxy can't relay UDP — drop
+ // HTTP proxy can't relay UDP - drop
continue;
}
add_connection_v6(sp, (const UINT8*)ipv6_header->SrcAddr, (const UINT8*)ipv6_header->DstAddr, dp, pcid6u);
@@ -760,7 +760,7 @@ static DWORD WINAPI packet_processor(LPVOID arg)
UINT32 proxy_config_id6 = 0;
action6 = check_process_rule_v6((const UINT8*)ipv6_header->SrcAddr, sp, (const UINT8*)ipv6_header->DstAddr, dp, FALSE, &pid6, &proxy_config_id6);
- // ::1 IPv6 loopback — use same "Localhost via Proxy" toggle as IPv4 127.
+ // ::1 IPv6 loopback - use same "Localhost via Proxy" toggle as IPv4 127.
if (action6 == RULE_ACTION_PROXY && !g_localhost_via_proxy)
{
const UINT8 *dst6 = (const UINT8*)ipv6_header->DstAddr;
@@ -885,7 +885,7 @@ static DWORD WINAPI packet_processor(LPVOID arg)
BYTE dst_first_octet = (ntohl(ip_header->DstAddr) >> 24) & 0xFF;
if (dst_first_octet != 127)
addr.Outbound = FALSE;
- // else: stay OUTBOUND — loopback echo delivers the packet
+ // else: stay OUTBOUND - loopback echo delivers the packet
}
else
{
@@ -1532,9 +1532,9 @@ static BOOL is_ipv6_multicast_or_linklocal(const UINT8 ip6[16])
if (ip6[0] == 0xFF) return TRUE;
// Link-local: FE80::/10 (equivalent to IPv4 APIPA 169.254.0.0/16)
if (ip6[0] == 0xFE && (ip6[1] & 0xC0) == 0x80) return TRUE;
- // Site-local (deprecated RFC 3879): FEC0::/10 — still seen on old equipment
+ // Site-local (deprecated RFC 3879): FEC0::/10 - still seen on old equipment
if (ip6[0] == 0xFE && (ip6[1] & 0xC0) == 0xC0) return TRUE;
- // Unspecified address: :: (all-zeros) — equivalent to IPv4 0.0.0.0
+ // Unspecified address: :: (all-zeros) - equivalent to IPv4 0.0.0.0
{
static const UINT8 unspec[16] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
if (memcmp(ip6, unspec, 16) == 0) return TRUE;
@@ -2073,7 +2073,7 @@ static BOOL is_broadcast_or_multicast(UINT32 ip)
// Unified rule matching function for both TCP and UDP
// Matches rules by process name, IP, port, and protocol
-// Inner matcher — caller MUST hold g_rules_lock (shared) for the whole traversal so
+// Inner matcher - caller MUST hold g_rules_lock (shared) for the whole traversal so
// rules_list and the strings it points to cannot be freed/edited mid-match.
static RuleAction match_rule_inner(const char *process_name, UINT32 dest_ip, UINT16 dest_port, BOOL is_udp, UINT32 *out_proxy_config_id)
{
@@ -2175,7 +2175,7 @@ static RuleAction match_rule_inner(const char *process_name, UINT32 dest_ip, UIN
return RULE_ACTION_DIRECT;
}
-// Public matcher — takes the shared rules lock so a concurrent AddRule/EditRule/
+// Public matcher - takes the shared rules lock so a concurrent AddRule/EditRule/
// DeleteRule/MoveRule from the GUI thread cannot free a node/string mid-match.
static RuleAction match_rule(const char *process_name, UINT32 dest_ip, UINT16 dest_port, BOOL is_udp, UINT32 *out_proxy_config_id)
{
@@ -2185,10 +2185,10 @@ static RuleAction match_rule(const char *process_name, UINT32 dest_ip, UINT16 de
return action;
}
-// IPv6 variant of match_rule — uses match_ip_list_v6 for host patterns.
+// IPv6 variant of match_rule - uses match_ip_list_v6 for host patterns.
// Supports exact addresses ("::1"), CIDR ("2001:db8::/32"), and wildcards ("*").
// IPv4-format patterns in target_hosts are silently skipped for IPv6 traffic.
-// Caller MUST hold g_rules_lock (shared) — see match_rule_v6 wrapper below.
+// Caller MUST hold g_rules_lock (shared) - see match_rule_v6 wrapper below.
static RuleAction match_rule_v6_inner(const char *process_name, const UINT8 dest_ip6[16], UINT16 dest_port, BOOL is_udp, UINT32 *out_proxy_config_id)
{
PROCESS_RULE *rule = rules_list;
@@ -3047,7 +3047,7 @@ static int socks5_udp_associate_with_config(SOCKET s, struct sockaddr_in *relay_
}
// TRUE if any enabled PROXY rule routes traffic through this proxy config. Used to skip
-// proactively establishing UDP ASSOCIATE for configs that no rule uses — otherwise the
+// proactively establishing UDP ASSOCIATE for configs that no rule uses - otherwise the
// relay wastes time (and can stall on a dead/unreachable host) connecting to proxies that
// will never carry traffic. A rule with proxy_config_id 0 means "first available", which
// could resolve to any config, so its presence marks all configs as potentially used.
@@ -3292,7 +3292,7 @@ static DWORD WINAPI udp_relay_server(LPVOID arg)
int result = recv(cfg->udp_tcp_ctrl, test_buf, sizeof(test_buf), MSG_PEEK);
if (result == 0 || (result == SOCKET_ERROR && WSAGetLastError() != WSAEWOULDBLOCK))
{
- log_message("[UDP RELAY] TCP control connection closed for proxy %s:%d — reconnecting", cfg->host, cfg->port);
+ log_message("[UDP RELAY] TCP control connection closed for proxy %s:%d - reconnecting", cfg->host, cfg->port);
closesocket(cfg->udp_tcp_ctrl);
cfg->udp_tcp_ctrl = INVALID_SOCKET;
if (cfg->udp_send_sock != INVALID_SOCKET)
@@ -3349,7 +3349,7 @@ static DWORD WINAPI udp_relay_server(LPVOID arg)
{
if (!establish_udp_associate_for_config(cfg))
{
- log_message("[UDP RELAY] UDP ASSOCIATE unavailable for %s:%d — dropping packet", cfg->host, cfg->port);
+ log_message("[UDP RELAY] UDP ASSOCIATE unavailable for %s:%d - dropping packet", cfg->host, cfg->port);
continue;
}
}
@@ -3371,7 +3371,7 @@ static DWORD WINAPI udp_relay_server(LPVOID arg)
if (sent == SOCKET_ERROR) {
int err = WSAGetLastError();
- log_message("[UDP RELAY ERROR] sendto proxy %s:%d failed: %d — reconnecting and retrying", cfg->host, cfg->port, err);
+ log_message("[UDP RELAY ERROR] sendto proxy %s:%d failed: %d - reconnecting and retrying", cfg->host, cfg->port, err);
if (cfg->udp_tcp_ctrl != INVALID_SOCKET) { closesocket(cfg->udp_tcp_ctrl); cfg->udp_tcp_ctrl = INVALID_SOCKET; }
if (cfg->udp_send_sock != INVALID_SOCKET) { closesocket(cfg->udp_send_sock); cfg->udp_send_sock = INVALID_SOCKET; }
cfg->udp_connected = FALSE;
@@ -3483,7 +3483,7 @@ static DWORD WINAPI udp_relay_server(LPVOID arg)
}
else
{
- log_message("[UDP RELAY] No session found for proxy response from %d.%d.%d.%d:%d — dropped",
+ log_message("[UDP RELAY] No session found for proxy response from %d.%d.%d.%d:%d - dropped",
recv_buf[4], recv_buf[5], recv_buf[6], recv_buf[7], src_port);
}
}
@@ -3935,9 +3935,9 @@ static DWORD WINAPI transfer_handler(LPVOID arg)
pair->sock_proxy = sock_proxy;
pair->refs = 2;
- // Upload: client → proxy (dedicated thread — may block on slow proxy send)
+ // Upload: client → proxy (dedicated thread - may block on slow proxy send)
ONE_WAY_CONFIG *up = (ONE_WAY_CONFIG *)malloc(sizeof(ONE_WAY_CONFIG));
- // Download: proxy → client (runs in this thread — loopback, rarely blocks)
+ // Download: proxy → client (runs in this thread - loopback, rarely blocks)
ONE_WAY_CONFIG *dn = (ONE_WAY_CONFIG *)malloc(sizeof(ONE_WAY_CONFIG));
if (!up || !dn)
@@ -4568,7 +4568,7 @@ PROXYBRIDGE_API BOOL ProxyBridge_EditRule(UINT32 rule_id, const char* process_na
if (!found)
{
- // rule_id not found — the pre-allocated strings were never installed, free them.
+ // rule_id not found - the pre-allocated strings were never installed, free them.
free(new_hosts);
free(new_ports);
free(new_domains);
@@ -4970,7 +4970,7 @@ PROXYBRIDGE_API int ProxyBridge_TestProxyConfigEx(UINT32 config_id, const char*
TLOG(" UDP ASSOCIATE granted; relay = %s:%u", inet_ntoa(relay.sin_addr), ntohs(relay.sin_port));
TLOG(" UDP is supported by this proxy");
}
- else TLOG(" UDP ASSOCIATE refused — this proxy does not support UDP");
+ else TLOG(" UDP ASSOCIATE refused - this proxy does not support UDP");
}
else TLOG(" Could not open a control connection for the UDP test");
closesocket(us);
@@ -5316,7 +5316,7 @@ static void flush_dns_resolver_cache(void)
}
// Recomputes the fast-path flags. Takes the shared rules lock itself, so callers must
-// NOT already hold g_rules_lock exclusive (SRW locks are non-recursive) — the rule API
+// NOT already hold g_rules_lock exclusive (SRW locks are non-recursive) - the rule API
// functions below release their exclusive lock before calling this.
static void update_has_active_rules(void)
{
@@ -5407,7 +5407,7 @@ PROXYBRIDGE_API BOOL ProxyBridge_Start(void)
// Without this, each WinDivertSend re-enters the capture queue, creating
// re-injection loops that delay delivery by seconds and cause DTLS handshake
// failures. With "not impostor", injected packets bypass the driver entirely
- // and flow directly to the OS — zero extra hops, no loops.
+ // and flow directly to the OS - zero extra hops, no loops.
// DHCP is deliberately excluded at the filter level so those packets never enter
// ProxyBridge at all. DHCP is link-local broadcast (0.0.0.0 -> 255.255.255.255) and
// #161 DHCPv4: client 68 / server 67 DHCPv6: client 546 / server 547
diff --git a/Windows/src/ProxyBridge.h b/Windows/src/ProxyBridge.h
index ed824ec..d94db7e 100644
--- a/Windows/src/ProxyBridge.h
+++ b/Windows/src/ProxyBridge.h
@@ -42,8 +42,8 @@ PROXYBRIDGE_API BOOL ProxyBridge_EditProxyConfig(UINT32 config_id, ProxyType t
PROXYBRIDGE_API BOOL ProxyBridge_DeleteProxyConfig(UINT32 config_id);
PROXYBRIDGE_API int ProxyBridge_TestProxyConfig(UINT32 config_id, const char* target_host, UINT16 target_port, char* result_buffer, size_t buffer_size);
// Detailed multi-step proxy check (like Proxifier's Proxy Checker). Streams human-readable
-// log lines through the callback: TCP reach, tunnel + auth, page load, latency, and — for
-// SOCKS5 — a UDP ASSOCIATE probe. Returns 0 if the critical tests passed, negative otherwise.
+// log lines through the callback: TCP reach, tunnel + auth, page load, latency, and - for
+// SOCKS5 - a UDP ASSOCIATE probe. Returns 0 if the critical tests passed, negative otherwise.
typedef void (*ProxyTestLogCallback)(const char* line, void* user);
PROXYBRIDGE_API int ProxyBridge_TestProxyConfigEx(UINT32 config_id, const char* target_host, UINT16 target_port, ProxyTestLogCallback callback, void* user);