diff --git a/ext/installfiles/windows/ZeroTier One.aip b/ext/installfiles/windows/ZeroTier One.aip index ea481cebb..5f76f4e5c 100644 --- a/ext/installfiles/windows/ZeroTier One.aip +++ b/ext/installfiles/windows/ZeroTier One.aip @@ -1,5 +1,5 @@ - + @@ -23,12 +23,13 @@ + - + - + @@ -41,6 +42,7 @@ + @@ -60,16 +62,16 @@ - + - - + + - - - + + + @@ -304,7 +306,7 @@ - + @@ -477,7 +479,7 @@ - + diff --git a/osdep/EthernetTap.cpp b/osdep/EthernetTap.cpp index ab3f7acfc..445a5fe43 100644 --- a/osdep/EthernetTap.cpp +++ b/osdep/EthernetTap.cpp @@ -158,4 +158,10 @@ bool EthernetTap::addIps(std::vector ips) return true; } +std::string EthernetTap::friendlyName() const +{ + // Most platforms do not have this. + return std::string(); +} + } // namespace ZeroTier diff --git a/osdep/EthernetTap.hpp b/osdep/EthernetTap.hpp index bf42526ac..43beb440d 100644 --- a/osdep/EthernetTap.hpp +++ b/osdep/EthernetTap.hpp @@ -51,6 +51,7 @@ public: virtual void put(const MAC &from,const MAC &to,unsigned int etherType,const void *data,unsigned int len) = 0; virtual std::string deviceName() const = 0; virtual void setFriendlyName(const char *friendlyName) = 0; + virtual std::string friendlyName() const; virtual void scanMulticastGroups(std::vector &added,std::vector &removed) = 0; virtual void setMtu(unsigned int mtu) = 0; virtual void setDns(const char *domain, const std::vector &servers) = 0; diff --git a/osdep/WindowsEthernetTap.cpp b/osdep/WindowsEthernetTap.cpp index ab6ea6194..460385b0e 100644 --- a/osdep/WindowsEthernetTap.cpp +++ b/osdep/WindowsEthernetTap.cpp @@ -810,6 +810,7 @@ void WindowsEthernetTap::setFriendlyName(const char *dn) { if (!_initialized) return; + HKEY ifp; if (RegOpenKeyExA(HKEY_LOCAL_MACHINE,(std::string("SYSTEM\\CurrentControlSet\\Control\\Network\\{4D36E972-E325-11CE-BFC1-08002BE10318}\\") + _netCfgInstanceId).c_str(),0,KEY_READ|KEY_WRITE,&ifp) == ERROR_SUCCESS) { RegSetKeyValueA(ifp,"Connection","Name",REG_SZ,(LPCVOID)dn,(DWORD)(strlen(dn)+1)); @@ -864,6 +865,16 @@ void WindowsEthernetTap::setFriendlyName(const char *dn) ev->Release(); } nsecc->Release(); + + _friendlyName_m.lock(); + _friendlyName = dn; + _friendlyName_m.unlock(); +} + +std::string WindowsEthernetTap::friendlyName() const +{ + Mutex::Lock l(_friendlyName_m); + return _friendlyName; } void WindowsEthernetTap::scanMulticastGroups(std::vector &added,std::vector &removed) diff --git a/osdep/WindowsEthernetTap.hpp b/osdep/WindowsEthernetTap.hpp index 243d16340..a08042d44 100644 --- a/osdep/WindowsEthernetTap.hpp +++ b/osdep/WindowsEthernetTap.hpp @@ -95,6 +95,7 @@ public: virtual void put(const MAC &from,const MAC &to,unsigned int etherType,const void *data,unsigned int len); virtual std::string deviceName() const; virtual void setFriendlyName(const char *friendlyName); + virtual std::string friendlyName() const; virtual void scanMulticastGroups(std::vector &added,std::vector &removed); virtual void setMtu(unsigned int mtu); virtual void setDns(const char* domain, const std::vector &servers); @@ -130,8 +131,8 @@ private: std::string _netCfgInstanceId; std::string _deviceInstanceId; std::string _mySubkeyName; - std::string _friendlyName; + Mutex _friendlyName_m; std::vector _assignedIps; // IPs assigned with addIp Mutex _assignedIps_m; diff --git a/service/OneService.cpp b/service/OneService.cpp index 8c0e64e97..bb72277e3 100644 --- a/service/OneService.cpp +++ b/service/OneService.cpp @@ -3028,13 +3028,6 @@ public: if ((ifname[0] == 'u') && (ifname[1] == 't') && (ifname[2] == 'u') && (ifname[3] == 'n')) return false; // ... as is utun# #endif -#ifdef _WIN32 - if ((ifname[0] == 'Z') && (ifname[1] == 'e') && (ifname[2] == 'r') && ifname[3] == 'o' && - (ifname[4] == 'T') && (ifname[5] == 'i') && (ifname[6] == 'e') && (ifname[7] == 'r')) { - return false; - } -#endif - #ifdef __FreeBSD__ if ((ifname[0] == 'l') && (ifname[1] == 'o')) return false; // loopback if ((ifname[0] == 'z') && (ifname[1] == 't')) return false; // sanity check: zt# @@ -3073,6 +3066,10 @@ public: if (i->ipsEqual(ifaddr)) return false; } +#ifdef _WIN32 + if (n->second.tap->friendlyName() == ifname) + return false; +#endif } } }