summaryrefslogtreecommitdiff
path: root/testing/toxic
diff options
context:
space:
mode:
Diffstat (limited to 'testing/toxic')
-rw-r--r--testing/toxic/main.c18
1 files changed, 10 insertions, 8 deletions
diff --git a/testing/toxic/main.c b/testing/toxic/main.c
index 752453f2..9bf0b9f6 100644
--- a/testing/toxic/main.c
+++ b/testing/toxic/main.c
@@ -157,8 +157,7 @@ int init_connection(void)
157 char line[MAXLINE]; 157 char line[MAXLINE];
158 int linecnt = 0; 158 int linecnt = 0;
159 while (fgets(line, sizeof(line), fp) && linecnt < MAXSERVERS) { 159 while (fgets(line, sizeof(line), fp) && linecnt < MAXSERVERS) {
160 int len = strlen(line); 160 if (strlen(line) > MINLINE)
161 if (len > MINLINE && len < MAXLINE)
162 strcpy(servers[linecnt++], line); 161 strcpy(servers[linecnt++], line);
163 } 162 }
164 if (linecnt < 1) { 163 if (linecnt < 1) {
@@ -248,14 +247,21 @@ static void init_windows()
248 247
249static void do_tox() 248static void do_tox()
250{ 249{
250 static int conn_try = 1;
251 static bool dht_on = false; 251 static bool dht_on = false;
252 if (!dht_on && DHT_isconnected()) { 252 if (!dht_on && !DHT_isconnected()) {
253 init_connection();
254 if (!(conn_try++ % 100))
255 wprintw(prompt->window, "\nAttempting to connect...\n");
256 }
257 else if (!dht_on && DHT_isconnected()) {
253 dht_on = true; 258 dht_on = true;
254 wprintw(prompt->window, "\nDHT connected.\n"); 259 wprintw(prompt->window, "\nDHT connected.\n");
255 } 260 }
256 else if (dht_on && !DHT_isconnected()) { 261 else if (dht_on && !DHT_isconnected()) {
257 dht_on = false; 262 dht_on = false;
258 wprintw(prompt->window, "\nDHT disconnected.\n"); 263 wprintw(prompt->window, "\nDHT disconnected. Attempting to reconnect.\n");
264 init_connection();
259 } 265 }
260 doMessenger(); 266 doMessenger();
261} 267}
@@ -440,10 +446,6 @@ int main(int argc, char *argv[])
440 load_data(DATA_FILE); 446 load_data(DATA_FILE);
441 free(DATA_FILE); 447 free(DATA_FILE);
442 448
443 int connected = init_connection();
444 if (connected != 0)
445 wprintw(prompt->window, "Auto-connect failed (error code %d)\n", connected);
446
447 if (f_flag == -1) { 449 if (f_flag == -1) {
448 attron(COLOR_PAIR(3) | A_BOLD); 450 attron(COLOR_PAIR(3) | A_BOLD);
449 wprintw(prompt->window, "You passed '-f' without giving an argument.\n" 451 wprintw(prompt->window, "You passed '-f' without giving an argument.\n"