mirror of
https://github.com/anope/anope.git
synced 2026-07-07 02:23:12 +02:00
Fixed bug #1187 - Fixed releasing enforcer clients on TS6 IRCds
This commit is contained in:
+2
-2
@@ -51,9 +51,9 @@ BotInfo::BotInfo(const Anope::string &nnick, const Anope::string &nuser, const A
|
||||
BotListByUID[this->uid] = this;
|
||||
|
||||
// If we're synchronised with the uplink already, send the bot.
|
||||
if (Me && !Me->GetLinks().empty() && Me->GetLinks().front()->IsSynced())
|
||||
if (Me && Me->IsSynced())
|
||||
{
|
||||
ircdproto->SendClientIntroduction(this->nick, this->GetIdent(), this->host, this->realname, ircd->pseudoclient_mode, this->uid);
|
||||
ircdproto->SendClientIntroduction(this, ircd->pseudoclient_mode);
|
||||
XLine x(this->nick, "Reserved for services");
|
||||
ircdproto->SendSQLine(&x);
|
||||
}
|
||||
|
||||
+13
-8
@@ -42,19 +42,24 @@ void introduce_user(const Anope::string &user)
|
||||
}
|
||||
|
||||
/* We make the bots go online */
|
||||
for (botinfo_map::const_iterator it = BotListByNick.begin(), it_end = BotListByNick.end(); it != it_end; ++it)
|
||||
for (user_map::const_iterator it = UserListByNick.begin(), it_end = UserListByNick.end(); it != it_end; ++it)
|
||||
{
|
||||
BotInfo *bi = it->second;
|
||||
User *u = it->second;
|
||||
|
||||
if (user.empty() || bi->nick.equals_ci(user))
|
||||
if (user.empty() || u->nick.equals_ci(user))
|
||||
{
|
||||
ircdproto->SendClientIntroduction(bi->nick, bi->GetIdent(), bi->host, bi->realname, ircd->pseudoclient_mode, bi->GetUID());
|
||||
XLine x(bi->nick, "Reserved for services");
|
||||
ircdproto->SendSQLine(&x);
|
||||
ircdproto->SendClientIntroduction(u, ircd->pseudoclient_mode);
|
||||
|
||||
for (UChannelList::const_iterator cit = bi->chans.begin(), cit_end = bi->chans.end(); cit != cit_end; ++cit)
|
||||
BotInfo *bi = findbot(u->nick);
|
||||
if (bi)
|
||||
{
|
||||
ircdproto->SendJoin(bi, *cit);
|
||||
XLine x(bi->nick, "Reserved for services");
|
||||
ircdproto->SendSQLine(&x);
|
||||
|
||||
for (UChannelList::const_iterator cit = bi->chans.begin(), cit_end = bi->chans.end(); cit != cit_end; ++cit)
|
||||
{
|
||||
ircdproto->SendJoin(bi, *cit);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+5
-9
@@ -281,7 +281,7 @@ int m_whois(const Anope::string &source, const Anope::string &who)
|
||||
{
|
||||
if (!source.empty() && !who.empty())
|
||||
{
|
||||
NickAlias *na;
|
||||
User *u;
|
||||
BotInfo *bi = findbot(who);
|
||||
if (bi)
|
||||
{
|
||||
@@ -291,15 +291,11 @@ int m_whois(const Anope::string &source, const Anope::string &who)
|
||||
ircdproto->SendNumeric(Config->ServerName, 317, source, "%s %ld %ld :seconds idle, signon time", bi->nick.c_str(), time(NULL) - bi->lastmsg, start_time);
|
||||
ircdproto->SendNumeric(Config->ServerName, 318, source, "%s :End of /WHOIS list.", who.c_str());
|
||||
}
|
||||
else if (!ircd->svshold && (na = findnick(who)) && na->HasFlag(NS_HELD))
|
||||
else if (!ircd->svshold && (u = finduser(who)) && u->server == Me)
|
||||
{
|
||||
/* We have a nick enforcer client here that we need to respond to.
|
||||
* We can't just say it doesn't exist here, even tho it does for
|
||||
* other servers :) -GD
|
||||
*/
|
||||
ircdproto->SendNumeric(Config->ServerName, 311, source, "%s %s %s * :Services Enforcer", na->nick.c_str(), Config->NSEnforcerUser.c_str(), Config->NSEnforcerHost.c_str());
|
||||
ircdproto->SendNumeric(Config->ServerName, 312, source, "%s %s :%s", na->nick.c_str(), Config->ServerName.c_str(), Config->ServerDesc.c_str());
|
||||
ircdproto->SendNumeric(Config->ServerName, 318, source, "%s :End of /WHOIS list.", who.c_str());
|
||||
ircdproto->SendNumeric(Config->ServerName, 311, source, "%s %s %s * :%s", u->nick.c_str(), u->GetIdent().c_str(), u->host.c_str(), u->realname.c_str());
|
||||
ircdproto->SendNumeric(Config->ServerName, 312, source, "%s %s :%s", u->nick.c_str(), Config->ServerName.c_str(), Config->ServerDesc.c_str());
|
||||
ircdproto->SendNumeric(Config->ServerName, 318, source, "%s :End of /WHOIS list.", u->nick.c_str());
|
||||
}
|
||||
else
|
||||
ircdproto->SendNumeric(Config->ServerName, 401, source, "%s :No such service.", who.c_str());
|
||||
|
||||
@@ -865,14 +865,6 @@ char *str_signed(unsigned char *str)
|
||||
return nstr;
|
||||
}
|
||||
|
||||
/* Equivalent to inet_ntoa */
|
||||
|
||||
void ntoa(struct in_addr addr, char *ipaddr, int len)
|
||||
{
|
||||
unsigned char *bytes = reinterpret_cast<unsigned char *>(&addr.s_addr);
|
||||
snprintf(ipaddr, len, "%u.%u.%u.%u", bytes[0], bytes[1], bytes[2], bytes[3]);
|
||||
}
|
||||
|
||||
/*
|
||||
* strlcat and strlcpy were ripped from openssh 2.5.1p2
|
||||
* They had the following Copyright info:
|
||||
|
||||
+8
-5
@@ -112,7 +112,13 @@ void NickAlias::Release()
|
||||
if (ircd->svshold)
|
||||
ircdproto->SendSVSHoldDel(this->nick);
|
||||
else
|
||||
ircdproto->SendQuit(this->nick, "");
|
||||
{
|
||||
User *u = finduser(this->nick);
|
||||
if (u && u->server == Me)
|
||||
{
|
||||
delete u;
|
||||
}
|
||||
}
|
||||
|
||||
this->UnsetFlag(NS_HELD);
|
||||
}
|
||||
@@ -133,10 +139,7 @@ void NickAlias::OnCancel(User *)
|
||||
ircdproto->SendSVSHold(this->nick);
|
||||
else
|
||||
{
|
||||
Anope::string uid = ircd->ts6 ? ts6_uid_retrieve() : "";
|
||||
|
||||
ircdproto->SendClientIntroduction(this->nick, Config->NSEnforcerUser, Config->NSEnforcerHost, "Services Enforcer", "+", uid);
|
||||
new NickServRelease(this->nick, uid, Config->NSReleaseTimeout);
|
||||
new NickServRelease(this, Config->NSReleaseTimeout);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+21
-14
@@ -23,10 +23,10 @@ typedef std::map<Anope::string, NickServRelease *> nickservreleases_map;
|
||||
static nickservcollides_map NickServCollides;
|
||||
static nickservreleases_map NickServReleases;
|
||||
|
||||
NickServCollide::NickServCollide(const Anope::string &_nick, time_t delay) : Timer(delay), nick(_nick)
|
||||
NickServCollide::NickServCollide(User *user, time_t delay) : Timer(delay), u(user), nick(u->nick)
|
||||
{
|
||||
/* Erase the current collide and use the new one */
|
||||
nickservcollides_map::iterator nit = NickServCollides.find(this->nick);
|
||||
nickservcollides_map::iterator nit = NickServCollides.find(user->nick);
|
||||
if (nit != NickServCollides.end())
|
||||
delete nit->second;
|
||||
|
||||
@@ -40,36 +40,43 @@ NickServCollide::~NickServCollide()
|
||||
|
||||
void NickServCollide::Tick(time_t ctime)
|
||||
{
|
||||
if (!u)
|
||||
return;
|
||||
/* If they identified or don't exist anymore, don't kill them. */
|
||||
User *u = finduser(this->nick);
|
||||
NickAlias *na = findnick(this->nick);
|
||||
if (!u || !na || u->Account() == na->nc || u->my_signon > this->GetSetTime())
|
||||
NickAlias *na = findnick(u->nick);
|
||||
if (!na || u->Account() == na->nc || u->my_signon > this->GetSetTime())
|
||||
return;
|
||||
|
||||
u->Collide(na);
|
||||
}
|
||||
|
||||
NickServRelease::NickServRelease(const Anope::string &_nick, const Anope::string &_uid, time_t delay) : Timer(delay), nick(_nick), uid(_uid)
|
||||
NickServRelease::NickServRelease(NickAlias *na, time_t delay) : User(na->nick, Config->NSEnforcerUser, Config->NSEnforcerHost, ts6_uid_retrieve()), Timer(delay), nick(na->nick)
|
||||
{
|
||||
this->realname = "Services Enforcer";
|
||||
this->server = Me;
|
||||
|
||||
/* Erase the current release timer and use the new one */
|
||||
nickservreleases_map::iterator nit = NickServReleases.find(this->nick);
|
||||
if (nit != NickServReleases.end())
|
||||
delete nit->second;
|
||||
|
||||
NickServReleases.insert(std::make_pair(nick, this));
|
||||
NickServReleases.insert(std::make_pair(this->nick, this));
|
||||
|
||||
ircdproto->SendClientIntroduction(this, "+");
|
||||
}
|
||||
|
||||
NickServRelease::~NickServRelease()
|
||||
{
|
||||
NickServReleases.erase(this->nick);
|
||||
|
||||
ircdproto->SendQuit(debug_cast<User *>(this), NULL);
|
||||
}
|
||||
|
||||
void NickServRelease::Tick(time_t ctime)
|
||||
void NickServRelease::Tick(time_t)
|
||||
{
|
||||
NickAlias *na = findnick(this->nick);
|
||||
|
||||
if (na)
|
||||
na->Release();
|
||||
/* Do not do anything here,
|
||||
* The timer manager will delete this timer which will do the necessary cleanup
|
||||
*/
|
||||
}
|
||||
|
||||
/*************************************************************************/
|
||||
@@ -218,12 +225,12 @@ int validate_user(User *u)
|
||||
else if (na->nc->HasFlag(NI_KILL_QUICK))
|
||||
{
|
||||
notice_lang(Config->s_NickServ, u, FORCENICKCHANGE_IN_20_SECONDS);
|
||||
new NickServCollide(na->nick, 20);
|
||||
new NickServCollide(u, 20);
|
||||
}
|
||||
else
|
||||
{
|
||||
notice_lang(Config->s_NickServ, u, FORCENICKCHANGE_IN_1_MINUTE);
|
||||
new NickServCollide(na->nick, 60);
|
||||
new NickServCollide(u, 60);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+5
-10
@@ -18,12 +18,12 @@ void IRCDProto::SendPrivmsgInternal(const BotInfo *bi, const Anope::string &dest
|
||||
send_cmd(ircd->ts6 ? bi->GetUID() : bi->nick, "PRIVMSG %s :%s", dest.c_str(), buf.c_str());
|
||||
}
|
||||
|
||||
void IRCDProto::SendQuitInternal(const BotInfo *bi, const Anope::string &buf)
|
||||
void IRCDProto::SendQuitInternal(const User *u, const Anope::string &buf)
|
||||
{
|
||||
if (!buf.empty())
|
||||
send_cmd(ircd->ts6 ? bi->GetUID() : bi->nick, "QUIT :%s", buf.c_str());
|
||||
send_cmd(ircd->ts6 ? u->GetUID() : u->nick, "QUIT :%s", buf.c_str());
|
||||
else
|
||||
send_cmd(ircd->ts6 ? bi->GetUID() : bi->nick, "QUIT");
|
||||
send_cmd(ircd->ts6 ? u->GetUID() : u->nick, "QUIT");
|
||||
}
|
||||
|
||||
void IRCDProto::SendPartInternal(const BotInfo *bi, const Channel *chan, const Anope::string &buf)
|
||||
@@ -160,19 +160,14 @@ void IRCDProto::SendGlobalPrivmsg(const BotInfo *bi, const Server *dest, const A
|
||||
send_cmd(ircd->ts6 ? bi->GetUID() : bi->nick, "PRIVMSG %s%s :%s", ircd->globaltldprefix, dest->GetName().c_str(), msg.c_str());
|
||||
}
|
||||
|
||||
void IRCDProto::SendQuit(const Anope::string &nick, const Anope::string &)
|
||||
{
|
||||
send_cmd(nick, "QUIT");
|
||||
}
|
||||
|
||||
void IRCDProto::SendQuit(const BotInfo *bi, const char *fmt, ...)
|
||||
void IRCDProto::SendQuit(const User *u, const char *fmt, ...)
|
||||
{
|
||||
va_list args;
|
||||
char buf[BUFSIZE] = "";
|
||||
va_start(args, fmt);
|
||||
vsnprintf(buf, BUFSIZE - 1, fmt, args);
|
||||
va_end(args);
|
||||
SendQuitInternal(bi, buf);
|
||||
SendQuitInternal(u, buf);
|
||||
}
|
||||
|
||||
void IRCDProto::SendPing(const Anope::string &servname, const Anope::string &who)
|
||||
|
||||
+2
-1
@@ -36,8 +36,9 @@ User::User(const Anope::string &snick, const Anope::string &sident, const Anope:
|
||||
/* we used to do this by calloc, no more. */
|
||||
server = NULL;
|
||||
nc = NULL;
|
||||
invalid_pw_count = timestamp = my_signon = invalid_pw_time = lastmemosend = lastnickreg = lastmail = 0;
|
||||
invalid_pw_count = invalid_pw_time = lastmemosend = lastnickreg = lastmail = 0;
|
||||
OnAccess = false;
|
||||
timestamp = my_signon = time(NULL);
|
||||
|
||||
this->nick = snick;
|
||||
this->ident = sident;
|
||||
|
||||
Reference in New Issue
Block a user