hotfix(proxy): fix CLI/api mismatch and add proxy type defaults
Signed-off-by: Bo <boironic@gmail.com>
This commit is contained in:
@@ -206,6 +206,7 @@ static int cmd_heap_info(int argc, char **argv)
|
|||||||
static struct {
|
static struct {
|
||||||
struct arg_str *host;
|
struct arg_str *host;
|
||||||
struct arg_int *port;
|
struct arg_int *port;
|
||||||
|
struct arg_str *type;
|
||||||
struct arg_end *end;
|
struct arg_end *end;
|
||||||
} proxy_args;
|
} proxy_args;
|
||||||
|
|
||||||
@@ -216,7 +217,16 @@ static int cmd_set_proxy(int argc, char **argv)
|
|||||||
arg_print_errors(stderr, proxy_args.end, argv[0]);
|
arg_print_errors(stderr, proxy_args.end, argv[0]);
|
||||||
return 1;
|
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");
|
printf("Proxy set. Restart to apply.\n");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@@ -732,10 +742,11 @@ esp_err_t serial_cli_init(void)
|
|||||||
/* set_proxy */
|
/* set_proxy */
|
||||||
proxy_args.host = arg_str1(NULL, NULL, "<host>", "Proxy host/IP");
|
proxy_args.host = arg_str1(NULL, NULL, "<host>", "Proxy host/IP");
|
||||||
proxy_args.port = arg_int1(NULL, NULL, "<port>", "Proxy port");
|
proxy_args.port = arg_int1(NULL, NULL, "<port>", "Proxy port");
|
||||||
proxy_args.end = arg_end(2);
|
proxy_args.type = arg_str0(NULL, NULL, "<type>", "Proxy type: http|socks5 (default: http)");
|
||||||
|
proxy_args.end = arg_end(3);
|
||||||
esp_console_cmd_t proxy_cmd = {
|
esp_console_cmd_t proxy_cmd = {
|
||||||
.command = "set_proxy",
|
.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,
|
.func = &cmd_set_proxy,
|
||||||
.argtable = &proxy_args,
|
.argtable = &proxy_args,
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -31,6 +31,9 @@
|
|||||||
#ifndef MIMI_SECRET_PROXY_PORT
|
#ifndef MIMI_SECRET_PROXY_PORT
|
||||||
#define MIMI_SECRET_PROXY_PORT ""
|
#define MIMI_SECRET_PROXY_PORT ""
|
||||||
#endif
|
#endif
|
||||||
|
#ifndef MIMI_SECRET_PROXY_TYPE
|
||||||
|
#define MIMI_SECRET_PROXY_TYPE ""
|
||||||
|
#endif
|
||||||
#ifndef MIMI_SECRET_SEARCH_KEY
|
#ifndef MIMI_SECRET_SEARCH_KEY
|
||||||
#define MIMI_SECRET_SEARCH_KEY ""
|
#define MIMI_SECRET_SEARCH_KEY ""
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -25,6 +25,7 @@
|
|||||||
/* HTTP Proxy (leave empty or set both) */
|
/* HTTP Proxy (leave empty or set both) */
|
||||||
#define MIMI_SECRET_PROXY_HOST ""
|
#define MIMI_SECRET_PROXY_HOST ""
|
||||||
#define MIMI_SECRET_PROXY_PORT ""
|
#define MIMI_SECRET_PROXY_PORT ""
|
||||||
|
#define MIMI_SECRET_PROXY_TYPE "" /* "http" or "socks5" */
|
||||||
|
|
||||||
/* Brave Search API */
|
/* Brave Search API */
|
||||||
#define MIMI_SECRET_SEARCH_KEY ""
|
#define MIMI_SECRET_SEARCH_KEY ""
|
||||||
|
|||||||
Reference in New Issue
Block a user