Skip to content
3 changes: 3 additions & 0 deletions docs/conf/inspircd.conf.example
Original file line number Diff line number Diff line change
Expand Up @@ -277,6 +277,9 @@
# useident: Defines if users in this class MUST respond to a ident query or not.
useident="no"

# forceident: Defines the ident which all users in this class will get
forceident=""

# limit: How many users are allowed in this class
limit="5000"

Expand Down
29 changes: 29 additions & 0 deletions src/modules/m_bridgechan.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#include "inspircd.h"

class BridgeChannel : public Module
{
public:

void init()
{
ServerInstance->Modules->Attach(I_OnUserPreJoin, this);
}

virtual ModResult OnUserPreJoin(User *user, Channel *chan, const char *cname, std::string &privs, const std::string &keygiven)
{
if ( cname[ 1 ] == '^' )
{
user->WriteNumeric( 384, "%s :Cannot join channel, reserved for bridges", cname );
ServerInstance->SNO->WriteGlobalSno( 'a', "%s tried to join bridge channel %s", user->nick.c_str(), cname );
return MOD_RES_DENY;
}
return MOD_RES_PASSTHRU;
}

Version GetVersion()
{
return Version( "Prevents clients from creating channels starting with ^" );
}
};

MODULE_INIT(BridgeChannel)
66 changes: 23 additions & 43 deletions src/modules/m_cgiirc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,14 @@

enum CGItype { PASS, IDENT, PASSFIRST, IDENTFIRST, WEBIRC };

// We need this method up here so that it can be acessed from anywhere
static void ChangeIP(User* user, const std::string& newip)
{
ServerInstance->Users->RemoveCloneCounts(user);
user->SetClientIP(newip.c_str());
ServerInstance->Users->AddLocalClone(user);
ServerInstance->Users->AddGlobalClone(user);
}

/** Holds a CGI site's details
*/
Expand Down Expand Up @@ -62,16 +70,10 @@ class CommandWebirc : public Command
{
public:
bool notify;
StringExtItem realhost;
StringExtItem realip;
LocalStringExt webirc_hostname;
LocalStringExt webirc_ip;

CGIHostlist Hosts;
CommandWebirc(Module* Creator)
: Command(Creator, "WEBIRC", 4),
realhost("cgiirc_realhost", Creator), realip("cgiirc_realip", Creator),
webirc_hostname("cgiirc_webirc_hostname", Creator), webirc_ip("cgiirc_webirc_ip", Creator)
: Command(Creator, "WEBIRC", 4)
{
works_before_reg = true;
this->syntax = "password client hostname ip";
Expand All @@ -87,28 +89,25 @@ class CommandWebirc : public Command
{
if(iter->type == WEBIRC && parameters[0] == iter->password)
{
realhost.set(user, user->host);
realip.set(user, user->GetIPString());

// TODO: Why do we have a 64 char check here, maybe we should handle this globally
bool host_ok = (parameters[2].length() < 64);
const std::string& newhost = (host_ok ? parameters[2] : parameters[3]);

if (notify)
ServerInstance->SNO->WriteGlobalSno('a', "Connecting user %s detected as using CGI:IRC (%s), changing real host to %s from %s", user->nick.c_str(), user->host.c_str(), newhost.c_str(), user->host.c_str());
ServerInstance->SNO->WriteGlobalSno('w', "Connecting user %s detected as using CGI:IRC (%s), changing real host to %s from %s", user->nick.c_str(), user->host.c_str(), newhost.c_str(), user->host.c_str());

// Check if we're happy with the provided hostname. If it's problematic then make sure we won't set a host later, just the IP
if (host_ok)
webirc_hostname.set(user, parameters[2]);
else
webirc_hostname.unset(user);
// Where the magic happens - change their IP
ChangeIP(user, parameters[3]);
// And follow this up by changing their host
user->host = user->dhost = newhost;

webirc_ip.set(user, parameters[3]);
return CMD_SUCCESS;
}
}
}

ServerInstance->SNO->WriteGlobalSno('a', "Connecting user %s tried to use WEBIRC, but didn't match any configured webirc blocks.", user->GetFullRealHost().c_str());
ServerInstance->SNO->WriteGlobalSno('w', "Warning: Connecting user %s tried to use WEBIRC, but didn't match any configured webirc blocks.", user->GetFullRealHost().c_str());
return CMD_FAILURE;
}
};
Expand Down Expand Up @@ -137,7 +136,7 @@ class CGIResolver : public Resolver
if ((them) && (!them->quitting))
{
if (notify)
ServerInstance->SNO->WriteGlobalSno('a', "Connecting user %s detected as using CGI:IRC (%s), changing real host to %s from %s", them->nick.c_str(), them->host.c_str(), result.c_str(), typ.c_str());
ServerInstance->SNO->WriteGlobalSno('w', "Connecting user %s detected as using CGI:IRC (%s), changing real host to %s from %s", them->nick.c_str(), them->host.c_str(), result.c_str(), typ.c_str());

if (result.length() > 64)
return;
Expand All @@ -156,7 +155,7 @@ class CGIResolver : public Resolver
User* them = ServerInstance->FindUUID(theiruid);
if ((them) && (!them->quitting))
{
ServerInstance->SNO->WriteToSnoMask('a', "Connecting user %s detected as using CGI:IRC (%s), but their host can't be resolved from their %s!", them->nick.c_str(), them->host.c_str(), typ.c_str());
ServerInstance->SNO->WriteToSnoMask('w', "Connecting user %s detected as using CGI:IRC (%s), but their host can't be resolved from their %s!", them->nick.c_str(), them->host.c_str(), typ.c_str());
}
}

