Skip to content

Commit

Permalink
detect family directly before setting TTL for NetBSD
Browse files Browse the repository at this point in the history
  • Loading branch information
dartvader316 committed Aug 14, 2024
1 parent 6c7116e commit 87e368f
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions desync.c
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit 87e368f

Please sign in to comment.