/** Get client IP string from sockaddr, using static internal buffer
* @return The IP string
*/
- const char* GetIPString();
+ const std::string& GetIPString();
/** Get CIDR mask, using default range, for this user
*/
bool match_hosts = false;
snprintf(TheHost,MAXBUF,"%s@%s",user->ident.c_str(),user->host.c_str());
- snprintf(TheIP, MAXBUF,"%s@%s",user->ident.c_str(),user->GetIPString());
+ snprintf(TheIP, MAXBUF,"%s@%s",user->ident.c_str(),user->GetIPString().c_str());
OperIndex::iterator i = ServerInstance->Config->oper_blocks.find(parameters[0]);
if (i != ServerInstance->Config->oper_blocks.end())
std::string acceptedhosts = tag->getString("host");
std::string hostname = user->ident + "@" + user->host;
- if (!OneOfMatches(hostname.c_str(), user->GetIPString(), acceptedhosts))
+ if (!OneOfMatches(hostname.c_str(), user->GetIPString().c_str(), acceptedhosts))
return false;
if (!LookupOper(opername, inputpass))
char TheIP[MAXBUF];
snprintf(TheHost,MAXBUF,"%s@%s",user->ident.c_str(), user->host.c_str());
- snprintf(TheIP, MAXBUF,"%s@%s",user->ident.c_str(), user->GetIPString());
+ snprintf(TheIP, MAXBUF,"%s@%s",user->ident.c_str(), user->GetIPString().c_str());
ConfigTagList tags = ServerInstance->Config->ConfTags("title");
for (ConfigIter i = tags.first; i != tags.second; ++i)
{
std::string timestr = ServerInstance->TimeString(kl->expiry);
ServerInstance->SNO->WriteGlobalSno('x',"K:line added due to DNSBL match on *@%s to expire on %s: %s",
- them->GetIPString(), timestr.c_str(), reason.c_str());
+ them->GetIPString().c_str(), timestr.c_str(), reason.c_str());
ServerInstance->XLines->ApplyLines();
}
else
{
std::string timestr = ServerInstance->TimeString(gl->expiry);
ServerInstance->SNO->WriteGlobalSno('x',"G:line added due to DNSBL match on *@%s to expire on %s: %s",
- them->GetIPString(), timestr.c_str(), reason.c_str());
+ them->GetIPString().c_str(), timestr.c_str(), reason.c_str());
ServerInstance->XLines->ApplyLines();
}
else
{
std::string timestr = ServerInstance->TimeString(zl->expiry);
ServerInstance->SNO->WriteGlobalSno('x',"Z:line added due to DNSBL match on *@%s to expire on %s: %s",
- them->GetIPString(), timestr.c_str(), reason.c_str());
+ them->GetIPString().c_str(), timestr.c_str(), reason.c_str());
ServerInstance->XLines->ApplyLines();
}
else
return MOD_RES_PASSTHRU;
return MOD_RES_DENY;
}
-
+
ModResult OnCheckReady(LocalUser *user)
{
if (countExt.get(user))
u->second->host.c_str(), /* 3: Displayed Host */
u->second->dhost.c_str(), /* 4: Real host */
u->second->ident.c_str(), /* 5: Ident */
- u->second->GetIPString(), /* 6: IP string */
+ u->second->GetIPString().c_str(), /* 6: IP string */
(unsigned long)u->second->signon, /* 7: Signon time for WHOWAS */
u->second->FormatModes(true), /* 8...n: Modes and params */
u->second->fullname.c_str()); /* size-1: GECOS */
dosend = false;
if (dosend)
- ServerInstance->SNO->WriteToSnoMask('C',"Client connecting at %s: %s (%s) [%s]", _new->server.c_str(), _new->GetFullRealHost().c_str(), _new->GetIPString(), _new->fullname.c_str());
+ ServerInstance->SNO->WriteToSnoMask('C',"Client connecting at %s: %s (%s) [%s]", _new->server.c_str(), _new->GetFullRealHost().c_str(), _new->GetIPString().c_str(), _new->fullname.c_str());
FOREACH_MOD(I_OnPostConnect,OnPostConnect(_new));
hostname.append("@").append(user->host);
- if (OneOfMatches(hostname.c_str(), user->GetIPString(), pattern.c_str()))
+ if (OneOfMatches(hostname.c_str(), user->GetIPString().c_str(), pattern.c_str()))
{
/* Opertype and host match, looks like this is it. */
{
if (!bound_user->dns_done)
{
- bound_user->WriteServ("NOTICE Auth :*** Your hostname is longer than the maximum of 64 characters, using your IP address (%s) instead.", bound_user->GetIPString());
+ bound_user->WriteServ("NOTICE Auth :*** Your hostname is longer than the maximum of 64 characters, using your IP address (%s) instead.", bound_user->GetIPString().c_str());
bound_user->dns_done = true;
}
}
{
if (!bound_user->dns_done)
{
- bound_user->WriteServ("NOTICE Auth :*** Your hostname does not match up with your IP address. Sorry, using your IP address (%s) instead.", bound_user->GetIPString());
+ bound_user->WriteServ("NOTICE Auth :*** Your hostname does not match up with your IP address. Sorry, using your IP address (%s) instead.", bound_user->GetIPString().c_str());
bound_user->dns_done = true;
}
}
LocalUser* bound_user = (LocalUser*)ServerInstance->FindUUID(uuid);
if (bound_user)
{
- bound_user->WriteServ("NOTICE Auth :*** Could not resolve your hostname: %s; using your IP address (%s) instead.", errormessage.c_str(), bound_user->GetIPString());
+ bound_user->WriteServ("NOTICE Auth :*** Could not resolve your hostname: %s; using your IP address (%s) instead.", errormessage.c_str(), bound_user->GetIPString().c_str());
bound_user->dns_done = true;
bound_user->stored_host.resize(0);
ServerInstance->stats->statsDnsBad++;
if (!b->Type.empty() && !New->exempt)
{
/* user banned */
- ServerInstance->Logs->Log("BANCACHE", DEBUG, std::string("BanCache: Positive hit for ") + New->GetIPString());
+ ServerInstance->Logs->Log("BANCACHE", DEBUG, "BanCache: Positive hit for " + New->GetIPString());
if (!ServerInstance->Config->MoronBanner.empty())
New->WriteServ("NOTICE %s :*** %s", New->nick.c_str(), ServerInstance->Config->MoronBanner.c_str());
this->QuitUser(New, b->Reason);
}
else
{
- ServerInstance->Logs->Log("BANCACHE", DEBUG, std::string("BanCache: Negative hit for ") + New->GetIPString());
+ ServerInstance->Logs->Log("BANCACHE", DEBUG, "BanCache: Negative hit for " + New->GetIPString());
}
}
else
if (!user->quietquit)
{
ServerInstance->SNO->WriteToSnoMask('q',"Client exiting: %s (%s) [%s]",
- user->GetFullRealHost().c_str(), user->GetIPString(), oper_reason.c_str());
+ user->GetFullRealHost().c_str(), user->GetIPString().c_str(), oper_reason.c_str());
}
}
else
if ((!ServerInstance->SilentULine(user->server)) && (!user->quietquit))
{
ServerInstance->SNO->WriteToSnoMask('Q',"Client exiting on server %s: %s (%s) [%s]",
- user->server.c_str(), user->GetFullRealHost().c_str(), user->GetIPString(), oper_reason.c_str());
+ user->server.c_str(), user->GetFullRealHost().c_str(), user->GetIPString().c_str(), oper_reason.c_str());
}
}
user->AddToWhoWas();
try
{
bool cached = false;
- const char* sip = this->GetIPString();
UserResolver *res_reverse;
QueryType resolvtype = this->client_sa.sa.sa_family == AF_INET6 ? DNS_QUERY_PTR6 : DNS_QUERY_PTR4;
- res_reverse = new UserResolver(this, sip, resolvtype, cached);
+ res_reverse = new UserResolver(this, this->GetIPString(), resolvtype, cached);
ServerInstance->AddResolver(res_reverse, cached);
}
for(const char* n = ident.c_str(); *n; n++)
*t++ = *n;
*t++ = '@';
- for(const char* n = this->GetIPString(); *n; n++)
+ for(const char* n = this->GetIPString().c_str(); *n; n++)
*t++ = *n;
*t = 0;
{
ServerInstance->Users->QuitUser(this, "No more connections allowed from your host via this connect class (local)");
if (a->maxconnwarn)
- ServerInstance->SNO->WriteToSnoMask('a', "WARNING: maximum LOCAL connections (%ld) exceeded for IP %s", a->GetMaxLocal(), this->GetIPString());
+ ServerInstance->SNO->WriteToSnoMask('a', "WARNING: maximum LOCAL connections (%ld) exceeded for IP %s", a->GetMaxLocal(), this->GetIPString().c_str());
return;
}
else if ((a->GetMaxGlobal()) && (ServerInstance->Users->GlobalCloneCount(this) > a->GetMaxGlobal()))
{
ServerInstance->Users->QuitUser(this, "No more connections allowed from your host via this connect class (global)");
if (a->maxconnwarn)
- ServerInstance->SNO->WriteToSnoMask('a', "WARNING: maximum GLOBAL connections (%ld) exceeded for IP %s", a->GetMaxGlobal(), this->GetIPString());
+ ServerInstance->SNO->WriteToSnoMask('a', "WARNING: maximum GLOBAL connections (%ld) exceeded for IP %s", a->GetMaxGlobal(), this->GetIPString().c_str());
return;
}
FOREACH_MOD(I_OnPostConnect,OnPostConnect(this));
ServerInstance->SNO->WriteToSnoMask('c',"Client connecting on port %d (class %s): %s (%s) [%s]",
- this->GetServerPort(), this->MyClass->name.c_str(), GetFullRealHost().c_str(), this->GetIPString(), this->fullname.c_str());
- ServerInstance->Logs->Log("BANCACHE", DEBUG, "BanCache: Adding NEGATIVE hit for %s", this->GetIPString());
+ this->GetServerPort(), this->MyClass->name.c_str(), GetFullRealHost().c_str(), this->GetIPString().c_str(), this->fullname.c_str());
+ ServerInstance->Logs->Log("BANCACHE", DEBUG, "BanCache: Adding NEGATIVE hit for " + this->GetIPString());
ServerInstance->BanCache->AddHit(this->GetIPString(), "", "");
// reset the flood penalty (which could have been raised due to things like auto +x)
CommandFloodPenalty = 0;
return 0;
}
-const char* User::GetIPString()
+const std::string& User::GetIPString()
{
int port;
if (cachedip.empty())
{
irc::sockets::satoap(client_sa, cachedip, port);
/* IP addresses starting with a : on irc are a Bad Thing (tm) */
- if (cachedip.c_str()[0] == ':')
+ if (cachedip[0] == ':')
cachedip.insert(0,1,'0');
}
- return cachedip.c_str();
+ return cachedip;
}
irc::sockets::cidr_mask User::GetCIDRMask()
this->SendWhoisLine(user, dest, 311, "%s %s %s %s * :%s",user->nick.c_str(), dest->nick.c_str(), dest->ident.c_str(), dest->dhost.c_str(), dest->fullname.c_str());
if (user == dest || user->HasPrivPermission("users/auspex"))
{
- this->SendWhoisLine(user, dest, 378, "%s %s :is connecting from %s@%s %s", user->nick.c_str(), dest->nick.c_str(), dest->ident.c_str(), dest->host.c_str(), dest->GetIPString());
+ this->SendWhoisLine(user, dest, 378, "%s %s :is connecting from %s@%s %s", user->nick.c_str(), dest->nick.c_str(), dest->ident.c_str(), dest->host.c_str(), dest->GetIPString().c_str());
}
std::string cl = dest->ChannelList(user, false);