mirror of
https://github.com/yarrick/iodine.git
synced 2025-04-04 05:43:33 +03:00
Merge branch 'jedisct1-fix-socket-length'
This commit is contained in:
commit
56e1887b93
3 changed files with 18 additions and 12 deletions
|
@ -147,7 +147,7 @@ void
|
|||
client_rotate_nameserver()
|
||||
{
|
||||
this.current_nameserver ++;
|
||||
if (this.current_nameserver >= this.nameserv_addrs_len)
|
||||
if (this.current_nameserver >= this.nameserv_addrs_count)
|
||||
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]);
|
||||
|
||||
sendto(this.dns_fd, packet, len, 0, (struct sockaddr*) &this.nameserv_addrs[this.current_nameserver],
|
||||
sizeof(struct sockaddr_storage));
|
||||
sendto(this.dns_fd, packet, len, 0, (struct sockaddr*) &this.nameserv_addrs[this.current_nameserver].addr,
|
||||
this.nameserv_addrs[this.current_nameserver].len);
|
||||
|
||||
client_rotate_nameserver();
|
||||
|
||||
|
|
|
@ -26,6 +26,11 @@ extern int stats;
|
|||
#define PENDING_QUERIES_LENGTH (MAX(this.windowsize_up, this.windowsize_down) * 4)
|
||||
#define INSTANCE this
|
||||
|
||||
struct nameserv {
|
||||
struct sockaddr_storage addr;
|
||||
int len;
|
||||
};
|
||||
|
||||
struct client_instance {
|
||||
int max_downstream_frag_size;
|
||||
int autodetect_frag_size;
|
||||
|
@ -37,8 +42,8 @@ struct client_instance {
|
|||
/* DNS nameserver info */
|
||||
char **nameserv_hosts;
|
||||
size_t nameserv_hosts_len;
|
||||
struct sockaddr_storage *nameserv_addrs;
|
||||
size_t nameserv_addrs_len;
|
||||
struct nameserv *nameserv_addrs;
|
||||
size_t nameserv_addrs_count;
|
||||
int current_nameserver;
|
||||
struct sockaddr_storage raw_serv;
|
||||
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
|
||||
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) {
|
||||
usage();
|
||||
|
@ -645,12 +645,13 @@ main(int argc, char **argv)
|
|||
errx(1, "Cannot lookup nameserver '%s': %s ",
|
||||
nameserv_host, gai_strerror(nameservaddr_len));
|
||||
}
|
||||
memcpy(&this.nameserv_addrs[n], &nameservaddr, sizeof(struct sockaddr_storage));
|
||||
this.nameserv_addrs_len ++;
|
||||
this.nameserv_addrs[n].len = nameservaddr_len;
|
||||
memcpy(&this.nameserv_addrs[n].addr, &nameservaddr, sizeof(struct sockaddr_storage));
|
||||
this.nameserv_addrs_count ++;
|
||||
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?");
|
||||
usage();
|
||||
}
|
||||
|
@ -733,9 +734,9 @@ main(int argc, char **argv)
|
|||
signal(SIGTERM, sighandler);
|
||||
|
||||
fprintf(stderr, "Sending DNS queries for %s to ", this.topdomain);
|
||||
for (int a = 0; a < this.nameserv_addrs_len; a++)
|
||||
fprintf(stderr, "%s%s", format_addr(&this.nameserv_addrs[a], sizeof(struct sockaddr_storage)),
|
||||
(a != this.nameserv_addrs_len - 1) ? ", " : "");
|
||||
for (int a = 0; a < this.nameserv_addrs_count; a++)
|
||||
fprintf(stderr, "%s%s", format_addr(&this.nameserv_addrs[a].addr, this.nameserv_addrs[a].len),
|
||||
(a != this.nameserv_addrs_count - 1) ? ", " : "");
|
||||
fprintf(stderr, "\n");
|
||||
|
||||
if (this.remote_forward_addr.ss_family != AF_UNSPEC)
|
||||
|
|
Loading…
Add table
Reference in a new issue