}
virtual void OnRehash(User* user, const std::string ¶meter)
- {
+ {
ConfigReader MyConf(ServerInstance);
for (int index = 0; index < MyConf.Enumerate("keyword"); index++)
* Taken from the UnrealIRCd 4.0 SVN version, based on
* InspIRCd 1.1.x.
*
- * UnrealIRCd 4.0 (C) 2007 Carsten Valdemar Munk
+ * UnrealIRCd 4.0 (C) 2007 Carsten Valdemar Munk
* This program is free but copyrighted software; see
* the file COPYING for details.
*
bool verbose;
bool useusername;
LDAP *conn;
-
+
public:
ModuleLDAPAuth(InspIRCd* Me)
: Module::Module(Me)
virtual void OnRehash(User* user, const std::string ¶meter)
{
ConfigReader Conf(ServerInstance);
-
+
base = Conf.ReadValue("ldapauth", "baserdn", 0);
- attribute = Conf.ReadValue("ldapauth", "attribute", 0);
+ attribute = Conf.ReadValue("ldapauth", "attribute", 0);
ldapserver = Conf.ReadValue("ldapauth", "server", 0);
allowpattern = Conf.ReadValue("ldapauth", "allowpattern", 0);
killreason = Conf.ReadValue("ldapauth", "killreason", 0);
password = Conf.ReadValue("ldapauth", "bindauth", 0);
verbose = Conf.ReadFlag("ldapauth", "verbose", 0); /* Set to true if failed connects should be reported to operators */
useusername = Conf.ReadFlag("ldapauth", "userfield", 0);
-
+
if (scope == "base")
searchscope = LDAP_SCOPE_BASE;
else if (scope == "onelevel")
searchscope = LDAP_SCOPE_ONELEVEL;
else searchscope = LDAP_SCOPE_SUBTREE;
-
+
Connect();
}
if (verbose)
ServerInstance->SNO->WriteToSnoMask('A', "LDAP connection failed: %s", ldap_err2string(res));
conn = NULL;
- return false;
+ return false;
}
-
+
res = ldap_set_option(conn, LDAP_OPT_PROTOCOL_VERSION, (void *)&v);
if (res != LDAP_SUCCESS)
{
ldap_msgfree(msg);
user->Extend("ldapauth_failed");
return false;
- }
+ }
}
-
-
+
+
virtual void OnUserDisconnect(User* user)
{
user->Shrink("ldapauthed");
- user->Shrink("ldapauth_failed");
+ user->Shrink("ldapauth_failed");
}
-
+
virtual bool OnCheckReady(User* user)
{
return user->GetExt("ldapauthed");
{
return Version(1,2,0,0,VF_VENDOR,API_VERSION);
}
-
+
};
MODULE_INIT(ModuleLDAPAuth)
* Taken from the UnrealIRCd 4.0 SVN version, based on
* InspIRCd 1.1.x.
*
- * UnrealIRCd 4.0 (C) 2007 Carsten Valdemar Munk
+ * UnrealIRCd 4.0 (C) 2007 Carsten Valdemar Munk
* This program is free but copyrighted software; see
* the file COPYING for details.
*
std::string password;
int searchscope;
LDAP *conn;
-
+
public:
ModuleLDAPAuth(InspIRCd* Me)
: Module::Module(Me)
virtual void OnRehash(User* user, const std::string ¶meter)
{
ConfigReader Conf(ServerInstance);
-
+
base = Conf.ReadValue("ldapoper", "baserdn", 0);
ldapserver = Conf.ReadValue("ldapoper", "server", 0);
std::string scope = Conf.ReadValue("ldapoper", "searchscope", 0);
username = Conf.ReadValue("ldapoper", "binddn", 0);
password = Conf.ReadValue("ldapoper", "bindauth", 0);
-
+
if (scope == "base")
searchscope = LDAP_SCOPE_BASE;
else if (scope == "onelevel")
searchscope = LDAP_SCOPE_ONELEVEL;
else searchscope = LDAP_SCOPE_SUBTREE;
-
+
Connect();
}
if (res != LDAP_SUCCESS)
{
conn = NULL;
- return false;
+ return false;
}
-
+
res = ldap_set_option(conn, LDAP_OPT_PROTOCOL_VERSION, (void *)&v);
if (res != LDAP_SUCCESS)
{
return true;
}
- virtual int OnPassCompare(Extensible* ex, const std::string &data, const std::string &input, const std::string &hashtype)
- {
+ virtual int OnPassCompare(Extensible* ex, const std::string &data, const std::string &input, const std::string &hashtype)
+ {
User* user = dynamic_cast<User*>(ex);
- if (hashtype == "ldap")
+ if (hashtype == "ldap")
{
- if (LookupOper(user, data, input))
- {
+ if (LookupOper(user, data, input))
+ {
/* This is an ldap oper and has been found, claim the OPER command */
- return 1;
- }
- }
+ return 1;
+ }
+ }
/* We don't know this oper! */
- return 0;
- }
+ return 0;
+ }
bool LookupOper(User* user, const std::string &what, const std::string &opassword)
{
free(authpass);
ldap_msgfree(msg);
return false;
- }
+ }
}
virtual Version GetVersion()
{
return Version(1,2,0,0,VF_VENDOR,API_VERSION);
}
-
+
};
MODULE_INIT(ModuleLDAPAuth)
class MsSQLResult : public SQLresult
{
- private:
+ private:
int currentrow;
int rows;
int cols;
SQLfieldList* fieldlist;
SQLfieldMap* fieldmap;
- public:
+ public:
MsSQLResult(Module* self, Module* to, unsigned int rid)
: SQLresult(self, to, rid), currentrow(0), rows(0), cols(0), fieldlist(NULL), fieldmap(NULL)
{
class SQLConn : public classbase
{
- private:
+ private:
ResultQueue results;
- InspIRCd* Instance;
+ InspIRCd* Instance;
Module* mod;
SQLhost host;
TDSLOGIN* login;
TDSSOCKET* sock;
TDSCONTEXT* context;
- public:
+ public:
SQLConn(InspIRCd* SI, Module* m, const SQLhost& hi)
: Instance(SI), mod(m), host(hi), login(NULL), sock(NULL), context(NULL)
{
{
if (!sock)
return SQLerror(BAD_CONN, "Socket was NULL, check if SQL server is running.");
-
+
/* Pointer to the buffer we screw around with substitution in */
char* query;
escend++;
}
*escend = 0;
-
+
for (char* n = escaped; *n; n++)
{
*queryend = *n;
}
delete[] query;
free(msquery);
-
+
int tds_res;
while (tds_process_tokens(sock, &tds_res, NULL, TDS_TOKEN_RESULTS) == TDS_SUCCEED)
{
default:
break;
- }
+ }
}
results.push_back(res);
SendNotify();
class ModuleMsSQL : public Module
{
- private:
+ private:
ConnMap connections;
unsigned long currid;
- public:
+ public:
ModuleMsSQL(InspIRCd* Me)
: Module::Module(Me), currid(0)
{
}
return false;
}
-
+
void ReadConf()
{
ClearOldConnections();
/* $ModDep: m_sqlv2.h */
/* THE NONBLOCKING MYSQL API!
- *
+ *
* MySQL provides no nonblocking (asyncronous) API of its own, and its developers recommend
* that instead, you should thread your program. This is what i've done here to allow for
* asyncronous SQL requests via mysql. The way this works is as follows:
std::string b = (row[field_count] ? row[field_count] : "");
SQLfield sqlf(b, !row[field_count]);
colnames.push_back(a);
- fieldlists[n].push_back(sqlf);
+ fieldlists[n].push_back(sqlf);
field_count++;
}
n++;
virtual SQLfieldMap* GetRowMapPtr()
{
fieldmap = new SQLfieldMap();
-
+
if (currentrow < rows)
{
for (int i = 0; i < Cols(); i++)
{
insp_sockaddr sock_us;
socklen_t uslen;
-
+
public:
class ModuleSQL : public Module
{
public:
-
+
ConfigReader *Conf;
InspIRCd* PublicServerInstance;
pthread_t Dispatcher;
SQLModule = this;
MessagePipe = new Notifier(ServerInstance);
-
+
pthread_attr_t attribs;
pthread_attr_init(&attribs);
pthread_attr_setdetachstate(&attribs, PTHREAD_CREATE_JOINABLE);
{
rehashing = true;
}
-
+
virtual Version GetVersion()
{
return Version(1,2,0,0,VF_VENDOR|VF_SERVICEPROVIDER,API_VERSION);
}
-
+
};
void* DispatcherThread(void* arg)
class ReconnectTimer : public Timer
{
- private:
+ private:
Module* mod;
- public:
+ public:
ReconnectTimer(InspIRCd* SI, Module* m)
: Timer(5, SI->Time(), false), mod(m)
{
*/
class SQLConn : public EventHandler
{
- private:
- InspIRCd* Instance;
+ private:
+ InspIRCd* Instance;
SQLhost confhost; /* The <database> entry */
Module* us; /* Pointer to the SQL provider itself */
PGconn* sql; /* PgSQL database connection handle */
QueryQueue queue; /* Queue of queries waiting to be executed on this connection */
time_t idle; /* Time we last heard from the database */
- public:
+ public:
SQLConn(InspIRCd* SI, Module* self, const SQLhost& hi)
: EventHandler(), Instance(SI), confhost(hi), us(self), sql(NULL), status(CWRITE), qinprog(false)
{
class ModulePgSQL : public Module
{
- private:
+ private:
ConnMap connections;
unsigned long currid;
char* sqlsuccess;
ReconnectTimer* retimer;
- public:
+ public:
ModulePgSQL(InspIRCd* Me)
: Module::Module(Me), currid(0)
{
class CoreExport RLine : public XLine
{
- public:
+ public:
/** Create a R-Line.
* @param s_time The set time
std::string killreason;
std::string allowpattern;
std::string databaseid;
-
+
bool verbose;
-
+
public:
ModuleSQLAuth(InspIRCd* Me)
: Module::Module(Me)
user->Extend("sqlauthed");
return 0;
}
-
+
if (!CheckCredentials(user))
{
ServerInstance->Users->QuitUser(user, killreason);
{
std::string thisquery = freeformquery;
std::string safepass = user->password;
-
+
/* Search and replace the escaped nick and escaped pass into the query */
SearchAndReplace(safepass, "\"", "");
/* Build the query */
SQLrequest req = SQLrequest(this, SQLprovider, databaseid, SQLquery(thisquery));
-
+
if(req.Send())
{
/* When we get the query response from the service provider we will be given an ID to play with,
* us to discard the query.
*/
AssociateUser(this, SQLutils, req.id, user).Send();
-
+
return true;
}
else
return false;
}
}
-
+
virtual const char* OnRequest(Request* request)
{
if(strcmp(SQLRESID, request->GetId()) == 0)
User* user = GetAssocUser(this, SQLutils, res->id).S().user;
UnAssociate(this, SQLutils, res->id).S();
-
+
if(user)
{
if(res->error.Id() == NO_ERROR)
ServerInstance->Users->QuitUser(user, killreason);
}
return SQLSUCCESS;
- }
+ }
return NULL;
}
-
+
virtual void OnUserDisconnect(User* user)
{
user->Shrink("sqlauthed");
- user->Shrink("sqlauth_failed");
+ user->Shrink("sqlauth_failed");
}
-
+
virtual bool OnCheckReady(User* user)
{
return user->GetExt("sqlauthed");
{
return Version(1,2,1,0,VF_VENDOR,API_VERSION);
}
-
+
};
MODULE_INIT(ModuleSQLAuth)
class SQLite3Result : public SQLresult
{
- private:
+ private:
int currentrow;
int rows;
int cols;
SQLfieldList* fieldlist;
SQLfieldMap* fieldmap;
- public:
+ public:
SQLite3Result(Module* self, Module* to, unsigned int rid)
: SQLresult(self, to, rid), currentrow(0), rows(0), cols(0), fieldlist(NULL), fieldmap(NULL)
{
class SQLConn : public classbase
{
- private:
+ private:
ResultQueue results;
- InspIRCd* Instance;
+ InspIRCd* Instance;
Module* mod;
SQLhost host;
sqlite3* conn;
- public:
+ public:
SQLConn(InspIRCd* SI, Module* m, const SQLhost& hi)
: Instance(SI), mod(m), host(hi)
{
class ModuleSQLite3 : public Module
{
- private:
+ private:
ConnMap connections;
unsigned long currid;
- public:
+ public:
ModuleSQLite3(InspIRCd* Me)
: Module::Module(Me), currid(0)
{
ServerInstance->SE->DelFd(resultnotify);
resultnotify->Close();
ServerInstance->BufferedSocketCull();
-
+
if (QueueFD >= 0)
{
shutdown(QueueFD, 2);
close(QueueFD);
}
-
+
if (resultdispatch)
{
ServerInstance->SE->DelFd(resultdispatch);
resultdispatch->Close();
ServerInstance->BufferedSocketCull();
}
-
+
ServerInstance->Modules->UnpublishInterface("SQL", this);
ServerInstance->Modules->UnpublishFeature("SQL");
ServerInstance->Modules->DoneWithInterface("SQLutils");
{
return Version(1,2,0,1,VF_VENDOR,API_VERSION);
}
-
+
};
MODULE_INIT(ModuleSQLLog)
virtual void OnRehash(User* user, const std::string ¶meter)
{
ConfigReader Conf(ServerInstance);
-
+
databaseid = Conf.ReadValue("sqloper", "dbid", 0); /* Database ID of a database configured for the service provider module */
hashtype = assign(Conf.ReadValue("sqloper", "hash", 0));
}
if ((validated) && (command == "OPER"))
{
if (LookupOper(user, parameters[0], parameters[1]))
- {
+ {
/* Returning true here just means the query is in progress, or on it's way to being
* in progress. Nothing about the /oper actually being successful..
* If the oper lookup fails later, we pass the command to the original handler
bool LookupOper(User* user, const std::string &username, const std::string &password)
{
Module* target;
-
+
target = ServerInstance->Modules->FindFeature("SQL");
if (target)
*/
SQLrequest req = SQLrequest(this, target, databaseid,
SQLquery("SELECT username, password, hostname, type FROM ircd_opers WHERE username = '?' AND password='?'") % username % md5_pass_hash);
-
+
if (req.Send())
{
/* When we get the query response from the service provider we will be given an ID to play with,
user->Extend("oper_user", strdup(username.c_str()));
user->Extend("oper_pass", strdup(password.c_str()));
-
+
return true;
}
else
return false;
}
}
-
+
virtual const char* OnRequest(Request* request)
{
if (strcmp(SQLRESID, request->GetId()) == 0)
user->GetExt("oper_user", tried_user);
user->GetExt("oper_pass", tried_pass);
-
+
if (user)
{
if (res->error.Id() == NO_ERROR)
/* We got a row in the result, this means there was a record for the oper..
* now we just need to check if their host matches, and if it does then
* oper them up.
- *
+ *
* We now (previous versions of the module didn't) support multiple SQL
* rows per-oper in the same way the config file does, all rows will be tried
* until one is found which matches. This is useful to define several different
* hosts for a single oper.
- *
+ *
* The for() loop works as SQLresult::GetRowMap() returns an empty map when there
* are no more rows to return.
*/
-
+
for (SQLfieldMap& row = res->GetRowMap(); row.size(); row = res->GetRowMap())
- {
+ {
if (OperUser(user, row["username"].d, row["password"].d, row["hostname"].d, row["type"].d))
{
/* If/when one of the rows matches, stop checking and return */
}
}
-
+
return SQLSUCCESS;
}
bool OperUser(User* user, const std::string &username, const std::string &password, const std::string &pattern, const std::string &type)
{
ConfigReader Conf(ServerInstance);
-
+
for (int j = 0; j < Conf.Enumerate("type"); j++)
{
std::string tname = Conf.ReadValue("type","name",j);
std::string hostname(user->ident);
hostname.append("@").append(user->host);
-
+
if ((tname == type) && OneOfMatches(hostname.c_str(), user->GetIPString(), pattern.c_str()))
{
/* Opertype and host match, looks like this is it. */
return true;
}
}
-
+
return false;
}
{
return Version(1,2,1,0,VF_VENDOR,API_VERSION);
}
-
+
};
MODULE_INIT(ModuleSQLOper)
virtual ~ModuleSQLutils()
{
ServerInstance->Modules->UnpublishInterface("SQLutils", this);
- }
+ }
virtual const char* OnRequest(Request* request)
if(strcmp(SQLUTILAU, request->GetId()) == 0)
{
AssociateUser* req = (AssociateUser*)request;
-
+
iduser.insert(std::make_pair(req->id, req->user));
-
+
AttachList(req->user, req->id);
}
else if(strcmp(SQLUTILAC, request->GetId()) == 0)
{
AssociateChan* req = (AssociateChan*)request;
-
- idchan.insert(std::make_pair(req->id, req->chan));
-
+
+ idchan.insert(std::make_pair(req->id, req->chan));
+
AttachList(req->chan, req->id);
}
else if(strcmp(SQLUTILUA, request->GetId()) == 0)
{
UnAssociate* req = (UnAssociate*)request;
-
+
/* Unassociate a given query ID with all users and channels
* it is associated with.
*/
-
+
DoUnAssociate(iduser, req->id);
DoUnAssociate(idchan, req->id);
}
else if(strcmp(SQLUTILGU, request->GetId()) == 0)
{
GetAssocUser* req = (GetAssocUser*)request;
-
+
IdUserMap::iterator iter = iduser.find(req->id);
-
+
if(iter != iduser.end())
{
req->user = iter->second;
}
else if(strcmp(SQLUTILGC, request->GetId()) == 0)
{
- GetAssocChan* req = (GetAssocChan*)request;
-
+ GetAssocChan* req = (GetAssocChan*)request;
+
IdChanMap::iterator iter = idchan.find(req->id);
-
+
if(iter != idchan.end())
{
req->chan = iter->second;
}
}
-
+
return SQLUTILSUCCESS;
}
-
+
virtual void OnUserDisconnect(User* user)
{
/* A user is disconnecting, first we need to check if they have a list of queries associated with them.
* associated them asks to look them up then it gets a NULL result and knows to discard the query.
*/
AssocIdList* il;
-
+
if(user->GetExt("sqlutils_queryids", il))
{
for(AssocIdList::iterator listiter = il->begin(); listiter != il->end(); listiter++)
{
IdUserMap::iterator iter;
-
+
iter = iduser.find(*listiter);
-
+
if(iter != iduser.end())
{
if(iter->second != user)
ServerInstance->Logs->Log("m_sqlutils",DEBUG, "BUG: user %s was extended with sqlutils_queryids but there was nothing matching in the map", user->nick.c_str());
}
}
-
+
user->Shrink("sqlutils_queryids");
delete il;
}
}
-
+
void AttachList(Extensible* obj, unsigned long id)
{
AssocIdList* il;
-
+
if(!obj->GetExt("sqlutils_queryids", il))
{
/* Doesn't already exist, create a new list and attach it. */
il = new AssocIdList;
obj->Extend("sqlutils_queryids", il);
}
-
+
/* Now either way we have a valid list in il, attached. */
il->push_back(id);
}
-
+
void RemoveFromList(Extensible* obj, unsigned long id)
{
AssocIdList* il;
-
+
if(obj->GetExt("sqlutils_queryids", il))
{
/* Only do anything if the list exists... (which it ought to) */
il->remove(id);
-
+
if(il->empty())
{
/* If we just emptied it.. */
}
}
}
-
+
template <class T> void DoUnAssociate(T &map, unsigned long id)
{
/* For each occurence of 'id' (well, only one..it's not a multimap) in 'map'
* 'id' from the list of query IDs attached to it.
*/
typename T::iterator iter = map.find(id);
-
+
if(iter != map.end())
{
/* Found a value indexed by 'id', call RemoveFromList()
RemoveFromList(iter->second, id);
}
}
-
+
virtual void OnChannelDelete(Channel* chan)
{
/* A channel is being destroyed, first we need to check if it has a list of queries associated with it.
* associated them asks to look them up then it gets a NULL result and knows to discard the query.
*/
AssocIdList* il;
-
+
if(chan->GetExt("sqlutils_queryids", il))
{
for(AssocIdList::iterator listiter = il->begin(); listiter != il->end(); listiter++)
{
IdChanMap::iterator iter;
-
+
iter = idchan.find(*listiter);
-
+
if(iter != idchan.end())
{
if(iter->second != chan)
{
ServerInstance->Logs->Log("m_sqlutils",DEBUG, "BUG: ID associated with channel %s doesn't have the same Channel* associated with it in the map (erasing anyway)", chan->name.c_str());
}
- idchan.erase(iter);
+ idchan.erase(iter);
}
else
{
ServerInstance->Logs->Log("m_sqlutils",DEBUG, "BUG: channel %s was extended with sqlutils_queryids but there was nothing matching in the map", chan->name.c_str());
}
}
-
+
chan->Shrink("sqlutils_queryids");
delete il;
}
}
-
+
virtual Version GetVersion()
{
return Version(1, 2, 0, 0, VF_VENDOR|VF_SERVICEPROVIDER, API_VERSION);
}
-
+
};
MODULE_INIT(ModuleSQLutils)
GenericCapHandler(ev, "tls", "tls");
}
- void Prioritize()
+ void Prioritize()
{
Module* server = ServerInstance->Modules->Find("m_spanningtree.so");
ServerInstance->Modules->SetPriority(this, I_OnPostConnect, PRIO_AFTER, &server);
ServerInstance->Modules->Attach(eventlist, this, 16);
}
- virtual void OnHookUserIO(User* user, const std::string &targetip)
+ virtual void OnHookUserIO(User* user, const std::string &targetip)
{
if (!user->io && isin(targetip,user->GetPort(), listenports))
{
{
ConfigReader Conf(ServerInstance);
- listenports.clear();
- clientactive = 0;
- sslports.clear();
-
- for(int index = 0; index < Conf.Enumerate("bind"); index++)
- {
- // For each <bind> tag
- std::string x = Conf.ReadValue("bind", "type", index);
- if(((x.empty()) || (x == "clients")) && (Conf.ReadValue("bind", "ssl", index) == "openssl"))
- {
- // Get the port we're meant to be listening on with SSL
- std::string port = Conf.ReadValue("bind", "port", index);
- std::string addr = Conf.ReadValue("bind", "address", index);
-
- irc::portparser portrange(port, false);
- long portno = -1;
- while ((portno = portrange.GetToken()))
- {
- clientactive++;
- try
- {
- listenports.push_back(addr + ":" + ConvToStr(portno));
-
- for (size_t i = 0; i < ServerInstance->Config->ports.size(); i++)
- if ((ServerInstance->Config->ports[i]->GetPort() == portno) && (ServerInstance->Config->ports[i]->GetIP() == addr))
- ServerInstance->Config->ports[i]->SetDescription("ssl");
- ServerInstance->Logs->Log("m_ssl_openssl",DEFAULT, "m_ssl_gnutls.so: Enabling SSL for port %ld", portno);
-
- sslports.append((addr.empty() ? "*" : addr)).append(":").append(ConvToStr(portno)).append(";");
- }
- catch (ModuleException &e)
- {
- ServerInstance->Logs->Log("m_ssl_openssl",DEFAULT, "m_ssl_gnutls.so: FAILED to enable SSL on port %ld: %s. Maybe it's already hooked by the same port on a different IP, or you have an other SSL or similar module loaded?", portno, e.GetReason());
- }
- }
- }
- }
+ listenports.clear();
+ clientactive = 0;
+ sslports.clear();
+
+ for(int index = 0; index < Conf.Enumerate("bind"); index++)
+ {
+ // For each <bind> tag
+ std::string x = Conf.ReadValue("bind", "type", index);
+ if(((x.empty()) || (x == "clients")) && (Conf.ReadValue("bind", "ssl", index) == "openssl"))
+ {
+ // Get the port we're meant to be listening on with SSL
+ std::string port = Conf.ReadValue("bind", "port", index);
+ std::string addr = Conf.ReadValue("bind", "address", index);
+
+ irc::portparser portrange(port, false);
+ long portno = -1;
+ while ((portno = portrange.GetToken()))
+ {
+ clientactive++;
+ try
+ {
+ listenports.push_back(addr + ":" + ConvToStr(portno));
+
+ for (size_t i = 0; i < ServerInstance->Config->ports.size(); i++)
+ if ((ServerInstance->Config->ports[i]->GetPort() == portno) && (ServerInstance->Config->ports[i]->GetIP() == addr))
+ ServerInstance->Config->ports[i]->SetDescription("ssl");
+ ServerInstance->Logs->Log("m_ssl_openssl",DEFAULT, "m_ssl_gnutls.so: Enabling SSL for port %ld", portno);
+
+ sslports.append((addr.empty() ? "*" : addr)).append(":").append(ConvToStr(portno)).append(";");
+ }
+ catch (ModuleException &e)
+ {
+ ServerInstance->Logs->Log("m_ssl_openssl",DEFAULT, "m_ssl_gnutls.so: FAILED to enable SSL on port %ld: %s. Maybe it's already hooked by the same port on a different IP, or you have an other SSL or similar module loaded?", portno, e.GetReason());
+ }
+ }
+ }
+ }
if (!sslports.empty())
sslports.erase(sslports.end() - 1);
virtual void OnRawSocketConnect(int fd)
{
- /* Are there any possibilities of an out of range fd? Hope not, but lets be paranoid */
+ /* Are there any possibilities of an out of range fd? Hope not, but lets be paranoid */
if ((fd < 0) || (fd > ServerInstance->SE->GetMaxFds() -1))
return;
{
// Is this right? Not sure if the unencrypted data is garaunteed to be the same length.
// Read into the inbuffer, offset from the beginning by the amount of data we have that insp hasn't taken yet.
-
+
int ret = SSL_read(session->sess, session->inbuf + session->inbufoffset, inbufsize - session->inbufoffset);
if (ret == 0)
{
this->source = "m_ssl_oper_cert.so";
syntax = "<nickname>";
- }
-
+ }
+
CmdResult Handle (const std::vector<std::string> ¶meters, User *user)
{
User* target = ServerInstance->FindNick(parameters[0]);
virtual int OnPreCommand(std::string &command, std::vector<std::string> ¶meters, User *user, bool validated, const std::string &original_line)
{
irc::string cmd = command.c_str();
-
+
if ((cmd == "OPER") && (validated))
{
char TheHost[MAXBUF];
ModuleSSLInfo(InspIRCd* Me)
: Module(Me)
{
-
+
newcommand = new cmd_sslinfo(ServerInstance);
ServerInstance->AddCommand(newcommand);
virtual ~ModuleSSLInfo()
{
}
-
+
virtual Version GetVersion()
{
return Version(1, 2, 0, 0, VF_VENDOR, API_VERSION);
class ModuleTestClient : public Module
{
private:
-
+
public:
ModuleTestClient(InspIRCd* Me)
ServerInstance->Modules->Attach(eventlist, this, 2);
}
-
+
virtual Version GetVersion()
{
return Version(1, 2, 0, 0, VF_VENDOR, API_VERSION);
}
-
+
virtual void OnBackgroundTimer(time_t)
{
Module* target = ServerInstance->Modules->FindFeature("SQL");
-
+
if(target)
{
SQLrequest foo = SQLrequest(this, target, "foo",
SQLquery("UPDATE rawr SET foo = '?' WHERE bar = 42") % time(NULL));
-
+
if(foo.Send())
{
ServerInstance->Logs->Log("m_testclient.so", DEBUG, "Sent query, got given ID %lu", foo.id);
}
}
}
-
+
virtual const char* OnRequest(Request* request)
{
if(strcmp(SQLRESID, request->GetId()) == 0)
{
ServerInstance->Logs->Log("m_testclient.so", DEBUG, "Got SQL result (%s)", request->GetId());
-
+
SQLresult* res = (SQLresult*)request;
if (res->error.Id() == NO_ERROR)
for (int r = 0; r < res->Rows(); r++)
{
ServerInstance->Logs->Log("m_testclient.so", DEBUG, "Row %d:", r);
-
+
for(int i = 0; i < res->Cols(); i++)
{
ServerInstance->Logs->Log("m_testclient.so", DEBUG, "\t[%s]: %s", res->ColName(i).c_str(), res->GetValue(r, i).d.c_str());
else
{
ServerInstance->Logs->Log("m_testclient.so", DEBUG, "SQLrequest failed: %s", res->error.Str());
-
+
}
-
+
return SQLSUCCESS;
}
-
+
ServerInstance->Logs->Log("m_testclient.so", DEBUG, "Got unsupported API version string: %s", request->GetId());
-
+
return NULL;
}
-
+
virtual ~ModuleTestClient()
{
- }
+ }
};
MODULE_INIT(ModuleTestClient)
float total_in_compressed;
float total_out_uncompressed;
float total_in_uncompressed;
-
+
public:
-
+
ModuleZLib(InspIRCd* Me)
: Module::Module(Me)
{
virtual void OnRawSocketAccept(int fd, const std::string &ip, int localport)
{
izip_session* session = &sessions[fd];
-
+
/* allocate state and buffers */
session->fd = fd;
session->status = IZIP_OPEN;
/* Add it to the frame queue */
session->inbuf->AddData(compr, readresult);
total_in_compressed += readresult;
-
+
/* Parse all completed frames */
int size = 0;
while ((size = session->inbuf->GetFrame(compr, CHUNK)) != 0)
/* If we cant call this, well, we're boned. */
if (inflateInit(&session->d_stream) != Z_OK)
return 0;
-
+
while ((session->d_stream.total_out < count) && (session->d_stream.total_in < (unsigned int)size))
{
session->d_stream.avail_in = session->d_stream.avail_out = 1;
if (inflate(&session->d_stream, Z_NO_FLUSH) == Z_STREAM_END)
break;
}
-
+
/* Stick a fork in me, i'm done */
inflateEnd(&session->d_stream);
*/
return ocount;
}
-
+
void CloseSession(izip_session* session)
{
if (session->status == IZIP_OPEN)
protected:
std::map<std::string,std::string> headers;
public:
-
+
/** Set the value of a header
* Sets the value of the named header. If the header is already present, it will be replaced
*/
{
headers[name] = data;
}
-
+
/** Set the value of a header, only if it doesn't exist already
* Sets the value of the named header. If the header is already present, it will NOT be updated
*/
if (!IsSet(name))
SetHeader(name, data);
}
-
+
/** Remove the named header
*/
void RemoveHeader(const std::string &name)
{
headers.erase(name);
}
-
+
/** Remove all headers
*/
void Clear()
{
headers.clear();
}
-
+
/** Get the value of a header
* @return The value of the header, or an empty string
*/
std::map<std::string,std::string>::iterator it = headers.find(name);
if (it == headers.end())
return std::string();
-
+
return it->second;
}
-
+
/** Check if the given header is specified
* @return true if the header is specified
*/
std::map<std::string,std::string>::iterator it = headers.find(name);
return (it != headers.end());
}
-
+
/** Get all headers, formatted by the HTTP protocol
* @return Returns all headers, formatted according to the HTTP protocol. There is no request terminator at the end
*/
std::string GetFormattedHeaders()
{
std::string re;
-
+
for (std::map<std::string,std::string>::iterator i = headers.begin(); i != headers.end(); i++)
re += i->first + ": " + i->second + "\r\n";
-
+
return re;
}
};
std::string document;
std::string ipaddr;
std::string postdata;
-
+
public:
HTTPHeaders *headers;
public:
HTTPHeaders headers;
-
+
/** The socket pointer from an earlier HTTPRequest
*/
void* sock;
{
public:
-
+
ModuleAbbreviation(InspIRCd* Me)
: Module(Me)
{
}
public:
-
+
ModuleAlias(InspIRCd* Me)
: Module(Me)
{
{
if (!ServerInstance->ULine(u->server))
{
- ServerInstance->SNO->WriteToSnoMask('A', "NOTICE -- Service "+Aliases[i].requires+" required by alias "+std::string(Aliases[i].text.c_str())+" is not on a u-lined server, possibly underhanded antics detected!");
+ ServerInstance->SNO->WriteToSnoMask('A', "NOTICE -- Service "+Aliases[i].requires+" required by alias "+std::string(Aliases[i].text.c_str())+" is not on a u-lined server, possibly underhanded antics detected!");
user->WriteNumeric(401, ""+std::string(user->nick)+" "+Aliases[i].requires+" :is an imposter! Please inform an IRC operator as soon as possible.");
return 1;
}
}
ServerInstance->Parser->CallHandler(command, pars, user);
}
-
+
virtual void OnRehash(User* user, const std::string ¶meter)
{
ReadAliases();
std::string msg = ":" + std::string(ServerInstance->Config->ServerName) + " NOTICE " + user->nick + " :System time for " +
ServerInstance->Config->ServerName + " is: " + fmtdate;
-
+
if (IS_LOCAL(user))
{
user->Write(msg);
ServerInstance->AddCommand(mycommand);
}
-
+
virtual ~Modulealltime()
{
}
-
+
virtual Version GetVersion()
{
return Version(1, 2, 0, 0, VF_COMMON | VF_VENDOR, API_VERSION);
}
-
+
};
MODULE_INIT(Modulealltime)
public:
ModuleAntiBear(InspIRCd* Me) : Module(Me)
{
-
+
Implementation eventlist[] = { I_OnUserRegister, I_OnPreCommand };
ServerInstance->Modules->Attach(eventlist, this, 2);
}
-
+
virtual ~ModuleAntiBear()
{
}
-
+
virtual Version GetVersion()
{
return Version(1,2,0,0,VF_VENDOR,API_VERSION);
return 1;
}
-
+
user->Shrink("antibear_timewait");
// Block the command, so the user doesn't receive a no such nick notice
return 1;
}
-
+
return 0;
}
ModuleAntiBottler(InspIRCd* Me)
: Module(Me)
{
-
+
Implementation eventlist[] = { I_OnPreCommand };
ServerInstance->Modules->Attach(eventlist, this, 1);
}
-
+
virtual ~ModuleAntiBottler()
{
}
-
+
virtual Version GetVersion()
{
return Version(1,2,0,1,VF_VENDOR,API_VERSION);
{
if (*j == ':')
break;
-
+
if (*j == '"')
{
not_bottler = true;
Me->Modules->Attach(eventlist, this, 6);
}
-
+
virtual ~ModuleAuditorium()
{
ServerInstance->Modes->DelMode(aum);
return Version(1, 2, 0, 0, VF_COMMON | VF_VENDOR, API_VERSION);
}
- virtual void OnNamesListItem(User* issuer, User* user, Channel* channel, std::string &prefixes, std::string &nick)
+ virtual void OnNamesListItem(User* issuer, User* user, Channel* channel, std::string &prefixes, std::string &nick)
{
if (!channel->IsModeSet('u'))
return;
return;
}
}
-
+
virtual void OnUserJoin(User* user, Channel* channel, bool sync, bool &silent)
{
if (channel->IsModeSet('u'))
class ModuleBanException : public Module
{
BanException* be;
-
+
public:
ModuleBanException(InspIRCd* Me) : Module(Me)
Me->Modules->Attach(list, this, 4);
}
-
+
virtual void On005Numeric(std::string &output)
{
output.append(" EXCEPTS=e");
{
modelist* list;
chan->GetExt(be->GetInfoKey(), list);
-
+
if (!list)
{
// No list, proceed normally
}
}
}
- return 0;
+ return 0;
}
virtual void OnCleanup(int target_type, void* item)
{
return Version(1, 2, 0, 3, VF_COMMON | VF_VENDOR, API_VERSION);
}
-
+
virtual ~ModuleBanException()
{
ServerInstance->Modes->DelMode(be);
* nick!ident#chan -> nick!ident@*#chan
* nick#chan -> nick!*@*#chan
*/
-
+
if(channel && (type == MODETYPE_CHANNEL) && param.length())
{
BanRedirectList* redirects;
-
+
std::string mask[4];
enum { NICK, IDENT, HOST, CHAN } current = NICK;
std::string::iterator start_pos = param.begin();
long maxbans = channel->GetMaxBans();
-
+
if(adding && (channel->bans.size() > static_cast<unsigned>(maxbans)))
{
source->WriteNumeric(478, "%s %s :Channel ban list for %s is full (maximum entries for this channel is %ld)", source->nick.c_str(), channel->name.c_str(), channel->name.c_str(), maxbans);
return false;
}
-
+
for(std::string::iterator curr = start_pos; curr != param.end(); curr++)
{
switch(*curr)
break;
}
}
-
+
if(mask[current].empty())
{
- mask[current].assign(start_pos, param.end());
+ mask[current].assign(start_pos, param.end());
}
-
+
/* nick@host wants to be changed to *!nick@host rather than nick!*@host... */
if(mask[NICK].length() && mask[HOST].length() && mask[IDENT].empty())
{
/* std::string::swap() is fast - it runs in constant time */
mask[NICK].swap(mask[IDENT]);
}
-
+
for(int i = 0; i < 3; i++)
{
if(mask[i].empty())
mask[i].assign("*");
}
}
-
+
param.assign(mask[NICK]).append(1, '!').append(mask[IDENT]).append(1, '@').append(mask[HOST]);
-
+
if(mask[CHAN].length())
{
if(!IS_LOCAL(source) || Srv->IsChannel(mask[CHAN].c_str(), ServerInstance->Config->Limits.ChanMax))
redirects = new BanRedirectList;
channel->Extend("banredirects", redirects);
}
-
+
/* Here 'param' doesn't have the channel on it yet */
redirects->push_back(BanRedirectEntry(mask[CHAN].c_str(), param.c_str()));
-
+
/* Now it does */
param.append(mask[CHAN]);
}
if(channel->GetExt("banredirects", redirects))
{
/* But there were, so we need to remove the matching one if there is one */
-
+
for(BanRedirectList::iterator redir = redirects->begin(); redir != redirects->end(); redir++)
{
/* Ugly as fuck */
if((irc::string(redir->targetchan.c_str()) == irc::string(mask[CHAN].c_str())) && (irc::string(redir->banmask.c_str()) == irc::string(param.c_str())))
{
redirects->erase(redir);
-
+
if(redirects->empty())
{
delete redirects;
channel->Shrink("banredirects");
}
-
+
break;
}
}
}
-
+
/* Append the channel so the default +b handler can remove the entry too */
param.append(mask[CHAN]);
}
}
}
}
-
+
return true;
}
};
{
re = new BanRedirect(Me);
nofollow = false;
-
+
if(!ServerInstance->Modes->AddModeWatcher(re))
{
delete re;
Me->Modules->Attach(list, this, 4);
}
-
+
virtual void OnChannelDelete(Channel* chan)
{
OnCleanup(TYPE_CHANNEL, chan);
}
-
+
virtual void OnCleanup(int target_type, void* item)
{
if(target_type == TYPE_CHANNEL)
{
Channel* chan = static_cast<Channel*>(item);
BanRedirectList* redirects;
-
+
if(chan->GetExt("banredirects", redirects))
{
irc::modestacker modestack(ServerInstance, false);
StringDeque stackresult;
std::vector<std::string> mode_junk;
mode_junk.push_back(chan->name);
-
+
for(BanRedirectList::iterator i = redirects->begin(); i != redirects->end(); i++)
{
modestack.Push('b', i->targetchan.insert(0, i->banmask));
}
-
+
for(BanRedirectList::iterator i = redirects->begin(); i != redirects->end(); i++)
{
modestack.PushPlus();
modestack.Push('b', i->banmask);
}
-
+
while(modestack.GetStackedLine(stackresult))
{
for(StringDeque::size_type i = 0; i < stackresult.size(); i++)
{
mode_junk.push_back(stackresult[i]);
}
-
+
ServerInstance->SendMode(mode_junk, ServerInstance->FakeClient);
}
-
+
delete redirects;
chan->Shrink("banredirects");
}
if (chan)
{
BanRedirectList* redirects;
-
+
if(chan->GetExt("banredirects", redirects))
{
/* We actually had some ban redirects to check */
-
+
/* This was replaced with user->MakeHostIP() when I had a snprintf(), but MakeHostIP() doesn't seem to add the nick.
* Maybe we should have a GetFullIPHost() or something to match GetFullHost() and GetFullRealHost?
*/
std::string ipmask(user->nick);
ipmask.append(1, '!').append(user->MakeHostIP());
-
+
for(BanRedirectList::iterator redir = redirects->begin(); redir != redirects->end(); redir++)
{
if(ServerInstance->MatchText(user->GetFullRealHost(), redir->banmask) || ServerInstance->MatchText(user->GetFullHost(), redir->banmask) || ServerInstance->MatchText(ipmask, redir->banmask))
{
/* tell them they're banned and are being transferred */
Channel* destchan = ServerInstance->FindChan(redir->targetchan);
-
+
if(destchan && ServerInstance->Modules->Find("m_redirect.so") && destchan->IsModeSet('L') && destchan->limit && (destchan->GetUserCounter() >= destchan->limit))
{
user->WriteNumeric(474, "%s %s :Cannot join channel (You are banned)", user->nick.c_str(), chan->name.c_str());
ServerInstance->Modes->DelModeWatcher(re);
delete re;
}
-
+
virtual Version GetVersion()
{
return Version(1, 0, 0, 0, VF_COMMON | VF_VENDOR, API_VERSION);
}
-
+
void Prioritize()
{
Module* banex = ServerInstance->Modules->Find("m_banexception.so");
{
int ForgetDelay;
BlockAction action;
-
+
public:
ModuleBlockAmsg(InspIRCd* Me) : Module(Me)
{
ServerInstance->Modules->Attach(eventlist, this, 3);
}
-
+
virtual ~ModuleBlockAmsg()
{
}
-
+
virtual Version GetVersion()
{
return Version(1,2,0,0,VF_VENDOR,API_VERSION);
}
-
+
virtual void OnRehash(User* user, const std::string ¶meter)
{
ConfigReader Conf(ServerInstance);
-
+
ForgetDelay = Conf.ReadInteger("blockamsg", "delay", 0, false);
-
+
if(Conf.GetError() == CONF_VALUE_NOT_FOUND)
ForgetDelay = -1;
-
+
std::string act = Conf.ReadValue("blockamsg", "action", 0);
-
+
if(act == "notice")
action = IBLOCK_NOTICE;
else if(act == "noticeopers")
// Don't do anything with unregistered users, or remote ones.
if(!user || (user->registered != REG_ALL) || !IS_LOCAL(user))
return 0;
-
+
// We want case insensitive command comparison.
// Add std::string contructor for irc::string :x
irc::string cmd = command.c_str();
-
+
if(validated && (cmd == "PRIVMSG" || cmd == "NOTICE") && (parameters.size() >= 2))
{
// parameters[0] should have the target(s) in it.
// I think it will be faster to first check if there are any commas, and if there are then try and parse it out.
// Most messages have a single target so...
-
+
int targets = 1;
int userchans = 0;
-
+
if(*parameters[0].c_str() != '#')
{
// Decrement if the first target wasn't a channel.
targets--;
}
-
+
for(const char* c = parameters[0].c_str(); *c; c++)
if((*c == ',') && *(c+1) && (*(c+1) == '#'))
targets++;
-
+
/* targets should now contain the number of channel targets the msg/notice was pointed at.
* If the msg/notice was a PM there should be no channel targets and 'targets' should = 0.
* We don't want to block PMs so...
{
return 0;
}
-
+
userchans = user->chans.size();
// Check that this message wasn't already sent within a few seconds.
BlockedMessage* m;
user->GetExt("amsgblock", m);
-
+
// If the message is identical and within the time.
// We check the target is *not* identical, that'd straying into the realms of flood control. Which isn't what we're doing...
// OR
ServerInstance->Users->QuitUser(user, "Global message (/amsg or /ame) detected");
else if(action == IBLOCK_NOTICE || action == IBLOCK_NOTICEOPERS)
user->WriteServ( "NOTICE %s :Global message (/amsg or /ame) detected", user->nick.c_str());
-
+
return 1;
}
-
+
if(m)
{
// If there's already a BlockedMessage allocated, use it.
m = new BlockedMessage(parameters[1], parameters[0].c_str(), ServerInstance->Time());
user->Extend("amsgblock", (char*)m);
}
- }
+ }
return 0;
}
-
+
void OnCleanup(int target_type, void* item)
{
if(target_type == TYPE_USER)
unsigned int minlen;
char capsmap[256];
public:
-
+
ModuleBlockCAPS(InspIRCd* Me) : Module(Me)
{
OnRehash(NULL,"");
class ModuleBlockColour : public Module
{
- bool AllowChanOps;
+ bool AllowChanOps;
BlockColor *bc;
public:
-
+
ModuleBlockColour(InspIRCd* Me) : Module(Me)
{
bc = new BlockColor(ServerInstance);
{
return 0;
}
-
+
if(c->IsModeSet('c'))
{
for (std::string::iterator i = text.begin(); i != text.end(); i++)
}
return 0;
}
-
+
virtual int OnUserPreNotice(User* user,void* dest,int target_type, std::string &text, char status, CUList &exempt_list)
{
return OnUserPreMessage(user,dest,target_type,text,status,exempt_list);
ServerInstance->Modes->DelMode(bc);
delete bc;
}
-
+
virtual Version GetVersion()
{
return Version(1,2,0,0,VF_COMMON|VF_VENDOR,API_VERSION);
class ModuleBotMode : public Module
{
-
+
BotMode* bm;
public:
ModuleBotMode(InspIRCd* Me)
: Module(Me)
{
-
+
bm = new BotMode(ServerInstance);
if (!ServerInstance->Modes->AddMode(bm))
throw ModuleException("Could not add new modes!");
ServerInstance->Modules->Attach(eventlist, this, 1);
}
-
+
virtual ~ModuleBotMode()
{
ServerInstance->Modes->DelMode(bm);
delete bm;
}
-
+
virtual Version GetVersion()
{
return Version(1,2,0,0,VF_COMMON|VF_VENDOR,API_VERSION);
for (user_hash::iterator i = ServerInstance->Users->clientlist->begin(); i != ServerInstance->Users->clientlist->end(); ++i)
{
callerid_data* dat = GetData(i->second, false);
-
+
if (!dat)
continue;
CAP LS
:alfred.staticbox.net CAP * LS :multi-prefix sasl
CAP REQ :multi-prefix
-:alfred.staticbox.net CAP * ACK :multi-prefix
+:alfred.staticbox.net CAP * ACK :multi-prefix
CAP CLEAR
:alfred.staticbox.net CAP * ACK :-multi-prefix
CAP REQ :multi-prefix
-:alfred.staticbox.net CAP * ACK :multi-prefix
+:alfred.staticbox.net CAP * ACK :multi-prefix
CAP LIST
:alfred.staticbox.net CAP * LIST :multi-prefix
CAP END
{
ServerInstance->XLines->UnregisterFactory(f);
}
-
+
virtual int OnStats(char symbol, User* user, string_list &results)
{
return 0;
class ModuleCensor : public Module
{
-
+
censor_t censors;
CensorUser *cu;
CensorChannel *cc;
-
+
public:
ModuleCensor(InspIRCd* Me)
: Module(Me)
irc::string text2 = text.c_str();
for (censor_t::iterator index = censors.begin(); index != censors.end(); index++)
- {
+ {
if (text2.find(index->first) != irc::string::npos)
{
if (index->second.empty())
user->WriteNumeric(936, "%s %s %s :Your message contained a censored word, and was blocked", user->nick.c_str(), ((Channel*)dest)->name.c_str(), index->first.c_str());
return 1;
}
-
+
this->ReplaceLine(text2,index->first,index->second);
}
}
text = text2.c_str();
return 0;
}
-
+
virtual int OnUserPreNotice(User* user,void* dest,int target_type, std::string &text, char status, CUList &exempt_list)
{
return OnUserPreMessage(user,dest,target_type,text,status,exempt_list);
}
-
+
virtual void OnRehash(User* user, const std::string ¶meter)
{
/*
delete MyConf;
}
-
+
virtual Version GetVersion()
{
return Version(1,2,0,0,VF_COMMON|VF_VENDOR,API_VERSION);
}
-
+
};
MODULE_INIT(ModuleCensor)
{
if(user->registered == REG_ALL)
return CMD_FAILURE;
-
+
for(CGIHostlist::iterator iter = Hosts.begin(); iter != Hosts.end(); iter++)
{
if(ServerInstance->MatchText(user->host, iter->hostmask) || ServerInstance->MatchText(user->GetIPString(), iter->hostmask))
public:
ModuleCgiIRC(InspIRCd* Me) : Module(Me)
{
-
+
OnRehash(NULL,"");
mycommand = new CommandWebirc(Me, Hosts, NotifyOpers);
ServerInstance->AddCommand(mycommand);
ServerInstance->Modules->Attach(eventlist, this, 7);
}
-
+
virtual void Prioritize()
{
ServerInstance->Modules->SetPriority(this, I_OnUserConnect, PRIO_FIRST);
{
ConfigReader Conf(ServerInstance);
Hosts.clear();
-
+
NotifyOpers = Conf.ReadFlag("cgiirc", "opernotice", 0); // If we send an oper notice when a CGI:IRC has their host changed.
-
+
if(Conf.GetError() == CONF_VALUE_NOT_FOUND)
NotifyOpers = true;
-
+
for(int i = 0; i < Conf.Enumerate("cgihost"); i++)
{
std::string hostmask = Conf.ReadValue("cgihost", "mask", i); // An allowed CGI:IRC host
std::string type = Conf.ReadValue("cgihost", "type", i); // What type of user-munging we do on this host.
std::string password = Conf.ReadValue("cgihost", "password", i);
-
+
if(hostmask.length())
{
if (type == "webirc" && !password.length()) {
User* user = (User*)item;
std::string* realhost;
std::string* realip;
-
+
if(user->GetExt("cgiirc_realhost", realhost))
{
delete realhost;
user->Shrink("cgiirc_realhost");
}
-
+
if(user->GetExt("cgiirc_realip", realip))
{
delete realip;
}
}
}
-
+
virtual void OnSyncUserMetaData(User* user, Module* proto, void* opaque, const std::string &extname, bool displayable)
{
if((extname == "cgiirc_realhost") || (extname == "cgiirc_realip"))
{
std::string* data;
-
+
if(user->GetExt(extname, data))
{
proto->ProtoSendMetaData(opaque, TYPE_USER, user, extname, *data);
{
OnCleanup(TYPE_USER, user);
}
-
+
virtual int OnUserRegister(User* user)
- {
+ {
for(CGIHostlist::iterator iter = Hosts.begin(); iter != Hosts.end(); iter++)
- {
+ {
if(ServerInstance->MatchText(user->host, iter->hostmask) || ServerInstance->MatchText(user->GetIPString(), iter->hostmask))
{
// Deal with it...
bool valid=false;
ServerInstance->Users->RemoveCloneCounts(user);
#ifdef IPV6
- valid = (inet_pton(AF_INET6, webirc_ip->c_str(), &((sockaddr_in6*)user->ip)->sin6_addr) > 0);
+ valid = (inet_pton(AF_INET6, webirc_ip->c_str(), &((sockaddr_in6*)user->ip)->sin6_addr) > 0);
if(!valid)
valid = (inet_aton(webirc_ip->c_str(), &((sockaddr_in*)user->ip)->sin_addr));
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());
}
}
-
+
user->password.clear();
return true;
}
-
+
return false;
}
-
+
bool CheckIdent(User* user)
{
int ip[4];
const char* ident;
char newip[16];
int len = user->ident.length();
-
+
if(len == 8)
ident = user->ident.c_str();
else if(len == 9 && user->ident[0] == '~')
ident = user->ident.c_str() + 1;
else
return false;
-
+
for(int i = 0; i < 4; i++)
if(!HexToInt(ip[i], ident + i*2))
return false;
snprintf(newip, 16, "%d.%d.%d.%d", ip[0], ip[1], ip[2], ip[3]);
-
+
user->Extend("cgiirc_realhost", new std::string(user->host));
user->Extend("cgiirc_realip", new std::string(user->GetIPString()));
ServerInstance->Users->RemoveCloneCounts(user);
return true;
}
-
+
bool IsValidHost(const std::string &host)
{
if(!host.size())
return false;
-
+
for(unsigned int i = 0; i < host.size(); i++)
{
if( ((host[i] >= '0') && (host[i] <= '9')) ||
((host[i] >= 'a') && (host[i] <= 'z')) ||
((host[i] == '-') && (i > 0) && (i+1 < host.size()) && (host[i-1] != '.') && (host[i+1] != '.')) ||
((host[i] == '.') && (i > 0) && (i+1 < host.size())) )
-
+
continue;
else
return false;
}
-
+
return true;
}
{
if(ip.size() < 7 || ip.size() > 15)
return false;
-
+
short sincedot = 0;
short dots = 0;
-
+
for(unsigned int i = 0; i < ip.size(); i++)
{
if((dots <= 3) && (sincedot <= 3))
else
{
return false;
-
+
}
}
-
+
if(dots != 3)
return false;
-
+
return true;
}
-
+
bool HexToInt(int &out, const char* in)
{
char ip[3];
ip[1] = in[1];
ip[2] = 0;
out = strtol(ip, NULL, 16);
-
+
if(out > 255 || out < 0)
return false;
return true;
}
-
+
virtual ~ModuleCgiIRC()
{
}
-
+
virtual Version GetVersion()
{
return Version(1,2,0,0,VF_VENDOR,API_VERSION);
}
-
+
};
MODULE_INIT(ModuleCgiIRC)
Implementation eventlist[] = { I_OnUserJoin };
ServerInstance->Modules->Attach(eventlist, this, 1);
}
-
+
virtual ~ModuleChanCreate()
{
ServerInstance->SNO->DisableSnomask('j');
}
-
+
virtual Version GetVersion()
{
return Version(1,2,0,0,VF_VENDOR,API_VERSION);
}
-
+
virtual void OnUserJoin(User* user, Channel* channel, bool sync, bool &silent)
{
if (channel->GetUserCounter() == 1)
{
public:
ChanFilter(InspIRCd* Instance) : ListModeBase(Instance, 'g', "End of channel spamfilter list", 941, 940, false, "chanfilter") { }
-
+
virtual bool ValidateParam(User* user, Channel* chan, std::string &word)
{
if ((word.length() > 35) || (word.empty()))
user->WriteNumeric(935, "%s %s %s :word is too %s for censor list",user->nick.c_str(), chan->name.c_str(), word.c_str(), (word.empty() ? "short" : "long"));
return false;
}
-
+
return true;
}
-
+
virtual bool TellListTooLong(User* user, Channel* chan, std::string &word)
{
user->WriteNumeric(939, "%s %s %s :Channel spamfilter list is full", user->nick.c_str(), chan->name.c_str(), word.c_str());
return true;
}
-
+
virtual void TellAlreadyOnList(User* user, Channel* chan, std::string &word)
{
user->WriteNumeric(937, "%s %s :The word %s is already on the spamfilter list",user->nick.c_str(), chan->name.c_str(), word.c_str());
}
-
+
virtual void TellNotSet(User* user, Channel* chan, std::string &word)
{
user->WriteNumeric(938, "%s %s :No such spamfilter word is set",user->nick.c_str(), chan->name.c_str());
class ModuleChanFilter : public Module
{
-
+
ChanFilter* cf;
-
+
public:
-
+
ModuleChanFilter(InspIRCd* Me)
: Module(Me)
{
{
cf->DoCleanup(target_type, item);
}
-
+
virtual int OnUserPreNotice(User* user,void* dest,int target_type, std::string &text, char status, CUList &exempt_list)
{
return OnUserPreMessage(user,dest,target_type,text,status,exempt_list);
}
-
+
virtual void OnSyncChannel(Channel* chan, Module* proto, void* opaque)
{
cf->DoSyncChannel(chan, proto, opaque);
{
return Version(1, 2, 0, 0, VF_COMMON | VF_VENDOR, API_VERSION);
}
-
+
virtual ~ModuleChanFilter()
{
ServerInstance->Modes->DelMode(cf);
std::vector<std::string> mode_junk;
mode_junk.push_back(channel->name);
irc::modestacker modestack(MyInstance, false);
- std::deque<std::string> stackresult;
+ std::deque<std::string> stackresult;
for (CUList::iterator i = cl->begin(); i != cl->end(); i++)
{
}
// source has +q, is a server, or ulined, we'll let them +-a the user.
if (source == ServerInstance->FakeClient ||
- ((source == theuser) && (!adding) && (FounderProtectBase::remove_own_privs)) ||
+ ((source == theuser) && (!adding) && (FounderProtectBase::remove_own_privs)) ||
(ServerInstance->ULine(source->nick.c_str())) ||
(ServerInstance->ULine(source->server)) ||
(!*source->server) ||
class ModuleChanProtect : public Module
{
-
+
bool FirstInGetsFounder;
char QPrefix;
char APrefix;
bool booting;
ChanProtect* cp;
ChanFounder* cf;
-
+
public:
-
+
ModuleChanProtect(InspIRCd* Me)
: Module(Me), FirstInGetsFounder(false), QPrefix(0), APrefix(0), DeprivSelf(false), DeprivOthers(false), booting(true), cp(NULL), cf(NULL)
{
DeprivSelf = Conf.ReadFlag("options","deprotectself",0);
DeprivOthers = Conf.ReadFlag("options","deprotectothers",0);
}
-
+
virtual int OnUserPreJoin(User *user, Channel *chan, const char *cname, std::string &privs, const std::string &keygiven)
{
// if the user is the first user into the channel, mark them as the founder, but only if
if (FirstInGetsFounder && !chan)
privs = QPrefix + "@";
-
+
return 0;
}
-
+
virtual void OnPostJoin(User *user, Channel *channel)
{
// This *must* be in PostJoin, not UserJoin - the former will make it appear to happen
// before the client is in the channel
-
+
// This notice was here originally because it was all done prior to the creation of
// privs in OnUserPreJoin. I've left it because it might still be wanted, but i'm
// not sure it really should be here - ops don't get shown, obviously, and the prefix
if (FirstInGetsFounder && channel->GetUserCounter() == 1)
user->WriteServ("MODE %s +q %s", channel->name.c_str(), user->nick.c_str());
}
-
+
virtual int OnAccessCheck(User* source,User* dest,Channel* channel,int access_type)
{
// here we perform access checks, this is the important bit that actually stops kicking/deopping
// (B) Theyre protected, and you're not
// always allow the action if:
// (A) The source is ulined
-
-
+
+
// firstly, if a ulined nick, or a server, is setting the mode, then allow them to set the mode
// without any access checks, we're not worthy :p
if ((ServerInstance->ULine(source->nick.c_str())) || (ServerInstance->ULine(source->server)) || (!*source->server))
}
break;
}
-
+
// we dont know what this access check is, or dont care. just carry on, nothing to see here.
return ACR_DEFAULT;
}
-
+
virtual ~ModuleChanProtect()
{
ServerInstance->Modes->DelMode(cp);
delete cp;
delete cf;
}
-
+
virtual Version GetVersion()
{
return Version(1, 2, 0, 0, VF_COMMON | VF_VENDOR, API_VERSION);
user->WriteServ(checkstr + " modes " + targchan->ChanModes(true));
user->WriteServ(checkstr + " membercount " + ConvToStr(targchan->GetUserCounter()));
-
+
/* now the ugly bit, spool current members of a channel. :| */
CUList *ulist= targchan->GetUsers();
public:
ModuleCheck(InspIRCd* Me) : Module(Me)
{
-
+
mycommand = new CommandCheck(ServerInstance);
ServerInstance->AddCommand(mycommand);
}
-
+
virtual ~ModuleCheck()
{
}
-
+
virtual Version GetVersion()
{
return Version(1, 2, 0, 0, VF_VENDOR, API_VERSION);
}
-
+
};
MODULE_INIT(ModuleCheck)
syntax = "<nick> <newhost>";
TRANSLATE3(TR_NICK, TR_TEXT, TR_END);
}
-
+
CmdResult Handle(const std::vector<std::string> ¶meters, User *user)
{
const char * x = parameters[1].c_str();
user->WriteServ("NOTICE %s :*** CHGHOST: Host must be specified", user->nick.c_str());
return CMD_FAILURE;
}
-
+
if ((parameters[1].c_str() - x) > 63)
{
user->WriteServ("NOTICE %s :*** CHGHOST: Host too long", user->nick.c_str());
ServerInstance->Modules->Attach(eventlist, this, 1);
}
-
+
void OnRehash(User* user, const std::string ¶meter)
{
ConfigReader Conf(ServerInstance);
~ModuleChgHost()
{
}
-
+
Version GetVersion()
{
return Version(1, 2, 0, 0, VF_COMMON | VF_VENDOR, API_VERSION);
}
-
+
};
MODULE_INIT(ModuleChgHost)
syntax = "<nick> <newident>";
TRANSLATE3(TR_NICK, TR_TEXT, TR_END);
}
-
+
CmdResult Handle(const std::vector<std::string> ¶meters, User *user)
{
User* dest = ServerInstance->FindNick(parameters[0]);
user->WriteServ("NOTICE %s :*** CHGIDENT: Ident must be specified", user->nick.c_str());
return CMD_FAILURE;
}
-
+
if (parameters[1].length() > ServerInstance->Config->Limits.IdentMax)
{
user->WriteServ("NOTICE %s :*** CHGIDENT: Ident is too long", user->nick.c_str());
return CMD_FAILURE;
}
-
+
if (!ServerInstance->IsIdent(parameters[1].c_str()))
{
user->WriteServ("NOTICE %s :*** CHGIDENT: Invalid characters in ident", user->nick.c_str());
class ModuleChgIdent : public Module
{
CommandChgident* mycommand;
-
-
+
+
public:
ModuleChgIdent(InspIRCd* Me) : Module(Me)
{
ServerInstance->AddCommand(mycommand);
}
-
+
virtual ~ModuleChgIdent()
{
}
-
+
virtual Version GetVersion()
{
return Version(1, 2, 0, 0, VF_COMMON | VF_VENDOR, API_VERSION);
}
-
+
};
MODULE_INIT(ModuleChgIdent)
syntax = "<nick> <newname>";
TRANSLATE3(TR_NICK, TR_TEXT, TR_END);
}
-
+
CmdResult Handle(const std::vector<std::string> ¶meters, User *user)
{
User* dest = ServerInstance->FindNick(parameters[0]);
user->WriteNumeric(401, "%s %s :No such nick/channel", user->nick.c_str(), parameters[0].c_str());
return CMD_FAILURE;
}
-
+
if (parameters[1].empty())
{
user->WriteServ("NOTICE %s :*** GECOS must be specified", user->nick.c_str());
return CMD_FAILURE;
}
-
+
if (parameters[1].length() > ServerInstance->Config->Limits.MaxGecos)
{
user->WriteServ("NOTICE %s :*** GECOS too long", user->nick.c_str());
return CMD_FAILURE;
}
-
+
if (IS_LOCAL(dest))
{
dest->ChangeName(parameters[1].c_str());
class ModuleChgName : public Module
{
CommandChgname* mycommand;
-
-
+
+
public:
ModuleChgName(InspIRCd* Me) : Module(Me)
{
ServerInstance->AddCommand(mycommand);
}
-
+
virtual ~ModuleChgName()
{
}
-
+
virtual Version GetVersion()
{
return Version(1, 2, 0, 0, VF_COMMON | VF_VENDOR, API_VERSION);
}
-
+
};
MODULE_INIT(ModuleChgName)
* For example, if it is passed "svn.inspircd.org" it will return ".inspircd.org".
* If it is passed "brainbox.winbot.co.uk" it will return ".co.uk",
* and if it is passed "localhost.localdomain" it will return ".localdomain".
- *
+ *
* This is used to ensure a significant part of the host is always cloaked (see Bug #216)
*/
std::string LastTwoDomainParts(const std::string &host)
}
}
else
- {
+ {
if (dest->IsModeSet('x'))
{
- /* User is removing the mode, so just restore their real host
- * and make it match the displayed one.
+ /* User is removing the mode, so just restore their real host
+ * and make it match the displayed one.
*/
dest->ChangeDisplayedHost(dest->host.c_str());
dest->SetMode('x',false);
/* Stick them all together */
return irc::stringjoiner(":", hashies, 0, hashies.size() - 1).GetJoined();
}
-
+
void DoRehash()
{
ConfigReader Conf(ServerInstance);
bool lowercase;
-
- /* These are *not* using the need_positive parameter of ReadInteger -
+
+ /* These are *not* using the need_positive parameter of ReadInteger -
* that will limit the valid values to only the positive values in a
* signed int. Instead, accept any value that fits into an int and
* cast it to an unsigned int. That will, a bit oddly, give us the full
prefix = Conf.ReadValue("cloak","prefix",0);
ipalways = Conf.ReadFlag("cloak", "ipalways", 0);
lowercase = Conf.ReadFlag("cloak", "lowercase", 0);
-
+
if (!lowercase)
{
xtab[0] = "F92E45D871BCA630";
class ModuleCloaking : public Module
{
private:
-
+
CloakUser* cu;
Module* HashModule;
if (target_type == TYPE_USER)
OnUserDisconnect((User*)item);
}
-
+
virtual ~ModuleCloaking()
{
ServerInstance->Modes->DelMode(cu);
delete cu;
ServerInstance->Modules->DoneWithInterface("HashRequest");
}
-
+
virtual Version GetVersion()
{
// returns the version number of the module to be
std::string hostcloak = cu->prefix + "-" + std::string(HashSumRequest(this, cu->HashProvider, dest->host.c_str()).Send()).substr(0,8) + a;
/* Fix by brain - if the cloaked host is > the max length of a host (64 bytes
- * according to the DNS RFC) then tough titty, they get cloaked as an IP.
+ * according to the DNS RFC) then tough titty, they get cloaked as an IP.
* Their ISP shouldnt go to town on subdomains, or they shouldnt have a kiddie
* vhost.
*/
public:
ModuleClones(InspIRCd* Me) : Module(Me)
{
-
+
mycommand = new CommandClones(ServerInstance);
ServerInstance->AddCommand(mycommand);
}
-
+
virtual ~ModuleClones()
{
}
-
+
virtual Version GetVersion()
{
return Version(1, 2, 0, 0, VF_VENDOR, API_VERSION);
}
-
+
};
MODULE_INIT(ModuleClones)
*
* Based on the UnrealIRCd 4.0 (1.1.x fork) module
*
- * UnrealIRCd 4.0 (C) 2007 Carsten Valdemar Munk
+ * UnrealIRCd 4.0 (C) 2007 Carsten Valdemar Munk
* This program is free but copyrighted software; see
* the file COPYING for details.
*
user->WriteServ("NOTICE %s :*** %i unknown connection%s closed",user->nick.c_str(),total,(total>1)?"s":"");
else
user->WriteServ("NOTICE %s :*** No unknown connections found",user->nick.c_str());
-
+
return CMD_LOCALONLY;
}
};
return MODEACTION_ALLOW;
}
}
-
+
return MODEACTION_DENY;
}
};
ServerInstance->Modules->Attach(eventlist, this, 2);
}
-
+
virtual ~ModulePrivacyMode()
{
ServerInstance->Modes->DelMode(pm);
delete pm;
}
-
+
virtual Version GetVersion()
{
return Version(1,2,0,0, VF_COMMON|VF_VENDOR, API_VERSION);
private:
std::string JoinChan;
std::vector<std::string> Joinchans;
-
+
int tokenize(const std::string &str, std::vector<std::string> &tokens)
{
ModuleModesOnConnect(InspIRCd* Me)
: Module(Me)
{
-
+
Conf = new ConfigReader(ServerInstance);
Implementation eventlist[] = { I_OnPostConnect, I_OnRehash };
ServerInstance->Modules->Attach(eventlist, this, 2);
delete Conf;
Conf = new ConfigReader(ServerInstance);
}
-
+
virtual ~ModuleModesOnConnect()
{
delete Conf;
}
-
+
virtual Version GetVersion()
{
return Version(1,2,0,1,VF_VENDOR,API_VERSION);
}
-
+
virtual void OnPostConnect(User* user)
{
if (!IS_LOCAL(user))
Implementation eventlist[] = { I_OnUserRegister, I_OnCheckReady, I_OnPreCommand, I_OnRehash, I_OnUserDisconnect, I_OnCleanup };
ServerInstance->Modules->Attach(eventlist, this, 6);
}
-
+
virtual void OnRehash(User* user, const std::string ¶m)
{
ConfigReader Conf(ServerInstance);
-
+
sendsnotice = Conf.ReadFlag("waitpong", "sendsnotice", 0);
-
+
if(Conf.GetError() == CONF_VALUE_NOT_FOUND)
sendsnotice = true;
-
+
killonbadreply = Conf.ReadFlag("waitpong", "killonbadreply", 0);
if(Conf.GetError() == CONF_VALUE_NOT_FOUND)
for(unsigned int i = 0; i < length; i++)
out[i] = ((rand() % 26) + 65);
out[length] = '\0';
-
+
return (char*)out;
}
-
+
virtual int OnUserRegister(User* user)
{
char* pingrpl = RandString(10);
-
+
user->Write("PING :%s", pingrpl);
-
+
if(sendsnotice)
user->WriteServ("NOTICE %s :*** If you are having problems connecting due to ping timeouts, please type /quote PONG %s or /raw PONG %s now.", user->nick.c_str(), pingrpl, pingrpl);
-
+
user->Extend(extenstr, pingrpl);
return 0;
}
-
+
virtual int OnPreCommand(std::string &command, std::vector<std::string> ¶meters, User* user, bool validated, const std::string &original_line)
{
if (command == "PONG")
{
char* pingrpl;
user->GetExt(extenstr, pingrpl);
-
+
if (pingrpl)
{
if (strcmp(pingrpl, parameters[0].c_str()) == 0)
char* pingrpl;
return (!user->GetExt(extenstr, pingrpl));
}
-
+
virtual void OnUserDisconnect(User* user)
{
char* pingrpl;
user->Shrink(extenstr);
}
}
-
+
virtual void OnCleanup(int target_type, void* item)
{
if (target_type == TYPE_USER)
User* user = (User*)item;
char* pingrpl;
user->GetExt(extenstr, pingrpl);
-
+
if (pingrpl)
{
delete[] pingrpl;
user->Shrink(extenstr);
- }
+ }
}
}
-
+
virtual ~ModuleWaitPong()
{
}
-
+
virtual Version GetVersion()
{
return Version(1, 2, 0, 1, VF_VENDOR, API_VERSION);
}
-
+
};
MODULE_INIT(ModuleWaitPong)
ServerInstance->Modules->Attach(eventlist, this, 3);
OnRehash(NULL, "");
}
-
+
virtual ~ModuleQuitBan()
{
}
-
+
virtual Version GetVersion()
{
return Version(1,2,0,0,VF_VENDOR,API_VERSION);
std::string quitmsg;
ConfigReader* conf;
-
+
public:
ModuleConnFlood(InspIRCd* Me) : Module(Me)
{
-
+
InitConf();
Implementation eventlist[] = { I_OnRehash, I_OnUserRegister };
ServerInstance->Modules->Attach(eventlist, this, 2);
return Version(1,2,0,0,VF_VENDOR,API_VERSION);
}
-
void InitConf()
{
/* read configuration variables */
first = ServerInstance->Time();
}
-
+
virtual int OnUserRegister(User* user)
{
time_t next = ServerInstance->Time();
-
+
if ((ServerInstance->startup_time + boot_wait) > next)
return 0;
-
+
/* time difference between first and latest connection */
time_t tdiff = next - first;
*/
class CommandTitle : public Command
{
-
public:
CommandTitle (InspIRCd* Instance) : Command(Instance,"TITLE",0,2)
{
TRANSLATE3(TR_NICK, TR_TEXT, TR_END);
}
-bool OneOfMatches(const char* host, const char* ip, const char* hostlist)
-{
- std::stringstream hl(hostlist);
- std::string xhost;
- while (hl >> xhost)
- {
- if (match(host, xhost) || match(ip,xhost, true))
- {
- return true;
- }
- }
- return false;
-}
+ bool OneOfMatches(const char* host, const char* ip, const char* hostlist)
+ {
+ std::stringstream hl(hostlist);
+ std::string xhost;
+ while (hl >> xhost)
+ {
+ if (match(host, xhost) || match(ip,xhost, true))
+ {
+ return true;
+ }
+ }
+ return false;
+ }
CmdResult Handle(const std::vector<std::string> ¶meters, User* user)
{
if (!IS_LOCAL(user))
return CMD_LOCALONLY;
-
+
char TheHost[MAXBUF];
char TheIP[MAXBUF];
user->Extend("ctitle", text);
ServerInstance->PI->SendMetaData(user, TYPE_USER, "ctitle", *text);
-
+
if (!vhost.empty())
user->ChangeDisplayedHost(vhost.c_str());
class ModuleCustomTitle : public Module
{
CommandTitle* mycommand;
-
+
public:
ModuleCustomTitle(InspIRCd* Me) : Module(Me)
{
-
+
mycommand = new CommandTitle(ServerInstance);
ServerInstance->AddCommand(mycommand);
Implementation eventlist[] = { I_OnDecodeMetaData, I_OnWhoisLine, I_OnSyncUserMetaData, I_OnUserQuit, I_OnCleanup };
}
}
}
-
+
virtual ~ModuleCustomTitle()
{
}
-
+
virtual Version GetVersion()
{
return Version(1, 2, 0, 0, VF_COMMON | VF_VENDOR, API_VERSION);
{
Channel* channel = ServerInstance->FindChan(parameters[0]);
std::string reason = ConvToStr("Cycling");
-
+
if (parameters.size() > 1)
{
/* reason provided, use it */
reason = reason + ": " + parameters[1];
}
-
+
if (!channel)
{
user->WriteNumeric(403, "%s %s :No such channel", user->nick.c_str(), parameters[0].c_str());
return CMD_FAILURE;
}
-
+
if (channel->HasUser(user))
{
/*
user->WriteServ("NOTICE "+std::string(user->nick)+" :*** You may not cycle, as you are banned on channel " + channel->name);
return CMD_FAILURE;
}
-
+
/* XXX in the future, this may move to a static Channel method (the delete.) -- w00t */
if (!channel->PartUser(user, reason.c_str()))
delete channel;
-
+
Channel::JoinUser(ServerInstance, user, parameters[0].c_str(), true, "", false, ServerInstance->Time());
}
ModuleCycle(InspIRCd* Me)
: Module(Me)
{
-
+
mycommand = new CommandCycle(ServerInstance);
ServerInstance->AddCommand(mycommand);
}
-
+
virtual ~ModuleCycle()
{
}
-
+
virtual Version GetVersion()
{
return Version(1, 2, 0, 1, VF_COMMON | VF_VENDOR, API_VERSION);
}
-
+
};
MODULE_INIT(ModuleCycle)
else if (parameters.size() > 0)
{
char action = *parameters[0].c_str();
-
+
// if they didn't specify an action, this is probably a command
if (action != '+' && action != '-')
{
// list current DCCALLOW list
DisplayDCCAllowList(user);
return CMD_FAILURE;
- }
+ }
else if (!strcasecmp(parameters[0].c_str(), "HELP"))
{
// display help
return CMD_FAILURE;
}
}
-
+
std::string nick = parameters[0].substr(1);
User *target = ServerInstance->FindNick(nick);
-
+
if (target)
{
-
+
if (action == '-')
{
// check if it contains any entries
{
delete dl;
user->Shrink("dccallow_list");
-
+
// remove from userlist
for (userlist::iterator j = ul.begin(); j != ul.end(); ++j)
{
return CMD_FAILURE;
}
}
-
+
std::string mask = std::string(target->nick)+"!"+std::string(target->ident)+"@"+std::string(target->dhost);
std::string default_length = Conf->ReadValue("dccallow", "length", 0);
-
+
long length;
if (parameters.size() < 2)
{
length = ServerInstance->Duration(default_length);
- }
+ }
else if (!atoi(parameters[1].c_str()))
{
length = 0;
{
length = ServerInstance->Duration(parameters[1]);
}
-
+
if (!ServerInstance->IsValidMask(mask.c_str()))
{
return CMD_FAILURE;
}
-
+
dl->push_back(DCCAllow(target->nick, mask, ServerInstance->Time(), length));
-
+
if (length > 0)
{
user->WriteNumeric(993, "%s %s :Added %s to DCCALLOW list for %ld seconds", user->nick.c_str(), user->nick.c_str(), target->nick.c_str(), length);
user->WriteNumeric(998, "%s : your DCCALLOW list will be deleted when you leave IRC.", user->nick.c_str());
user->WriteNumeric(999, "%s :End of DCCALLOW HELP", user->nick.c_str());
}
-
+
void DisplayDCCAllowList(User* user)
{
// display current DCCALLOW list
user->WriteNumeric(990, "%s :Users on your DCCALLOW list:", user->nick.c_str());
-
+
if (user->GetExt("dccallow_list", dl))
{
for (dccallowlist::const_iterator c = dl->begin(); c != dl->end(); ++c)
user->WriteNumeric(991, "%s %s :%s (%s)", user->nick.c_str(), user->nick.c_str(), c->nickname.c_str(), c->hostmask.c_str());
}
}
-
+
user->WriteNumeric(992, "%s :End of DCCALLOW list", user->nick.c_str());
- }
+ }
};
-
+
class ModuleDCCAllow : public Module
{
CommandDccallow* mycommand;
virtual void OnUserQuit(User* user, const std::string &reason, const std::string &oper_message)
{
dccallowlist* udl;
-
+
// remove their DCCALLOW list if they have one
if (user->GetExt("dccallow_list", udl))
{
user->Shrink("dccallow_list");
RemoveFromUserlist(user);
}
-
+
// remove them from any DCCALLOW lists
// they are currently on
RemoveNick(user);
/* Always allow a user to dcc themselves (although... why?) */
if (user == u)
return 0;
-
+
if ((text.length()) && (text[0] == '\1'))
{
Expire();
// :jamie!jamie@test-D4457903BA652E0F.silverdream.org PRIVMSG eimaj :DCC SEND m_dnsbl.cpp 3232235786 52650 9676
// :jamie!jamie@test-D4457903BA652E0F.silverdream.org PRIVMSG eimaj :VERSION
-
+
if (strncmp(text.c_str(), "\1DCC ", 5) == 0)
- {
+ {
if (u->GetExt("dccallow_list", dl) && dl->size())
{
for (dccallowlist::const_iterator iter = dl->begin(); iter != dl->end(); ++iter)
if (ServerInstance->MatchText(user->GetFullHost(), iter->hostmask))
return 0;
}
-
+
// tokenize
std::stringstream ss(text);
std::string buf;
std::vector<std::string> tokens;
-
+
while (ss >> buf)
tokens.push_back(buf);
-
+
irc::string type = tokens[1].c_str();
-
+
bool blockchat = Conf->ReadFlag("dccallow", "blockchat", 0);
-
+
if (type == "SEND")
{
std::string defaultaction = Conf->ReadValue("dccallow", "action", 0);
std::string filename = tokens[2];
-
- if (defaultaction == "allow")
+
+ if (defaultaction == "allow")
return 0;
-
+
for (unsigned int i = 0; i < bfl.size(); i++)
{
if (ServerInstance->MatchText(filename, bfl[i].filemask))
}
return 0;
}
-
+
void Expire()
{
for (userlist::iterator iter = ul.begin(); iter != ul.end(); ++iter)
}
}
}
-
+
void RemoveNick(User* user)
{
/* Iterate through all DCCALLOW lists and remove user */
{
if (i->nickname == user->nick)
{
-
+
u->WriteServ("NOTICE %s :%s left the network or changed their nickname and has been removed from your DCCALLOW list", u->nick.c_str(), i->nickname.c_str());
u->WriteNumeric(995, "%s %s :Removed %s from your DCCALLOW list", u->nick.c_str(), u->nick.c_str(), i->nickname.c_str());
dl->erase(i);
bf.action = action;
bfl.push_back(bf);
}
-
+
}
virtual ~ModuleDCCAllow()
Implementation eventlist[] = { I_OnUserJoin, I_OnUserPart, I_OnUserKick, I_OnUserQuit, I_OnNamesListItem, I_OnText };
ServerInstance->Modules->Attach(eventlist, this, 6);
}
-
+
virtual ~ModuleDelayJoin()
{
ServerInstance->Modes->DelMode(djm);
user->Shrink("delayjoin_"+channel->name);
/* Check if the user is left on any other +D channels, if so don't take away the
- * metadata that says theyre on one or more channels
+ * metadata that says theyre on one or more channels
*/
for (UCListIter f = user->chans.begin(); f != user->chans.end(); f++)
if (f->first->IsModeSet('D'))
{
private:
-
+
ConfigReader *Conf;
public:
ModuleDenyChannels(InspIRCd* Me) : Module(Me)
{
-
+
Conf = new ConfigReader(ServerInstance);
Implementation eventlist[] = { I_OnUserPreJoin, I_OnRehash };
ServerInstance->Modules->Attach(eventlist, this, 2);
}
-
+
virtual void OnRehash(User* user, const std::string ¶m)
{
delete Conf;
{
std::string name = Conf->ReadValue("badchan","name",i);
std::string redirect = Conf->ReadValue("badchan","redirect",i);
-
+
if (!redirect.empty())
{
-
+
if (!ServerInstance->IsChannel(redirect.c_str(), ServerInstance->Config->Limits.ChanMax))
{
if (user)
user->WriteServ("Notice %s :Invalid badchan redirect '%s'", user->nick.c_str(), redirect.c_str());
throw ModuleException("Invalid badchan redirect, not a channel");
}
-
+
for (int j =0; j < Conf->Enumerate("badchan"); j++)
{
if (match(redirect, Conf->ReadValue("badchan","name",j)))
if (match(redirect, Conf->ReadValue("goodchan","name",k)))
goodchan = true;
}
-
+
if (!goodchan)
{
/* <badchan:redirect> is a badchan */
{
delete Conf;
}
-
+
virtual Version GetVersion()
{
return Version(1,2,0,1,VF_VENDOR,API_VERSION);
return 0;
}
}
-
+
if (ServerInstance->IsChannel(redirect.c_str(), ServerInstance->Config->Limits.ChanMax))
{
/* simple way to avoid potential loops: don't redirect to +L channels */
{
ServerInstance->XLines->ApplyLines();
}
- else
+ else
delete zl;
break;
}
e->banaction = str2banaction(MyConf->ReadValue("dnsbl", "action", i));
e->duration = ServerInstance->Duration(MyConf->ReadValue("dnsbl", "duration", i));
-
+
/* Use portparser for record replies */
/* yeah, logic here is a little messy */
/* don't do anything with this hot potato */
return 0;
}
-
+
virtual int OnStats(char symbol, User* user, string_list &results)
{
if (symbol != 'd')
return 0;
-
+
unsigned long total_hits = 0, total_misses = 0;
for (std::vector<DNSBLConfEntry*>::iterator i = DNSBLConfEntries.begin(); i != DNSBLConfEntries.end(); i++)
{
total_hits += (*i)->stats_hits;
total_misses += (*i)->stats_misses;
-
+
results.push_back(std::string(ServerInstance->Config->ServerName) + " 304 " + user->nick + " :DNSBLSTATS DNSbl \"" + (*i)->name + "\" had " +
ConvToStr((*i)->stats_hits) + " hits and " + ConvToStr((*i)->stats_misses) + " misses");
}
-
+
results.push_back(std::string(ServerInstance->Config->ServerName) + " 304 " + user->nick + " :DNSBLSTATS Total hits: " + ConvToStr(total_hits));
results.push_back(std::string(ServerInstance->Config->ServerName) + " 304 " + user->nick + " :DNSBLSTATS Total misses: " + ConvToStr(total_misses));
-
+
return 0;
}
};
class ModuleFilter : public FilterBase
{
-
+
filter_t filters;
public:
OnRehash(NULL,"");
}
-
+
virtual ~ModuleFilter()
{
}
class ModuleFoobar : public Module
{
private:
-
+
// It is recommended that your class makes use of one or more Server
// objects. A server object is a class which contains methods which
// encapsulate the exports from the core of the ircd.
// such methods include Debug, SendChannel, etc.
-
-
+
+
public:
ModuleFoobar(InspIRCd* Me)
: Module(Me)
{
// The constructor just makes a copy of the server class
-
-
+
+
Implementation eventlist[] = { I_OnUserConnect, I_OnUserQuit, I_OnUserJoin, I_OnUserPart, I_OnUserPreJoin };
ServerInstance->Modules->Attach(eventlist, this, 5);
}
-
+
virtual ~ModuleFoobar()
{
}
-
+
virtual Version GetVersion()
{
// this method instantiates a class of type Version, and returns
// the modules version information using it.
-
+
return Version(1,2,0,1,VF_VENDOR,API_VERSION);
}
-
+
virtual void OnUserConnect(User* user)
{
// method called when a user connects
-
+
std::string b = user->nick;
ServerInstance->Logs->Log("m_foobar",DEBUG,"Foobar: User connecting: "+b);
}
virtual void OnUserQuit(User* user, const std::string &reason, const std::string &oper_message)
{
// method called when a user disconnects
-
+
std::string b = user->nick;
ServerInstance->Logs->Log("m_foobar",DEBUG,"Foobar: User quitting: "+b);
}
-
+
virtual void OnUserJoin(User* user, Channel* channel, bool sync, bool &silent)
{
// method called when a user joins a channel
virtual void OnUserPart(User* user, Channel* channel, const std::string &partreason, bool &silent)
{
// method called when a user parts a channel
-
+
std::string c = channel->name;
std::string b = user->nick;
ServerInstance->Logs->Log("m_foobar",DEBUG,"Foobar: User "+b+" parted "+c);
CommandGloadmodule *mycommand;
CommandGunloadmodule *mycommand2;
CommandGreloadmodule *mycommand3;
-
+
public:
ModuleGlobalLoad(InspIRCd* Me) : Module(Me)
{
-
+
mycommand = new CommandGloadmodule(ServerInstance);
mycommand2 = new CommandGunloadmodule(ServerInstance);
mycommand3 = new CommandGreloadmodule(ServerInstance);
ServerInstance->AddCommand(mycommand3);
}
-
+
virtual ~ModuleGlobalLoad()
{
}
-
+
virtual Version GetVersion()
{
return Version(1, 2, 0, 0, VF_COMMON | VF_VENDOR, API_VERSION);
ServerInstance->SNO->EnableSnomask('g',"GLOBOPS");
}
-
+
virtual ~ModuleGlobops()
{
ServerInstance->SNO->DisableSnomask('g');
}
-
+
virtual Version GetVersion()
{
return Version(1, 2, 0, 1, VF_COMMON | VF_VENDOR, API_VERSION);
user->WriteServ("NOTICE %s :HELPOP topic index", user->nick.c_str());
for (std::map<irc::string, std::string>::iterator iter = helpop_map.begin(); iter != helpop_map.end(); iter++)
{
- user->WriteServ("NOTICE %s : %s", user->nick.c_str(), iter->first.c_str());
+ user->WriteServ("NOTICE %s : %s", user->nick.c_str(), iter->first.c_str());
}
user->WriteServ("NOTICE %s :*** End of HELPOP topic index", user->nick.c_str());
}
ServerInstance->Modes->DelMode(ho);
delete ho;
}
-
+
virtual Version GetVersion()
{
return Version(1,2,0,1,VF_COMMON|VF_VENDOR,API_VERSION);
return MODEACTION_ALLOW;
}
}
-
+
return MODEACTION_DENY;
}
};
class ModuleHideChans : public Module
{
-
+
HideChans* hm;
public:
ModuleHideChans(InspIRCd* Me)
: Module(Me)
{
-
+
hm = new HideChans(ServerInstance);
if (!ServerInstance->Modes->AddMode(hm))
throw ModuleException("Could not add new modes!");
ServerInstance->Modules->Attach(eventlist, this, 1);
}
-
+
virtual ~ModuleHideChans()
{
ServerInstance->Modes->DelMode(hm);
delete hm;
}
-
+
virtual Version GetVersion()
{
return Version(1,2,0,0,VF_COMMON|VF_VENDOR,API_VERSION);
return MODEACTION_ALLOW;
}
}
-
+
return MODEACTION_DENY;
}
};
class ModuleHideOper : public Module
{
-
+
HideOper* hm;
public:
ModuleHideOper(InspIRCd* Me)
: Module(Me)
{
-
+
hm = new HideOper(ServerInstance);
if (!ServerInstance->Modes->AddMode(hm))
throw ModuleException("Could not add new modes!");
ServerInstance->Modules->Attach(eventlist, this, 1);
}
-
+
virtual ~ModuleHideOper()
{
ServerInstance->Modes->DelMode(hm);
delete hm;
}
-
+
virtual Version GetVersion()
{
return Version(1,2,0,0,VF_COMMON|VF_VENDOR,API_VERSION);
std::string MySuffix;
std::string MyPrefix;
std::string MySeparator;
-
+
public:
ModuleHostChange(InspIRCd* Me)
: Module(Me)
Implementation eventlist[] = { I_OnRehash, I_OnUserConnect };
ServerInstance->Modules->Attach(eventlist, this, 2);
}
-
+
virtual ~ModuleHostChange()
{
for (hostchanges_t::iterator i = hostchanges.begin(); i != hostchanges.end(); i++)
hostchanges[mask] = x;
}
}
-
+
virtual Version GetVersion()
{
// returns the version number of the module to be
// listed in /MODULES
return Version(1,2,0,1,VF_VENDOR,API_VERSION);
}
-
+
virtual void OnUserConnect(User* user)
{
for (hostchanges_t::iterator i = hostchanges.begin(); i != hostchanges.end(); i++)
}
if (complete.empty())
complete = "i-have-a-lame-nick";
-
+
if (!MyPrefix.empty())
newhost = MyPrefix + MySeparator + complete;
else
{
FileReader* index;
HttpState InternalState;
-
+
HTTPHeaders headers;
std::string reqbuffer;
std::string postdata;
std::string request_type;
std::string uri;
std::string http_version;
-
+
public:
HttpServerSocket(InspIRCd* SI, std::string shost, int iport, bool listening, unsigned long maxtime, FileReader* index_page) : BufferedSocket(SI, shost, iport, listening, maxtime), index(index_page), postsize(0)
~HttpServerSocket()
{
}
-
+
virtual int OnIncomingConnection(int newsock, char* ip)
{
if (InternalState == HTTP_LISTEN)
default:
return "WTF";
break;
-
+
}
}
-
+
void SendHTTPError(int response)
{
HTTPHeaders empty;
std::string data = "<html><head></head><body>Server error "+ConvToStr(response)+": "+Response(response)+"<br>"+
"<small>Powered by <a href='http://www.inspircd.org'>InspIRCd</a></small></body></html>";
-
+
SendHeaders(data.length(), response, empty);
this->Write(data);
this->FlushWriteBuffer();
}
-
+
void SendHeaders(unsigned long size, int response, HTTPHeaders &rheaders)
{
char *date = asctime(timeinfo);
date[strlen(date) - 1] = '\0';
rheaders.CreateHeader("Date", date);
-
+
rheaders.CreateHeader("Server", "InspIRCd/m_httpd.so/1.2");
rheaders.SetHeader("Content-Length", ConvToStr(size));
-
+
if (size)
rheaders.CreateHeader("Content-Type", "text/html");
else
rheaders.RemoveHeader("Content-Type");
-
+
/* Supporting Connection: keep-alive causes a whole world of hurt syncronizing timeouts,
* so remove it, its not essential for what we need.
*/
rheaders.SetHeader("Connection", "Close");
-
+
this->Write(rheaders.GetFormattedHeaders());
this->Write("\r\n");
}
/* Check that the data read is a valid pointer and it has some content */
if (!data || !*data)
return false;
-
+
if (InternalState == HTTP_SERVE_RECV_POSTDATA)
{
postdata.append(data);
else
{
reqbuffer.append(data);
-
+
if (reqbuffer.length() >= 8192)
{
Instance->Logs->Log("m_httpd",DEBUG, "m_httpd dropped connection due to an oversized request buffer");
reqbuffer.clear();
return false;
}
-
+
if (InternalState == HTTP_SERVE_WAIT_REQUEST)
CheckRequestBuffer();
}
-
+
return true;
}
-
+
void CheckRequestBuffer()
{
std::string::size_type reqend = reqbuffer.find("\r\n\r\n");
if (reqend == std::string::npos)
return;
-
+
// We have the headers; parse them all
std::string::size_type hbegin = 0, hend;
while ((hend = reqbuffer.find("\r\n", hbegin)) != std::string::npos)
{
if (hbegin == hend)
break;
-
+
if (request_type.empty())
{
std::istringstream cheader(std::string(reqbuffer, hbegin, hend - hbegin));
cheader >> request_type;
cheader >> uri;
cheader >> http_version;
-
+
if (request_type.empty() || uri.empty() || http_version.empty())
{
SendHTTPError(400);
SetWrite();
return;
}
-
+
hbegin = hend + 2;
continue;
}
-
+
std::string cheader = reqbuffer.substr(hbegin, hend - hbegin);
-
+
std::string::size_type fieldsep = cheader.find(':');
if ((fieldsep == std::string::npos) || (fieldsep == 0) || (fieldsep == cheader.length() - 1))
{
SetWrite();
return;
}
-
+
headers.SetHeader(cheader.substr(0, fieldsep), cheader.substr(fieldsep + 2));
-
+
hbegin = hend + 2;
}
-
+
reqbuffer.erase(0, reqend + 4);
-
+
std::transform(request_type.begin(), request_type.end(), request_type.begin(), ::toupper);
std::transform(http_version.begin(), http_version.end(), http_version.begin(), ::toupper);
-
+
if ((http_version != "HTTP/1.1") && (http_version != "HTTP/1.0"))
{
SendHTTPError(505);
SetWrite();
return;
}
-
+
if (headers.IsSet("Content-Length") && (postsize = atoi(headers.GetHeader("Content-Length").c_str())) != 0)
{
InternalState = HTTP_SERVE_RECV_POSTDATA;
-
+
if (reqbuffer.length() >= postsize)
{
postdata = reqbuffer.substr(0, postsize);
postdata = reqbuffer;
reqbuffer.clear();
}
-
+
if (postdata.length() >= postsize)
ServeData();
-
+
return;
}
-
+
ServeData();
}
class ModuleHTTPAccessList : public Module
{
-
+
std::string stylesheet;
bool changed;
std::vector<HTTPACL> acl_list;
irc::spacesepstream sep(authorization);
std::string authtype;
std::string base64;
-
+
sep.GetToken(authtype);
if (authtype == "Basic")
{
class ModuleHttpStats : public Module
{
-
+
std::string stylesheet;
bool changed;
class ModuleHttpStats : public Module
{
-
+
std::string stylesheet;
bool changed;
}
data << "</userlist><serverlist>";
-
+
ProtoServerList sl;
ServerInstance->PI->GetServerList(sl);
* Using this framework we have a much more stable module.
*
* A few things to note:
- *
+ *
* O The only place that may *delete* an active or inactive
* ident socket is OnUserDisconnect in the module class.
* Because this is out of scope of the socket class there is
*
* O Closure of the ident socket with the Close() method will
* not cause removal of the socket from memory or detatchment
- * from its 'parent' User class. It will only flag it as an
+ * from its 'parent' User class. It will only flag it as an
* inactive socket in the socket engine.
*
* O Timeouts are handled in OnCheckReaady at the same time as
/* We allocate two of these because sizeof(sockaddr_in6) > sizeof(sockaddr_in) */
sockaddr* s = new sockaddr[2];
sockaddr* addr = new sockaddr[2];
-
+
#ifdef IPV6
/* Horrid icky nasty ugly berkely socket crap. */
if (v6)
#else
int req_size = snprintf(req, sizeof(req), "%d,%d\r\n", ntohs(raddr.sin6_port), ntohs(laddr.sin6_port));
#endif
-
+
/* Send failed if we didnt write the whole ident request --
* might as well give up if this happens!
*/
Implementation eventlist[] = { I_OnRehash, I_OnUserRegister, I_OnCheckReady, I_OnCleanup, I_OnUserDisconnect };
ServerInstance->Modules->Attach(eventlist, this, 5);
}
-
+
virtual Version GetVersion()
{
return Version(1, 2, 1, 0, VF_VENDOR, API_VERSION);
}
-
-
+
+
virtual void OnRehash(User *user, const std::string ¶m)
{
ConfigReader MyConf(ServerInstance);
-
+
RequestTimeout = MyConf.ReadInteger("ident", "timeout", 0, true);
if (!RequestTimeout)
RequestTimeout = 5;
}
-
+
virtual int OnUserRegister(User *user)
{
/* User::ident is currently the username field from USER; with m_ident loaded, that
return Version(1, 2, 0, 0, VF_COMMON | VF_VENDOR, API_VERSION);
}
-
+
virtual void OnUserJoin(User* user, Channel* channel, bool sync, bool &silent)
{
if (user->IsModeSet('Q'))
}
return 0;
}
-
+
virtual int OnUserPreMessage(User* user,void* dest,int target_type, std::string &text, char status, CUList &exempt_list)
{
return OnUserPreNotice(user, dest, target_type, text, status, exempt_list);
va_list argsPtr;
char textbuffer[MAXBUF];
char tb[MAXBUF];
-
+
va_start(argsPtr, text);
vsnprintf(textbuffer, MAXBUF, text, argsPtr);
va_end(argsPtr);
snprintf(tb,MAXBUF,":%s %s",user->GetFullHost().c_str(), textbuffer);
-
+
CUList *ulist = channel->GetUsers();
-
+
for (CUList::iterator i = ulist->begin(); i != ulist->end(); i++)
{
/* User only appears to vanish for non-opers */
Implementation eventlist[] = { I_OnRequest, I_On005Numeric, I_OnCheckInvite };
ServerInstance->Modules->Attach(eventlist, this, 3);
}
-
+
virtual void On005Numeric(std::string &output)
{
output.append(" INVEX=I");
}
-
+
virtual int OnCheckInvite(User* user, Channel* chan)
{
if(chan != NULL)
// or if there wasn't a list, there can't be anyone on it, so we don't need to do anything.
}
- return 0;
+ return 0;
}
virtual const char* OnRequest(Request* request)
{
ie->DoRehash();
}
-
+
virtual Version GetVersion()
{
return Version(1, 2, 0, 3, VF_VENDOR | VF_COMMON, API_VERSION);
return std::make_pair(true, ConvToStr(x->joins)+":"+ConvToStr(x->secs));
else
return std::make_pair(false, parameter);
- }
+ }
bool CheckTimeStamp(time_t theirs, time_t ours, const std::string &their_param, const std::string &our_param, Channel* channel)
{
class ModuleJoinFlood : public Module
{
-
+
JoinFlood* jf;
-
+
public:
-
+
ModuleJoinFlood(InspIRCd* Me)
: Module(Me)
{
-
+
jf = new JoinFlood(ServerInstance);
if (!ServerInstance->Modes->AddMode(jf))
throw ModuleException("Could not add new modes!");
Implementation eventlist[] = { I_OnChannelDelete, I_OnUserPreJoin, I_OnUserJoin };
ServerInstance->Modules->Attach(eventlist, this, 3);
}
-
+
virtual int OnUserPreJoin(User* user, Channel* chan, const char* cname, std::string &privs, const std::string &keygiven)
{
if (chan)
ServerInstance->Modes->DelMode(jf);
delete jf;
}
-
+
virtual Version GetVersion()
{
return Version(1, 2, 0, 0, VF_COMMON | VF_VENDOR, API_VERSION);
ModuleJumpServer(InspIRCd* Me)
: Module(Me)
{
-
+
js = new CommandJumpserver(ServerInstance);
ServerInstance->AddCommand(js);
Implementation eventlist[] = { I_OnUserRegister };
ServerInstance->Modules->Attach(eventlist, this, 1);
}
-
+
virtual ~ModuleJumpServer()
{
}
{
return Version(1,2,0,1,VF_VENDOR,API_VERSION);
}
-
+
};
MODULE_INIT(ModuleJumpServer)
return std::make_pair(true, channel->GetModeParameter('J'));
else
return std::make_pair(false, parameter);
- }
+ }
bool CheckTimeStamp(time_t theirs, time_t ours, const std::string &their_param, const std::string &our_param, Channel* channel)
{
/* When TS is equal, the alphabetically later one wins */
return (their_param < our_param);
}
-
+
ModeAction OnModeChange(User* source, User* dest, Channel* channel, std::string ¶meter, bool adding, bool)
{
if (!adding)
{
// Taking the mode off, we need to clean up.
delaylist* dl;
-
+
if (channel->GetExt("norejoinusers", dl))
{
delete dl;
channel->Shrink("norejoinusers");
}
-
+
if (!channel->IsModeSet('J'))
{
return MODEACTION_DENY;
class ModuleKickNoRejoin : public Module
{
-
+
KickRejoin* kr;
-
+
public:
-
+
ModuleKickNoRejoin(InspIRCd* Me)
: Module(Me)
{
-
+
kr = new KickRejoin(ServerInstance);
if (!ServerInstance->Modes->AddMode(kr))
throw ModuleException("Could not add new modes!");
if (chan->GetExt("norejoinusers", dl))
{
std::vector<User*> itemstoremove;
-
+
for (delaylist::iterator iter = dl->begin(); iter != dl->end(); iter++)
{
if (iter->second > time(NULL))
{
- if (iter->first == user)
+ if (iter->first == user)
{
user->WriteNumeric(495, "%s %s :You must wait %s seconds after being kicked to rejoin (+J)", user->nick.c_str(), chan->name.c_str(), chan->GetModeParameter('J').c_str());
return 1;
itemstoremove.push_back(iter->first);
}
}
-
+
for (unsigned int i = 0; i < itemstoremove.size(); i++)
dl->erase(itemstoremove[i]);
-
+
if (!dl->size())
{
// Now it's empty..
}
return 0;
}
-
+
virtual void OnUserKick(User* source, User* user, Channel* chan, const std::string &reason, bool &silent)
{
if (chan->IsModeSet('J') && (source != user))
(*dl)[user] = time(NULL) + strtoint(chan->GetModeParameter('J'));
}
}
-
+
virtual void OnChannelDelete(Channel* chan)
{
delaylist* dl;
-
+
if (chan->GetExt("norejoinusers", dl))
{
delete dl;
chan->Shrink("norejoinusers");
}
}
-
+
virtual void OnCleanup(int target_type, void* item)
{
if(target_type == TYPE_CHANNEL)
ServerInstance->Modes->DelMode(kr);
delete kr;
}
-
+
virtual Version GetVersion()
{
return Version(1, 2, 0, 0, VF_COMMON | VF_VENDOR, API_VERSION);
syntax = "<channel> <reason>";
TRANSLATE3(TR_TEXT, TR_TEXT, TR_END);
}
-
+
CmdResult Handle (const std::vector<std::string> ¶meters, User *user)
{
Channel* c = ServerInstance->FindChan(parameters[0]);
void byteSwap(word32 *buf, unsigned words)
{
byte *p = (byte *)buf;
-
+
do
{
*buf++ = (word32)((unsigned)p[3] << 8 | p[2]) << 16 |
ctx->buf[2] = ikey[2];
ctx->buf[3] = ikey[3];
}
-
+
ctx->bytes[0] = 0;
ctx->bytes[1] = 0;
}
void MD5Update(MD5Context *ctx, byte const *buf, int len)
{
word32 t;
-
+
/* Update byte count */
-
+
t = ctx->bytes[0];
if ((ctx->bytes[0] = t + len) < t)
ctx->bytes[1]++; /* Carry from low to high */
-
+
t = 64 - (t & 0x3f); /* Space available in ctx->in (at least 1) */
if ((unsigned)t > (unsigned)len)
{
MD5Transform(ctx->buf, ctx->in);
buf += (unsigned)t;
len -= (unsigned)t;
-
+
/* Process data in 64-byte chunks */
while (len >= 64)
{
buf += 64;
len -= 64;
}
-
+
/* Handle any remaining bytes of data. */
memcpy(ctx->in, buf, len);
}
-
+
void MD5Final(byte digest[16], MD5Context *ctx)
{
int count = (int)(ctx->bytes[0] & 0x3f); /* Bytes in ctx->in */
byte *p = (byte *)ctx->in + count; /* First unused byte */
-
+
/* Set the first char of padding to 0x80. There is always room. */
*p++ = 0x80;
-
+
/* Bytes of padding needed to make 56 bytes (-8..55) */
count = 56 - 1 - count;
-
+
if (count < 0)
{ /* Padding forces an extra block */
memset(p, 0, count+8);
}
memset(p, 0, count+8);
byteSwap(ctx->in, 14);
-
+
/* Append length in bits and transform */
ctx->in[14] = ctx->bytes[0] << 3;
ctx->in[15] = ctx->bytes[1] << 3 | ctx->bytes[0] >> 29;
MD5Transform(ctx->buf, ctx->in);
-
+
byteSwap(ctx->buf, 4);
memcpy(digest, ctx->buf, 16);
memset(ctx, 0, sizeof(ctx));
}
-
+
void MD5Transform(word32 buf[4], word32 const in[16])
{
register word32 a, b, c, d;
-
+
a = buf[0];
b = buf[1];
c = buf[2];
d = buf[3];
-
+
MD5STEP(F1, a, b, c, d, in[0] + 0xd76aa478, 7);
MD5STEP(F1, d, a, b, c, in[1] + 0xe8c7b756, 12);
MD5STEP(F1, c, d, a, b, in[2] + 0x242070db, 17);
MD5STEP(F1, d, a, b, c, in[13] + 0xfd987193, 12);
MD5STEP(F1, c, d, a, b, in[14] + 0xa679438e, 17);
MD5STEP(F1, b, c, d, a, in[15] + 0x49b40821, 22);
-
+
MD5STEP(F2, a, b, c, d, in[1] + 0xf61e2562, 5);
MD5STEP(F2, d, a, b, c, in[6] + 0xc040b340, 9);
MD5STEP(F2, c, d, a, b, in[11] + 0x265e5a51, 14);
MD5STEP(F2, d, a, b, c, in[2] + 0xfcefa3f8, 9);
MD5STEP(F2, c, d, a, b, in[7] + 0x676f02d9, 14);
MD5STEP(F2, b, c, d, a, in[12] + 0x8d2a4c8a, 20);
-
+
MD5STEP(F3, a, b, c, d, in[5] + 0xfffa3942, 4);
MD5STEP(F3, d, a, b, c, in[8] + 0x8771f681, 11);
MD5STEP(F3, c, d, a, b, in[11] + 0x6d9d6122, 16);
MD5STEP(F3, d, a, b, c, in[12] + 0xe6db99e5, 11);
MD5STEP(F3, c, d, a, b, in[15] + 0x1fa27cf8, 16);
MD5STEP(F3, b, c, d, a, in[2] + 0xc4ac5665, 23);
-
+
MD5STEP(F4, a, b, c, d, in[0] + 0xf4292244, 6);
MD5STEP(F4, d, a, b, c, in[7] + 0x432aff97, 10);
MD5STEP(F4, c, d, a, b, in[14] + 0xab9423a7, 15);
MD5STEP(F4, d, a, b, c, in[11] + 0xbd3af235, 10);
MD5STEP(F4, c, d, a, b, in[2] + 0x2ad7d2bb, 15);
MD5STEP(F4, b, c, d, a, in[9] + 0xeb86d391, 21);
-
+
buf[0] += a;
buf[1] += b;
buf[2] += c;
buf[3] += d;
}
-
-
+
+
void MyMD5(void *dest, void *orig, int len, unsigned int* ikey)
{
MD5Context context;
MD5Update(&context, (const unsigned char*)orig, len);
MD5Final((unsigned char*)dest, &context);
}
-
-
+
+
void GenHash(const char* src, char* dest, const char* xtab, unsigned int* ikey, size_t srclen)
{
unsigned char bytes[16];
Implementation eventlist[] = { I_OnRequest };
ServerInstance->Modules->Attach(eventlist, this, 1);
}
-
+
virtual ~ModuleMD5()
{
ServerInstance->Modules->UnpublishInterface("HashRequest", this);
}
-
+
virtual const char* OnRequest(Request* request)
{
HashRequest* MD5 = (HashRequest*)request;
return MODEACTION_ALLOW;
}
}
-
+
return MODEACTION_DENY;
}
};
class ModuleMsgFlood : public Module
{
-
+
MsgFlood* mf;
-
+
public:
-
+
ModuleMsgFlood(InspIRCd* Me)
: Module(Me)
{
-
+
mf = new MsgFlood(ServerInstance);
if (!ServerInstance->Modes->AddMode(mf))
throw ModuleException("Could not add new modes!");
Implementation eventlist[] = { I_OnChannelDelete, I_OnUserPreNotice, I_OnUserPreMessage };
ServerInstance->Modules->Attach(eventlist, this, 3);
}
-
+
int ProcessMessages(User* user,Channel* dest, const std::string &text)
{
if (!IS_LOCAL(user) || CHANOPS_EXEMPT(ServerInstance, 'f') && dest->GetStatus(user) == STATUS_OP)
return 1;
}
}
-
+
return 0;
}
{
if (target_type == TYPE_CHANNEL)
return ProcessMessages(user,(Channel*)dest,text);
-
+
return 0;
}
{
if (target_type == TYPE_CHANNEL)
return ProcessMessages(user,(Channel*)dest,text);
-
+
return 0;
}
ServerInstance->Modes->DelMode(mf);
delete mf;
}
-
+
virtual Version GetVersion()
{
return Version(1, 2, 0, 0, VF_COMMON | VF_VENDOR, API_VERSION);
class ModuleNamesX : public Module
{
public:
-
+
ModuleNamesX(InspIRCd* Me)
: Module(Me)
{
Implementation eventlist[] = { I_OnUserPreNick, I_On005Numeric };
ServerInstance->Modules->Attach(eventlist, this, 2);
}
-
+
virtual ~ModuleNickBan()
{
}
-
+
virtual Version GetVersion()
{
return Version(1,2,0,0,VF_VENDOR,API_VERSION);
return std::make_pair(true, ConvToStr(x->nicks)+":"+ConvToStr(x->secs));
else
return std::make_pair(false, parameter);
- }
+ }
bool CheckTimeStamp(time_t theirs, time_t ours, const std::string &their_param, const std::string &our_param, Channel* channel)
{
class ModuleNickFlood : public Module
{
NickFlood* jf;
-
+
public:
-
+
ModuleNickFlood(InspIRCd* Me)
: Module(Me)
{
-
+
jf = new NickFlood(ServerInstance);
if (!ServerInstance->Modes->AddMode(jf))
throw ModuleException("Could not add new modes!");
return 0;
}
-
+
void OnChannelDelete(Channel* chan)
{
nickfloodsettings *f;
ServerInstance->Modes->DelMode(jf);
delete jf;
}
-
+
virtual Version GetVersion()
{
return Version(1, 2, 0, 0, VF_COMMON | VF_VENDOR, API_VERSION);
ModuleNickLock(InspIRCd* Me)
: Module(Me)
{
-
+
cmd1 = new CommandNicklock(ServerInstance);
cmd2 = new CommandNickunlock(ServerInstance);
ServerInstance->AddCommand(cmd1);
Implementation eventlist[] = { I_OnUserPreNick, I_OnUserQuit, I_OnCleanup };
ServerInstance->Modules->Attach(eventlist, this, 3);
}
-
+
virtual ~ModuleNickLock()
{
}
-
+
virtual Version GetVersion()
{
return Version(1, 2, 0, 1, VF_COMMON | VF_VENDOR, API_VERSION);
class ModuleNoCTCP : public Module
{
-
+
NoCTCP* nc;
-
+
public:
-
+
ModuleNoCTCP(InspIRCd* Me)
: Module(Me)
{
-
+
nc = new NoCTCP(ServerInstance);
if (!ServerInstance->Modes->AddMode(nc))
throw ModuleException("Could not add new modes!");
{
return OnUserPreNotice(user,dest,target_type,text,status,exempt_list);
}
-
+
virtual int OnUserPreNotice(User* user,void* dest,int target_type, std::string &text, char status, CUList &exempt_list)
{
if ((target_type == TYPE_CHANNEL) && (IS_LOCAL(user)))
{
Channel* c = (Channel*)dest;
-
+
if (CHANOPS_EXEMPT(ServerInstance, 'C') && c->GetStatus(user) == STATUS_OP)
{
return 0;
}
-
+
if (c->IsModeSet('C'))
{
if ((text.length()) && (text[0] == '\1'))
ServerInstance->Modes->DelMode(ni);
delete ni;
}
-
+
virtual Version GetVersion()
{
return Version(1,2,0,0,VF_COMMON|VF_VENDOR,API_VERSION);
class ModuleNoKicks : public Module
{
-
+
NoKicks* nk;
-
+
public:
-
+
ModuleNoKicks(InspIRCd* Me)
: Module(Me)
{
-
+
nk = new NoKicks(ServerInstance);
if (!ServerInstance->Modes->AddMode(nk))
throw ModuleException("Could not add new modes!");
ServerInstance->Modes->DelMode(nk);
delete nk;
}
-
+
virtual Version GetVersion()
{
return Version(1,2,0,0,VF_COMMON|VF_VENDOR,API_VERSION);
ModuleNoNickChange(InspIRCd* Me)
: Module(Me)
{
-
+
nn = new NoNicks(ServerInstance);
ServerInstance->Modes->AddMode(nn);
Implementation eventlist[] = { I_OnUserPreNick };
ServerInstance->Modules->Attach(eventlist, this, 1);
}
-
+
virtual ~ModuleNoNickChange()
{
ServerInstance->Modes->DelMode(nn);
delete nn;
}
-
+
virtual Version GetVersion()
{
return Version(1,2,0,1,VF_COMMON|VF_VENDOR,API_VERSION);
class ModuleNoNotice : public Module
{
-
+
NoNotice* nt;
public:
-
+
ModuleNoNotice(InspIRCd* Me)
: Module(Me)
{
-
+
nt = new NoNotice(ServerInstance);
if (!ServerInstance->Modes->AddMode(nt))
throw ModuleException("Could not add new modes!");
ServerInstance->Modules->Attach(eventlist, this, 1);
}
-
+
virtual int OnUserPreNotice(User* user,void* dest,int target_type, std::string &text, char status, CUList &exempt_list)
{
if ((target_type == TYPE_CHANNEL) && (IS_LOCAL(user)))
ServerInstance->Modes->DelMode(nt);
delete nt;
}
-
+
virtual Version GetVersion()
{
return Version(1,2,0,0,VF_COMMON|VF_VENDOR,API_VERSION);
class ModuleOperChans : public Module
{
-
+
OperChans* oc;
public:
ModuleOperChans(InspIRCd* Me)
: Module(Me)
{
-
+
oc = new OperChans(ServerInstance);
if (!ServerInstance->Modes->AddMode(oc))
throw ModuleException("Could not add new modes!");
}
return 0;
}
-
+
virtual ~ModuleOperChans()
{
ServerInstance->Modes->DelMode(oc);
delete oc;
}
-
+
virtual Version GetVersion()
{
return Version(1,2,0,0,VF_VENDOR|VF_COMMON,API_VERSION);
virtual void OnRehash(User* user, const std::string ¶meter)
{
ConfigReader* conf = new ConfigReader(ServerInstance);
-
+
operChan = conf->ReadValue("operjoin", "channel", 0);
override = conf->ReadFlag("operjoin", "override", "0", 0);
operChans.clear();
class ModuleOperLog : public Module
{
private:
-
+
public:
ModuleOperLog(InspIRCd* Me) : Module(Me)
{
-
+
Implementation eventlist[] = { I_OnPreCommand, I_On005Numeric };
ServerInstance->Modules->Attach(eventlist, this, 2);
}
-
+
virtual ~ModuleOperLog()
{
}
-
+
virtual Version GetVersion()
{
return Version(1,2,0,0,VF_VENDOR,API_VERSION);
}
-
+
virtual int OnPreCommand(std::string &command, std::vector<std::string> ¶meters, User *user, bool validated, const std::string &original_line)
{
/* If the command doesnt appear to be valid, we dont want to mess with it. */
if (!validated)
return 0;
-
+
if ((IS_OPER(user)) && (IS_LOCAL(user)) && (user->HasPermission(command)))
{
Command* thiscommand = ServerInstance->Parser->GetHandler(command);
}
};
-
-
+
+
MODULE_INIT(ModuleOperLog)
{
private:
-
+
ConfigReader *Conf;
public:
ModuleModesOnOper(InspIRCd* Me)
: Module(Me)
{
-
+
Conf = new ConfigReader(ServerInstance);
Implementation eventlist[] = { I_OnPostOper, I_OnRehash };
ServerInstance->Modules->Attach(eventlist, this, 2);
delete Conf;
Conf = new ConfigReader(ServerInstance);
}
-
+
virtual ~ModuleModesOnOper()
{
delete Conf;
}
-
+
virtual Version GetVersion()
{
return Version(1,2,0,1,VF_VENDOR,API_VERSION);
}
-
+
virtual void OnPostOper(User* user, const std::string &opertype, const std::string &opername)
{
// whenever a user opers, go through the oper types, find their <type:modes>,
opermotd = new FileReader(ServerInstance, filename);
delete conf;
}
-
+
ModuleOpermotd(InspIRCd* Me)
: Module(Me)
{
class ModuleOverride : public Module
{
-
+
override_t overrides;
bool RequireKey;
bool NoisyOverride;
int OverOps, OverDeops, OverVoices, OverDevoices, OverHalfops, OverDehalfops;
public:
-
+
ModuleOverride(InspIRCd* Me)
: Module(Me)
- {
+ {
// read our config options (main config file)
OnRehash(NULL,"");
ServerInstance->SNO->EnableSnomask('O', "OVERRIDE");
Implementation eventlist[] = { I_OnRehash, I_OnAccessCheck, I_On005Numeric, I_OnUserPreJoin, I_OnUserPreKick, I_OnPostCommand };
ServerInstance->Modules->Attach(eventlist, this, 6);
}
-
+
virtual void OnRehash(User* user, const std::string ¶meter)
{
// on a rehash we delete our classes for good measure and create them again.
ConfigReader* Conf = new ConfigReader(ServerInstance);
-
+
// re-read our config options on a rehash
NoisyOverride = Conf->ReadFlag("override", "noisy", 0);
RequireKey = Conf->ReadFlag("override", "requirekey", 0);
std::string tokenlist = Conf->ReadValue("type","override",j);
overrides[typen] = tokenlist;
}
-
+
delete Conf;
}
}
return 0;
}
-
+
virtual int OnAccessCheck(User* source,User* dest,Channel* channel,int access_type)
{
if (IS_OPER(source))
}
break;
}
-
+
if (CanOverride(source,"OTHERMODE"))
{
if (NoisyOverride)
return ACR_DEFAULT;
}
-
+
virtual int OnUserPreJoin(User* user, Channel* chan, const char* cname, std::string &privs, const std::string &keygiven)
{
if (IS_LOCAL(user) && IS_OPER(user))
}
return -1;
}
-
+
if ((!chan->key.empty()) && (CanOverride(user,"KEY")) && keygiven != chan->key)
{
if (RequireKey && keygiven != "override")
ServerInstance->SNO->WriteToSnoMask('O', user->nick+" used oper override to bypass +k on "+std::string(cname));
return -1;
}
-
+
if ((chan->limit > 0) && (chan->GetUserCounter() >= chan->limit) && (CanOverride(user,"LIMIT")))
{
if (RequireKey && keygiven != "override")
}
return 0;
}
-
+
virtual ~ModuleOverride()
{
ServerInstance->SNO->DisableSnomask('O');
}
-
+
virtual Version GetVersion()
{
return Version(1,2,0,1,VF_VENDOR,API_VERSION);
class ModuleOperHash : public Module
{
-
+
CommandMkpasswd* mycommand;
hashymodules hashers; /* List of modules which implement HashRequest */
std::deque<std::string> names; /* Module names which implement HashRequest */
Implementation eventlist[] = { I_OnPassCompare, I_OnLoadModule };
ServerInstance->Modules->Attach(eventlist, this, 2);
}
-
+
virtual ~ModuleOperHash()
{
if (diduseiface) ServerInstance->Modules->DoneWithInterface("HashRequest");
{
PermChannel *p;
public:
-
+
ModulePermanentChannels(InspIRCd* Me) : Module(Me)
{
p = new PermChannel(ServerInstance);
/*
* A few things to note:
- *
+ *
* O The only place that may *delete* an active or inactive
* ident socket is OnUserDisconnect in the module class.
* Because this is out of scope of the socket class there is
*
* O Closure of the ident socket with the Close() method will
* not cause removal of the socket from memory or detatchment
- * from its 'parent' User class. It will only flag it as an
+ * from its 'parent' User class. It will only flag it as an
* inactive socket in the socket engine.
*
* O Timeouts are handled in OnCheckReaady at the same time as
{
this->response[i] = rstr[i];
}
-
+
socklen_t size = 0;
#ifdef IPV6
/* Does this look like a v6 ip address? */
/* We allocate two of these because sizeof(sockaddr_in6) > sizeof(sockaddr_in) */
sockaddr* s = new sockaddr[2];
sockaddr* addr = new sockaddr[2];
-
+
#ifdef IPV6
/* Horrid icky nasty ugly berkely socket crap. */
if (v6)
Implementation eventlist[] = { I_OnRehash, I_OnUserRegister, I_OnCleanup, I_OnUserDisconnect };
ServerInstance->Modules->Attach(eventlist, this, 4);
}
-
+
virtual Version GetVersion()
{
return Version(1, 2, 1, 0, VF_VENDOR, API_VERSION);
}
-
-
+
+
virtual void OnRehash(User *user, const std::string ¶m)
{
ConfigReader MyConf(ServerInstance);
-
+
RequestTimeout = MyConf.ReadInteger("ident", "timeout", 0, true);
if (!RequestTimeout)
RequestTimeout = 5;
}
-
+
virtual int OnUserRegister(User *user)
{
user->WriteServ("NOTICE Auth :*** Checking you for proxies...");
Implementation eventlist[] = { I_OnUserPreMessage, I_OnUserPreNotice, I_On005Numeric };
ServerInstance->Modules->Attach(eventlist, this, 3);
}
-
+
virtual ~ModuleQuietBan()
{
}
-
+
virtual Version GetVersion()
{
return Version(1,2,0,0,VF_VENDOR,API_VERSION);
return 1;
}
}
-
+
return 0;
}
ModuleRandQuote(InspIRCd* Me)
: Module(Me)
{
-
+
conf = new ConfigReader(ServerInstance);
// Sort the Randomizer thingie..
srand(time(NULL));
ServerInstance->Modules->Attach(eventlist, this, 1);
}
-
+
virtual ~ModuleRandQuote()
{
delete conf;
delete quotes;
}
-
+
virtual Version GetVersion()
{
return Version(1,2,0,1,VF_VENDOR,API_VERSION);
}
-
+
virtual void OnUserConnect(User* user)
{
if (mycommand)
/* When TS is equal, the alphabetically later one wins */
return (their_param < our_param);
}
-
+
ModeAction OnModeChange(User* source, User* dest, Channel* channel, std::string ¶meter, bool adding, bool)
{
if (adding)
}
return MODEACTION_DENY;
-
+
}
};
class ModuleRedirect : public Module
{
-
+
Redirect* re;
-
+
public:
-
+
ModuleRedirect(InspIRCd* Me)
: Module(Me)
{
-
+
re = new Redirect(ServerInstance);
if (!ServerInstance->Modes->AddMode(re))
throw ModuleException("Could not add new modes!");
Implementation eventlist[] = { I_OnUserPreJoin };
ServerInstance->Modules->Attach(eventlist, this, 1);
}
-
+
virtual int OnUserPreJoin(User* user, Channel* chan, const char* cname, std::string &privs, const std::string &keygiven)
{
ServerInstance->Modes->DelMode(re);
delete re;
}
-
+
virtual Version GetVersion()
{
return Version(1, 2, 0, 0, VF_COMMON | VF_VENDOR, API_VERSION);
return 0;
}
-
+
virtual ~ModuleRegOnlyCreate()
{
}
-
+
virtual Version GetVersion()
{
return Version(1, 2, 0, 0, VF_VENDOR, API_VERSION);
/* $ModDesc: Provides a /remove command, this is mostly an alternative to /kick, except makes users appear to have parted the channel */
-/*
+/*
* This module supports the use of the +q and +a usermodes, but should work without them too.
* Usage of the command is restricted to +hoaq, and you cannot remove a user with a "higher" level than yourself.
* eg: +h can remove +hv and users with no modes. +a can remove +aohv and users with no modes.
*/
class RemoveBase
{
- private:
+ private:
bool& supportnokicks;
InspIRCd* ServerInstance;
-
+
protected:
RemoveBase(InspIRCd* Instance, bool& snk) : supportnokicks(snk), ServerInstance(Instance)
{
- }
-
- enum ModeLevel { PEON = 0, HALFOP = 1, OP = 2, ADMIN = 3, OWNER = 4, ULINE = 5 };
-
+ }
+
+ enum ModeLevel { PEON = 0, HALFOP = 1, OP = 2, ADMIN = 3, OWNER = 4, ULINE = 5 };
+
/* This little function just converts a chanmode character (U ~ & @ & +) into an integer (5 4 3 2 1 0) */
/* XXX - We should probably use the new mode prefix rank stuff
* for this instead now -- Brain */
{
return PEON;
}
-
+
switch (privs[0])
{
case 'U':
return PEON;
}
}
-
+
CmdResult Handle (const std::vector<std::string>& parameters, User *user, bool neworder)
{
const char* channame;
std::string protectkey;
std::string founderkey;
bool hasnokicks;
-
+
/* Set these to the parameters needed, the new version of this module switches it's parameters around
* supplying a new command with the new order while keeping the old /remove with the older order.
* /remove <nick> <channel> [reason ...]
*/
channame = parameters[ neworder ? 0 : 1].c_str();
username = parameters[ neworder ? 1 : 0].c_str();
-
+
/* Look up the user we're meant to be removing from the channel */
target = ServerInstance->FindNick(username);
-
+
/* And the channel we're meant to be removing them from */
channel = ServerInstance->FindChan(channame);
{
user->WriteServ( "NOTICE %s :*** The user %s is not on channel %s", user->nick.c_str(), target->nick.c_str(), channel->name.c_str());
return CMD_FAILURE;
- }
-
+ }
+
/* This is adding support for the +q and +a channel modes, basically if they are enabled, and the remover has them set.
* Then we change the @|%|+ to & if they are +a, or ~ if they are +q */
protectkey = "cm_protect_" + std::string(channel->name);
founderkey = "cm_founder_" + std::string(channel->name);
-
+
if (ServerInstance->ULine(user->server) || ServerInstance->ULine(user->nick.c_str()))
{
ulevel = chartolevel("U");
{
ulevel = chartolevel(channel->GetPrefixChar(user));
}
-
+
/* Now it's the same idea, except for the target. If they're ulined make sure they get a higher level than the sender can */
if (ServerInstance->ULine(target->server) || ServerInstance->ULine(target->nick.c_str()))
{
{
tlevel = chartolevel(channel->GetPrefixChar(target));
}
-
+
hasnokicks = (ServerInstance->Modules->Find("m_nokicks.so") && channel->IsModeSet('Q'));
-
+
/* We support the +Q channel mode via. the m_nokicks module, if the module is loaded and the mode is set then disallow the /remove */
if ((!IS_LOCAL(user)) || (!supportnokicks || !hasnokicks || (ulevel == ULINE)))
{
// but you can do this, nenolod -brain
std::string reasonparam("No reason given");
-
+
/* If a reason is given, use it */
if(parameters.size() > 2)
{
syntax = "<nick> <channel> [<reason>]";
TRANSLATE4(TR_NICK, TR_TEXT, TR_TEXT, TR_END);
}
-
+
CmdResult Handle (const std::vector<std::string>& parameters, User *user)
{
return RemoveBase::Handle(parameters, user, false);
CommandRemove* mycommand;
CommandFpart* mycommand2;
bool supportnokicks;
-
-
+
+
public:
ModuleRemove(InspIRCd* Me)
: Module(Me)
{
output.append(" REMOVE");
}
-
+
virtual void OnRehash(User* user, const std::string&)
{
ConfigReader conf(ServerInstance);
supportnokicks = conf.ReadFlag("remove", "supportnokicks", 0);
}
-
+
virtual ~ModuleRemove()
{
}
-
+
virtual Version GetVersion()
{
return Version(1, 2, 1, 0, VF_COMMON | VF_VENDOR, API_VERSION);
}
-
+
};
MODULE_INIT(ModuleRemove)
Implementation eventlist[] = { I_OnLocalTopicChange, I_OnUserPreNick, I_OnUserPreNotice, I_OnUserPreMessage };
ServerInstance->Modules->Attach(eventlist, this, 4);
}
-
+
virtual ~ModuleRestrictBanned()
{
}
-
+
virtual Version GetVersion()
{
return Version(1,2,0,1,VF_VENDOR,API_VERSION);
{
return CheckRestricted(user, channel, "change the topic");
}
-
+
virtual int OnUserPreMessage(User* user,void* dest,int target_type, std::string &text, char status, CUList &exempt_list)
{
return OnUserPreNotice(user,dest,target_type,text,status,exempt_list);
class ModuleRestrictChans : public Module
{
-
+
std::map<irc::string,int> allowchans;
ModuleRestrictChans(InspIRCd* Me)
: Module(Me)
{
-
+
ReadConfig();
Implementation eventlist[] = { I_OnUserPreJoin, I_OnRehash };
ServerInstance->Modules->Attach(eventlist, this, 2);
ReadConfig();
}
-
+
virtual int OnUserPreJoin(User* user, Channel* chan, const char* cname, std::string &privs, const std::string &keygiven)
{
irc::string x = cname;
}
return 0;
}
-
+
virtual ~ModuleRestrictChans()
{
}
-
+
virtual Version GetVersion()
{
return Version(1,2,0,1,VF_VENDOR,API_VERSION);
class ModuleRestrictMsg : public Module
{
-
+
public:
-
+
ModuleRestrictMsg(InspIRCd* Me)
: Module(Me)
{
-
+
Implementation eventlist[] = { I_OnUserPreMessage, I_OnUserPreNotice };
ServerInstance->Modules->Attach(eventlist, this, 2);
}
virtual ~ModuleRestrictMsg()
{
}
-
+
virtual Version GetVersion()
{
return Version(1,2,0,1,VF_VENDOR,API_VERSION);
* The RIPEMD-160 software is freely available for use under the terms and
* conditions described hereunder, which shall be deemed to be accepted by
* any user of the software and applicable on any use of the software:
- *
+ *
* 1. K.U.Leuven Department of Electrical Engineering-ESAT/COSIC shall for
* all purposes be considered the owner of the RIPEMD-160 software and of
* all copyright, trade secret, patent or other intellectual property
* circumstances K.U.Leuven R&D will be held liable for any deficiency,
* fault or other mishappening with regard to the use or performance of
* the software.
- * 3. User agrees to give due credit to K.U.Leuven in scientific publications
- * or communications in relation with the use of the RIPEMD-160 software
- * as follows: RIPEMD-160 software written by Antoon Bosselaers,
+ * 3. User agrees to give due credit to K.U.Leuven in scientific publications
+ * or communications in relation with the use of the RIPEMD-160 software
+ * as follows: RIPEMD-160 software written by Antoon Bosselaers,
* available at http://www.esat.kuleuven.be/~cosicart/ps/AB-9601/.
*
*/
#define ROL(x, n) (((x) << (n)) | ((x) >> (32-(n))))
/* the five basic functions F(), G() and H() */
-#define F(x, y, z) ((x) ^ (y) ^ (z))
-#define G(x, y, z) (((x) & (y)) | (~(x) & (z)))
+#define F(x, y, z) ((x) ^ (y) ^ (z))
+#define G(x, y, z) (((x) & (y)) | (~(x) & (z)))
#define H(x, y, z) (((x) | ~(y)) ^ (z))
-#define I(x, y, z) (((x) & (z)) | ((y) & ~(z)))
+#define I(x, y, z) (((x) & (z)) | ((y) & ~(z)))
#define J(x, y, z) ((x) ^ ((y) | ~(z)))
-
+
/* the ten basic operations FF() through III() */
#define FF(a, b, c, d, e, x, s) {\
FF(cc, dd, ee, aa, bb, X[13], 7);
FF(bb, cc, dd, ee, aa, X[14], 9);
FF(aa, bb, cc, dd, ee, X[15], 8);
-
+
/* round 2 */
GG(ee, aa, bb, cc, dd, X[ 7], 7);
GG(dd, ee, aa, bb, cc, X[ 4], 6);
GG(bb, cc, dd, ee, aa, X[14], 7);
GG(aa, bb, cc, dd, ee, X[11], 13);
GG(ee, aa, bb, cc, dd, X[ 8], 12);
-
+
/* round 3 */
HH(dd, ee, aa, bb, cc, X[ 3], 11);
HH(cc, dd, ee, aa, bb, X[10], 13);
HH(aa, bb, cc, dd, ee, X[11], 12);
HH(ee, aa, bb, cc, dd, X[ 5], 7);
HH(dd, ee, aa, bb, cc, X[12], 5);
-
+
/* round 4 */
II(cc, dd, ee, aa, bb, X[ 1], 11);
II(bb, cc, dd, ee, aa, X[ 9], 12);
JJJ(aaa, bbb, ccc, ddd, eee, X[12], 6);
/* parallel round 2 */
- III(eee, aaa, bbb, ccc, ddd, X[ 6], 9);
+ III(eee, aaa, bbb, ccc, ddd, X[ 6], 9);
III(ddd, eee, aaa, bbb, ccc, X[11], 13);
III(ccc, ddd, eee, aaa, bbb, X[ 3], 15);
III(bbb, ccc, ddd, eee, aaa, X[ 7], 7);
HHH(eee, aaa, bbb, ccc, ddd, X[ 4], 7);
HHH(ddd, eee, aaa, bbb, ccc, X[13], 5);
- /* parallel round 4 */
+ /* parallel round 4 */
GGG(ccc, ddd, eee, aaa, bbb, X[ 8], 15);
GGG(bbb, ccc, ddd, eee, aaa, X[ 6], 5);
GGG(aaa, bbb, ccc, ddd, eee, X[ 4], 8);
: _what(swhat)
{
}
-
+
virtual ~JsonException() throw() { }
-
+
virtual const char *what() const throw()
{
return _what.c_str();
class ModuleRpcJson : public Module
{
private:
-
+
public:
ModuleRpcJson(InspIRCd *Me) : Module(Me)
{
Implementation eventlist[] = { I_OnEvent };
ServerInstance->Modules->Attach(eventlist, this, 1);
}
-
+
virtual ~ModuleRpcJson()
{
ServerInstance->Modules->UnpublishInterface("RPC", this);
}
-
+
virtual Version GetVersion()
{
return Version(1, 2, 0, 0, VF_SERVICEPROVIDER | VF_VENDOR, API_VERSION);
}
-
-
+
+
virtual void OnEvent(Event *event)
{
if (event->GetEventID() == "httpd_url")
{
HTTPRequest *req = (HTTPRequest*) event->GetData();
-
+
if ((req->GetURI() == "/rpc/json") || (req->GetURI() == "/rpc/json/"))
{
std::stringstream data;
-
+
RPCValue *reqobj = NULL;
-
+
try
{
reqobj = this->JSONParse(req->GetPostData());
-
+
if (!reqobj || (reqobj->GetType() != RPCObject))
throw JsonException("RPC requests must be in the form of a single object");
-
+
RPCValue *method = reqobj->GetObject("method");
if (!method || method->GetType() != RPCString)
throw JsonException("RPC requests must have a 'method' string field");
-
+
RPCValue *params = reqobj->GetObject("params");
if (!params || params->GetType() != RPCArray)
throw JsonException("RPC requests must have a 'params' array field");
-
+
RPCRequest modreq("json", method->GetString(), params);
Event mev((char*) &modreq, this, "RPCMethod");
mev.Send(ServerInstance);
-
+
if (!modreq.claimed)
throw JsonException("Unrecognized method");
-
+
if (!modreq.error.empty())
{
data << "{\"result\":null,\"error\":\"" << modreq.error << "\"";
this->JSONSerialize(modreq.result, data);
data << ",\"error\":null";
}
-
+
if (reqobj->GetObject("id"))
{
data << ",\"id\":";
this->JSONSerialize(reqobj->GetObject("id"), data);
}
data << "}";
-
+
delete reqobj;
reqobj = NULL;
}
delete reqobj;
data << "{\"result\":null,\"error\":\"" << e.what() << "\"}";
}
-
+
HTTPDocument response(req->sock, &data, 200);
response.headers.SetHeader("X-Powered-By", "m_rpc_json.so");
response.headers.SetHeader("Content-Type", "application/json");
response.headers.SetHeader("Connection", "Keep-Alive");
-
+
Request rreq((char*) &response, (Module*) this, event->GetSource());
rreq.Send();
}
}
}
-
+
void AttachToParent(RPCValue *parent, RPCValue *child, const std::string &key = "")
{
if (!parent || !child)
return;
-
+
if (parent->GetType() == RPCArray)
parent->ArrayAdd(child);
else if (parent->GetType() == RPCObject)
else
throw JsonException("Cannot add a value to a non-container");
}
-
+
void AttachToParentReset(RPCValue *parent, RPCValue *&child, std::string &key)
{
AttachToParent(parent, child, key);
child = NULL;
key.clear();
}
-
+
RPCValue *JSONParse(const std::string &data)
{
bool pisobject = false;
std::string pvkey;
RPCValue *aparent = NULL;
RPCValue *value = NULL;
-
+
for (std::string::const_iterator i = data.begin(); i != data.end(); i++)
{
if (instring)
if (*i == '"')
{
instring = false;
-
+
if (pisobject && vkey.empty())
vkey = stmp;
else
value = new RPCValue(stmp);
-
+
stmp.clear();
}
else
stmp += *i;
-
+
continue;
}
-
+
if ((*i == ' ') || (*i == '\t') || (*i == '\r') || (*i == '\n'))
continue;
-
+
if (*i == '{')
{
// Begin object
if ((value) || (pisobject && vkey.empty()))
throw JsonException("Unexpected begin object token ('{')");
-
+
RPCValue *nobj = new RPCValue(RPCObject, aparent);
aparent = nobj;
pvkey = vkey;
// End object
if ((!aparent) || (!pisobject) || (!vkey.empty() && !value))
throw JsonException("Unexpected end object token ('}')");
-
+
// End value
if (value)
AttachToParentReset(aparent, value, vkey);
-
+
if (!aparent->parent)
return aparent;
-
+
value = aparent;
aparent = aparent->parent;
vkey = pvkey;
// Begin string
if (value)
throw JsonException("Unexpected begin string token ('\"')");
-
+
instring = true;
}
else if (*i == ':')
{
if ((!aparent) || (!value) || ((pisobject) && (vkey.empty())))
throw JsonException("Unexpected value seperator token (',')");
-
+
AttachToParentReset(aparent, value, vkey);
}
else if (*i == '[')
// Begin array
if ((value) || (pisobject && vkey.empty()))
throw JsonException("Unexpected begin array token ('[')");
-
+
RPCValue *nar = new RPCValue(RPCArray, aparent);
aparent = nar;
pvkey = vkey;
// End array (also an end value delimiter)
if (!aparent || pisobject)
throw JsonException("Unexpected end array token (']')");
-
+
if (value)
AttachToParentReset(aparent, value, vkey);
-
+
if (!aparent->parent)
return aparent;
-
+
value = aparent;
aparent = aparent->parent;
vkey = pvkey;
{
std::string ds = std::string(i, data.end());
char *eds = NULL;
-
+
errno = 0;
double v = strtod(ds.c_str(), &eds);
-
+
if (errno != 0)
throw JsonException("Error parsing numeric value");
-
+
value = new RPCValue(v);
-
+
i += eds - ds.c_str() - 1;
}
else
throw JsonException("Unknown data in value portion");
}
}
-
+
if (instring)
throw JsonException("Unterminated string");
-
+
if (aparent && pisobject)
throw JsonException("Unterminated object");
else if (aparent && !pisobject)
throw JsonException("Unterminated array");
-
+
if (value)
return value;
else
throw JsonException("No JSON data found");
}
-
+
void JSONSerialize(RPCValue *value, std::stringstream &re)
{
int ac;
class ModuleRPCTest : public Module
{
private:
-
+
public:
ModuleRPCTest(InspIRCd *Me) : Module(Me)
{
Implementation eventlist[] = { I_OnEvent };
ServerInstance->Modules->Attach(eventlist, this, 1);
}
-
+
virtual ~ModuleRPCTest()
{
}
-
+
virtual Version GetVersion()
{
return Version(1, 2, 0, 0, VF_VENDOR, API_VERSION);
}
-
-
+
+
virtual void OnEvent(Event *ev)
{
if (ev->GetEventID() == "RPCMethod")
{
RPCRequest *req = (RPCRequest*) ev->GetData();
-
+
if (req->method == "test.echo")
{
req->claimed = true;
req->error = "Insufficient parameters";
return;
}
-
+
req->result->SetString(req->parameters->GetArray(0)->GetString());
}
}
Implementation eventlist[] = { I_OnBufferFlushed, I_OnPreCommand, I_OnCleanup, I_OnUserQuit, I_On005Numeric, I_OnRehash };
ServerInstance->Modules->Attach(eventlist, this, 6);
}
-
+
virtual ~ModuleSafeList()
{
}
ServerNameSize = strlen(ServerInstance->Config->ServerName) + 4;
global_listing = 0;
}
-
+
virtual Version GetVersion()
{
return Version(1,2,0,0,VF_VENDOR,API_VERSION);
}
-
+
/*
* OnPreCommand()
* Intercept the LIST command.
- */
+ */
virtual int OnPreCommand(std::string &command, std::vector<std::string> ¶meters, User *user, bool validated, const std::string &original_line)
{
/* If the command doesnt appear to be valid, we dont want to mess with it. */
if (!validated)
return 0;
-
+
if (command == "LIST")
{
return this->HandleList(parameters, user);
}
return 0;
}
-
+
/*
* HandleList()
* Handle (override) the LIST command.
/* First, let's check if the user is currently /list'ing */
ListData *ld;
user->GetExt("safelist_cache", ld);
-
+
if (ld)
{
/* user is already /list'ing, we don't want to do shit. */
user->Shrink("safelist_last");
}
-
+
/*
* start at channel 0! ;)
*/
ModuleSajoin(InspIRCd* Me)
: Module(Me)
{
-
+
mycommand = new CommandSajoin(ServerInstance);
ServerInstance->AddCommand(mycommand);
}
-
+
virtual ~ModuleSajoin()
{
}
-
+
virtual Version GetVersion()
{
return Version(1, 2, 0, 1, VF_COMMON | VF_VENDOR, API_VERSION);
}
-
+
};
MODULE_INIT(ModuleSajoin)
ModuleSaMode(InspIRCd* Me)
: Module(Me)
{
-
+
mycommand = new CommandSamode(ServerInstance);
ServerInstance->AddCommand(mycommand);
}
-
+
virtual ~ModuleSaMode()
{
}
-
+
virtual Version GetVersion()
{
return Version(1, 2, 0, 0, VF_COMMON | VF_VENDOR, API_VERSION);
ModuleSanick(InspIRCd* Me)
: Module(Me)
{
-
+
mycommand = new CommandSanick(ServerInstance);
ServerInstance->AddCommand(mycommand);
}
-
+
virtual ~ModuleSanick()
{
}
-
+
virtual Version GetVersion()
{
return Version(1, 2, 0, 1, VF_COMMON | VF_VENDOR, API_VERSION);
}
-
+
};
MODULE_INIT(ModuleSanick)
ModuleSapart(InspIRCd* Me)
: Module(Me)
{
-
+
mycommand = new CommandSapart(ServerInstance);
ServerInstance->AddCommand(mycommand);
}
-
+
virtual ~ModuleSapart()
{
}
-
+
virtual Version GetVersion()
{
return Version(1, 2, 0, 1, VF_COMMON | VF_VENDOR, API_VERSION);
}
-
+
};
MODULE_INIT(ModuleSapart)
user->WriteNumeric(990, "%s :Cannot use an SA command on a u-lined client",user->nick.c_str());
return CMD_FAILURE;
}
-
+
ServerInstance->SNO->WriteToSnoMask('A', std::string(user->nick)+" used SAQUIT to make "+std::string(dest->nick)+" quit with a reason of "+parameters[1]);
-
+
// Pass the command on, so the client's server can quit it properly.
if (!IS_LOCAL(dest))
return CMD_SUCCESS;
-
+
ServerInstance->Users->QuitUser(dest, parameters[1]);
return CMD_LOCALONLY;
}
ModuleSaquit(InspIRCd* Me)
: Module(Me)
{
-
+
mycommand = new CommandSaquit(ServerInstance);
ServerInstance->AddCommand(mycommand);
}
-
+
virtual ~ModuleSaquit()
{
}
-
+
virtual Version GetVersion()
{
return Version(1, 2, 0, 0, VF_COMMON | VF_VENDOR, API_VERSION);
}
-
+
};
MODULE_INIT(ModuleSaquit)
{
CommandAuthenticate* sasl;
public:
-
+
ModuleSASL(InspIRCd* Me)
: Module(Me)
{
Implementation eventlist[] = { I_OnRehash, I_OnPreCommand, I_On005Numeric };
ServerInstance->Modules->Attach(eventlist, this, 3);
}
-
+
virtual ~ModuleSecureList()
{
}
-
+
virtual Version GetVersion()
{
return Version(1,2,0,0,VF_VENDOR,API_VERSION);
WaitTime = MyConf->ReadInteger("securelist", "waittime", "60", 0, true);
delete MyConf;
}
-
+
/*
* OnPreCommand()
* Intercept the LIST command.
- */
+ */
virtual int OnPreCommand(std::string &command, std::vector<std::string> ¶meters, User *user, bool validated, const std::string &original_line)
{
/* If the command doesnt appear to be valid, we dont want to mess with it. */
if (!validated)
return 0;
-
+
if ((command == "LIST") && (ServerInstance->Time() < (user->signon+WaitTime)) && (!IS_OPER(user)))
{
/* Normally wouldnt be allowed here, are they exempt? */
}
};
-
+
MODULE_INIT(ModuleSecureList)
*/
class Channel_r : public ModeHandler
{
-
+
public:
Channel_r(InspIRCd* Instance) : ModeHandler(Instance, 'r', 0, 0, false, MODETYPE_CHANNEL, false) { }
*/
class User_r : public ModeHandler
{
-
+
public:
User_r(InspIRCd* Instance) : ModeHandler(Instance, 'r', 0, 0, false, MODETYPE_USER, false) { }
*/
class ModuleServices : public Module
{
-
+
Channel_r* m1;
Channel_R* m2;
Channel_M* m3;
ModuleServices(InspIRCd* Me)
: Module(Me)
{
-
+
m1 = new Channel_r(ServerInstance);
m2 = new Channel_R(ServerInstance);
m3 = new Channel_M(ServerInstance);
{
throw ModuleException("Could not add user and channel modes!");
}
-
+
kludgeme = false;
Implementation eventlist[] = { I_OnWhois, I_OnUserPostNick, I_OnUserPreMessage, I_OnUserPreNotice, I_OnUserPreJoin };
ServerInstance->Modules->Attach(eventlist, this, 5);
kludgeme = false;
}
}
-
+
virtual int OnUserPreMessage(User* user,void* dest,int target_type, std::string &text, char status, CUList &exempt_list)
{
if (!IS_LOCAL(user))
}
return 0;
}
-
+
virtual int OnUserPreNotice(User* user,void* dest,int target_type, std::string &text, char status, CUList &exempt_list)
{
return OnUserPreMessage(user,dest,target_type,text,status, exempt_list);
}
-
+
virtual int OnUserPreJoin(User* user, Channel* chan, const char* cname, std::string &privs, const std::string &keygiven)
{
if (chan)
delete m4;
delete m5;
}
-
+
virtual Version GetVersion()
{
return Version(1,2,0,0,VF_COMMON|VF_VENDOR,API_VERSION);
class ModuleServicesAccount : public Module
{
-
+
AChannel_R* m1;
AChannel_M* m2;
AUser_R* m3;
public:
ModuleServicesAccount(InspIRCd* Me) : Module(Me)
{
-
+
m1 = new AChannel_R(ServerInstance);
m2 = new AChannel_M(ServerInstance);
m3 = new AUser_R(ServerInstance);
return 0;
user->GetExt("accountname", account);
-
+
if (target_type == TYPE_CHANNEL)
{
Channel* c = (Channel*)dest;
-
+
if ((c->IsModeSet('M')) && (!account))
{
if ((ServerInstance->ULine(user->nick.c_str())) || (ServerInstance->ULine(user->server)))
if (target_type == TYPE_USER)
{
User* u = (User*)dest;
-
+
if ((u->modes['R'-65]) && (!account))
{
if ((ServerInstance->ULine(user->nick.c_str())) || (ServerInstance->ULine(user->server)))
}
return 0;
}
-
+
virtual int OnUserPreNotice(User* user,void* dest,int target_type, std::string &text, char status, CUList &exempt_list)
{
return OnUserPreMessage(user, dest, target_type, text, status, exempt_list);
}
-
+
virtual int OnUserPreJoin(User* user, Channel* chan, const char* cname, std::string &privs, const std::string &keygiven)
{
std::string *account;
user->GetExt("accountname", account);
-
+
if (chan)
{
if (chan->IsModeSet('R'))
}
return 0;
}
-
+
// Whenever the linking module wants to send out data, but doesnt know what the data
// represents (e.g. it is metadata, added to a User or Channel by a module) then
// this method is called. We should use the ProtoSendMetaData function after we've
{
// check if its our metadata key, and its associated with a user
if ((target_type == TYPE_USER) && (extname == "accountname"))
- {
+ {
User* dest = (User*)target;
-
+
/* logging them out? */
if (extdata.empty())
{
delete m2;
delete m3;
}
-
+
virtual Version GetVersion()
{
return Version(1,2,0,0,VF_COMMON|VF_VENDOR,API_VERSION);
class ModuleServProtectMode : public Module
{
-
+
ServProtectMode* bm;
public:
ModuleServProtectMode(InspIRCd* Me)
: Module(Me)
{
-
+
bm = new ServProtectMode(ServerInstance);
if (!ServerInstance->Modes->AddMode(bm))
throw ModuleException("Could not add new modes!");
ServerInstance->Modules->Attach(eventlist, this, 4);
}
-
+
virtual ~ModuleServProtectMode()
{
ServerInstance->Modes->DelMode(bm);
delete bm;
}
-
+
virtual Version GetVersion()
{
return Version(1,2,0,0,VF_COMMON,API_VERSION);
public:
ModuleSetHost(InspIRCd* Me)
: Module(Me)
- {
+ {
OnRehash(NULL,"");
mycommand = new CommandSethost(ServerInstance, hostmap);
ServerInstance->AddCommand(mycommand);
virtual ~ModuleSetHost()
{
}
-
+
virtual Version GetVersion()
{
return Version(1, 2, 0, 1, VF_COMMON | VF_VENDOR, API_VERSION);
}
-
+
};
MODULE_INIT(ModuleSetHost)
user->WriteServ("NOTICE %s :*** SETIDENT: Ident must be specified", user->nick.c_str());
return CMD_FAILURE;
}
-
+
if (parameters[0].size() > ServerInstance->Config->Limits.IdentMax)
{
user->WriteServ("NOTICE %s :*** SETIDENT: Ident is too long", user->nick.c_str());
return CMD_FAILURE;
}
-
+
if (!ServerInstance->IsIdent(parameters[0].c_str()))
{
user->WriteServ("NOTICE %s :*** SETIDENT: Invalid characters in ident", user->nick.c_str());
return CMD_FAILURE;
}
-
+
user->ChangeIdent(parameters[0].c_str());
ServerInstance->SNO->WriteToSnoMask('A', "%s used SETIDENT to change their ident to '%s'", user->nick.c_str(), user->ident.c_str());
class ModuleSetIdent : public Module
{
CommandSetident* mycommand;
-
+
public:
ModuleSetIdent(InspIRCd* Me) : Module(Me)
{
-
+
mycommand = new CommandSetident(ServerInstance);
ServerInstance->AddCommand(mycommand);
}
-
+
virtual ~ModuleSetIdent()
{
}
-
+
virtual Version GetVersion()
{
return Version(1, 2, 0, 0, VF_COMMON | VF_VENDOR, API_VERSION);
}
-
+
};
ModuleSetIdle(InspIRCd* Me)
: Module(Me)
{
-
+
mycommand = new CommandSetidle(ServerInstance);
ServerInstance->AddCommand(mycommand);
}
-
+
virtual ~ModuleSetIdle()
{
}
-
+
virtual Version GetVersion()
{
return Version(1, 2, 0, 0, VF_COMMON | VF_VENDOR, API_VERSION);
user->WriteServ("NOTICE %s :*** SETNAME: GECOS must be specified", user->nick.c_str());
return CMD_FAILURE;
}
-
+
if (parameters[0].size() > ServerInstance->Config->Limits.MaxGecos)
{
user->WriteServ("NOTICE %s :*** SETNAME: GECOS too long", user->nick.c_str());
return CMD_FAILURE;
}
-
+
if (user->ChangeName(parameters[0].c_str()))
{
ServerInstance->SNO->WriteToSnoMask('A', "%s used SETNAME to change their GECOS to %s", user->nick.c_str(), parameters[0].c_str());
ModuleSetName(InspIRCd* Me)
: Module(Me)
{
-
+
mycommand = new CommandSetname(ServerInstance);
ServerInstance->AddCommand(mycommand);
}
-
+
virtual ~ModuleSetName()
{
}
-
+
virtual Version GetVersion()
{
return Version(1, 2, 0, 1, VF_COMMON | VF_VENDOR, API_VERSION);
}
-
+
};
MODULE_INIT(ModuleSetName)
{
int j;
sub_block = message + ((i - 1) << 6);
-
+
for (j = 0; j < 16; j++)
PACK32(&sub_block[j << 2], &w[j]);
for (j = 16; j < 64; j++)
ctx->h[j] += wv[j];
}
}
-
+
void SHA256Update(SHA256Context *ctx, unsigned char *message, unsigned int len)
{
/*
unsigned int tmp_len = SHA256_BLOCK_SIZE - ctx->len;
unsigned int rem_len = len < tmp_len ? len : tmp_len;
-
+
memcpy(&ctx->block[ctx->len], message, rem_len);
if (ctx->len + len < SHA256_BLOCK_SIZE)
{
ctx->len = rem_len;
ctx->tot_len += (block_nb + 1) << 6;
}
-
+
void SHA256Final(SHA256Context *ctx, unsigned char *digest)
{
unsigned int block_nb = (1 + ((SHA256_BLOCK_SIZE - 9) < (ctx->len % SHA256_BLOCK_SIZE)));
for (int i = 0 ; i < 8; i++)
UNPACK32(ctx->h[i], &digest[i << 2]);
}
-
+
void SHA256(const char *src, char *dest, int len, const char* hxc, const unsigned int* ikey = NULL)
{
// Generate the hash
class ModuleShowwhois : public Module
{
-
+
SeeWhois* sw;
public:
ModuleShowwhois(InspIRCd* Me) : Module(Me)
{
-
+
sw = new SeeWhois(ServerInstance);
if (!ServerInstance->Modes->AddMode(sw))
throw ModuleException("Could not add new modes!");
virtual int OnStats(char symbol, User* user, string_list& out)
{
// XXX write me
-//format << Srv->Config->ServerName << " 223 " << user->nick << " :" << iter->banmask << " " << iter->set_on << " " << iter->length << " " <<
-//iter->set_by << " " << iter->reason;
-
+//format << Srv->Config->ServerName << " 223 " << user->nick << " :" << iter->banmask << " " << iter->set_on << " " << iter->length << " " <<
+//iter->set_by << " " << iter->reason;
+
return 0;
}
*/
if (!ServerInstance->ULine(user->server))
return CMD_FAILURE;
-
+
User *u = ServerInstance->FindNick(parameters[0]);
if (!u)
return CMD_FAILURE;
-
+
if (IS_LOCAL(u))
{
ServerInstance->Parser->CallHandler("SILENCE", std::vector<std::string>(++parameters.begin(), parameters.end()), u);
}
-
+
return CMD_SUCCESS;
}
};
if (parameters.size() > 1) {
pattern = CompilePattern(parameters[1].c_str());
}
-
+
if (!mask.length())
{
// 'SILENCE +' or 'SILENCE -', assume *!*@*
mask = "*!*@*";
}
-
+
ModeParser::CleanMask(mask);
if (action == '-')
case 'c':
p |= SILENCE_CHANNEL;
break;
- case 'i':
+ case 'i':
p |= SILENCE_INVITE;
break;
case 'n':
CommandSVSSilence *cmdsvssilence;
unsigned int maxsilence;
public:
-
+
ModuleSilence(InspIRCd* Me)
: Module(Me), maxsilence(32)
{
virtual ~ModuleSilence()
{
}
-
+
virtual Version GetVersion()
{
return Version(1, 2, 0, 1, VF_COMMON | VF_VENDOR, API_VERSION);
User* u = Instance->FindNick(prefix);
Utils->DoOneToAllButSender(prefix, "ADDLINE", params, u ? u->server : prefix);
TreeServer *remoteserver = Utils->FindServer(u ? u->server : prefix);
-
+
if (!remoteserver->bursting)
{
Instance->XLines->ApplyLines();
if (((this->CapKeys.find("HALFOP") == this->CapKeys.end()) && (Instance->Config->AllowHalfop)) || ((this->CapKeys.find("HALFOP") != this->CapKeys.end()) && (this->CapKeys.find("HALFOP")->second != ConvToStr(Instance->Config->AllowHalfop))))
reason = "We don't both have halfop support enabled/disabled identically";
-
+
/* Challenge response, store their challenge for our password */
std::map<std::string,std::string>::iterator n = this->CapKeys.find("CHALLENGE");
if (Utils->ChallengeResponse && (n != this->CapKeys.end()) && (Instance->Modules->Find("m_sha256.so")))
if (user)
setter = user->nick;
else
- {
+ {
TreeServer* t = Utils->FindServer(prefix);
if (t)
setter = t->GetName().c_str();
if (params.size() > 3)
params[params.size() - 1] = ":" + params[params.size() - 1];
-
+
Utils->DoOneToAllButSender(source,"FJOIN",params,source);
if (!TS)
/* Advance past the comma, to the nick */
usr++;
-
+
/* Check the user actually exists */
who = this->Instance->FindUUID(usr);
if (who)
}
return true;
}
-
+
else
/* Straight string compare of plaintext */
return ours == theirs;
-}
+}
bool TreeSocket::RemoteKill(const std::string &prefix, std::deque<std::string> ¶ms)
-{
+{
if (params.size() != 2)
return true;
if (who)
{
- /* Prepend kill source, if we don't have one */
+ /* Prepend kill source, if we don't have one */
if (*(params[1].c_str()) != '[')
{
params[1] = "[" + prefix + "] Killed (" + params[1] +")";
if (ServerInstance->Users->UnregisteredUserCount())
user->WriteNumeric(253, "%s %d :unknown connections",user->nick.c_str(),ServerInstance->Users->UnregisteredUserCount());
-
+
if (ServerInstance->ChannelCount())
user->WriteNumeric(254, "%s %ld :channels formed",user->nick.c_str(),ServerInstance->ChannelCount());
-
+
user->WriteNumeric(255, "%s :I have %d clients and %d servers",user->nick.c_str(),ServerInstance->Users->LocalUserCount(),ulined_local_count ? this->CountLocalServs() - ulined_local_count : this->CountLocalServs());
user->WriteNumeric(265, "%s :Current Local Users: %d Max: %d",user->nick.c_str(),ServerInstance->Users->LocalUserCount(),max_local);
user->WriteNumeric(266, "%s :Current Global Users: %d Max: %d",user->nick.c_str(),n_users,max_global);
// ... if we can find a proper route to them
if (tsock)
{
- tsock->WriteLine(std::string(":") + ServerInstance->Config->GetSID() + " PING " +
+ tsock->WriteLine(std::string(":") + ServerInstance->Config->GetSID() + " PING " +
ServerInstance->Config->GetSID() + " " + s->GetID());
s->LastPingMsec = ts;
}
else
ServerInstance->PI->SendUserNotice(user, text);
}
-
+
SendingRemoteMessage = false;
}
-
+
int ModuleSpanningTree::HandleConnect(const std::vector<std::string>& parameters, User* user)
{
for (std::vector<Link>::iterator x = Utils->LinkBlocks.begin(); x < Utils->LinkBlocks.end(); x++)
return;
char data[MAXBUF];
- snprintf(data,MAXBUF,"%s %s %s %lu %lu :%s", x->type.c_str(), x->Displayable(),
+ snprintf(data,MAXBUF,"%s %s %s %lu %lu :%s", x->type.c_str(), x->Displayable(),
ServerInstance->Config->ServerName, (unsigned long)x->set_time, (unsigned long)x->duration, x->reason);
std::deque<std::string> params;
params.push_back(data);
{
modes.append("b");
params.append(" ").append(b->data);
- linesize += size;
+ linesize += size;
}
if ((params.length() >= Instance->Config->Limits.MaxModes) || (currsize > 350))
{
* These days, we have UID. And, so what we do is, force nick change client(s)
* involved according to timestamp rules.
*
- * RULES:
- * user@ip equal:
- * Force nick change on OLDER timestamped client
- * user@ip differ:
- * Force nick change on NEWER timestamped client
- * TS EQUAL:
- * FNC both.
- *
- * This stops abusive use of collisions, simplifies problems with loops, and so on.
+ * RULES:
+ * user@ip equal:
+ * Force nick change on OLDER timestamped client
+ * user@ip differ:
+ * Force nick change on NEWER timestamped client
+ * TS EQUAL:
+ * FNC both.
+ *
+ * This stops abusive use of collisions, simplifies problems with loops, and so on.
* -- w00t
*/
bool bChangeLocal = true;
*/
/* $ModDesc: Provides a spanning tree server link protocol */
-
+
#include "inspircd.h"
#include "commands/cmd_whois.h"
#include "commands/cmd_stats.h"
#include "socket.h"
#include "wildcard.h"
-#include "xline.h"
-#include "transport.h"
-
+#include "xline.h"
+#include "transport.h"
+
#include "m_spanningtree/timesynctimer.h"
#include "m_spanningtree/resolvers.h"
#include "m_spanningtree/main.h"
*/
/* $ModDesc: Provides a spanning tree server link protocol */
-
+
#include "inspircd.h"
#include "wildcard.h"
time_t secs_up = ServerInstance->Time() - Current->age;
return (" [Up: " + TimeToStr(secs_up) + " Lag: " + (Current->rtt == 0 ? "<1" : ConvToStr(Current->rtt)) + "ms]");
}
-
+
// WARNING: NOT THREAD SAFE - DONT GET ANY SMART IDEAS.
void ModuleSpanningTree::ShowMap(TreeServer* Current, User* user, int depth, char matrix[128][128], float &totusers, float &totservers)
{
ServerInstance->Logs->Log("map",DEBUG,"ShowMap depth %d totusers %0.2f totservers %0.2f", depth, totusers, totservers);
if (line < 128)
- {
+ {
for (int t = 0; t < depth; t++)
{
ServerInstance->Logs->Log("map",DEBUG,"Zero to depth");
matrix[line][t] = ' ';
}
-
+
// For Aligning, we need to work out exactly how deep this thing is, and produce
// a 'Spacer' String to compensate.
char spacer[40];
else
{
spacer[5] = '\0';
- }
+ }
float percent;
char text[128];
*/
/* $ModDesc: Provides a spanning tree server link protocol */
-
+
#include "inspircd.h"
#include "commands/cmd_whois.h"
#include "commands/cmd_stats.h"
#include "socket.h"
#include "wildcard.h"
-#include "xline.h"
-#include "transport.h"
-
+#include "xline.h"
+#include "transport.h"
+
#include "m_spanningtree/timesynctimer.h"
#include "m_spanningtree/resolvers.h"
#include "m_spanningtree/main.h"
*/
/* $ModDesc: Provides a spanning tree server link protocol */
-
+
#include "inspircd.h"
#include "commands/cmd_whois.h"
#include "commands/cmd_stats.h"
#include "socket.h"
#include "wildcard.h"
-#include "xline.h"
-#include "transport.h"
-
+#include "xline.h"
+#include "transport.h"
+
#include "m_spanningtree/timesynctimer.h"
#include "m_spanningtree/resolvers.h"
#include "m_spanningtree/main.h"
*/
/* $ModDesc: Provides a spanning tree server link protocol */
-
+
#include "inspircd.h"
#include "commands/cmd_whois.h"
#include "commands/cmd_stats.h"
#include "socket.h"
#include "wildcard.h"
-#include "xline.h"
-#include "transport.h"
+#include "xline.h"
+#include "transport.h"
#include "m_spanningtree/timesynctimer.h"
#include "m_spanningtree/resolvers.h"
*/
/* $ModDesc: Provides a spanning tree server link protocol */
-
+
#include "inspircd.h"
#include "commands/cmd_whois.h"
#include "commands/cmd_stats.h"
#include "socket.h"
#include "wildcard.h"
-#include "xline.h"
-#include "transport.h"
-
+#include "xline.h"
+#include "transport.h"
+
#include "m_spanningtree/timesynctimer.h"
#include "m_spanningtree/resolvers.h"
#include "m_spanningtree/main.h"
#include "m_spanningtree/treesocket.h"
#include "m_spanningtree/rconnect.h"
#include "m_spanningtree/rsquit.h"
-
+
/* $ModDep: m_spanningtree/timesynctimer.h m_spanningtree/resolvers.h m_spanningtree/main.h m_spanningtree/utils.h m_spanningtree/treeserver.h m_spanningtree/link.h m_spanningtree/treesocket.h m_spanningtree/rconnect.h m_spanningtree/rsquit.h */
int ModuleSpanningTree::HandleStats(const std::vector<std::string>& parameters, User* user)
*/
/* $ModDesc: Provides a spanning tree server link protocol */
-
+
#include "inspircd.h"
#include "commands/cmd_whois.h"
#include "commands/cmd_stats.h"
#include "socket.h"
#include "wildcard.h"
-#include "xline.h"
-#include "transport.h"
-
+#include "xline.h"
+#include "transport.h"
+
#include "m_spanningtree/timesynctimer.h"
#include "m_spanningtree/resolvers.h"
#include "m_spanningtree/main.h"
#include "m_spanningtree/treesocket.h"
#include "m_spanningtree/rconnect.h"
#include "m_spanningtree/rsquit.h"
-
+
/* $ModDep: m_spanningtree/timesynctimer.h m_spanningtree/resolvers.h m_spanningtree/main.h m_spanningtree/utils.h m_spanningtree/treeserver.h m_spanningtree/link.h m_spanningtree/treesocket.h m_spanningtree/rconnect.h m_spanningtree/rsquit.h */
int ModuleSpanningTree::HandleTime(const std::vector<std::string>& parameters, User* user)
// we dont' override for local server
if (found == Utils->TreeRoot)
return 0;
-
+
std::deque<std::string> params;
params.push_back(found->GetName());
params.push_back(user->uuid);
*/
/* $ModDesc: Provides a spanning tree server link protocol */
-
+
#include "inspircd.h"
#include "commands/cmd_whois.h"
#include "commands/cmd_stats.h"
#include "socket.h"
#include "wildcard.h"
-#include "xline.h"
-#include "transport.h"
-
+#include "xline.h"
+#include "transport.h"
+
#include "m_spanningtree/timesynctimer.h"
#include "m_spanningtree/resolvers.h"
#include "m_spanningtree/main.h"
#include "m_spanningtree/treesocket.h"
#include "m_spanningtree/rconnect.h"
#include "m_spanningtree/rsquit.h"
-
+
/* $ModDep: m_spanningtree/timesynctimer.h m_spanningtree/resolvers.h m_spanningtree/main.h m_spanningtree/utils.h m_spanningtree/treeserver.h m_spanningtree/link.h m_spanningtree/treesocket.h m_spanningtree/rconnect.h m_spanningtree/rsquit.h */
int ModuleSpanningTree::HandleRemoteWhois(const std::vector<std::string>& parameters, User* user)
*/
/* $ModDesc: Provides a spanning tree server link protocol */
-
+
#include "inspircd.h"
#include "commands/cmd_whois.h"
#include "commands/cmd_stats.h"
#include "socket.h"
#include "wildcard.h"
-#include "xline.h"
-#include "transport.h"
-
+#include "xline.h"
+#include "transport.h"
+
#include "m_spanningtree/timesynctimer.h"
#include "m_spanningtree/resolvers.h"
#include "m_spanningtree/main.h"
ServerInstance->Logs->Log("m_spanningtree",DEBUG,"TRANSLATION: %s - type is %d", parameters[j].c_str(), translate_to);
ServerInstance->Parser->TranslateUIDs(translate_to, parameters[j], target);
-
+
if (j == (parameters.size() - 1))
params.push_back(":" + target);
else
*/
/* $ModDesc: Provides a spanning tree server link protocol */
-
+
#include "inspircd.h"
#include "commands/cmd_whois.h"
#include "commands/cmd_stats.h"
#include "socket.h"
#include "wildcard.h"
-#include "xline.h"
-#include "transport.h"
-
+#include "xline.h"
+#include "transport.h"
+
#include "m_spanningtree/timesynctimer.h"
#include "m_spanningtree/resolvers.h"
#include "m_spanningtree/main.h"
}
Channel* channel = Instance->FindChan(target);
-
+
if (channel)
{
if (messagetype == "PRIVMSG")
else
{
User* user = Instance->FindNick(target);
-
+
if (user)
{
if (messagetype == "PRIVMSG")
Instance->Logs->Log("m_spanningtree",DEBUG, "S[%d] I %s", this->GetFd(), line.c_str());
this->Split(line.c_str(),params);
-
+
if (params.empty())
return true;
-
+
if ((params[0][0] == ':') && (params.size() > 1))
{
prefix = params[0].substr(1);
params.pop_front();
-
+
if (prefix.empty())
{
this->SendError("BUG (?) Empty prefix recieved.");
return false;
}
}
-
+
command = params[0].c_str();
params.pop_front();
/*
* Now, check for (and parse) commands as appropriate. -- w
- */
-
+ */
+
/* Find the server that this command originated from, used in the handlers below */
TreeServer *ServerSource = Utils->FindServer(prefix);
this->Instance->SNO->WriteToSnoMask('l', "WTF: Got BURST from a nonexistant server(?): %s", (ServerSource ? ServerSource->GetName().c_str() : prefix.c_str()));
return false;
}
-
+
ServerSource->bursting = true;
return Utils->DoOneToAllButSenderRaw(line, sourceserv, prefix, command, params);
}
this->Instance->SNO->WriteToSnoMask('l', "WTF: Got ENDBURST from a nonexistant server(?): %s", (ServerSource ? ServerSource->GetName().c_str() : prefix.c_str()));
return false;
}
-
+
ServerSource->FinishBurst();
return Utils->DoOneToAllButSenderRaw(line, sourceserv, prefix, command, params);
}
return false;
}
}
-
+
// Insert into the parser
this->Instance->SendMode(modelist, this->Instance->FakeClient);
-
+
// Pass out to the network
return Utils->DoOneToAllButSenderRaw(line,sourceserv,prefix,command,params);
}
}
}
}
-
+
// its a user
std::vector<std::string> strparams(params.begin(), params.end());
if (!quitserver.empty())
{
Utils->Creator->RemoteMessage(NULL,"Connection to '\2%s\2' failed.",quitserver.c_str());
- time_t server_uptime = Instance->Time() - this->age;
+ time_t server_uptime = Instance->Time() - this->age;
if (server_uptime)
Utils->Creator->RemoteMessage(NULL,"Connection to '\2%s\2' was established for %s", quitserver.c_str(), Utils->Creator->TimeToStr(server_uptime).c_str());
}
Instance->Users->AddGlobalClone(_new);
bool dosend = true;
-
+
if ((this->Utils->quiet_bursts && remoteserver->bursting) || this->Instance->SilentULine(_new->server))
dosend = false;
-
+
if (dosend)
this->Instance->SNO->WriteToSnoMask('C',"Client connecting at %s: %s!%s@%s [%s] [%s]", _new->server, _new->nick.c_str(), _new->ident.c_str(), _new->host.c_str(), _new->GetIPString(), _new->fullname.c_str());
return 0;
}
- void Prioritize()
- {
+ void Prioritize()
+ {
/* To ensure that we get priority over namesx and delayjoin for names list generation */
Module* list[] = { ServerInstance->Modules->Find("m_namesx.so"), ServerInstance->Modules->Find("m_delayjoin.so") };
ServerInstance->Modules->SetPriority(this, I_OnUserList, PRIO_BEFORE, list, 2);
}
-
+
virtual ~ModuleSpy()
{
}
-
+
virtual Version GetVersion()
{
return Version(1, 2, 0, 0, VF_VENDOR, API_VERSION);
class ModuleSSLDummy : public Module
{
-
+
char* dummy;
public:
-
+
ModuleSSLDummy(InspIRCd* Me) : Module(Me)
{
-
+
Implementation eventlist[] = { I_OnSyncUserMetaData, I_OnDecodeMetaData, I_OnWhois };
ServerInstance->Modules->Attach(eventlist, this, 3);
}
-
+
virtual ~ModuleSSLDummy()
{
}
-
+
virtual Version GetVersion()
{
return Version(1, 0, 0, 0, VF_VENDOR, API_VERSION);
ServerInstance->SendWhoisLine(source, dest, 320, "%s %s :is using a secure connection", source->nick.c_str(), dest->nick.c_str());
}
}
-
+
virtual void OnSyncUserMetaData(User* user, Module* proto, void* opaque, const std::string &extname, bool displayable)
{
// check if the linking module wants to know about OUR metadata
}
}
}
-
+
virtual void OnDecodeMetaData(int target_type, void* target, const std::string &extname, const std::string &extdata)
{
// check if its our metadata key, and its associated with a user
class ModuleSSLModes : public Module
{
-
+
SSLMode* sslm;
-
+
public:
ModuleSSLModes(InspIRCd* Me)
: Module(Me)
{
-
+
sslm = new SSLMode(ServerInstance);
if (!ServerInstance->Modes->AddMode(sslm))
return 1;
}
}
-
+
return 0;
}
ServerInstance->Modes->DelMode(sslm);
delete sslm;
}
-
+
virtual Version GetVersion()
{
return Version(1, 2, 0, 0, VF_COMMON | VF_VENDOR, API_VERSION);
bool AllowChanOps;
ChannelStripColor *csc;
UserStripColor *usc;
-
+
public:
ModuleStripColor(InspIRCd* Me) : Module(Me)
{
delete usc;
delete csc;
}
-
+
virtual void ReplaceLine(std::string &sentence)
{
/* refactor this completely due to SQUIT bug since the old code would strip last char and replace with \0 --peavey */
}
else
seq = 0;
-
+
if (seq || ((*i == 2) || (*i == 15) || (*i == 22) || (*i == 21) || (*i == 31)))
{
if (i != sentence.begin())
return 0;
}
-
+
virtual int OnUserPreNotice(User* user,void* dest,int target_type, std::string &text, char status, CUList &exempt_list)
{
return OnUserPreMessage(user,dest,target_type,text,status,exempt_list);
}
-
+
virtual Version GetVersion()
{
return Version(1, 2, 0, 0, VF_COMMON | VF_VENDOR, API_VERSION);
}
-
+
};
MODULE_INIT(ModuleStripColor)
// parameters[0] = w00t
// parameters[1] = 1h3m2s
// parameters[2] = Registered nickname
-
+
/* Already exists? */
if (HoldMap.find(parameters[0].c_str()) != HoldMap.end())
{
unsigned long length = ServerInstance->Duration(parameters[1]);
std::string reason = (parameters.size() > 2) ? parameters[2] : "No reason supplied";
-
+
SVSHold* S = new SVSHold(parameters[0], user->nick, ServerInstance->Time(), length, reason);
SVSHolds.push_back(S);
HoldMap[parameters[0].c_str()] = S;
class ModuleSVSHold : public Module
{
CommandSvshold *mycommand;
-
+
public:
ModuleSVSHold(InspIRCd* Me) : Module(Me)
ServerInstance->Modules->Attach(eventlist, this, 4);
}
-
+
virtual int OnStats(char symbol, User* user, string_list &results)
{
ExpireBans();
-
+
if(symbol == 'S')
{
for(SVSHoldlist::iterator iter = SVSHolds.begin(); iter != SVSHolds.end(); iter++)
results.push_back(std::string(ServerInstance->Config->ServerName)+" 210 "+user->nick+" "+(*iter)->nickname.c_str()+" "+(*iter)->set_by+" "+ConvToStr((*iter)->set_on)+" "+ConvToStr((*iter)->length)+" "+ConvToStr(remaining)+" :"+(*iter)->reason);
}
}
-
+
return 0;
}
virtual int OnUserPreNick(User *user, const std::string &newnick)
{
ExpireBans();
-
+
/* check SVSHolds in here, and apply as necessary. */
SVSHoldMap::iterator n = HoldMap.find(assign(newnick));
if (n != HoldMap.end())
}
return 0;
}
-
+
virtual void OnSyncOtherMetaData(Module* proto, void* opaque, bool displayable)
{
for(SVSHoldMap::iterator iter = HoldMap.begin(); iter != HoldMap.end(); iter++)
virtual ~ModuleSVSHold()
{
}
-
+
virtual Version GetVersion()
{
return Version(1, 2, 0, 1, VF_COMMON | VF_VENDOR, API_VERSION);
std::string EncodeSVSHold(const SVSHold* ban)
{
- std::ostringstream stream;
+ std::ostringstream stream;
stream << ban->nickname << " " << ban->set_by << " " << ban->set_on << " " << ban->length << " :" << ban->reason;
- return stream.str();
+ return stream.str();
}
SVSHold* DecodeSVSHold(const std::string &data)
*/
class CommandSwhois : public Command
{
-
+
public:
CommandSwhois (InspIRCd* Instance) : Command(Instance,"SWHOIS","o",2)
{
CmdResult Handle(const std::vector<std::string> ¶meters, User* user)
{
User* dest = ServerInstance->FindNick(parameters[0]);
-
+
if (!dest)
{
user->WriteNumeric(401, "%s %s :No such nick/channel", user->nick.c_str(), parameters[0].c_str());
return CMD_FAILURE;
}
-
+
std::string* text;
dest->GetExt("swhois", text);
if (!ServerInstance->ULine(user->server))
// Ulines set SWHOISes silently
ServerInstance->SNO->WriteToSnoMask('A', "%s used SWHOIS to set %s's extra whois from '%s' to '%s'", user->nick.c_str(), dest->nick.c_str(), text->c_str(), parameters[0].c_str());
-
+
dest->Shrink("swhois");
delete text;
}
// Ulines set SWHOISes silently
ServerInstance->SNO->WriteToSnoMask('A', "%s used SWHOIS to set %s's extra whois to '%s'", user->nick.c_str(), dest->nick.c_str(), parameters[0].c_str());
}
-
+
text = new std::string(parameters[0]);
dest->Extend("swhois", text);
* -- Brain
*/
ServerInstance->PI->SendMetaData(dest, TYPE_USER, "swhois", *text);
-
+
// If it's an empty swhois, unset it (not ideal, but ok)
if (text->empty())
{
class ModuleSWhois : public Module
{
CommandSwhois* mycommand;
-
+
ConfigReader* Conf;
-
+
public:
ModuleSWhois(InspIRCd* Me) : Module(Me)
{
-
+
Conf = new ConfigReader(ServerInstance);
mycommand = new CommandSwhois(ServerInstance);
ServerInstance->AddCommand(mycommand);
dest->Extend("swhois", text);
}
}
-
+
virtual void OnPostCommand(const std::string &command, const std::vector<std::string> ¶ms, User *user, CmdResult result, const std::string &original_line)
{
if ((command != "OPER") || (result != CMD_SUCCESS))
return;
-
+
std::string swhois;
-
+
for (int i = 0; i < Conf->Enumerate("oper"); i++)
{
std::string name = Conf->ReadValue("oper", "name", i);
-
+
if (name == params[0])
{
swhois = Conf->ReadValue("oper", "swhois", i);
break;
}
}
-
+
if (!swhois.length())
{
for (int i = 0; i < Conf->Enumerate("type"); i++)
{
std::string type = Conf->ReadValue("type", "name", i);
-
+
if (type == user->oper)
{
swhois = Conf->ReadValue("type", "swhois", i);
user->Shrink("swhois");
delete old;
}
-
+
if (!swhois.length())
return;
-
+
std::string *text = new std::string(swhois);
user->Extend("swhois", text);
ServerInstance->PI->SendMetaData(user, TYPE_USER, "swhois", *text);
{
delete Conf;
}
-
+
virtual Version GetVersion()
{
return Version(1, 2, 0, 0, VF_COMMON | VF_VENDOR, API_VERSION);
ModuleTaxonomy(InspIRCd* Me)
: Module(Me)
{
-
+
// Create a new command
newcommand = new CommandTaxonomy(ServerInstance, this, claimed);
ServerInstance->AddCommand(newcommand);
ModuleTimedBans(InspIRCd* Me)
: Module(Me)
{
-
+
mycommand = new CommandTban(ServerInstance);
ServerInstance->AddCommand(mycommand);
TimedBanList.clear();
Implementation eventlist[] = { I_OnDelBan, I_OnBackgroundTimer };
ServerInstance->Modules->Attach(eventlist, this, 2);
}
-
+
virtual ~ModuleTimedBans()
{
TimedBanList.clear();
}
}
}
-
+
virtual Version GetVersion()
{
return Version(1, 2, 0, 0, VF_COMMON | VF_VENDOR, API_VERSION);
/* $ModDesc: Provides /tline command used to test who a mask matches */
/** Handle /TLINE
- */
+ */
class CommandTline : public Command
{
public:
else
user->WriteServ( "NOTICE %s :*** TLINE: Counted %0.0f user(s). Matched '%s' against no user(s).", user->nick.c_str(), n_counted, parameters[0].c_str());
- return CMD_LOCALONLY;
+ return CMD_LOCALONLY;
}
};
ModuleTLine(InspIRCd* Me)
: Module(Me)
{
-
+
newcommand = new CommandTline(ServerInstance);
ServerInstance->AddCommand(newcommand);
virtual ~ModuleTLine()
{
}
-
+
virtual Version GetVersion()
{
return Version(1, 2, 0, 0, VF_VENDOR,API_VERSION);
{
CUList nl;
public:
-
+
ModuleUHNames(InspIRCd* Me)
: Module(Me)
{
#include "inspircd.h"
/** Handle /UNINVITE
- */
+ */
class CommandUninvite : public Command
{
public:
{
User* u = ServerInstance->FindNick(parameters[0]);
Channel* c = ServerInstance->FindChan(parameters[1]);
-
+
if ((!c) || (!u))
- {
+ {
if (!c)
{
user->WriteNumeric(401, "%s %s :No such nick/channel",user->nick.c_str(), parameters[1].c_str());
{
user->WriteNumeric(401, "%s %s :No such nick/channel",user->nick.c_str(), parameters[0].c_str());
}
-
+
return CMD_FAILURE;
- }
+ }
if (c->modes[CM_INVITEONLY])
{
ModuleUninvite(InspIRCd* Me) : Module(Me)
{
-
+
mycommand = new CommandUninvite(ServerInstance);
ServerInstance->AddCommand(mycommand);
}
-
+
virtual ~ModuleUninvite()
{
}
-
+
virtual Version GetVersion()
{
return Version(1, 2, 0, 0, VF_VENDOR, API_VERSION);
ModuleUserIP(InspIRCd* Me)
: Module(Me)
{
-
+
mycommand = new CommandUserip(ServerInstance);
ServerInstance->AddCommand(mycommand);
Implementation eventlist[] = { I_On005Numeric };
{
output = output + std::string(" USERIP");
}
-
+
virtual ~ModuleUserIP()
{
}
-
+
virtual Version GetVersion()
{
return Version(1,2,0,1,VF_VENDOR,API_VERSION);
}
-
+
};
MODULE_INIT(ModuleUserIP)
private:
CommandVhost* mycommand;
-
+
public:
ModuleVHost(InspIRCd* Me) : Module(Me)
{
ServerInstance->AddCommand(mycommand);
}
-
+
virtual ~ModuleVHost()
{
}
{
return Version(1,2,0,1,VF_VENDOR,API_VERSION);
}
-
+
};
MODULE_INIT(ModuleVHost)
*
* KEY: Brain ---> Watched by: Boo, w00t, Om
* KEY: Boo ---> Watched by: Brain, w00t
- *
+ *
* This is used when we want to tell all the users that are watching someone that
* they are now available or no longer available. For example, if the hash was
* populated as shown above, then when Brain signs on, messages are sent to Boo, w00t
{
if (!ServerInstance->ULine(user->server))
return CMD_FAILURE;
-
+
User *u = ServerInstance->FindNick(parameters[0]);
if (!u)
return CMD_FAILURE;
-
+
if (IS_LOCAL(u))
{
ServerInstance->Parser->CallHandler("WATCH", parameters, u);
}
-
+
return CMD_SUCCESS;
}
};
CommandWatch* mycommand;
CommandSVSWatch *sw;
unsigned int maxwatch;
-
+
public:
Modulewatch(InspIRCd* Me)
: Module(Me), maxwatch(32)
if (n != i2->second.end())
/* I'm no longer watching you... */
i2->second.erase(n);
-
+
if (!i2->second.size())
whos_watching_me->erase(user->nick.c_str());
}
}
}
}
- }
+ }
virtual void On005Numeric(std::string &output)
{
// we don't really have a limit...
output = output + " WATCH=" + ConvToStr(maxwatch);
}
-
+
virtual ~Modulewatch()
{
delete whos_watching_me;
}
-
+
virtual Version GetVersion()
{
return Version(1, 2, 0, 0, VF_COMMON | VF_VENDOR, API_VERSION);
return true;
}
-
+
virtual Version GetVersion()
{
}
}
- virtual void OnCleanup(int target_type, void* item)
+ virtual void OnCleanup(int target_type, void* item)
{
if(target_type == TYPE_USER)
{