More useful to allow arrays of IPs to bind to.

This commit is contained in:
Adam Ierymenko 2018-01-25 17:27:08 -05:00
parent 125ec622ca
commit 5f5302e595
3 changed files with 20 additions and 8 deletions

View file

@ -565,7 +565,7 @@ public:
}
// Read local configuration
bool bindToWildcard = false;
std::vector<InetAddress> explicitBind;
{
std::map<InetAddress,ZT_PhysicalPathConfiguration> ppc;
@ -635,7 +635,17 @@ public:
_controllerDbPath = cdbp;
// Bind to wildcard instead of to specific interfaces (disables full tunnel capability)
bindToWildcard = OSUtils::jsonBool(settings["bindToWildcard"],false);
json &bind = settings["bind"];
if (bind.is_array()) {
for(unsigned long i=0;i<bind.size();++i) {
const std::string ips(OSUtils::jsonString(bind[i],""));
if (ips.length() > 0) {
InetAddress ip(ips.c_str());
if ((ip.ss_family == AF_INET)||(ip.ss_family == AF_INET6))
explicitBind.push_back(ip);
}
}
}
}
// Set trusted paths if there are any
@ -805,7 +815,7 @@ public:
if (_ports[i])
p[pc++] = _ports[i];
}
_binder.refresh(_phy,p,pc,bindToWildcard,*this);
_binder.refresh(_phy,p,pc,explicitBind,*this);
{
Mutex::Lock _l(_nets_m);
for(std::map<uint64_t,NetworkState>::iterator n(_nets.begin());n!=_nets.end();++n) {