Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions doc/toxic.1
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 3 additions & 0 deletions doc/toxic.1.asc
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
8 changes: 6 additions & 2 deletions src/bootstrap.c
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down Expand Up @@ -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);
Expand Down
16 changes: 14 additions & 2 deletions src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down Expand Up @@ -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'},
Expand All @@ -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;
Expand Down Expand Up @@ -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");
Expand Down
1 change: 1 addition & 0 deletions src/run_options.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Loading