- Link L;
- std::string Allow = Conf->ReadValue("link", "allowmask", j);
- L.Name = (Conf->ReadValue("link", "name", j)).c_str();
- L.AllowMask = Allow;
- L.IPAddr = Conf->ReadValue("link", "ipaddr", j);
- L.FailOver = Conf->ReadValue("link", "failover", j).c_str();
- L.Port = Conf->ReadInteger("link", "port", j, true);
- L.SendPass = Conf->ReadValue("link", "sendpass", j);
- L.RecvPass = Conf->ReadValue("link", "recvpass", j);
- L.AutoConnect = Conf->ReadInteger("link", "autoconnect", j, true);
- L.HiddenFromStats = Conf->ReadFlag("link", "statshidden", j);
- L.Timeout = Conf->ReadInteger("link", "timeout", j, true);
- L.Hook = Conf->ReadValue("link", "transport", j);
- L.Bind = Conf->ReadValue("link", "bind", j);
- L.Hidden = Conf->ReadFlag("link", "hidden", j);
-
- if ((!L.Hook.empty()) && (hooks.find(L.Hook.c_str()) == hooks.end()))
- {
- throw CoreException("Can't find transport type '"+L.Hook+"' for link '"+assign(L.Name)+"' - maybe you forgot to load it BEFORE m_spanningtree in your config file? Skipping <link> tag completely.");
- continue;
-
- }
-
- L.NextConnectTime = time(NULL) + L.AutoConnect;
-
- if (L.Name.find('.') == std::string::npos)
- throw CoreException("The link name '"+assign(L.Name)+"' is invalid and must contain at least one '.' character");
-
- if (L.Name.length() > 64)
- throw CoreException("The link name '"+assign(L.Name)+"' is longer than 64 characters!");
-
- if ((!L.IPAddr.empty()) && (!L.RecvPass.empty()) && (!L.SendPass.empty()) && (!L.Name.empty()) && (L.Port))
+ ConfigTag* tag = i->second;
+ reference<Link> L = new Link(tag);
+ L->Name = tag->getString("name").c_str();
+ L->AllowMask = tag->getString("allowmask");
+ L->IPAddr = tag->getString("ipaddr");
+ L->Port = tag->getInt("port");
+ L->SendPass = tag->getString("sendpass", tag->getString("password"));
+ L->RecvPass = tag->getString("recvpass", tag->getString("password"));
+ L->Fingerprint = tag->getString("fingerprint");
+ L->HiddenFromStats = tag->getBool("statshidden");
+ L->Timeout = tag->getInt("timeout", 30);
+ L->Hook = tag->getString("ssl");
+ L->Bind = tag->getString("bind");
+ L->Hidden = tag->getBool("hidden");
+
+ if (L->Name.empty())
+ throw ModuleException("Invalid configuration, found a link tag without a name!" + (!L->IPAddr.empty() ? " IP address: "+L->IPAddr : ""));
+
+ if (L->Name.find('.') == std::string::npos)
+ throw ModuleException("The link name '"+assign(L->Name)+"' is invalid as it must contain at least one '.' character");
+
+ if (L->Name.length() > 64)
+ throw ModuleException("The link name '"+assign(L->Name)+"' is invalid as it is longer than 64 characters");
+
+ if (L->RecvPass.empty())
+ throw ModuleException("Invalid configuration for server '"+assign(L->Name)+"', recvpass not defined");
+
+ if (L->SendPass.empty())
+ throw ModuleException("Invalid configuration for server '"+assign(L->Name)+"', sendpass not defined");
+
+ if ((L->SendPass.find(' ') != std::string::npos) || (L->RecvPass.find(' ') != std::string::npos))
+ throw ModuleException("Link block '" + assign(L->Name) + "' has a password set that contains a space character which is invalid");
+
+ if ((L->SendPass[0] == ':') || (L->RecvPass[0] == ':'))
+ throw ModuleException("Link block '" + assign(L->Name) + "' has a password set that begins with a colon (:) which is invalid");
+
+ if (L->IPAddr.empty())