mirror of
https://github.com/Tha14/toxic.git
synced 2024-11-26 13:53:26 +01:00
Ignore bootstrap nodes that use a domain instead of IP address
Domains cause toxcore to do blocking DNS requests which creates noticable lag and might (??) leak IP addresses when using a proxy
This commit is contained in:
parent
151f5f0c51
commit
221d761ff4
@ -77,7 +77,6 @@ static struct DHT_Nodes {
|
|||||||
char keys[MAXNODES][TOX_PUBLIC_KEY_SIZE];
|
char keys[MAXNODES][TOX_PUBLIC_KEY_SIZE];
|
||||||
} Nodes;
|
} Nodes;
|
||||||
|
|
||||||
|
|
||||||
/* Return true if nodeslist pointed to by fp needs to be updated.
|
/* Return true if nodeslist pointed to by fp needs to be updated.
|
||||||
* This will be the case if the file is empty, has an invalid format,
|
* This will be the case if the file is empty, has an invalid format,
|
||||||
* or if the file is older than the given timeout.
|
* or if the file is older than the given timeout.
|
||||||
@ -297,6 +296,11 @@ int load_DHT_nodeslist(void)
|
|||||||
memcpy(ipv4_string, ip_start, ip_len);
|
memcpy(ipv4_string, ip_start, ip_len);
|
||||||
ipv4_string[ip_len] = 0;
|
ipv4_string[ip_len] = 0;
|
||||||
|
|
||||||
|
/* ignore domains because we don't want toxcore doing DNS requests during bootstrap. */
|
||||||
|
if (!is_ip4_address(ipv4_string)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
/* Extract port */
|
/* Extract port */
|
||||||
const char *port_start = strstr(ip_start, PORT_JSON_VALUE);
|
const char *port_start = strstr(ip_start, PORT_JSON_VALUE);
|
||||||
|
|
||||||
|
@ -26,7 +26,9 @@
|
|||||||
#include <time.h>
|
#include <time.h>
|
||||||
#include <limits.h>
|
#include <limits.h>
|
||||||
#include <dirent.h>
|
#include <dirent.h>
|
||||||
|
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
|
#include <arpa/inet.h>
|
||||||
|
|
||||||
#include "toxic.h"
|
#include "toxic.h"
|
||||||
#include "windows.h"
|
#include "windows.h"
|
||||||
@ -478,3 +480,10 @@ void set_window_title(ToxWindow *self, const char *title, int len)
|
|||||||
|
|
||||||
snprintf(self->name, sizeof(self->name), "%s", cpy);
|
snprintf(self->name, sizeof(self->name), "%s", cpy);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Return true if address appears to be a valid ipv4 address. */
|
||||||
|
bool is_ip4_address(const char *address)
|
||||||
|
{
|
||||||
|
struct sockaddr_in s_addr;
|
||||||
|
return inet_pton(AF_INET, address, &(s_addr.sin_addr)) != 0;
|
||||||
|
}
|
||||||
|
@ -161,4 +161,7 @@ int check_file_signature(const char *signature, size_t size, FILE *fp);
|
|||||||
/* sets window title in tab bar. */
|
/* sets window title in tab bar. */
|
||||||
void set_window_title(ToxWindow *self, const char *title, int len);
|
void set_window_title(ToxWindow *self, const char *title, int len);
|
||||||
|
|
||||||
|
/* Return true if address appears to be a valid ipv4 address. */
|
||||||
|
bool is_ip4_address(const char *address);
|
||||||
|
|
||||||
#endif /* #define MISC_TOOLS_H */
|
#endif /* #define MISC_TOOLS_H */
|
||||||
|
Loading…
Reference in New Issue
Block a user