Skip to content

Commit

Permalink
Try to get all packets from mud
Browse files Browse the repository at this point in the history
Signed-off-by: Adrien Gallouët <adrien@gallouet.fr>
  • Loading branch information
angt committed Jun 27, 2019
1 parent 5e89ebc commit 4a68866
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions src/bind.c
Original file line number Diff line number Diff line change
Expand Up @@ -314,11 +314,18 @@ gt_bind(int argc, char **argv)
}
}

if (FD_ISSET(mud_fd, &rfds)) {
const int r = mud_recv(mud, buf, sizeof(buf));
if (FD_ISSET(mud_fd, &rfds)) {
int n = 1000;

if (r > 0 && ip_is_valid(buf, r))
tun_write(tun_fd, buf, (size_t)r);
while (n--) {
const int r = mud_recv(mud, buf, sizeof(buf));

if (r <= 0)
break;

if (ip_is_valid(buf, r))
tun_write(tun_fd, buf, (size_t)r);
}
}

if (FD_ISSET(tun_fd, &rfds) && !mud_send_wait(mud)) {
Expand Down

0 comments on commit 4a68866

Please sign in to comment.