diff --git a/doc/toxic.1 b/doc/toxic.1 index ffab2c70a..1dcdf0379 100644 --- a/doc/toxic.1 +++ b/doc/toxic.1 @@ -91,6 +91,14 @@ for DHT bootstrap nodes instead of \fI~/\&.config/tox/DHTnodes\&.json\fR .RE .PP +\-N, \-\-nodes\-url nodes\-list\-url +.RS +Use specified +\fInodes-list-url\fR +for DHT bootstrap nodes status info instead of +\fIhttps://nodes\&.tox\&.chat/json\fR +.RE +.PP \-o, \-\-noconnect .RS 4 Do not connect to the DHT network diff --git a/doc/toxic.1.asc b/doc/toxic.1.asc index 1287e8b9c..abc24361e 100644 --- a/doc/toxic.1.asc +++ b/doc/toxic.1.asc @@ -46,6 +46,9 @@ OPTIONS -n, --nodes nodes-file:: Use specified 'nodes-file' for DHT bootstrap nodes instead of '~/.config/tox/DHTnodes.json' +-N, --nodes-url nodes-list-url:: + Use specified 'nodes-list-url' for DHT bootstrap nodes status info instead of 'https://nodes.tox.chat/json' + -o, --noconnect:: Do not connect to the DHT network diff --git a/src/bootstrap.c b/src/bootstrap.c index 576d56d72..30c57d1b7 100644 --- a/src/bootstrap.c +++ b/src/bootstrap.c @@ -29,7 +29,7 @@ #include "windows.h" /* URL that we get the JSON encoded nodes list from. */ -#define NODES_LIST_URL "https://nodes.tox.chat/json" +#define DEFAULT_NODES_LIST_URL "https://nodes.tox.chat/json" #define DEFAULT_NODES_FILENAME "DHTnodes.json" @@ -206,7 +206,11 @@ static int curl_fetch_nodes_JSON(const Run_Options *run_opts, struct Recv_Curl_D goto on_exit; } - ret = curl_easy_setopt(c_handle, CURLOPT_URL, NODES_LIST_URL); + if (!string_is_empty(run_opts->nodes_path)) { + ret = curl_easy_setopt(c_handle, CURLOPT_URL, run_opts->nodes_list_url); + } else { + ret = curl_easy_setopt(c_handle, CURLOPT_URL, DEFAULT_NODES_LIST_URL); + } if (ret != CURLE_OK) { fprintf(stderr, "Failed to set url (libcurl error %d)", ret); diff --git a/src/main.c b/src/main.c index 5d9ec85fc..350fb3f05 100644 --- a/src/main.c +++ b/src/main.c @@ -861,6 +861,7 @@ static void print_usage(void) fprintf(stderr, " -l, --logging Enable toxcore logging: Requires [log_path | stderr]\n"); fprintf(stderr, " -L, --no-lan Disable local discovery\n"); fprintf(stderr, " -n, --nodes Use specified DHTnodes file\n"); + fprintf(stderr, " -N, --nodes-url Use specified DHTnodes list url\n"); fprintf(stderr, " -o, --noconnect Do not connect to the DHT network\n"); fprintf(stderr, " -p, --SOCKS5-proxy Use SOCKS5 proxy: Requires [IP] [port]\n"); fprintf(stderr, " -P, --HTTP-proxy Use HTTP proxy: Requires [IP] [port]\n"); @@ -994,6 +995,7 @@ static void parse_args(Toxic *toxic, Init_Queue *init_q, int argc, char *argv[]) {"logging", required_argument, 0, 'l'}, {"no-lan", no_argument, 0, 'L'}, {"nodes", required_argument, 0, 'n'}, + {"nodes-url", required_argument, 0, 'N'}, {"help", no_argument, 0, 'h'}, {"noconnect", no_argument, 0, 'o'}, {"namelist", required_argument, 0, 'r'}, @@ -1010,9 +1012,9 @@ static void parse_args(Toxic *toxic, Init_Queue *init_q, int argc, char *argv[]) }; #ifdef TOX_EXPERIMENTAL - const char *opts_str = "4bdehLotuxvc:f:l:n:r:s:p:P:T:"; + const char *opts_str = "4bdehLotuxvc:f:l:n:N:r:s:p:P:T:"; #else - const char *opts_str = "4bdehLotuxvc:f:l:n:r:p:P:T:"; + const char *opts_str = "4bdehLotuxvc:f:l:n:N:r:p:P:T:"; #endif // TOX_EXPERIMENTAL int opt = 0; @@ -1076,6 +1078,16 @@ static void parse_args(Toxic *toxic, Init_Queue *init_q, int argc, char *argv[]) break; } + case 'N': { + if (optarg == NULL ) { + init_queue_add(init_q, "Invaild argument for option : %d", opt); + break; + } + + snprintf(run_opts->nodes_list_url, sizeof(run_opts->nodes_list_url), "%s", optarg); + break; + } + case 'o': { run_opts->no_connect = true; init_queue_add(init_q, "DHT disabled"); diff --git a/src/run_options.h b/src/run_options.h index 27b12cfe4..e4e815dcf 100644 --- a/src/run_options.h +++ b/src/run_options.h @@ -45,6 +45,7 @@ typedef struct Run_Options { char nameserver_path[TOXIC_MAX_PATH_LENGTH]; char config_path[TOXIC_MAX_PATH_LENGTH]; char nodes_path[TOXIC_MAX_PATH_LENGTH]; + char nodes_list_url[TOXIC_MAX_PATH_LENGTH]; bool logging; FILE *log_fp;