mirror of
https://github.com/Tha14/toxic.git
synced 2024-11-30 08:13:28 +01:00
Fallback to loading /usr/share/toxic/DHTservers.
First try ~/.config/tox/DHTservers, and fallback to the /usr/share one if the former fails. This should allow people just starting toxic for the first time to connect to the DHT.
This commit is contained in:
parent
9f309ecb96
commit
6be1c907d9
19
src/main.c
19
src/main.c
@ -146,11 +146,14 @@ static char servers[MAXSERVERS][SERVERLEN];
|
||||
static uint16_t ports[MAXSERVERS];
|
||||
static uint8_t keys[MAXSERVERS][TOX_CLIENT_ID_SIZE];
|
||||
|
||||
int serverlist_load(void)
|
||||
static int serverlist_load(const char *filename)
|
||||
{
|
||||
FILE *fp = NULL;
|
||||
|
||||
fp = fopen(SRVLIST_FILE, "r");
|
||||
if (!filename)
|
||||
return 1;
|
||||
|
||||
fp = fopen(filename, "r");
|
||||
|
||||
if (fp == NULL)
|
||||
return 1;
|
||||
@ -213,9 +216,15 @@ int init_connection(Tox *m)
|
||||
*/
|
||||
if (!init_connection_serverlist_loaded) {
|
||||
init_connection_serverlist_loaded = 1;
|
||||
int res = serverlist_load();
|
||||
int res = serverlist_load(SRVLIST_FILE);
|
||||
if (res)
|
||||
{
|
||||
// Fallback on the provided DHTServers in /usr/share,
|
||||
// so new starts of toxic will connect to the DHT.
|
||||
serverlist_load(PACKAGE_DATADIR "/DHTservers");
|
||||
if (res)
|
||||
return res;
|
||||
}
|
||||
|
||||
if (!linecnt)
|
||||
return 4;
|
||||
@ -509,9 +518,6 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
}
|
||||
|
||||
if (config_err) {
|
||||
SRVLIST_FILE = strdup(PACKAGE_DATADIR "/DHTservers");
|
||||
} else {
|
||||
SRVLIST_FILE = malloc(strlen(user_config_dir) + strlen(CONFIGDIR) + strlen("DHTservers") + 1);
|
||||
if (SRVLIST_FILE != NULL) {
|
||||
strcpy(SRVLIST_FILE, user_config_dir);
|
||||
@ -522,7 +528,6 @@ int main(int argc, char *argv[])
|
||||
fprintf(stderr, "malloc() failed. Aborting...\n");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
}
|
||||
|
||||
free(user_config_dir);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user