mirror of
https://github.com/yarrick/iodine.git
synced 2025-04-10 04:21:01 +00:00
Merge branch 'fix-socket-length' of https://github.com/jedisct1/iodine into jedisct1-fix-socket-length
This commit is contained in:
commit
adee2b7996
3 changed files with 18 additions and 12 deletions
|
@ -147,7 +147,7 @@ void
|
||||||
client_rotate_nameserver()
|
client_rotate_nameserver()
|
||||||
{
|
{
|
||||||
this.current_nameserver ++;
|
this.current_nameserver ++;
|
||||||
if (this.current_nameserver >= this.nameserv_addrs_len)
|
if (this.current_nameserver >= this.nameserv_addrs_count)
|
||||||
this.current_nameserver = 0;
|
this.current_nameserver = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -364,8 +364,8 @@ send_query(uint8_t *hostname)
|
||||||
|
|
||||||
DEBUG(4, " Sendquery: id %5d name[0] '%c'", q.id, hostname[0]);
|
DEBUG(4, " Sendquery: id %5d name[0] '%c'", q.id, hostname[0]);
|
||||||
|
|
||||||
sendto(this.dns_fd, packet, len, 0, (struct sockaddr*) &this.nameserv_addrs[this.current_nameserver],
|
sendto(this.dns_fd, packet, len, 0, (struct sockaddr*) &this.nameserv_addrs[this.current_nameserver].addr,
|
||||||
sizeof(struct sockaddr_storage));
|
this.nameserv_addrs[this.current_nameserver].len);
|
||||||
|
|
||||||
client_rotate_nameserver();
|
client_rotate_nameserver();
|
||||||
|
|
||||||
|
|
|
@ -26,6 +26,11 @@ extern int stats;
|
||||||
#define PENDING_QUERIES_LENGTH (MAX(this.windowsize_up, this.windowsize_down) * 4)
|
#define PENDING_QUERIES_LENGTH (MAX(this.windowsize_up, this.windowsize_down) * 4)
|
||||||
#define INSTANCE this
|
#define INSTANCE this
|
||||||
|
|
||||||
|
struct nameserv {
|
||||||
|
struct sockaddr_storage addr;
|
||||||
|
int len;
|
||||||
|
};
|
||||||
|
|
||||||
struct client_instance {
|
struct client_instance {
|
||||||
int max_downstream_frag_size;
|
int max_downstream_frag_size;
|
||||||
int autodetect_frag_size;
|
int autodetect_frag_size;
|
||||||
|
@ -37,8 +42,8 @@ struct client_instance {
|
||||||
/* DNS nameserver info */
|
/* DNS nameserver info */
|
||||||
char **nameserv_hosts;
|
char **nameserv_hosts;
|
||||||
size_t nameserv_hosts_len;
|
size_t nameserv_hosts_len;
|
||||||
struct sockaddr_storage *nameserv_addrs;
|
struct nameserv *nameserv_addrs;
|
||||||
size_t nameserv_addrs_len;
|
size_t nameserv_addrs_count;
|
||||||
int current_nameserver;
|
int current_nameserver;
|
||||||
struct sockaddr_storage raw_serv;
|
struct sockaddr_storage raw_serv;
|
||||||
int raw_serv_len;
|
int raw_serv_len;
|
||||||
|
|
15
src/iodine.c
15
src/iodine.c
|
@ -623,7 +623,7 @@ main(int argc, char **argv)
|
||||||
|
|
||||||
// Preallocate memory with expected number of hosts
|
// Preallocate memory with expected number of hosts
|
||||||
this.nameserv_hosts = malloc(sizeof(char *) * this.nameserv_hosts_len);
|
this.nameserv_hosts = malloc(sizeof(char *) * this.nameserv_hosts_len);
|
||||||
this.nameserv_addrs = malloc(sizeof(struct sockaddr_storage) * this.nameserv_hosts_len);
|
this.nameserv_addrs = malloc(sizeof(struct nameserv) * this.nameserv_hosts_len);
|
||||||
|
|
||||||
if (argc == 0) {
|
if (argc == 0) {
|
||||||
usage();
|
usage();
|
||||||
|
@ -645,12 +645,13 @@ main(int argc, char **argv)
|
||||||
errx(1, "Cannot lookup nameserver '%s': %s ",
|
errx(1, "Cannot lookup nameserver '%s': %s ",
|
||||||
nameserv_host, gai_strerror(nameservaddr_len));
|
nameserv_host, gai_strerror(nameservaddr_len));
|
||||||
}
|
}
|
||||||
memcpy(&this.nameserv_addrs[n], &nameservaddr, sizeof(struct sockaddr_storage));
|
this.nameserv_addrs[n].len = nameservaddr_len;
|
||||||
this.nameserv_addrs_len ++;
|
memcpy(&this.nameserv_addrs[n].addr, &nameservaddr, sizeof(struct sockaddr_storage));
|
||||||
|
this.nameserv_addrs_count ++;
|
||||||
nameserv_host = NULL;
|
nameserv_host = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.nameserv_addrs_len <= 0 || !this.nameserv_hosts[0]) {
|
if (this.nameserv_addrs_count <= 0 || !this.nameserv_hosts[0]) {
|
||||||
warnx("No nameservers found - not connected to any network?");
|
warnx("No nameservers found - not connected to any network?");
|
||||||
usage();
|
usage();
|
||||||
}
|
}
|
||||||
|
@ -733,9 +734,9 @@ main(int argc, char **argv)
|
||||||
signal(SIGTERM, sighandler);
|
signal(SIGTERM, sighandler);
|
||||||
|
|
||||||
fprintf(stderr, "Sending DNS queries for %s to ", this.topdomain);
|
fprintf(stderr, "Sending DNS queries for %s to ", this.topdomain);
|
||||||
for (int a = 0; a < this.nameserv_addrs_len; a++)
|
for (int a = 0; a < this.nameserv_addrs_count; a++)
|
||||||
fprintf(stderr, "%s%s", format_addr(&this.nameserv_addrs[a], sizeof(struct sockaddr_storage)),
|
fprintf(stderr, "%s%s", format_addr(&this.nameserv_addrs[a].addr, this.nameserv_addrs[a].len),
|
||||||
(a != this.nameserv_addrs_len - 1) ? ", " : "");
|
(a != this.nameserv_addrs_count - 1) ? ", " : "");
|
||||||
fprintf(stderr, "\n");
|
fprintf(stderr, "\n");
|
||||||
|
|
||||||
if (this.remote_forward_addr.ss_family != AF_UNSPEC)
|
if (this.remote_forward_addr.ss_family != AF_UNSPEC)
|
||||||
|
|
Loading…
Add table
Reference in a new issue