diff --git a/main/cli/serial_cli.c b/main/cli/serial_cli.c index 48ee2c8..8667a45 100644 --- a/main/cli/serial_cli.c +++ b/main/cli/serial_cli.c @@ -206,6 +206,7 @@ static int cmd_heap_info(int argc, char **argv) static struct { struct arg_str *host; struct arg_int *port; + struct arg_str *type; struct arg_end *end; } proxy_args; @@ -216,7 +217,16 @@ static int cmd_set_proxy(int argc, char **argv) arg_print_errors(stderr, proxy_args.end, argv[0]); return 1; } - http_proxy_set(proxy_args.host->sval[0], (uint16_t)proxy_args.port->ival[0]); + const char *proxy_type = "http"; + if (proxy_args.type->count > 0 && proxy_args.type->sval[0] && proxy_args.type->sval[0][0]) { + proxy_type = proxy_args.type->sval[0]; + } + if (strcmp(proxy_type, "http") != 0 && strcmp(proxy_type, "socks5") != 0) { + printf("Invalid proxy type: %s. Use http or socks5.\n", proxy_type); + return 1; + } + + http_proxy_set(proxy_args.host->sval[0], (uint16_t)proxy_args.port->ival[0], proxy_type); printf("Proxy set. Restart to apply.\n"); return 0; } @@ -732,10 +742,11 @@ esp_err_t serial_cli_init(void) /* set_proxy */ proxy_args.host = arg_str1(NULL, NULL, "", "Proxy host/IP"); proxy_args.port = arg_int1(NULL, NULL, "", "Proxy port"); - proxy_args.end = arg_end(2); + proxy_args.type = arg_str0(NULL, NULL, "", "Proxy type: http|socks5 (default: http)"); + proxy_args.end = arg_end(3); esp_console_cmd_t proxy_cmd = { .command = "set_proxy", - .help = "Set HTTP proxy (e.g. set_proxy 192.168.1.83 7897)", + .help = "Set proxy (e.g. set_proxy 192.168.1.83 7897 [http|socks5])", .func = &cmd_set_proxy, .argtable = &proxy_args, }; diff --git a/main/mimi_config.h b/main/mimi_config.h index 47a3597..c90eb34 100644 --- a/main/mimi_config.h +++ b/main/mimi_config.h @@ -31,6 +31,9 @@ #ifndef MIMI_SECRET_PROXY_PORT #define MIMI_SECRET_PROXY_PORT "" #endif +#ifndef MIMI_SECRET_PROXY_TYPE +#define MIMI_SECRET_PROXY_TYPE "" +#endif #ifndef MIMI_SECRET_SEARCH_KEY #define MIMI_SECRET_SEARCH_KEY "" #endif diff --git a/main/mimi_secrets.h.example b/main/mimi_secrets.h.example index bf76def..456ecbc 100644 --- a/main/mimi_secrets.h.example +++ b/main/mimi_secrets.h.example @@ -25,6 +25,7 @@ /* HTTP Proxy (leave empty or set both) */ #define MIMI_SECRET_PROXY_HOST "" #define MIMI_SECRET_PROXY_PORT "" +#define MIMI_SECRET_PROXY_TYPE "" /* "http" or "socks5" */ /* Brave Search API */ #define MIMI_SECRET_SEARCH_KEY ""