if (hostname.length() < 65)
{
/* Check we didnt time out */
- if (this->bound_user->registered != REG_ALL)
+ if ((this->bound_user->registered != REG_ALL) && (!this->bound_user->dns_done))
{
/* Hostnames starting with : are not a good thing (tm) */
if (*(hostname.c_str()) == ':')
}
else
{
- this->bound_user->WriteServ("NOTICE Auth :*** Your hostname is longer than the maximum of 64 characters, using your IP address (%s) instead.", this->bound_user->GetIPString());
+ if (!this->bound_user->dns_done)
+ {
+ this->bound_user->WriteServ("NOTICE Auth :*** Your hostname is longer than the maximum of 64 characters, using your IP address (%s) instead.", this->bound_user->GetIPString());
+ this->bound_user->dns_done = true;
+ }
}
}
else
{
- this->bound_user->WriteServ("NOTICE Auth :*** Your hostname does not match up with your IP address. Sorry, using your IP address (%s) instead.", this->bound_user->GetIPString());
+ if (!this->bound_user->dns_done)
+ {
+ this->bound_user->WriteServ("NOTICE Auth :*** Your hostname does not match up with your IP address. Sorry, using your IP address (%s) instead.", this->bound_user->GetIPString());
+ this->bound_user->dns_done = true;
+ }
}
}
}
sendq = "";
WriteError = "";
res_forward = res_reverse = NULL;
+ Visibility = NULL;
ip = NULL;
chans.clear();
invites.clear();
return true;
// are they even an oper at all?
- if (*this->oper)
+ if (IS_OPER(this))
{
opertype_t::iterator iter_opertype = ServerInstance->Config->opertypes.find(this->oper);
if (iter_opertype != ServerInstance->Config->opertypes.end())
try
{
- if (data.length() > 512)
- sendq.append(data.substr(0,510)).append("\r\n");
+ if (data.length() > MAXBUF - 2) /* MAXBUF has a value of 514, to account for line terminators */
+ sendq.append(data.substr(0,MAXBUF - 4)).append("\r\n"); /* MAXBUF-4 = 510 */
else
sendq.append(data);
}
{
try
{
- if (*this->oper)
+ if (IS_OPER(this))
{
+ // unset their oper type (what IS_OPER checks), and remove +o
*this->oper = 0;
this->modes[UM_OPERATOR] = 0;
+
+ // remove them from the opers list.
for (std::vector<userrec*>::iterator a = ServerInstance->all_opers.begin(); a < ServerInstance->all_opers.end(); a++)
{
if (*a == this)
Instance->AddLocalClone(New);
Instance->AddGlobalClone(New);
+ /*
+ * First class check. We do this again in FullConnect after DNS is done, and NICK/USER is recieved.
+ * See my note down there for why this is required. DO NOT REMOVE. :) -- w00t
+ */
ConnectClass* i = New->GetClass();
-
- if ((!i) || (i->GetType() == CC_DENY))
- {
- userrec::QuitUser(Instance, New,"Unauthorised connection");
- return;
- }
+ New->CheckClass();
New->pingmax = i->GetPingTime();
New->nping = Instance->Time() + i->GetPingTime() + Instance->Config->dns_timeout;
return 0;
}
-void userrec::FullConnect()
+/*
+ * Check class restrictions
+ */
+void userrec::CheckClass()
{
- ServerInstance->stats->statsConnects++;
- this->idle_lastmsg = ServerInstance->Time();
-
ConnectClass* a = this->GetClass();
if ((!a) || (a->GetType() == CC_DENY))
{
- this->muted = true;
- ServerInstance->GlobalCulls.AddItem(this,"Unauthorised connection");
+ userrec::QuitUser(ServerInstance, this, "Unauthorised connection");
return;
}
if ((!a->GetPass().empty()) && (!this->haspassed))
{
- this->muted = true;
- ServerInstance->GlobalCulls.AddItem(this,"Invalid password");
+ userrec::QuitUser(ServerInstance, this, "Invalid password");
+ return;
+ }
+
+ if ((!a) || (a->GetType() == CC_DENY))
+ {
+ userrec::QuitUser(ServerInstance, this,"Unauthorised connection");
return;
}
- if (this->LocalCloneCount() > a->GetMaxLocal())
+ if ((a->GetMaxLocal()) && (this->LocalCloneCount() > a->GetMaxLocal()))
{
- this->muted = true;
- ServerInstance->GlobalCulls.AddItem(this, "No more connections allowed from your host via this connect class (local)");
+ userrec::QuitUser(ServerInstance, this, "No more connections allowed from your host via this connect class (local)");
ServerInstance->WriteOpers("*** WARNING: maximum LOCAL connections (%ld) exceeded for IP %s", a->GetMaxLocal(), this->GetIPString());
return;
}
- else if (this->GlobalCloneCount() > a->GetMaxGlobal())
+ else if ((a->GetMaxGlobal()) && (this->GlobalCloneCount() > a->GetMaxGlobal()))
{
- this->muted = true;
- ServerInstance->GlobalCulls.AddItem(this, "No more connections allowed from your host via this connect class (global)");
- ServerInstance->WriteOpers("*** WARNING: maximum GLOBAL connections (%ld) exceeded for IP %s",a->GetMaxGlobal(), this->GetIPString());
+ userrec::QuitUser(ServerInstance, this, "No more connections allowed from your host via this connect class (global)");
+ ServerInstance->WriteOpers("*** WARNING: maximum GLOBAL connections (%ld) exceeded for IP %s", a->GetMaxGlobal(), this->GetIPString());
return;
}
+}
+
+void userrec::FullConnect()
+{
+ ServerInstance->stats->statsConnects++;
+ this->idle_lastmsg = ServerInstance->Time();
+
+ /*
+ * You may be thinking "wtf, we checked this in userrec::AddClient!" - and yes, we did, BUT.
+ * At the time AddClient is called, we don't have a resolved host, by here we probably do - which
+ * may put the user into a totally seperate class with different restrictions! so we *must* check again.
+ * Don't remove this! -- w00t
+ */
+ this->CheckClass();
if (!this->exempt)
{
if (ServerInstance->unregistered_count)
ServerInstance->unregistered_count--;
+ /* Trigger LUSERS output, give modules a chance too */
+ int MOD_RESULT = 0;
+ FOREACH_RESULT(I_OnPreCommand, OnPreCommand("LUSERS", NULL, 0, this, true, "LUSERS"));
+ if (!MOD_RESULT)
+ ServerInstance->CallCommandHandler("LUSERS", NULL, 0, this);
+
/*
* fix 3 by brain, move registered = 7 below these so that spurious modes and host
* changes dont go out onto the network and produce 'fake direction'.
FOREACH_MOD(I_OnPostConnect,OnPostConnect(this));
- ServerInstance->SNO->WriteToSnoMask('c',"Client connecting on port %d: %s!%s@%s [%s]", this->GetPort(), this->nick, this->ident, this->host, this->GetIPString());
+ ServerInstance->SNO->WriteToSnoMask('c',"Client connecting on port %d: %s!%s@%s [%s] [%s]", this->GetPort(), this->nick, this->ident, this->host, this->GetIPString(), this->fullname);
}
/** userrec::UpdateNick()
CUList* ulist = v->first->GetUsers();
for (CUList::iterator i = ulist->begin(); i != ulist->end(); i++)
{
- if ((IS_LOCAL(i->second)) && (already_sent[i->second->fd] != uniq_id))
+ if ((IS_LOCAL(i->first)) && (already_sent[i->first->fd] != uniq_id))
{
- already_sent[i->second->fd] = uniq_id;
- i->second->Write(out);
+ already_sent[i->first->fd] = uniq_id;
+ i->first->Write(out);
sent_to_at_least_one = true;
}
}
CUList *ulist = v->first->GetUsers();
for (CUList::iterator i = ulist->begin(); i != ulist->end(); i++)
{
- if (this != i->second)
+ if (this != i->first)
{
- if ((IS_LOCAL(i->second)) && (already_sent[i->second->fd] != uniq_id))
+ if ((IS_LOCAL(i->first)) && (already_sent[i->first->fd] != uniq_id))
{
- already_sent[i->second->fd] = uniq_id;
- i->second->Write(*i->second->oper ? out2 : out1);
+ already_sent[i->first->fd] = uniq_id;
+ i->first->Write(IS_OPER(i->first) ? out2 : out1);
}
}
}
CUList *ulist = v->first->GetUsers();
for (CUList::iterator i = ulist->begin(); i != ulist->end(); i++)
{
- if (this != i->second)
+ if (this != i->first)
{
- if ((IS_LOCAL(i->second)) && (already_sent[i->second->fd] != uniq_id))
+ if ((IS_LOCAL(i->first)) && (already_sent[i->first->fd] != uniq_id))
{
- already_sent[i->second->fd] = uniq_id;
- i->second->Write(out1);
+ already_sent[i->first->fd] = uniq_id;
+ i->first->Write(out1);
}
}
}
void userrec::WriteWallOps(const std::string &text)
{
- /* Does nothing if theyre not opered */
- if ((!*this->oper) && (IS_LOCAL(this)))
+ if (!IS_OPER(this) && IS_LOCAL(this))
return;
- std::string wallop = "WALLOPS :";
-
- try
- {
- wallop.append(text);
- }
- catch (...)
- {
- ServerInstance->Log(DEBUG,"Exception in userrec::Write() std::string::append");
- return;
- }
+ std::string wallop = "WALLOPS :" + text;
for (std::vector<userrec*>::const_iterator i = ServerInstance->local_users.begin(); i != ServerInstance->local_users.end(); i++)
{
* If the channel is NOT private/secret OR the user shares a common channel
* If the user is an oper, and the <options:operspywhois> option is set.
*/
- if ((source == this) || (*source->oper && ServerInstance->Config->OperSpyWhois) || (((!i->first->modes[CM_PRIVATE]) && (!i->first->modes[CM_SECRET])) || (i->first->HasUser(source))))
+ if ((source == this) || (IS_OPER(source) && ServerInstance->Config->OperSpyWhois) || (((!i->first->modes[CM_PRIVATE]) && (!i->first->modes[CM_SECRET])) || (i->first->HasUser(source))))
{
list.append(i->first->GetPrefixChar(this)).append(i->first->name).append(" ");
}
{
for (ClassVector::iterator i = ServerInstance->Config->Classes.begin(); i != ServerInstance->Config->Classes.end(); i++)
{
- if ((match(this->GetIPString(),i->GetHost().c_str(),true)) || (match(this->host,i->GetHost().c_str())))
- return &(*i);
+ if (((match(this->GetIPString(),i->GetHost().c_str(),true)) || (match(this->host,i->GetHost().c_str()))))
+ {
+ if (i->GetPort())
+ {
+ if (this->GetPort() == i->GetPort())
+ return &(*i);
+ else
+ continue;
+ }
+ else
+ return &(*i);
+ }
}
return NULL;
}
return operquit ? operquit : "";
}
+VisData::VisData()
+{
+}
+
+VisData::~VisData()
+{
+}
+
+bool VisData::VisibleTo(userrec* user)
+{
+ return true;
+}