Skip to content

Commit

Permalink
fix binding temporary ipv6 addresses on macos (#1910)
Browse files Browse the repository at this point in the history
The check code wasn't running.

I don't know why !defined(TARGET_OS_IOS) would exclude code on
desktop macOS. I did a quick search and changed it to defined(TARGET_OS_MAC).
Not 100% sure what the most correct solution there is.

You can verify the old and new versions with

`ifconfig | grep temporary`

plus

`zerotier-cli info -j` -> listeningOn
  • Loading branch information
laduke authored Mar 21, 2023
1 parent ce9330e commit 314099a
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions osdep/Binder.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@

#if (defined(__unix__) || defined(__APPLE__)) && !defined(__LINUX__) && !defined(ZT_SDK)
#include <net/if.h>
#if ! defined(TARGET_OS_IOS)
#if defined(TARGET_OS_OSX)
#include <netinet6/in6_var.h>
#endif
#include <sys/ioctl.h>
Expand Down Expand Up @@ -333,7 +333,7 @@ class Binder {
while (ifa) {
if ((ifa->ifa_name) && (ifa->ifa_addr)) {
InetAddress ip = *(ifa->ifa_addr);
#if (defined(__unix__) || defined(__APPLE__)) && !defined(__LINUX__) && !defined(ZT_SDK) && !defined(TARGET_OS_IOS)
#if (defined(__unix__) || defined(__APPLE__)) && !defined(__LINUX__) && !defined(ZT_SDK) && defined(TARGET_OS_OSX)
// Check if the address is an IPv6 Temporary Address, macOS/BSD version
if (ifa->ifa_addr->sa_family == AF_INET6) {
struct sockaddr_in6* sa6 = (struct sockaddr_in6*)ifa->ifa_addr;
Expand All @@ -349,8 +349,8 @@ class Binder {

// if this is a temporary IPv6 address, skip to the next address
if (flags & IN6_IFF_TEMPORARY) {
char buf[64];
#ifdef ZT_TRACE
char buf[64];
fprintf(stderr, "skip binding to temporary IPv6 address: %s\n", ip.toIpString(buf));
#endif
ifa = ifa->ifa_next;
Expand Down

0 comments on commit 314099a

Please sign in to comment.