|
|||
|
|||
|


Public Member Functions | |
| ModuleSQLLog (InspIRCd *Me) | |
| virtual | ~ModuleSQLLog () |
| void | Implements (char *List) |
| The Implements function specifies which methods a module should receive events for. | |
| void | ReadConfig () |
| virtual void | OnRehash (userrec *user, const std::string ¶meter) |
| Called on rehash. | |
| virtual char * | OnRequest (Request *request) |
| Called whenever a Request class is sent to your module by another module. | |
| void | AddLogEntry (int category, const std::string &nick, const std::string &host, const std::string &source) |
| virtual void | OnOper (userrec *user, const std::string &opertype) |
| Called whenever a user opers locally. | |
| virtual void | OnGlobalOper (userrec *user) |
| Called whenever a user is given usermode +o, anywhere on the network. | |
| virtual int | OnKill (userrec *source, userrec *dest, const std::string &reason) |
| Called when a client is disconnected by KILL. | |
| virtual int | OnPreCommand (const std::string &command, const char **parameters, int pcnt, userrec *user, bool validated, const std::string &original_line) |
| Called whenever any command is about to be executed. | |
| virtual void | OnUserConnect (userrec *user) |
| Called when a user connects. | |
| virtual void | OnUserQuit (userrec *user, const std::string &reason, const std::string &oper_message) |
| Called when a user quits. | |
| virtual void | OnLoadModule (Module *mod, const std::string &name) |
| Called whenever a module is loaded. | |
| virtual Version | GetVersion () |
| Returns the version number of a Module. | |
Private Attributes | |
| ConfigReader * | Conf |
Definition at line 182 of file m_sqllog.cpp.
|
|
Definition at line 187 of file m_sqllog.cpp. References active_queries, InspIRCd::FindFeature(), InspIRCd::FindModule(), OnRehash(), Module::ServerInstance, and InspIRCd::UseInterface(). 00188 : Module::Module(Me) 00189 { 00190 ServerInstance->UseInterface("SQLutils"); 00191 ServerInstance->UseInterface("SQL"); 00192 00193 Module* SQLutils = ServerInstance->FindModule("m_sqlutils.so"); 00194 if (!SQLutils) 00195 throw ModuleException("Can't find m_sqlutils.so. Please load m_sqlutils.so before m_sqlauth.so."); 00196 00197 SQLModule = ServerInstance->FindFeature("SQL"); 00198 00199 OnRehash(NULL,""); 00200 MyMod = this; 00201 active_queries.clear(); 00202 }
|
|
|
Definition at line 204 of file m_sqllog.cpp. References InspIRCd::DoneWithInterface(), and Module::ServerInstance. 00205 { 00206 ServerInstance->DoneWithInterface("SQL"); 00207 ServerInstance->DoneWithInterface("SQLutils"); 00208 }
|
|
||||||||||||||||||||
|
Definition at line 251 of file m_sqllog.cpp. References active_queries, dbid, FIND_SOURCE, SQLrequest::id, QueryInfo::qs, Request::Send(), and SQLreq. Referenced by OnGlobalOper(), OnKill(), OnLoadModule(), OnOper(), OnPreCommand(), OnUserConnect(), and OnUserQuit(). 00252 { 00253 // is the sql module loaded? If not, we don't attempt to do anything. 00254 if (!SQLModule) 00255 return; 00256 00257 SQLrequest req = SQLreq(this, SQLModule, dbid, "SELECT id,actor FROM ircd_log_actors WHERE actor='?'", source); 00258 if(req.Send()) 00259 { 00260 QueryInfo* i = new QueryInfo(nick, source, host, req.id, category); 00261 i->qs = FIND_SOURCE; 00262 active_queries[req.id] = i; 00263 } 00264 }
|
|
|
Returns the version number of a Module. The method should return a Version object with its version information assigned via Version::Version Reimplemented from Module. Definition at line 306 of file m_sqllog.cpp. References API_VERSION, and VF_VENDOR. 00307 { 00308 return Version(1,1,0,1,VF_VENDOR,API_VERSION); 00309 }
|
|
|
The Implements function specifies which methods a module should receive events for. The char* parameter passed to this function contains a set of true or false values (1 or 0) which indicate wether each function is implemented. You must use the Iimplementation enum (documented elsewhere on this page) to mark functions as active. For example, to receive events for OnUserJoin(): Implements[I_OnUserJoin] = 1;
Reimplemented from Module. Definition at line 210 of file m_sqllog.cpp. References I_OnGlobalOper, I_OnKill, I_OnLoadModule, I_OnOper, I_OnPreCommand, I_OnRehash, I_OnRequest, I_OnUserConnect, and I_OnUserQuit. 00211 { 00212 List[I_OnRehash] = List[I_OnOper] = List[I_OnGlobalOper] = List[I_OnKill] = 1; 00213 List[I_OnPreCommand] = List[I_OnUserConnect] = 1; 00214 List[I_OnUserQuit] = List[I_OnLoadModule] = List[I_OnRequest] = 1; 00215 }
|
|
|
Called whenever a user is given usermode +o, anywhere on the network. You cannot override this and prevent it from happening as it is already happened and such a task must be performed by another server. You can however bounce modes by sending servermodes out to reverse mode changes.
Reimplemented from Module. Definition at line 271 of file m_sqllog.cpp. References AddLogEntry(), connection::host, LT_OPER, userrec::nick, and userrec::server. 00272 { 00273 AddLogEntry(LT_OPER,user->nick,user->host,user->server); 00274 }
|
|
||||||||||||||||
|
Called when a client is disconnected by KILL. If a client is killed by a server, e.g. a nickname collision or protocol error, source is NULL. Return 1 from this function to prevent the kill, and 0 from this function to allow it as normal. If you prevent the kill no output will be sent to the client, it is down to your module to generate this information. NOTE: It is NOT advisable to stop kills which originate from servers or remote users. If you do so youre risking race conditions, desyncs and worse!
Reimplemented from Module. Definition at line 276 of file m_sqllog.cpp. References AddLogEntry(), connection::host, LT_KILL, and userrec::nick. 00277 { 00278 AddLogEntry(LT_KILL,dest->nick,dest->host,source->nick); 00279 return 0; 00280 }
|
|
||||||||||||
|
Called whenever a module is loaded. mod will contain a pointer to the module, and string will contain its name, for example m_widgets.so. This function is primary for dependency checking, your module may decide to enable some extra features if it sees that you have for example loaded "m_killwidgets.so" with "m_makewidgets.so". It is highly recommended that modules do *NOT* bail if they cannot satisfy dependencies, but instead operate under reduced functionality, unless the dependency is absolutely neccessary (e.g. a module that extends the features of another module).
Reimplemented from Module. Definition at line 301 of file m_sqllog.cpp. References AddLogEntry(), InspIRCd::Config, LT_LOADMODULE, Module::ServerInstance, and ServerConfig::ServerName. 00302 { 00303 AddLogEntry(LT_LOADMODULE,name,ServerInstance->Config->ServerName, ServerInstance->Config->ServerName); 00304 }
|
|
||||||||||||
|
Called whenever a user opers locally. The userrec will contain the oper mode 'o' as this function is called after any modifications are made to the user's structure by the core.
Reimplemented from Module. Definition at line 266 of file m_sqllog.cpp. References AddLogEntry(), connection::host, LT_OPER, userrec::nick, and userrec::server. 00267 { 00268 AddLogEntry(LT_OPER,user->nick,user->host,user->server); 00269 }
|
|
||||||||||||||||||||||||||||
|
Called whenever any command is about to be executed. This event occurs for all registered commands, wether they are registered in the core, or another module, and for invalid commands. Invalid commands may only be sent to this function when the value of validated is false. By returning 1 from this method you may prevent the command being executed. If you do this, no output is created by the core, and it is down to your module to produce any output neccessary. Note that unless you return 1, you should not destroy any structures (e.g. by using InspIRCd::QuitUser) otherwise when the command's handler function executes after your method returns, it will be passed an invalid pointer to the user object and crash!)
Reimplemented from Module. Definition at line 282 of file m_sqllog.cpp. References AddLogEntry(), LT_XLINE, userrec::nick, and userrec::server. 00283 { 00284 if ((command == "GLINE" || command == "KLINE" || command == "ELINE" || command == "ZLINE") && validated) 00285 { 00286 AddLogEntry(LT_XLINE,user->nick,command[0]+std::string(":")+std::string(parameters[0]),user->server); 00287 } 00288 return 0; 00289 }
|
|
||||||||||||
|
Called on rehash. This method is called prior to a /REHASH or when a SIGHUP is received from the operating system. You should use it to reload any files so that your module keeps in step with the rest of the application. If a parameter is given, the core has done nothing. The module receiving the event can decide if this parameter has any relevence to it.
Reimplemented from Module. Definition at line 223 of file m_sqllog.cpp. References ReadConfig(). Referenced by ModuleSQLLog(). 00224 { 00225 ReadConfig(); 00226 }
|
|
|
Called whenever a Request class is sent to your module by another module. Please see the documentation of Request::Send() for further information. The Request sent can always be assumed to be non-NULL, you should not change the request object or its data. Your method may return arbitary data in the char* result which the requesting module may be able to use for pre-determined purposes (e.g. the results of an SQL query, etc).
Reimplemented from Module. Definition at line 228 of file m_sqllog.cpp. References active_queries, Request::GetId(), SQLresult::id, SQLRESID, and SQLSUCCESS. 00229 { 00230 if(strcmp(SQLRESID, request->GetId()) == 0) 00231 { 00232 SQLresult* res; 00233 std::map<unsigned long, QueryInfo*>::iterator n; 00234 00235 res = static_cast<SQLresult*>(request); 00236 n = active_queries.find(res->id); 00237 00238 if (n != active_queries.end()) 00239 { 00240 n->second->Go(res); 00241 std::map<unsigned long, QueryInfo*>::iterator n = active_queries.find(res->id); 00242 active_queries.erase(n); 00243 } 00244 00245 return SQLSUCCESS; 00246 } 00247 00248 return NULL; 00249 }
|
|
|
Called when a user connects. The details of the connecting user are available to you in the parameter userrec *user
Reimplemented from Module. Definition at line 291 of file m_sqllog.cpp. References AddLogEntry(), connection::host, LT_CONNECT, userrec::nick, and userrec::server. 00292 { 00293 AddLogEntry(LT_CONNECT,user->nick,user->host,user->server); 00294 }
|
|
||||||||||||||||
|
Called when a user quits. The details of the exiting user are available to you in the parameter userrec *user This event is only called when the user is fully registered when they quit. To catch raw disconnections, use the OnUserDisconnect method.
Reimplemented from Module. Definition at line 296 of file m_sqllog.cpp. References AddLogEntry(), connection::host, LT_DISCONNECT, userrec::nick, and userrec::server. 00297 { 00298 AddLogEntry(LT_DISCONNECT,user->nick,user->host,user->server); 00299 }
|
|
|
Definition at line 217 of file m_sqllog.cpp. References Conf, dbid, ConfigReader::ReadValue(), and Module::ServerInstance. Referenced by OnRehash(). 00218 { 00219 ConfigReader Conf(ServerInstance); 00220 dbid = Conf.ReadValue("sqllog","dbid",0); // database id of a database configured in sql module 00221 }
|
|
|
Definition at line 184 of file m_sqllog.cpp. Referenced by ReadConfig(). |