Skip to content

Commit

Permalink
Fix m_dnsbl not checking cgiirc users when the cgiirc address is elined
Browse files Browse the repository at this point in the history
  • Loading branch information
attilamolnar committed Mar 11, 2013
1 parent 2bdbb28 commit fe9e594
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 14 deletions.
2 changes: 1 addition & 1 deletion include/modules.h
Expand Up @@ -116,7 +116,7 @@ struct ModResult {
* and numerical comparisons in preprocessor macros if they wish to support * and numerical comparisons in preprocessor macros if they wish to support
* multiple versions of InspIRCd in one file. * multiple versions of InspIRCd in one file.
*/ */
#define INSPIRCD_VERSION_API 3 #define INSPIRCD_VERSION_API 4


/** /**
* This #define allows us to call a method in all * This #define allows us to call a method in all
Expand Down
8 changes: 4 additions & 4 deletions include/users.h
Expand Up @@ -393,9 +393,9 @@ class CoreExport User : public Extensible
/** Sets the client IP for this user /** Sets the client IP for this user
* @return true if the conversion was successful * @return true if the conversion was successful
*/ */
virtual bool SetClientIP(const char* sip); virtual bool SetClientIP(const char* sip, bool recheck_eline = true);


virtual void SetClientIP(const irc::sockets::sockaddrs& sa); virtual void SetClientIP(const irc::sockets::sockaddrs& sa, bool recheck_eline = true);


/** Constructor /** Constructor
* @throw CoreException if the UID allocated to the user already exists * @throw CoreException if the UID allocated to the user already exists
Expand Down Expand Up @@ -825,9 +825,9 @@ class CoreExport LocalUser : public User, public InviteBase
*/ */
void SetClass(const std::string &explicit_name = ""); void SetClass(const std::string &explicit_name = "");


bool SetClientIP(const char* sip); bool SetClientIP(const char* sip, bool recheck_eline = true);


void SetClientIP(const irc::sockets::sockaddrs& sa); void SetClientIP(const irc::sockets::sockaddrs& sa, bool recheck_eline = true);


void SendText(const std::string& line); void SendText(const std::string& line);
void Write(const std::string& text); void Write(const std::string& text);
Expand Down
8 changes: 4 additions & 4 deletions src/modules/m_cgiirc.cpp
Expand Up @@ -176,9 +176,9 @@ class ModuleCgiIRC : public Module
CommandWebirc cmd; CommandWebirc cmd;
LocalIntExt waiting; LocalIntExt waiting;


static void RecheckElineAndClass(LocalUser* user) static void RecheckClass(LocalUser* user)
{ {
user->exempt = (ServerInstance->XLines->MatchesLine("E", user) != NULL); user->MyClass = NULL;
user->SetClass(); user->SetClass();
user->CheckClass(); user->CheckClass();
} }
Expand All @@ -198,7 +198,7 @@ class ModuleCgiIRC : public Module
ChangeIP(user, newip); ChangeIP(user, newip);
user->host = user->dhost = user->GetIPString(); user->host = user->dhost = user->GetIPString();
user->InvalidateCache(); user->InvalidateCache();
RecheckElineAndClass(user); RecheckClass(user);
// Don't create the resolver if the core couldn't put the user in a connect class or when dns is disabled // Don't create the resolver if the core couldn't put the user in a connect class or when dns is disabled
if (user->quitting || ServerInstance->Config->NoUserDns) if (user->quitting || ServerInstance->Config->NoUserDns)
return; return;
Expand Down Expand Up @@ -295,7 +295,7 @@ class ModuleCgiIRC : public Module
std::string* webirc_hostname = cmd.webirc_hostname.get(user); std::string* webirc_hostname = cmd.webirc_hostname.get(user);
user->host = user->dhost = (webirc_hostname ? *webirc_hostname : user->GetIPString()); user->host = user->dhost = (webirc_hostname ? *webirc_hostname : user->GetIPString());


RecheckElineAndClass(user); RecheckClass(user);
if (user->quitting) if (user->quitting)
return MOD_RES_DENY; return MOD_RES_DENY;


Expand Down
13 changes: 8 additions & 5 deletions src/users.cpp
Expand Up @@ -987,36 +987,39 @@ irc::sockets::cidr_mask User::GetCIDRMask()
return irc::sockets::cidr_mask(client_sa, range); return irc::sockets::cidr_mask(client_sa, range);
} }


bool User::SetClientIP(const char* sip) bool User::SetClientIP(const char* sip, bool recheck_eline)
{ {
cachedip.clear(); cachedip.clear();
cached_hostip.clear(); cached_hostip.clear();
return irc::sockets::aptosa(sip, 0, client_sa); return irc::sockets::aptosa(sip, 0, client_sa);
} }


void User::SetClientIP(const irc::sockets::sockaddrs& sa) void User::SetClientIP(const irc::sockets::sockaddrs& sa, bool recheck_eline)
{ {
cachedip.clear(); cachedip.clear();
cached_hostip.clear(); cached_hostip.clear();
memcpy(&client_sa, &sa, sizeof(irc::sockets::sockaddrs)); memcpy(&client_sa, &sa, sizeof(irc::sockets::sockaddrs));
} }


bool LocalUser::SetClientIP(const char* sip) bool LocalUser::SetClientIP(const char* sip, bool recheck_eline)
{ {
irc::sockets::sockaddrs sa; irc::sockets::sockaddrs sa;
if (!irc::sockets::aptosa(sip, 0, sa)) if (!irc::sockets::aptosa(sip, 0, sa))
// Invalid // Invalid
return false; return false;


LocalUser::SetClientIP(sa); LocalUser::SetClientIP(sa, recheck_eline);
return true; return true;
} }


void LocalUser::SetClientIP(const irc::sockets::sockaddrs& sa) void LocalUser::SetClientIP(const irc::sockets::sockaddrs& sa, bool recheck_eline)
{ {
if (sa != client_sa) if (sa != client_sa)
{ {
User::SetClientIP(sa); User::SetClientIP(sa);
if (recheck_eline)
this->exempt = (ServerInstance->XLines->MatchesLine("E", this) != NULL);

FOREACH_MOD(I_OnSetUserIP,OnSetUserIP(this)); FOREACH_MOD(I_OnSetUserIP,OnSetUserIP(this));
} }
} }
Expand Down

0 comments on commit fe9e594

Please sign in to comment.