Expand All @@ -183,18 +182,8 @@ class ModuleCgiIRC : public Module
user->CheckClass();
}

static void ChangeIP(LocalUser* user, const std::string& newip)
{
ServerInstance->Users->RemoveCloneCounts(user);
user->SetClientIP(newip.c_str());
ServerInstance->Users->AddLocalClone(user);
ServerInstance->Users->AddGlobalClone(user);
}

void HandleIdentOrPass(LocalUser* user, const std::string& newip, bool was_pass)
{
cmd.realhost.set(user, user->host);
cmd.realip.set(user, user->GetIPString());
ChangeIP(user, newip);
user->host = user->dhost = user->GetIPString();
user->InvalidateCache();
Expand All @@ -213,7 +202,7 @@ class ModuleCgiIRC : public Module
catch (...)
{
if (cmd.notify)
ServerInstance->SNO->WriteToSnoMask('a', "Connecting user %s detected as using CGI:IRC (%s), but I could not resolve their hostname!", user->nick.c_str(), user->host.c_str());
ServerInstance->SNO->WriteToSnoMask('w', "Connecting user %s detected as using CGI:IRC (%s), but I could not resolve their hostname!", user->nick.c_str(), user->host.c_str());
}
}

Expand All @@ -225,7 +214,10 @@ class ModuleCgiIRC : public Module
void init()
{
OnRehash(NULL);
ServiceProvider* providerlist[] = { &cmd, &cmd.realhost, &cmd.realip, &cmd.webirc_hostname, &cmd.webirc_ip, &waiting };

ServerInstance->SNO->EnableSnomask('w', "CGIIRC");

ServiceProvider* providerlist[] = { &cmd, &waiting };
ServerInstance->Modules->AddServices(providerlist, sizeof(providerlist)/sizeof(ServiceProvider*));

Implementation eventlist[] = { I_OnRehash, I_OnUserRegister, I_OnCheckReady };
Expand Down Expand Up @@ -286,15 +278,6 @@ class ModuleCgiIRC : public Module
if (waiting.get(user))
return MOD_RES_DENY;

std::string *webirc_ip = cmd.webirc_ip.get(user);
if (!webirc_ip)
return MOD_RES_PASSTHRU;

ChangeIP(user, *webirc_ip);

std::string* webirc_hostname = cmd.webirc_hostname.get(user);
user->host = user->dhost = (webirc_hostname ? *webirc_hostname : user->GetIPString());

RecheckClass(user);
if (user->quitting)
return MOD_RES_DENY;
Expand All @@ -303,9 +286,6 @@ class ModuleCgiIRC : public Module
if (user->quitting)
return MOD_RES_DENY;

cmd.webirc_hostname.unset(user);
cmd.webirc_ip.unset(user);

return MOD_RES_PASSTHRU;
}

Expand Down
54 changes: 54 additions & 0 deletions src/modules/m_conn_banner.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
/*
* InspIRCd -- Internet Relay Chat Daemon
*
* Copyright (C) 2012 Attila Molnar <attilamolnar@hush.com>
*
* This file is part of InspIRCd. InspIRCd is free software: you can
* redistribute it and/or modify it under the terms of the GNU General Public
* License as published by the Free Software Foundation, version 2.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
* details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

/* $ModAuthor: Attila Molnar */
/* $ModAuthorMail: attilamolnar@hush.com */
/* $ModDesc: Displays a static text to every connecting user before registration */
/* $ModDepends: core 2.0 */

#include "inspircd.h"

class ModuleConnBanner : public Module
{
std::string text;
public:
void init()
{
OnRehash(NULL);
Implementation eventlist[] = { I_OnRehash, I_OnUserInit };
ServerInstance->Modules->Attach(eventlist, this, sizeof(eventlist)/sizeof(Implementation));
}

void OnRehash(User* user)
{
text = ServerInstance->Config->ConfValue("connbanner")->getString("text");
}

void OnUserInit(LocalUser* user)
{
if (!text.empty())
user->WriteServ("NOTICE Auth :*** " + text);
}

Version GetVersion()
{
return Version("Displays a static text to every connecting user before registration", VF_VENDOR);
}
};

MODULE_INIT(ModuleConnBanner)
3 changes: 2 additions & 1 deletion src/modules/m_delayjoin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ class DelayJoinMode : public ModeHandler
public:
DelayJoinMode(Module* Parent) : ModeHandler(Parent, "delayjoin", 'D', PARAM_NONE, MODETYPE_CHANNEL)
{
levelrequired = OP_VALUE;
ConfigTag* conf = ServerInstance->Config->ConfValue("delayjoin");
levelrequired = (conf && conf->getBool("allowhalfop", false)) ? HALFOP_VALUE : OP_VALUE;
}

ModeAction OnModeChange(User* source, User* dest, Channel* channel, std::string &parameter, bool adding);
Expand Down
7 changes: 7 additions & 0 deletions src/modules/m_ident.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -311,6 +311,13 @@ class ModuleIdent : public Module
if (!tag->getBool("useident", true))
return;

std::string ForcedIdent = tag->getString("forceident");
if (!ForcedIdent.empty())
{
user->ident = ForcedIdent;
return;
}

user->WriteServ("NOTICE Auth :*** Looking up your ident...");

try
Expand Down
Loading