diff --git a/desync.c b/desync.c index 027f2dec..e75247fc 100644 --- a/desync.c +++ b/desync.c @@ -55,7 +55,12 @@ int get_family(struct sockaddr *dst) int setttl(int fd, int ttl, int family) { int _ttl = ttl; - +#ifdef __NetBSD__ + struct sockaddr_in fd_addr; + socklen_t fd_addr_len = sizeof(fd_addr); + getsockname(fd, (struct sockaddr *) &fd_addr, &fd_addr_len); + family = fd_addr.sin_family; +#endif if (family == AF_INET) { if (setsockopt(fd, IPPROTO_IP, IP_TTL, (char *)&_ttl, sizeof(_ttl)) < 0) { @@ -417,12 +422,6 @@ ssize_t desync(int sfd, char *buffer, size_t bfsize, char *host = 0; int len = 0, type = 0; int fa = get_family(dst); -#ifdef __NetBSD__ - struct sockaddr_in sfd_addr; - socklen_t sfd_addr_len = sizeof(sfd_addr); - getsockname(sfd, (struct sockaddr *) &sfd_addr, &sfd_addr_len); - fa = sfd_addr.sin_family; -#endif // parse packet if ((len = parse_tls(buffer, n, &host))) { type = IS_HTTPS;