userrec* a = (userrec*)*n;
log(DEBUG,"Kill %s fd=%d",a->nick,a->fd);
if (!IS_LOCAL(a))
- kill_link(a,reason_s);
+ userrec::QuitUser(a,reason_s);
}
return time_to_die.size();
}
modelist[0] = params[0].c_str();
modelist[1] = to_keep.c_str();
- for (n = 2; (n < params.size()) && (n < 64); n++)
+ if (params_to_keep.size() > 2)
{
- log(DEBUG,"Item %d of %d: %s",n, params.size(), params_to_keep[n].c_str());
- modelist[q++] = params_to_keep[n].c_str();
+ for (q = 2; (q < params_to_keep.size()) && (q < 64); q++)
+ {
+ log(DEBUG,"Item %d of %d", q, params_to_keep.size());
+ modelist[n++] = params_to_keep[q].c_str();
+ }
}
if (smode)
userrec* user = Srv->FindNick(source);
if (!user)
{
- WriteChannelWithServ(source.c_str(), c, "TOPIC %s :%s", c->name, c->topic);
+ c->WriteChannelWithServ(source.c_str(), "TOPIC %s :%s", c->name, c->topic);
}
else
{
- WriteChannel(c, user, "TOPIC %s :%s", c->name, c->topic);
+ c->WriteChannel(user, "TOPIC %s :%s", c->name, c->topic);
nsource = user->server;
}
/* all done, send it on its way */
memset(&mode_users,0,sizeof(mode_users));
mode_users[0] = first;
mode_users[1] = modestring;
- strcpy(first,"+");
+ strcpy(modestring,"+");
unsigned int modectr = 2;
userrec* who = NULL;
who = Srv->FindNick(usr);
if (who)
{
- Srv->JoinUserToChannel(who,channel,key);
+ chanrec::JoinUser(who, channel.c_str(), true, key);
if (modectr >= (MAXMODES-1))
{
/* theres a mode for this user. push them onto the mode queue, and flush it
{
log(DEFAULT,"Channel TS for %s changed from %lu to %lu",us->name,ourTS,TS);
us->age = TS;
+ ourTS = TS;
}
}
else
params.push_back(ConvToStr(us->age));
}
params.push_back(mode_users[x]);
+
}
// tell everyone to bounce the modes. bad modes, bad!
DoOneToMany(Srv->GetServerName(),"FMODE",params);
/* there werent enough modes built up to flush it during FJOIN,
* or, there are a number left over. flush them out.
*/
- if ((modectr > 2) && (who))
+ if ((modectr > 2) && (who) && (us))
{
if (ourTS >= TS)
{
{
log(DEFAULT,"Channel TS for %s changed from %lu to %lu",us->name,ourTS,TS);
us->age = TS;
+ ourTS = TS;
}
}
else
/* This is not required as one is sent in OnUserPostNick below
*/
//DoOneToMany(u->nick,"NICK",par);
- Srv->ChangeUserNick(u,params[1]);
+ if (!u->ForceNickChange(params[1].c_str()))
+ {
+ userrec::QuitUser(u, "Nickname collision");
+ return true;
+ }
u->age = atoi(params[2].c_str());
}
}
if (u)
{
- Srv->JoinUserToChannel(u,params[1],"");
+ chanrec::JoinUser(u, params[1].c_str(), false);
DoOneToAllButSender(prefix,"SVSJOIN",params,prefix);
}
return true;
params[1] = ":" + params[1];
DoOneToAllButSender(prefix,"KILL",params,sourceserv);
::Write(who->fd, ":%s KILL %s :%s (%s)", sourceserv.c_str(), who->nick, sourceserv.c_str(), reason.c_str());
- Srv->QuitUser(who,reason);
+ userrec::QuitUser(who,reason);
}
return true;
}
chanrec* chan = Srv->FindChannel(params[0]);
if (user && chan)
{
- server_kick_channel(user,chan,(char*)params[2].c_str(),false);
+ if (!chan->ServerKickUser(user, params[2].c_str(), false))
+ /* Yikes, the channels gone! */
+ delete chan;
}
}
if (this->InboundServerName != "")
p.push_back(prefix);
p.push_back("Nickname collision");
DoOneToMany(Srv->GetServerName(),"KILL",p);
- Srv->QuitUser(x,"Nickname collision ("+prefix+" -> "+params[0]+")");
+ userrec::QuitUser(x,"Nickname collision ("+prefix+" -> "+params[0]+")");
userrec* y = Srv->FindNick(prefix);
if (y)
{
- Srv->QuitUser(y,"Nickname collision");
+ userrec::QuitUser(y,"Nickname collision");
}
return DoOneToAllButSenderRaw(line,sourceserv,prefix,command,params);
}
* IPs for which we don't have a link block.
*/
bool found = false;
- vector<Link>::iterator i;
+
found = (std::find(ValidIPs.begin(), ValidIPs.end(), ip) != ValidIPs.end());
if (!found)
{
- WriteOpers("Server connection from %s denied (no link blocks with that IP address)", ip);
- close(newsock);
- return false;
+ for (vector<std::string>::iterator i = ValidIPs.begin(); i != ValidIPs.end(); i++)
+ if (MatchCIDR(ip, (*i).c_str()))
+ found = true;
+
+ if (!found)
+ {
+ WriteOpers("Server connection from %s denied (no link blocks with that IP address)", ip);
+ close(newsock);
+ return false;
+ }
}
TreeSocket* s = new TreeSocket(newsock, ip);
Srv->AddSocket(s);
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.Port = Conf->ReadInteger("link","port",j,true);
{
ValidIPs.push_back(L.IPAddr);
+ if (Allow.length())
+ ValidIPs.push_back(Allow);
+
/* Needs resolving */
insp_inaddr binip;
if (insp_aton(L.IPAddr.c_str(), &binip) < 1)
params[1] = s->GetName();
DoOneToOne(user->nick, "STATS", params, s->GetName());
}
+ else
+ {
+ WriteServ(user->fd, "402 %s %s :No such server", user->nick, parameters[0]);
+ }
return 1;
}
return 0;