/* Gave a hook, but it wasnt one we know */
if ((!x->Hook.empty()) && (Utils->hooks.find(x->Hook.c_str()) == Utils->hooks.end()))
return;
- TreeSocket* newsocket = new TreeSocket(Utils, ServerInstance, x->IPAddr,x->Port,false,x->Timeout ? x->Timeout : 10,x->Name.c_str(), x->Bind, x->Hook.empty() ? NULL : Utils->hooks[x->Hook.c_str()]);
+ TreeSocket* newsocket = new TreeSocket(Utils, ServerInstance, x->IPAddr,x->Port, x->Timeout ? x->Timeout : 10,x->Name.c_str(), x->Bind, x->Hook.empty() ? NULL : Utils->hooks[x->Hook.c_str()]);
if (newsocket->GetFd() > -1)
{
/* Handled automatically on success */
}
}
+void ModuleSpanningTree::DoConnectTimeout(time_t curtime)
+{
+ std::vector<Link*> failovers;
+ for (std::map<TreeSocket*, std::pair<std::string, int> >::iterator i = Utils->timeoutlist.begin(); i != Utils->timeoutlist.end(); i++)
+ {
+ TreeSocket* s = i->first;
+ std::pair<std::string, int> p = i->second;
+ if (curtime > s->age + p.second)
+ {
+ ServerInstance->SNO->WriteToSnoMask('l',"CONNECT: Error connecting \002%s\002 (timeout of %d seconds)",p.first.c_str(),p.second);
+ ServerInstance->SE->DelFd(s);
+ s->Close();
+ Link* MyLink = Utils->FindLink(p.first);
+ if (MyLink)
+ failovers.push_back(MyLink);
+ }
+ }
+ /* Trigger failover for each timed out socket */
+ for (std::vector<Link*>::const_iterator n = failovers.begin(); n != failovers.end(); ++n)
+ {
+ Utils->DoFailOver(*n);
+ }
+}
+
int ModuleSpanningTree::HandleVersion(const std::vector<std::string>& parameters, User* user)
{
// we've already checked if pcnt > 0, so this is safe
{
AutoConnectServers(curtime);
DoPingChecks(curtime);
+ DoConnectTimeout(curtime);
}
void ModuleSpanningTree::OnUserJoin(User* user, Channel* channel, bool sync, bool &silent)
void ModuleSpanningTree::OnRemoteKill(User* source, User* dest, const std::string &reason, const std::string &operreason)
{
+ if (!IS_LOCAL(source)) return; // Only start routing if we're origin.
std::deque<std::string> params;
params.push_back(":"+reason);
Utils->DoOneToMany(dest->uuid,"OPERQUIT",params);
ModuleSpanningTree::~ModuleSpanningTree()
{
- /* This will also free the listeners */
delete ServerInstance->PI;
ServerInstance->PI = new ProtocolInterface(ServerInstance);
+ /* This will also free the listeners */
delete Utils;
ServerInstance->Timers->DelTimer(RefreshTimer);