Skip to content

Commit 3406f9f

Browse files
committed
removed unwanted code for linux
1 parent 9669a3e commit 3406f9f

8 files changed

Lines changed: 254 additions & 259 deletions

File tree

Linux/cli/main.c

Lines changed: 15 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,7 @@ static bool parse_proxy_url(const char* url, ProxyType* type, char* host, uint16
227227
username[0] = '\0';
228228
password[0] = '\0';
229229

230-
// Parse type://
230+
// parse type://
231231
char* scheme_end = strstr(buffer, "://");
232232
if (scheme_end == NULL)
233233
{
@@ -254,7 +254,7 @@ static bool parse_proxy_url(const char* url, ProxyType* type, char* host, uint16
254254
return false;
255255
}
256256

257-
// Parse host:port[:username:password]
257+
// parse host:port[:user:pass]
258258
char* parts[4];
259259
int num_parts = 0;
260260
char* token = strtok(rest, ":");
@@ -298,7 +298,7 @@ static bool is_root(void)
298298

299299
int main(int argc, char *argv[])
300300
{
301-
// Check for cleanup flag first - ignores all other args
301+
// check cleanup flag
302302
for (int i = 1; i < argc; i++)
303303
{
304304
if (strcmp(argv[i], "--cleanup") == 0)
@@ -315,7 +315,7 @@ int main(int argc, char *argv[])
315315
int num_rules = 0;
316316
bool dns_via_proxy = true;
317317

318-
// Parse arguments
318+
// parse args
319319
for (int i = 1; i < argc; i++)
320320
{
321321
if (strcmp(argv[i], "--help") == 0 || strcmp(argv[i], "-h") == 0)
@@ -371,15 +371,15 @@ int main(int argc, char *argv[])
371371

372372
show_banner();
373373

374-
// Check root privileges
374+
// need root
375375
if (!is_root())
376376
{
377377
printf("\033[31m\nERROR: ProxyBridge requires root privileges!\033[0m\n");
378378
printf("Please run this application with sudo or as root.\n\n");
379379
return 1;
380380
}
381381

382-
// Parse proxy configuration
382+
// parse proxy config
383383
ProxyType proxy_type;
384384
char proxy_host[256];
385385
uint16_t proxy_port;
@@ -389,11 +389,8 @@ int main(int argc, char *argv[])
389389
if (!parse_proxy_url(proxy_url, &proxy_type, proxy_host, &proxy_port, proxy_username, proxy_password))
390390
return 1;
391391

392-
// Setup callbacks based on verbose level - only enable what we need
393-
// Verbose 0: No callbacks, no logging (most efficient)
394-
// Verbose 1: Only log messages
395-
// Verbose 2: Only connection events
396-
// Verbose 3: Both logs and connections
392+
// setup callbacks based on verbose
393+
// 0=nothing 1=logs 2=connections 3=both
397394

398395
if (verbose_level == 1 || verbose_level == 3)
399396
ProxyBridge_SetLogCallback(log_callback);
@@ -405,10 +402,10 @@ int main(int argc, char *argv[])
405402
else
406403
ProxyBridge_SetConnectionCallback(NULL); // Explicitly disable
407404

408-
// Enable traffic logging in C library only when needed (prevents unnecessary processing)
405+
// turn on traffic logging when needed
409406
ProxyBridge_SetTrafficLoggingEnabled(verbose_level > 0);
410407

411-
// Display configuration
408+
// show config
412409
printf("Proxy: %s://%s:%u\n",
413410
proxy_type == PROXY_TYPE_HTTP ? "http" : "socks5",
414411
proxy_host, proxy_port);
@@ -418,7 +415,7 @@ int main(int argc, char *argv[])
418415

419416
printf("DNS via Proxy: %s\n", dns_via_proxy ? "Enabled" : "Disabled");
420417

421-
// Configure proxy
418+
// setup proxy
422419
if (!ProxyBridge_SetProxyConfig(proxy_type, proxy_host, proxy_port,
423420
proxy_username[0] ? proxy_username : "",
424421
proxy_password[0] ? proxy_password : ""))
@@ -429,7 +426,7 @@ int main(int argc, char *argv[])
429426

430427
ProxyBridge_SetDnsViaProxy(dns_via_proxy);
431428

432-
// Add rules
429+
// add rules
433430
if (num_rules > 0)
434431
{
435432
printf("Rules: %d\n", num_rules);
@@ -469,7 +466,7 @@ int main(int argc, char *argv[])
469466
printf("Use --rule to add proxy rules. See --help for examples.\n");
470467
}
471468

472-
// Start ProxyBridge
469+
// start proxybridge
473470
if (!ProxyBridge_Start())
474471
{
475472
fprintf(stderr, "ERROR: Failed to start ProxyBridge\n");
@@ -485,13 +482,13 @@ int main(int argc, char *argv[])
485482
signal(SIGABRT, signal_handler); // Catch abort
486483
signal(SIGBUS, signal_handler); // Catch bus error
487484

488-
// Main loop
485+
// main loop
489486
while (keep_running)
490487
{
491488
sleep(1);
492489
}
493490

494-
// Cleanup
491+
// cleanup
495492
ProxyBridge_Stop();
496493
printf("ProxyBridge stopped.\n");
497494

Linux/gui/gui_config.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
#define CONFIG_DIR "/etc/proxybridge"
44
#define CONFIG_PATH "/etc/proxybridge/config.ini"
55

6-
// save settings to file
6+
// save config
77
void save_config() {
88
struct stat st = {0};
99
if (stat(CONFIG_DIR, &st) == -1) {

Linux/gui/gui_logs.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#include "gui.h"
22

3-
// filter the text view based on user imput
3+
// filter logs based on search
44
static void filter_text_view(GtkTextBuffer *buffer, const char *text) {
55
if (!buffer) return;
66

@@ -18,7 +18,7 @@ static void filter_text_view(GtkTextBuffer *buffer, const char *text) {
1818

1919
char *line_text = gtk_text_buffer_get_text(buffer, &line_start, &line_end, FALSE);
2020

21-
// case insensitive search
21+
// search case insensitive
2222
char *lower_line = g_utf8_strdown(line_text, -1);
2323
char *lower_search = g_utf8_strdown(text, -1);
2424

@@ -64,7 +64,7 @@ static void free_connection_data(ConnectionData *data) {
6464
}
6565
}
6666

67-
// update logs safely from main thread
67+
// update logs from main thread
6868
static gboolean update_log_gui(gpointer user_data) {
6969
LogData *data = (LogData *)user_data;
7070
if (!data) return FALSE;
@@ -86,7 +86,7 @@ static gboolean update_log_gui(gpointer user_data) {
8686
return FALSE; // done
8787
}
8888

89-
// update connection info safely
89+
// update conn info
9090
static gboolean update_connection_gui_append(gpointer user_data) {
9191
ConnectionData *data = (ConnectionData *)user_data;
9292
if (!data) return FALSE;

0 commit comments

Comments
 (0)