X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;f=src%2Fmodules%2Fm_spanningtree%2Futils.cpp;h=671fad7c3f9a57d293538ec62ac9ee7f1913be1c;hb=715074dd10079a3ed846e8815290ba0d13cd4bd8;hp=6b83a17a3e5d102308c62a028b09bff98e229a74;hpb=b5c983ca55f9a46863904db0afd8f6add63d1a45;p=user%2Fhenk%2Fcode%2Finspircd.git diff --git a/src/modules/m_spanningtree/utils.cpp b/src/modules/m_spanningtree/utils.cpp index 6b83a17a3..671fad7c3 100644 --- a/src/modules/m_spanningtree/utils.cpp +++ b/src/modules/m_spanningtree/utils.cpp @@ -1,3 +1,16 @@ +/* +------------------------------------+ + * | Inspire Internet Relay Chat Daemon | + * +------------------------------------+ + * + * InspIRCd: (C) 2002-2007 InspIRCd Development Team + * See: http://www.inspircd.org/wiki/index.php/Credits + * + * This program is free but copyrighted software; see + * the file COPYING for details. + * + * --------------------------------------------------- + */ + #include "configreader.h" #include "users.h" #include "channels.h" @@ -332,6 +345,56 @@ bool SpanningTreeUtilities::DoOneToOne(const std::string &prefix, const std::str } } +void SpanningTreeUtilities::RefreshIPCache() +{ + ValidIPs.clear(); + for (std::vector::iterator L = LinkBlocks.begin(); L != LinkBlocks.end(); L++) + { + if ((L->IPAddr != "") && (L->RecvPass != "") && (L->SendPass != "") && (L->Name != "") && (L->Port)) + { + ValidIPs.push_back(L->IPAddr); + + if (L->AllowMask.length()) + ValidIPs.push_back(L->AllowMask); + + /* Needs resolving */ + bool ipvalid = true; + QueryType start_type = DNS_QUERY_A; +#ifdef IPV6 + start_type = DNS_QUERY_AAAA; + if (strchr(L->IPAddr.c_str(),':')) + { + in6_addr n; + if (inet_pton(AF_INET6, L->IPAddr.c_str(), &n) < 1) + ipvalid = false; + } + else + { + in_addr n; + if (inet_aton(L->IPAddr.c_str(),&n) < 1) + ipvalid = false; + } +#else + in_addr n; + if (inet_aton(L->IPAddr.c_str(),&n) < 1) + ipvalid = false; +#endif + if (!ipvalid) + { + try + { + bool cached; + SecurityIPResolver* sr = new SecurityIPResolver((Module*)this->Creator, this, ServerInstance, L->IPAddr, *L, cached, start_type); + ServerInstance->AddResolver(sr, cached); + } + catch (ModuleException& e) + { + } + } + } + } +} + void SpanningTreeUtilities::ReadConfiguration(bool rebind) { ConfigReader* Conf = new ConfigReader(ServerInstance); @@ -366,7 +429,7 @@ void SpanningTreeUtilities::ReadConfiguration(bool rebind) } else { - ServerInstance->Log(DEFAULT,"m_spanningtree: Warning: Failed to bind server port %s:%d: %s",IP.c_str(), portno, strerror(errno)); + ServerInstance->Log(DEFAULT,"m_spanningtree: Warning: Failed to bind server port: %s:%d: %s",IP.c_str(), portno, strerror(errno)); listener->Close(); DELETE(listener); } @@ -377,23 +440,28 @@ void SpanningTreeUtilities::ReadConfiguration(bool rebind) FlatLinks = Conf->ReadFlag("options","flatlinks",0); HideULines = Conf->ReadFlag("options","hideulines",0); AnnounceTSChange = Conf->ReadFlag("options","announcets",0); - EnableTimeSync = !(Conf->ReadFlag("options","notimesync",0)); + EnableTimeSync = Conf->ReadFlag("timesync","enable",0); + MasterTime = Conf->ReadFlag("timesync", "master", 0); + ChallengeResponse = !Conf->ReadFlag("options", "disablehmac", 0); LinkBlocks.clear(); ValidIPs.clear(); for (int j =0; j < Conf->Enumerate("link"); j++) { Link L; - std::string Allow = Conf->ReadValue("link","allowmask",j); - L.Name = (Conf->ReadValue("link","name",j)).c_str(); - 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","hidden",j); - L.Timeout = Conf->ReadInteger("link","timeout",j,true); + 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", "hidden", 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())) { @@ -415,13 +483,34 @@ void SpanningTreeUtilities::ReadConfiguration(bool rebind) ValidIPs.push_back(Allow); /* Needs resolving */ - insp_inaddr binip; - if (insp_aton(L.IPAddr.c_str(), &binip) < 1) + bool ipvalid = true; + QueryType start_type = DNS_QUERY_A; +#ifdef IPV6 + start_type = DNS_QUERY_AAAA; + if (strchr(L.IPAddr.c_str(),':')) + { + in6_addr n; + if (inet_pton(AF_INET6, L.IPAddr.c_str(), &n) < 1) + ipvalid = false; + } + else + { + in_addr n; + if (inet_aton(L.IPAddr.c_str(),&n) < 1) + ipvalid = false; + } +#else + in_addr n; + if (inet_aton(L.IPAddr.c_str(),&n) < 1) + ipvalid = false; +#endif + + if (!ipvalid) { try { bool cached; - SecurityIPResolver* sr = new SecurityIPResolver((Module*)this->Creator, this, ServerInstance, L.IPAddr, L, cached); + SecurityIPResolver* sr = new SecurityIPResolver((Module*)this->Creator, this, ServerInstance, L.IPAddr, L, cached, start_type); ServerInstance->AddResolver(sr, cached); } catch (ModuleException& e)