mirror of
https://github.com/Tha14/toxic.git
synced 2024-11-23 01:13:01 +01:00
Merge remote-tracking branch 'upstream/master' into ipv6.init_connection
This commit is contained in:
commit
560e6be66b
38
src/main.c
38
src/main.c
@ -136,22 +136,22 @@ int serverlist_load()
|
|||||||
char line[MAXLINE];
|
char line[MAXLINE];
|
||||||
while (fgets(line, sizeof(line), fp) && linecnt < MAXSERVERS) {
|
while (fgets(line, sizeof(line), fp) && linecnt < MAXSERVERS) {
|
||||||
if (strlen(line) > MINLINE) {
|
if (strlen(line) > MINLINE) {
|
||||||
char *name = strtok(server, " ");
|
char *name = strtok(line, " ");
|
||||||
char *port = strtok(NULL, " ");
|
char *port = strtok(NULL, " ");
|
||||||
char *key_ascii = strtok(NULL, " ");
|
char *key_ascii = strtok(NULL, " ");
|
||||||
/* invalid line */
|
/* invalid line */
|
||||||
if (name == NULL || port == NULL || key_ascii == NULL)
|
if (name == NULL || port == NULL || key_ascii == NULL)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
strncpy(servers[linecnt], name, SERVERLEN);
|
strncpy(servers[linecnt], name, SERVERLEN);
|
||||||
servers[linecnt][SERVERLEN - 1] = 0;
|
servers[linecnt][SERVERLEN - 1] = 0;
|
||||||
ports[linecnt] = htons(atoi(port));
|
ports[linecnt] = htons(atoi(port));
|
||||||
|
|
||||||
uint8_t *key_binary = hex_string_to_bin(key_ascii);
|
uint8_t *key_binary = hex_string_to_bin(key_ascii);
|
||||||
memcpy(keys[linecnt], key_binary, TOX_CLIENT_ID_SIZE);
|
memcpy(keys[linecnt], key_binary, TOX_CLIENT_ID_SIZE);
|
||||||
free(binary_string);
|
free(key_binary);
|
||||||
|
|
||||||
linecnt++;
|
linecnt++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -166,8 +166,8 @@ int serverlist_load()
|
|||||||
|
|
||||||
int init_connection_helper(Tox *m, int linenumber)
|
int init_connection_helper(Tox *m, int linenumber)
|
||||||
{
|
{
|
||||||
return tox_bootstrap_from_address(m, servers[linenumber, TOX_ENABLE_IPV6_DEFAULT,
|
return tox_bootstrap_from_address(m, servers[linenumber], TOX_ENABLE_IPV6_DEFAULT,
|
||||||
ports[linenumber], keys[linenumber]);
|
ports[linenumber], keys[linenumber]);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Connects to a random DHT server listed in the DHTservers file
|
/* Connects to a random DHT server listed in the DHTservers file
|
||||||
@ -195,14 +195,14 @@ int init_connection(Tox *m)
|
|||||||
if (res)
|
if (res)
|
||||||
return res;
|
return res;
|
||||||
|
|
||||||
if (!linecnt)
|
if (!linecnt)
|
||||||
return 4;
|
return 4;
|
||||||
|
|
||||||
res = 6;
|
res = 6;
|
||||||
int linenumber;
|
int linenumber;
|
||||||
for(linenumber = 0; linenumber < linecnt; linenumber++)
|
for(linenumber = 0; linenumber < linecnt; linenumber++)
|
||||||
if (init_connection_helper(m, linenumber))
|
if (init_connection_helper(m, linenumber))
|
||||||
res = 0;
|
res = 0;
|
||||||
|
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user