diff options
| author | 2007-04-06 14:03:06 +0000 | |
|---|---|---|
| committer | 2007-04-06 14:03:06 +0000 | |
| commit | 3d1ad0939fae743f9e10c07d1200665491c61012 (patch) | |
| tree | f77d18bf3299aa0bf7453850854bbce17734e649 /src/modules/m_spanningtree/utils.cpp | |
| parent | Fix the previous commit better - always copy the null terminator (oops) (diff) | |
Fix bug #224 by refreshing the security ip cache every hour. The easier solution of course is not use crappy dynamic ips :p
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@6745 e03df62e-2008-0410-955e-edbf42e46eb7
Diffstat (limited to 'src/modules/m_spanningtree/utils.cpp')
| -rw-r--r-- | src/modules/m_spanningtree/utils.cpp | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/src/modules/m_spanningtree/utils.cpp b/src/modules/m_spanningtree/utils.cpp index 03203a97d..7d02e5c90 100644 --- a/src/modules/m_spanningtree/utils.cpp +++ b/src/modules/m_spanningtree/utils.cpp @@ -332,6 +332,56 @@ bool SpanningTreeUtilities::DoOneToOne(const std::string &prefix, const std::str } } +void SpanningTreeUtilities::RefreshIPCache() +{ + ValidIPs.clear(); + for (std::vector<Link>::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); @@ -386,6 +436,7 @@ void SpanningTreeUtilities::ReadConfiguration(bool rebind) 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); |
