mirror of
https://github.com/Tha14/toxic.git
synced 2024-11-27 02:53:27 +01:00
fix connection error codes
This commit is contained in:
parent
eb09fceed7
commit
e7920d1da7
16
src/main.c
16
src/main.c
@ -200,16 +200,15 @@ int init_connection_helper(Tox *m, int line)
|
|||||||
* return codes:
|
* return codes:
|
||||||
* 1: failed to open server file
|
* 1: failed to open server file
|
||||||
* 2: no line of sufficient length in server file
|
* 2: no line of sufficient length in server file
|
||||||
* 3: (old, removed) failed to split a selected line in the server file
|
* 3: failed to resolve name to IP
|
||||||
* 4: failed to resolve name to IP
|
* 4: serverlist file contains no acceptable line
|
||||||
* 5: serverlist file contains no acceptable line
|
|
||||||
*/
|
*/
|
||||||
static bool srvlist_loaded = false;
|
static bool srvlist_loaded = false;
|
||||||
|
|
||||||
int init_connection(Tox *m)
|
int init_connection(Tox *m)
|
||||||
{
|
{
|
||||||
if (linecnt > 0) /* already loaded serverlist */
|
if (linecnt > 0) /* already loaded serverlist */
|
||||||
return init_connection_helper(m, rand() % linecnt) ? 0 : 4;
|
return init_connection_helper(m, rand() % linecnt) ? 0 : 3;
|
||||||
|
|
||||||
/* only once:
|
/* only once:
|
||||||
* - load the serverlist
|
* - load the serverlist
|
||||||
@ -220,17 +219,18 @@ int init_connection(Tox *m)
|
|||||||
int res = serverlist_load(SRVLIST_FILE);
|
int res = serverlist_load(SRVLIST_FILE);
|
||||||
|
|
||||||
if (res) {
|
if (res) {
|
||||||
/* Fallback on the provided DHTServers in /usr/share,
|
/* Fallback on the provided DHTServers in /usr/share or /usr/local/share,
|
||||||
so new starts of toxic will connect to the DHT. */
|
so new starts of toxic will connect to the DHT. */
|
||||||
res = serverlist_load(PACKAGE_DATADIR "/DHTservers");
|
res = serverlist_load(PACKAGE_DATADIR "/DHTservers");
|
||||||
|
|
||||||
if (res)
|
if (res)
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!linecnt)
|
if (!linecnt)
|
||||||
return 4;
|
return 2;
|
||||||
|
|
||||||
res = 6;
|
res = 3;
|
||||||
int line;
|
int line;
|
||||||
|
|
||||||
for(line = 0; line < linecnt; line++)
|
for(line = 0; line < linecnt; line++)
|
||||||
@ -241,7 +241,7 @@ int init_connection(Tox *m)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* empty serverlist file */
|
/* empty serverlist file */
|
||||||
return 5;
|
return 4;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void do_connection(Tox *m, ToxWindow *prompt)
|
static void do_connection(Tox *m, ToxWindow *prompt)
|
||||||
|
Loading…
Reference in New Issue
Block a user