mirror of
https://github.com/ZeroTier/ZeroTierOne
synced 2025-08-14 18:48:36 -07:00
Automatically detect Ethernet tap friendly name in Windows shouldBind stuff.
This commit is contained in:
parent
e8390afad5
commit
79e2fd4586
6 changed files with 37 additions and 19 deletions
|
@ -158,4 +158,10 @@ bool EthernetTap::addIps(std::vector<InetAddress> ips)
|
|||
return true;
|
||||
}
|
||||
|
||||
std::string EthernetTap::friendlyName() const
|
||||
{
|
||||
// Most platforms do not have this.
|
||||
return std::string();
|
||||
}
|
||||
|
||||
} // namespace ZeroTier
|
||||
|
|
|
@ -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<MulticastGroup> &added,std::vector<MulticastGroup> &removed) = 0;
|
||||
virtual void setMtu(unsigned int mtu) = 0;
|
||||
virtual void setDns(const char *domain, const std::vector<InetAddress> &servers) = 0;
|
||||
|
|
|
@ -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<MulticastGroup> &added,std::vector<MulticastGroup> &removed)
|
||||
|
|
|
@ -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<MulticastGroup> &added,std::vector<MulticastGroup> &removed);
|
||||
virtual void setMtu(unsigned int mtu);
|
||||
virtual void setDns(const char* domain, const std::vector<InetAddress> &servers);
|
||||
|
@ -130,8 +131,8 @@ private:
|
|||
std::string _netCfgInstanceId;
|
||||
std::string _deviceInstanceId;
|
||||
std::string _mySubkeyName;
|
||||
|
||||
std::string _friendlyName;
|
||||
Mutex _friendlyName_m;
|
||||
|
||||
std::vector<InetAddress> _assignedIps; // IPs assigned with addIp
|
||||
Mutex _assignedIps_m;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue