* ---------------------------------------------------
*/
-#ifndef __BASE_H__
-#define __BASE_H__
+#ifndef __BASE_H__
+#define __BASE_H__
#include <map>
#include <deque>
* Wherever possible, all classes you create should inherit from this,
* giving them the ability to be passed to various core functions
* as 'anonymous' classes.
-*/
+*/
class CoreExport classbase
{
public:
* Holds all extensible metadata for the class.
*/
ExtensibleStore Extension_Items;
-
+
public:
/** Extend an Extensible class.
* @return Returns true on success.
*/
bool Shrink(const std::string &key);
-
+
/** Get an extension item.
*
* @param key The key parameter is an arbitary string which identifies the extension data
return false;
}
}
-
+
/** Get an extension item.
*
* @param key The key parameter is an arbitary string which identifies the extension data
* @return Returns true if the item was found and false if it was not.
- *
+ *
* This single-parameter version only checks if the key exists, it does nothing with
* the 'data' field and is probably only useful in conjunction with the single-parameter
* version of Extend().
/** OR two BoolSets together
*/
BoolSet operator|(BoolSet other);
-
+
/** AND two BoolSets together
*/
BoolSet operator&(BoolSet other);
* function will return true, otherwise it will return false.
*/
bool IsValidCommand(const std::string &commandname, unsigned int pcnt, User * user);
-
+
/** LoopCall is used to call a command classes handler repeatedly based on the contents of a comma seperated list.
* There are two overriden versions of this method, one of which takes two potential lists and the other takes one.
* We need a version which takes two potential lists for JOIN, because a JOIN may contain two lists of items at once,
};
#endif
-
/** Whowas container, contains a map of vectors of users tracked by WHOWAS
*/
whowas_users whowas;
-
+
/** Whowas container, contains a map of time_t to users tracked by WHOWAS
*/
whowas_users_fifo whowas_fifo;
/* handy defines */
/** Determines if a channel op is exempt from given mode m,
- * in config of server instance s.
+ * in config of server instance s.
*/
#define CHANOPS_EXEMPT(s, m) (s->Config->ExemptChanOps[(unsigned char)m])
/** Not used any more as it is named, can probably be removed or renamed.
*/
int DoDownloads();
-
+
/** This holds all the information in the config file,
* it's indexed by tag name to a vector of key/values.
*/
/** Notice to give to users when they are Xlined
*/
char MoronBanner[MAXBUF];
-
+
/* Holds the network name the local server
* belongs to. This is an arbitary field defined
* by the administrator.
* foreground.
*/
bool nofork;
-
+
/** If this value if true then all log
* messages will be output, regardless of
* the level given in the config file.
* option.
*/
bool forcedebug;
-
+
/** If this is true then log output will be
* written to the logfile. This is the default.
* If you put -nolog on the commandline then
* only to operators.
*/
char UserStats[MAXBUF];
-
+
/** The path and filename of the ircd.log file
*/
std::string logpath;
* tag/key/value at load-time rather than at read-value time.
*/
bool LoadConf(ConfigDataHash &target, FILE* &conf, const std::string &filename, std::ostringstream &errorstream);
-
+
/** Writes 'length' chars into 'result' as a string
*/
bool ConfValue(ConfigDataHash &target, const char* tag, const char* var, int index, char* result, int length, bool allow_linefeeds = false);
/** Writes 'length' chars into 'result' as a string
*/
bool ConfValue(ConfigDataHash &target, const std::string &tag, const std::string &var, const std::string &default_value, int index, std::string &result, bool allow_linefeeds = false);
-
+
/** Tries to convert the value to an integer and write it to 'result'
*/
bool ConfValueInteger(ConfigDataHash &target, const char* tag, const char* var, int index, int &result);
/** Tries to convert the value to an integer and write it to 'result'
*/
bool ConfValueInteger(ConfigDataHash &target, const std::string &tag, const std::string &var, const std::string &default_value, int index, int &result);
-
+
/** Returns true if the value exists and has a true value, false otherwise
*/
bool ConfValueBool(ConfigDataHash &target, const char* tag, const char* var, int index);
/** Returns true if the value exists and has a true value, false otherwise
*/
bool ConfValueBool(ConfigDataHash &target, const std::string &tag, const std::string &var, const std::string &default_value, int index);
-
+
/** Returns the number of occurences of tag in the config file
*/
int ConfValueEnum(ConfigDataHash &target, const char* tag);
/** Returns the number of occurences of tag in the config file
*/
int ConfValueEnum(ConfigDataHash &target, const std::string &tag);
-
+
/** Returns the numbers of vars inside the index'th 'tag in the config file
*/
int ConfVarEnum(ConfigDataHash &target, const char* tag, int index);
*/
bool InitClasses(ServerConfig* conf, const char* tag);
-/** Initialize an oper type
+/** Initialize an oper type
*/
bool DoType(ServerConfig* conf, const char* tag, char** entries, ValueList &values, int* types);
/** Initialize x line
*/
bool InitXLine(ServerConfig* conf, const char* tag);
-
+
/** Add a config-defined zline
*/
bool DoZLine(ServerConfig* conf, const char* tag, char** entries, ValueList &values, int* types);
*/
bool DoELine(ServerConfig* conf, const char* tag, char** entries, ValueList &values, int* types);
-
-
-
#endif
-
*
* ---------------------------------------------------
*/
-
+
#ifndef __CTABLES_H__
#define __CTABLES_H__
translation.push_back(x5);translation.push_back(x6);translation.push_back(x7);translation.push_back(x8);
#endif
-
/** The last error string, or NULL
*/
const char *err;
-
+
public:
/** This constructor loads the module using dlopen()
* @param ServerInstance The creator class of this object
: CoreException(message, "the core")
{
}
-
+
/** This destructor solves world hunger, cancels the world debt, and causes the world to end.
* Actually no, it does nothing. Never mind.
* @throws Nothing!
: CoreException(message, "the core")
{
}
-
+
/** This destructor solves world hunger, cancels the world debt, and causes the world to end.
* Actually no, it does nothing. Never mind.
* @throws Nothing!
* The init_module function is the only exported extern "C" declaration
* in any module file. In a cmd_*.cpp file the equivilant is init_command
*/
- typedef ReturnType * (initfunctype) (InspIRCd*);
-
+ typedef ReturnType * (initfunctype) (InspIRCd*);
+
/** Pointer to the init function.
*/
initfunctype* init_func;
/** Instance pointer to be passed to init_*() when it is called.
*/
InspIRCd* ServerInstance;
-
+
public:
/** Default constructor.
* This constructor passes its paramerers down through DLLFactoryBase and then DLLManager
*/
DLLFactory(InspIRCd* Instance, const char *fname, const char *func_name)
: DLLManager(Instance, fname), init_func(NULL), ServerInstance(Instance)
- {
+ {
const char* error = LastError();
-
+
if(!error)
{
if(!GetSymbol((void **)&init_func, func_name))
throw LoadModuleException(error);
}
}
-
+
/** Calls the 'init_module' C exported function within a module, which
* returns a pointer to a Module derived object.
*/
return NULL;
}
}
-
+
/** The destructor deletes the ModuleFactory pointer.
*/
~DLLFactory()
*
* ---------------------------------------------------
*/
-
+
#ifndef INSPIRCD_HASHMAP_H
#define INSPIRCD_HASHMAP_H
#define hash_map unordered_map
#define nspace std::tr1
#define BEGIN_HASHMAP_NAMESPACE namespace std { namespace tr1 {
- #define END_HASHMAP_NAMESPACE } }
+ #define END_HASHMAP_NAMESPACE } }
#endif
#else
#include <hash_map>
#define END_HASHMAP_NAMESPACE }
#endif
-
-
#endif
-
* @param modeletter The mode letter to insert
*/
void Push(char modeletter);
-
+
/** Push a '+' symbol onto the stack.
*/
void PushPlus();
-
+
/** Push a '-' symbol onto the stack.
*/
void PushMinus();
-
+
/** Return zero or more elements which form the
* mode line. This will be clamped to a max of
* MAXMODES items (MAXMODES-1 mode parameters and
class CoreExport tokenstream : public classbase
{
private:
-
+
/** Original string
*/
std::string tokens;
/** Used to split on commas
*/
commasepstream* sep;
-
+
/** Current position in a range of ports
*/
long in_range;
-
+
/** Starting port in a range of ports
*/
long range_begin;
-
+
/** Ending port in a range of ports
*/
long range_end;
-
+
/** Allow overlapped port ranges
*/
bool overlapped;
-
+
/** Used to determine overlapping of ports
* without O(n) algorithm being used
*/
std::map<long, bool> overlap_set;
-
+
/** Returns true if val overlaps an existing range
*/
bool Overlaps(long val);
public:
-
+
/** Create a portparser and fill it with the provided data
* @param source The source text to parse from
* @param allow_overlapped Allow overlapped ranges
*/
portparser(const std::string &source, bool allow_overlapped = true);
-
+
/** Frees the internal commasepstream object
*/
~portparser();
-
+
/** Fetch the next token from the stream
* @return The next port number is returned, or 0 if none remain
*/
END_HASHMAP_NAMESPACE
#endif
-
#define _FILE_OFFSET_BITS 64
#ifndef _LARGEFILE_SOURCE
#define _LARGEFILE_SOURCE
-#endif
+#endif
#ifndef WIN32
#define DllExport
virtual bool OnDataReady();
/**
- * When it is ok to write to the socket, and a
+ * When it is ok to write to the socket, and a
* write event was requested, this method is
* triggered.
*
};
#endif
-
* E.g.
*
* nick -> nick!*@*
- *
+ *
* nick!ident -> nick!ident@*
- *
+ *
* host.name -> *!*@host.name
- *
+ *
* ident@host.name -> *!ident@host.name
*
* This method can be used on both IPV4 and IPV6 user masks.
*/
static void CleanMask(std::string &mask);
- /** Get the last string to be processed, as it was sent to the user or channel.
+ /** Get the last string to be processed, as it was sent to the user or channel.
* Use this to display a string you just sent to be parsed, as the actual output
* may be different to what you sent after it has been 'cleaned up' by the parser.
* @return Last parsed string, as seen by users.
};
#endif
-
I_OnDecodeMetaData, I_ProtoSendMode, I_ProtoSendMetaData, I_OnWallops, I_OnChangeHost, I_OnChangeName, I_OnAddLine,
I_OnDelLine, I_OnExpireLine, I_OnCleanup, I_OnUserPostNick, I_OnAccessCheck, I_On005Numeric, I_OnKill, I_OnRemoteKill, I_OnLoadModule, I_OnUnloadModule,
I_OnBackgroundTimer, I_OnPreCommand, I_OnCheckReady, I_OnCheckInvite, I_OnRawMode,
- I_OnCheckKey, I_OnCheckLimit, I_OnCheckBan, I_OnCheckExtBan, I_OnCheckStringExtBan, I_OnStats, I_OnChangeLocalUserHost, I_OnChangeLocalUserGecos,
+ I_OnCheckKey, I_OnCheckLimit, I_OnCheckBan, I_OnCheckExtBan, I_OnCheckStringExtBan, I_OnStats, I_OnChangeLocalUserHost, I_OnChangeLocalUserGecos,
I_OnLocalTopicChange, I_OnPostLocalTopicChange, I_OnEvent, I_OnRequest, I_OnGlobalOper, I_OnPostConnect, I_OnAddBan, I_OnDelBan,
I_OnRawSocketAccept, I_OnRawSocketClose, I_OnRawSocketWrite, I_OnRawSocketRead, I_OnChangeLocalUserGECOS, I_OnUserRegister,
I_OnChannelPreDelete, I_OnChannelDelete, I_OnPostOper, I_OnSyncOtherMetaData, I_OnSetAway, I_OnUserList,
* @return 1 To prevent the join, 0 to allow it.
*/
virtual int OnUserPreJoin(User* user, Channel* chan, const char* cname, std::string &privs, const std::string &keygiven);
-
+
/** Called whenever a user is about to be kicked.
* Returning a value of 1 from this function stops the process immediately, causing no
* output to be sent to the user by the core. If you do this you must produce your own numerics,
* @param opertype The opers type name
*/
virtual void OnPostOper(User* user, const std::string &opername, const std::string &opertype);
-
+
/** Called whenever a user types /INFO.
* The User will contain the information of the user who typed the command. Modules may use this
* method to output their own credits in /INFO (which is the ircd's version of an about box).
* @param user The user issuing /INFO
*/
virtual void OnInfo(User* user);
-
+
/** Called whenever a /WHOIS is performed on a local user.
* The source parameter contains the details of the user who issued the WHOIS command, and
* the dest parameter contains the information of the user they are whoising.
* @param dest The user who is being WHOISed
*/
virtual void OnWhois(User* source, User* dest);
-
+
/** Called whenever a user is about to invite another user into a channel, before any processing is done.
* Returning 1 from this function stops the process immediately, causing no
* output to be sent to the user by the core. If you do this you must produce your own numerics,
* @return 1 to deny the invite, 0 to check whether or not the user has permission to invite, -1 to explicitly allow the invite
*/
virtual int OnUserPreInvite(User* source,User* dest,Channel* channel, time_t timeout);
-
+
/** Called after a user has been successfully invited to a channel.
* You cannot prevent the invite from occuring using this function, to do that,
* use OnUserPreInvite instead.
* @param timeout The time the invite will expire (0 == never)
*/
virtual void OnUserInvite(User* source,User* dest,Channel* channel, time_t timeout);
-
+
/** Called whenever a user is about to PRIVMSG A user or a channel, before any processing is done.
* Returning any nonzero value from this function stops the process immediately, causing no
* output to be sent to the user by the core. If you do this you must produce your own numerics,
* @param text The original message text causing the exempt list to be built
*/
virtual void OnBuildExemptList(MessageType message_type, Channel* chan, User* sender, char status, CUList &exempt_list, const std::string &text);
-
+
/** Called before any nickchange, local or remote. This can be used to implement Q-lines etc.
* Please note that although you can see remote nickchanges through this function, you should
* NOT make any changes to the User if the user is a remote user as this may cause a desnyc.
* @param extdata Encoded data for this extension name, which will be encoded at the oppsite end by an identical module using OnDecodeMetaData
*/
virtual void ProtoSendMetaData(void* opaque, TargetTypeFlags target_type, void* target, const std::string &extname, const std::string &extdata);
-
+
/** Called after every WALLOPS command.
* @param user The user sending the WALLOPS
* @param text The content of the WALLOPS message
* @param newhost The new GECOS
* @return 1 to deny the GECOS change, 0 to allow
*/
- virtual int OnChangeLocalUserGECOS(User* user, const std::string &newhost);
+ virtual int OnChangeLocalUserGECOS(User* user, const std::string &newhost);
/** Called whenever a topic is changed by a local user.
* Return 1 to deny the topic change, 0 to check details on the change, -1 to let it through with no checks
/** Error code
*/
long error;
-
+
public:
/** Default constructor.
* This constructor initialises the ConfigReader class to read the inspircd.conf file
* This function will return false if the file could not be opened.
*/
bool Exists();
-
+
/** Retrieve one line from the file.
* This method retrieves one line from the text file. If an empty non-NULL string is returned,
* the index was out of bounds, or the line had no data on it.
/** Holds a string describing the last module error to occur
*/
std::string LastModuleError;
-
+
/** The feature names published by various modules
*/
featurelist Features;
/** The interface names published by various modules
*/
interfacelist Interfaces;
-
+
/** Total number of modules loaded into the ircd
*/
- int ModCount;
-
+ int ModCount;
+
/** Our pointer to the main insp instance
*/
InspIRCd* Instance;
/** Destructor
*/
- ~ModuleManager();
+ ~ModuleManager();
/** Change the priority of one event in a module.
* Each module event has a list of modules which are attached to that event type.
* set it to be the last called, or PRIO_BEFORE and PRIO_AFTER
* to set it to be before or after one or more other modules.
* @param modules If PRIO_BEFORE or PRIO_AFTER is set in parameter 's',
- * then this contains a list of one or more modules your module must be
+ * then this contains a list of one or more modules your module must be
* placed before or after. Your module will be placed before the highest
* priority module in this list for PRIO_BEFORE, or after the lowest
* priority module in this list for PRIO_AFTER.
* @param mod Module to detach from
*/
void DetachAll(Module* mod);
-
+
/** Returns text describing the last module error
* @return The last error message to occur
*/
* @return True if the module was unloaded
*/
bool Unload(const char* filename);
-
+
/** Called by the InspIRCd constructor to load all modules from the config file.
*/
void LoadAll();
-
+
/** Get the total number of currently loaded modules
* @return The number of loaded modules
*/
{
return this->ModCount;
}
-
+
/** Find a module by name, and return a Module* to it.
* This is preferred over iterating the module lists yourself.
* @param name The module name to look up
* @return A pointer to the module, or NULL if the module cannot be found
*/
Module* Find(const std::string &name);
-
+
/** Publish a 'feature'.
* There are two ways for a module to find another module it depends on.
* Either by name, using InspIRCd::FindModule, or by feature, using this
/* +------------------------------------+
* | Inspire Internet Relay Chat Daemon |
* +------------------------------------+
- *
+ *
* InspIRCd: (C) 2002-2009 InspIRCd Development Team
* See: http://www.inspircd.org/wiki/index.php/Credits
*
ERR_NOPRIVILEGES = 481, // rfc, beware though, we use this for other things opers may not do also
ERR_CHANOPRIVSNEEDED = 482, // rfc, beware though, we use this for other things like trying to kick a uline
- ERR_ALLMUSTSSL = 490, // unrealircd
+ ERR_ALLMUSTSSL = 490, // unrealircd
ERR_NOCTCPALLOWED = 492, // XXX: bzzzz. 1459 defines this as ERR_NOSERVICEHOST, research it more and perhaps change this! (ERR_CANNOTSENDTOCHAN?)
// wtf, we also use this for m_noinvite. UGLY!
ERR_DELAYREJOIN = 495, // insp-specific, XXX: we should use 'resource temporarily unavailable' from ircnet/ratbox or whatever
}
return -1;
}
-
+
/** Global I/O completion port that sockets attach to.
*/
HANDLE m_completionPort;
- /** This is kinda shitty... :/ for getting an address from a real fd.
+ /** This is kinda shitty... :/ for getting an address from a real fd.
*/
std::map<int, EventHandler*> m_binding;
__inline int GetRemainingFds()
{
register int count = 0;
- register int i = 0;
+ register int i = 0;
for(; i < MAX_DESCRIPTORS; ++i)
if(ref[i] == 0)
++count;
};
#endif
-
class CoreExport PThreadEngine : public ThreadEngine
{
private:
-
+
bool Mutex(bool enable);
public:
inline std::string stringtime(InspIRCd* Instance)
{
std::ostringstream TIME;
- TIME << Instance->Time();
+ TIME << Instance->Time();
return TIME.str();
}
* specified in ListModeBase::configtag
*/
limitlist chanlimits;
-
+
public:
/** Constructor.
* @param Instance The creator of this class
infokey = "listbase_mode_" + std::string(1, mode) + "_list";
}
- /** See mode.h
+ /** See mode.h
*/
std::pair<bool,std::string> ModeSet(User*, User*, Channel* channel, const std::string ¶meter)
{
mode_junk.push_back(stackresult[j]);
}
- ServerInstance->SendMode(mode_junk, ServerInstance->FakeClient);
+ ServerInstance->SendMode(mode_junk, ServerInstance->FakeClient);
}
}
}
{
/* Give a subclass a chance to error about this */
TellAlreadyOnList(source, channel, parameter);
-
+
// it does, deny the change
return MODEACTION_DENY;
}
{
source->WriteNumeric(478, "%s %s %s :Channel ban/ignore list is full", source->nick.c_str(), channel->name.c_str(), parameter.c_str());
}
-
+
parameter = "";
- return MODEACTION_DENY;
+ return MODEACTION_DENY;
}
else
{
virtual void DoCleanup(int, void*)
{
}
-
+
/** Validate parameters.
* Overridden by implementing module.
* @param source Source user adding the parameter
{
return true;
}
-
+
/** Tell the user the list is too long.
* Overridden by implementing module.
* @param source Source user adding the parameter
{
return false;
}
-
+
/** Tell the user an item is already on the list.
* Overridden by implementing module.
* @param source Source user adding the parameter
virtual void TellAlreadyOnList(User*, Channel*, std::string&)
{
}
-
+
/** Tell the user that the parameter is not in the list.
* Overridden by implementing module.
* @param source Source user removing the parameter
{
LM->literal = LM->user->nick + "!" + LM->user->ident + "@" + LM->user->GetIPString();
}
-
+
for (modelist::iterator it = mlist->begin(); it != mlist->end(); it++)
{
if (LM->extban && it->mask.length() > 1 && it->mask[0] == LM->extban && it->mask[1] == ':')
};
#endif
-
UserManager(InspIRCd *Instance) : ServerInstance(Instance)
{
}
-
+
~UserManager()
{
for (user_hash::iterator i = clientlist->begin();i != clientlist->end();i++)
void AddGlobalClone(User *user);
/** Remove all clone counts from the user, you should
- * use this if you change the user's IP address
+ * use this if you change the user's IP address
* after they have registered.
* @param user The user to remove
*/
* Use InspIRCd::IsNick() to validate nicknames.
*/
std::string nick;
-
+
/** The user's unique identifier.
* This is the unique identifier which the user has across the network.
*/
std::string uuid;
-
+
/** The users ident reply.
* Two characters are added to the user-defined limit to compensate for the tilde etc.
*/
std::string ident;
-
+
/** The host displayed to non-opers (used for cloaking etc).
* This usually matches the value of User::host.
*/
std::string dhost;
-
+
/** The users full name (GECOS).
*/
std::string fullname;
-
+
/** The user's mode list.
* NOT a null terminated string.
* Also NOT an array.
* If this string is empty, the user is not marked as away.
*/
std::string awaymsg;
-
+
/** Time the user last went away.
* This is ONLY RELIABLE if user IS_AWAY()!
*/
* The value of this is the value of a valid 'type name=' tag.
*/
std::string oper;
-
+
/** True when DNS lookups are completed.
* The UserResolver classes res_forward and res_reverse will
* set this value once they complete.
* modules may check it.
*/
std::string password;
-
+
/** User's receive queue.
* Lines from the IRCd awaiting processing are stored here.
* Upgraded april 2005, old system a bit hairy.
//class ServerConfig;
#endif
-
/** The time the line was added.
*/
time_t set_time;
-
+
/** The duration of the ban, or 0 if permenant
*/
long duration;
-
+
/** Source of the ban. This can be a servername or an oper nickname
*/
char* source;
-
+
/** Reason for the ban
*/
char* reason;
*/
typedef std::pair<std::string, std::string> IdentHostPair;
-/** XLineFactory is used to generate an XLine pointer, given just the
+/** XLineFactory is used to generate an XLine pointer, given just the
* pattern, timing information and type of line to create. This is used
* for example in the spanningtree module which will call an XLineFactory
* to create a new XLine when it is inbound on a server link, so that it
* @param t Type of XLine this factory generates
*/
XLineFactory(InspIRCd* Instance, const std::string &t) : ServerInstance(Instance), type(t) { }
-
+
/** Return the type of XLine this factory generates
* @return The type of XLine this factory generates
*/
* will generate a new XLine specialized to that type. For example if you
* pass the XLineFactory that handles glines some data it will return a
* pointer to a GLine, polymorphically represented as XLine. This is used where
- * you do not know the full details of the item you wish to create, e.g. in a
+ * you do not know the full details of the item you wish to create, e.g. in a
* server protocol module like m_spanningtree, when you receive xlines from other
* servers.
* @param xlf XLineFactory pointer to register
};
#endif
-
close(FH);
my $time = promptstring_s("Please enter the number of days that this certificate is valid for","365");
-
+
system("cat openssl.template | openssl req -x509 -nodes -newkey rsa:1024 -keyout key.pem -out cert.pem -days $time 2>/dev/null");
system("openssl dhparam -out dhparams.pem 1024");
unlink("openssl.template");
/* 0: check status, 1: don't, -1: disallow change silently */
FOREACH_RESULT(I_OnLocalTopicChange,OnLocalTopicChange(u,this,ntopic));
-
+
if (MOD_RESULT == 1)
return CMD_FAILURE;
else if (MOD_RESULT == 0)
command_p.push_back(token);
std::transform(command.begin(), command.end(), command.begin(), ::toupper);
-
+
/* find the command, check it exists */
Commandtable::iterator cm = cmdlist.find(command);
-
+
if (cm == cmdlist.end())
{
int MOD_RESULT = 0;
{
// BE CAREFUL: .end() returns past the end of the vector, hence decrement.
std::vector<std::string>::iterator it = --command_p.end();
-
+
lparam.insert(0, " " + *(it));
command_p.erase(it); // remove last element
}
return translations;
}
-
-
{
char itrigger[MAXBUF];
long matches = 0;
-
+
if (!Config->ConfValue(Config->config_data, "insane","trigger", 0, itrigger, MAXBUF))
strlcpy(itrigger,"95.5",MAXBUF);
-
+
if (Config->ConfValueBool(Config->config_data, "insane","hostmasks", 0))
return false;
-
+
for (user_hash::iterator u = this->Users->clientlist->begin(); u != this->Users->clientlist->end(); u++)
{
if ((InspIRCd::Match(u->second->MakeHost(), mask, ascii_case_insensitive_map)) ||
{
char itrigger[MAXBUF];
long matches = 0;
-
+
if (!Config->ConfValue(Config->config_data, "insane","trigger",0,itrigger,MAXBUF))
strlcpy(itrigger,"95.5",MAXBUF);
-
+
if (Config->ConfValueBool(Config->config_data, "insane","ipmasks",0))
return false;
-
+
for (user_hash::iterator u = this->Users->clientlist->begin(); u != this->Users->clientlist->end(); u++)
{
if (InspIRCd::Match(u->second->GetIPString(), ip, ascii_case_insensitive_map))
{
char itrigger[MAXBUF];
long matches = 0;
-
+
if (!Config->ConfValue(Config->config_data, "insane","trigger",0,itrigger,MAXBUF))
strlcpy(itrigger,"95.5",MAXBUF);
-
+
if (Config->ConfValueBool(Config->config_data, "insane","nickmasks",0))
return false;
ServerInstance->Logs->Log("COMMAND",SPARSE, diebuf);
ServerInstance->SendError(diebuf);
}
-
+
if (ServerInstance->Config->DieDelay)
sleep(ServerInstance->Config->DieDelay);
CmdResult CommandEline::Handle (const std::vector<std::string>& parameters, User *user)
{
std::string target = parameters[0];
-
+
if (parameters.size() >= 3)
{
IdentHostPair ih;
CmdResult CommandGline::Handle (const std::vector<std::string>& parameters, User *user)
{
std::string target = parameters[0];
-
+
if (parameters.size() >= 3)
{
IdentHostPair ih;
return CMD_SUCCESS;
}
-
}
else
ih = ServerInstance->XLines->IdentSplit(target.c_str());
-
+
if (ih.first.empty())
{
user->WriteServ("NOTICE %s :*** Target not found", user->nick.c_str());
return CMD_SUCCESS;
}
-
CUList exempt_list;
user->idle_lastmsg = ServerInstance->Time();
-
+
if (ServerInstance->Parser->LoopCall(user, this, parameters, 0))
return CMD_SUCCESS;
if (parameters[0][0] == '$')
}
return CMD_SUCCESS;
}
-
+
const char* destnick = parameters[0].c_str();
if (IS_LOCAL(user))
return CMD_SUCCESS;
}
-
// tell them they suck, and lag them up to help prevent brute-force attacks
user->WriteNumeric(491, "%s :Invalid oper credentials",user->nick.c_str());
user->IncreasePenalty(10);
-
+
snprintf(broadcast, MAXBUF, "WARNING! Failed oper attempt by %s!%s@%s using login '%s': The following fields do not match: %s", user->nick.c_str(), user->ident.c_str(), user->host.c_str(), parameters[0].c_str(), fields.c_str());
ServerInstance->SNO->WriteToSnoMask('o',std::string(broadcast));
ServerInstance->PI->SendSNONotice("o", std::string("OPER: ") + broadcast);
}
return CMD_SUCCESS;
}
-
return CMD_SUCCESS;
Channel* c = ServerInstance->FindChan(parameters[0]);
-
+
if (c)
{
if (!c->PartUser(user, reason))
CUList except_list;
user->idle_lastmsg = ServerInstance->Time();
-
+
if (ServerInstance->Parser->LoopCall(user, this, parameters, 0))
return CMD_SUCCESS;
chan->WriteAllExcept(user, false, status, except_list, "PRIVMSG %c%s :%s", status, chan->name.c_str(), text);
}
}
- else
+ else
{
chan->WriteAllExcept(user, false, status, except_list, "PRIVMSG %s :%s", chan->name.c_str(), text);
}
if (IS_LOCAL(user))
{
const char* targetserver = strchr(destnick, '@');
-
+
if (targetserver)
{
std::string nickonly;
}
int MOD_RESULT = 0;
-
+
std::string temp = parameters[1];
FOREACH_RESULT(I_OnUserPreMessage,OnUserPreMessage(user, dest, TYPE_USER, temp, 0, except_list));
if (MOD_RESULT) {
}
return CMD_SUCCESS;
}
-
return CMD_SUCCESS;
}
}
-
+
ServerInstance->SNO->WriteToSnoMask('A', "RELOAD MODULE: %s unsuccessfully reloaded %s",user->nick.c_str(), parameters[0].c_str());
user->WriteNumeric(975, "%s %s :%s",user->nick.c_str(), parameters[0].c_str(), ServerInstance->Modules->LastError().c_str());
return CMD_FAILURE;
results.push_back(sn + " 481 " + user->nick + " :Permission denied - STATS " + statschar + " requires the servers/auspex priv.");
return;
}
-
+
int MOD_RESULT = 0;
FOREACH_RESULT(I_OnStats,OnStats(statschar, user, results));
if (MOD_RESULT)
case 'n':
case 'c':
break;
-
+
case 'i':
{
int idx = 0;
}
}
break;
-
+
case 'Y':
{
int idx = 0;
}
}
break;
-
+
case 'P':
{
int idx = 0;
results.push_back(sn+" 249 "+user->nick+" :"+ConvToStr(idx)+" OPER(s)");
}
break;
-
+
case 'k':
ServerInstance->XLines->InvokeStats("K",216,user,results);
break;
timeval tv;
char percent[30];
gettimeofday(&tv, NULL);
-
+
float n_elapsed = ((tv.tv_sec - ServerInstance->stats->LastSampled.tv_sec) * 1000000 + tv.tv_usec - ServerInstance->stats->LastSampled.tv_usec);
float n_eaten = ((R.ru_utime.tv_sec - ServerInstance->stats->LastCPU.tv_sec) * 1000000 + R.ru_utime.tv_usec - ServerInstance->stats->LastCPU.tv_usec);
float per = (n_eaten / n_elapsed) * 100;
#endif
}
break;
-
+
case 'T':
{
char buffer[MAXBUF];
{
std::string retbuf = std::string("302 ") + user->nick + " :";
-
for (unsigned int i = 0; i < parameters.size(); i++)
{
User *u = ServerInstance->FindNick(parameters[i]);
if (CanView(ch,user))
{
bool inside = ch->HasUser(user);
-
+
/* who on a channel. */
CUList *cu = ch->GetUsers();
-
+
for (CUList::iterator i = cu->begin(); i != cu->end(); i++)
{
/* None of this applies if we WHO ourselves */
/* opers only, please */
if (opt_viewopersonly && !IS_OPER(i->first))
continue;
-
+
/* If we're not inside the channel, hide +i users */
if (i->first->IsModeSet('i') && !inside && !user->HasPrivPermission("users/auspex"))
continue;
}
-
+
SendWhoLine(user, initial, ch, i->first, whoresults);
}
}
return CMD_FAILURE;
}
}
-
time_t rawtime = u->signon;
tm *timeinfo;
char b[MAXBUF];
-
+
timeinfo = localtime(&rawtime);
-
+
/* XXX - 'b' could be only 25 chars long and then strlcpy() would terminate it for us too? */
strlcpy(b,asctime(timeinfo),MAXBUF);
b[24] = 0;
user->WriteNumeric(314, "%s %s %s %s * :%s",user->nick.c_str(),parameters[0].c_str(),u->ident,u->dhost,u->gecos);
-
+
if (user->HasPrivPermission("users/auspex"))
user->WriteNumeric(379, "%s %s :was connecting from *@%s", user->nick.c_str(), parameters[0].c_str(), u->host);
-
+
if (*ServerInstance->Config->HideWhoisServer && !user->HasPrivPermission("servers/auspex"))
user->WriteNumeric(312, "%s %s %s :%s",user->nick.c_str(),parameters[0].c_str(), ServerInstance->Config->HideWhoisServer, b);
else
}
User *u = ServerInstance->FindNick(target.c_str());
-
+
if (u)
{
target = u->GetIPString();
this->rr_class = 1;
this->type = qt;
-
+
DNS::EmptyHeader(payload,header,length);
#ifdef IPV6
/* Is the DNS connection down? */
if (this->GetFd() == -1)
return NULL;
-
+
/* Create an id */
id = this->PRNG() & DNS::MAX_REQUEST_ID;
/* DNS::Rehash() sets this to a valid ptr
*/
this->cache = NULL;
-
+
/* Again, DNS::Rehash() sets this to a
* valid value
*/
DNSHeader h;
int id;
int length;
-
+
if ((length = this->MakePayload(name, DNS_QUERY_A, 1, (unsigned char*)&h.payload)) == -1)
return -1;
default:
break;
-
}
/* Build the reply with the id and hostname/ip in it */
/* XXX: We actually initialise 'rr' here including its ttl field */
if (curanswer == result_we_want)
DNS::FillResourceRecord(&rr,&header.payload[i]);
-
+
i += 10;
if (rr.type != this->type)
{
else
return NULL;
}
-
+
void DNS::DelCache(const std::string &source)
{
cache->erase(source.c_str());
res = this->GetResult(resultnum);
ServerInstance->Logs->Log("RESOLVER",DEBUG,"Result %d id %d", resultnum, res.id);
-
+
/* Is there a usable request id? */
if (res.id != -1)
{
{
if (ServerInstance && ServerInstance->stats)
ServerInstance->stats->statsDnsGood++;
-
+
if (!this->GetCache(res.original.c_str()))
this->cache->insert(std::make_pair(res.original.c_str(), CachedQuery(res.result, res.ttl)));
Classes[res.id] = NULL;
}
}
-
+
if (ServerInstance && ServerInstance->stats)
ServerInstance->stats->statsDns++;
}
resultnum++;
}
-
+
/** Add a derived Resolver to the working set */
bool DNS::AddResolverClass(Resolver* r)
{
val += (s->statsConnects ^ (unsigned long)s->statsSent ^ (unsigned long)s->statsRecv) - ServerInstance->Config->ports.size();
return val;
}
-
-
* try extract a symbol from the library
* get any error message is there is any
*/
-
+
if (h)
{
dlerror(); // clear value
if (!*v || err)
return false;
}
-
+
/* succeeded :) */
return true;
}
return "";
/* EWW! This used to be using sprintf, which is WAY inefficient. -Special */
-
+
const char *hex = "0123456789abcdef";
static char hexbuf[MAXBUF];
{
while (((Overlaps(in_range)) && (in_range <= range_end)))
in_range++;
-
+
if (in_range <= range_end)
return in_range;
}
text = replacement;
return text;
}*/
-
return FindUUID(nick);
user_hash::iterator iter = this->Users->clientlist->find(nick);
-
+
if (iter == this->Users->clientlist->end())
return NULL;
c++;
}
- size_t len = c - chname;
+ size_t len = c - chname;
/* too long a name - note funky pointer arithmetic here. */
if (len > max)
{
{
if (!n || !*n)
return false;
-
+
unsigned int p = 0;
for (const char* i = n; *i; i++, p++)
{
{
std::string &tok = Config->data005;
std::string::size_type ebpos;
-
+
if ((ebpos = tok.find(" EXTBAN=,")) == std::string::npos)
{
tok.append(" EXTBAN=,");
else
tok.insert(ebpos + 9, 1, c);
}
-
-
-
InspIRCd::InspIRCd(int argc, char** argv)
: GlobalCulls(this),
- /* Functor initialisation. Note that the ordering here is very important.
+ /* Functor initialisation. Note that the ordering here is very important.
*
* THIS MUST MATCH ORDER OF DECLARATION OF THE HandleWhateverFunc classes
* within class InspIRCd.
#ifdef WIN32
// Strict, frequent checking of memory on debug builds
_CrtSetDbgFlag ( _CRTDBG_CHECK_ALWAYS_DF | _CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF );
-
+
// Avoid erroneous frees on early exit
WindowsIPC = 0;
#endif
this->PI = new ProtocolInterface(this);
this->s_signal = 0;
-
+
// Create base manager classes early, so nothing breaks
this->Users = new UserManager(this);
-
+
this->Users->unregistered_count = 0;
this->Users->clientlist = new user_hash();
/* Windows can (and defaults to) hide file extensions, so let's play a bit nice for windows users. */
std::string txtconf = this->ConfigFileName;
txtconf.append(".txt");
-
+
if (ServerConfig::FileExists(txtconf.c_str()))
{
strlcat(this->ConfigFileName, ".txt", MAXBUF);
printf("\n");
this->Modules->LoadAll();
-
+
/* Just in case no modules were loaded - fix for bug #101 */
this->BuildISupport();
InitializeDisabledCommands(Config->DisabledCommands, this);
}
printf("\nInspIRCd is now running as '%s'[%s] with %d max open sockets\n", Config->ServerName,Config->GetSID().c_str(), SE->GetMaxFds());
-
+
#ifndef WINDOWS
if (!Config->nofork)
{
this->stats->LastCPU = ru.ru_utime;
}
#else
- WindowsIPC->Check();
+ WindowsIPC->Check();
#endif
}
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
* 3. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-
+
#ifndef HAS_STRLCPY
CoreExport size_t strlcat(char *dst, const char *src, size_t siz)
{
return shift_down;
}
-
*
* How it works:
* Modules create their own logstream types (core will create one for 'file logging' for example) and create instances of these logstream types
- * and register interest in a certain logtype. Globbing is not here, with the exception of * - for all events.. loglevel is used to drop
+ * and register interest in a certain logtype. Globbing is not here, with the exception of * - for all events.. loglevel is used to drop
* events that are of no interest to a logstream.
*
* When Log is called, the vector of logstreams for that type is iterated (along with the special vector for "*"), and all registered logstreams
* NOTE: Somehow we have to let LogManager manage the non-blocking file streams and provide an interface to share them with various LogStreams,
* as, for example, a user may want to let 'KILL' and 'XLINE' snotices go to /home/ircd/inspircd/logs/operactions.log, or whatever. How
* can we accomplish this easily? I guess with a map of pre-loved logpaths, and a pointer of FILE *..
- *
+ *
*/
void LogManager::SetupNoFork()
FileWriter::~FileWriter()
{
}
-
}
ModePair ModeChannelKey::ModeSet(User*, User*, Channel* channel, const std::string ¶meter)
-{
+{
if (channel->modes[CM_KEY])
{
std::string ckey = channel->GetModeParameter('k');
return MODEACTION_DENY;
}
}
-
Instance->Logs->Log("MODULE", DEFAULT, LastModuleError);
return false;
}
-
+
if (!ServerConfig::FileExists(modfile))
{
LastModuleError = "Module file could not be found: " + filename_str;
Instance->Logs->Log("MODULE", DEFAULT, LastModuleError);
return false;
}
-
+
if (Modules.find(filename_str) != Modules.end())
- {
+ {
LastModuleError = "Module " + filename_str + " is already loaded, cannot load a module twice!";
Instance->Logs->Log("MODULE", DEFAULT, LastModuleError);
return false;
}
-
+
Module* newmod = NULL;
ircd_module* newhandle = NULL;
{
Instance->Config->ConfValue(Instance->Config->config_data, "module", "name", count, configToken, MAXBUF);
printf_c("[\033[1;32m*\033[0m] Loading module:\t\033[1;32m%s\033[0m\n",configToken);
-
- if (!this->Load(configToken))
+
+ if (!this->Load(configToken))
{
Instance->Logs->Log("MODULE", DEFAULT, this->LastError());
printf_c("\n[\033[1;31m*\033[0m] %s\n\n", this->LastError().c_str());
bool ModuleManager::UnpublishFeature(const std::string &FeatureName)
{
featurelist::iterator iter = Features.find(FeatureName);
-
+
if (iter == Features.end())
return false;
std::string ConfigReader::ReadValue(const std::string &tag, const std::string &name, const std::string &default_value, int index, bool allow_linefeeds)
{
- /* Don't need to strlcpy() tag and name anymore, ReadConf() takes const char* */
+ /* Don't need to strlcpy() tag and name anymore, ReadConf() takes const char* */
std::string result;
-
+
if (!ServerInstance->Config->ConfValue(*this->data, tag, name, default_value, index, result, allow_linefeeds))
{
this->error = CONF_VALUE_NOT_FOUND;
int ConfigReader::ReadInteger(const std::string &tag, const std::string &name, const std::string &default_value, int index, bool need_positive)
{
int result;
-
+
if(!ServerInstance->Config->ConfValueInteger(*this->data, tag, name, default_value, index, result))
{
this->error = CONF_VALUE_NOT_FOUND;
return 0;
}
-
+
if ((need_positive) && (result < 0))
{
this->error = CONF_INT_NEGATIVE;
return 0;
}
-
+
return result;
}
ServerInstance->Modules->Attach(eventlist, this, 3);
}
-
bool OneOfMatches(const char* host, const char* ip, const char* hostlist)
{
std::stringstream hl(hostlist);
/** User
*/
User* user;
-
+
AssociateUser(Module* s, Module* d, unsigned long i, User* u)
: Request(s, d, SQLUTILAU), id(i), user(u)
{
}
-
+
AssociateUser& S()
{
Send();
/** Channel
*/
Channel* chan;
-
+
AssociateChan(Module* s, Module* d, unsigned long i, Channel* u)
: Request(s, d, SQLUTILAC), id(i), chan(u)
{
}
-
+
AssociateChan& S()
{
Send();
: Request(s, d, SQLUTILUA), id(i)
{
}
-
+
UnAssociate& S()
{
Send();
: Request(s, d, SQLUTILGU), id(i), user(NULL)
{
}
-
+
GetAssocUser& S()
{
Send();
: Request(s, d, SQLUTILGC), id(i), chan(NULL)
{
}
-
+
GetAssocChan& S()
{
Send();
keyfile = confdir + keyfile;
int ret;
-
+
if (cred_alloc)
{
// Deallocate the old credentials
}
else
cred_alloc = true;
-
+
if((ret = gnutls_certificate_allocate_credentials(&x509_cred)) < 0)
ServerInstance->Logs->Log("m_ssl_gnutls",DEFAULT, "m_ssl_gnutls.so: Failed to allocate certificate credentials: %s", gnutls_strerror(ret));
-
+
if((ret = gnutls_dh_params_init(&dh_params)) < 0)
ServerInstance->Logs->Log("m_ssl_gnutls",DEFAULT, "m_ssl_gnutls.so: Failed to initialise DH parameters: %s", gnutls_strerror(ret));
-
+
if((ret =gnutls_certificate_set_x509_trust_file(x509_cred, cafile.c_str(), GNUTLS_X509_FMT_PEM)) < 0)
ServerInstance->Logs->Log("m_ssl_gnutls",DEFAULT, "m_ssl_gnutls.so: Failed to set X.509 trust file '%s': %s", cafile.c_str(), gnutls_strerror(ret));
ConfigReader MyConf(ServerInstance);
AllowBots = MyConf.ReadFlag("fantasy", "allowbots", "no", 0);
-
+
std::string fpre = MyConf.ReadValue("fantasy","prefix",0);
fprefix = fpre.empty() ? '!' : fpre[0];
if (i == Aliases.end())
return 0;
-
+
/* Avoid iterating on to other aliases if no patterns match */
std::multimap<std::string, Alias>::iterator upperbound = Aliases.upper_bound(fcommand);
i++;
}
-
+
return 0;
}
if (c)
{
/* Channel specific variables */
- SearchAndReplace(newline, std::string("$chan"), c->name);
+ SearchAndReplace(newline, std::string("$chan"), c->name);
}
irc::tokenstream ss(newline);
{
return FounderProtectBase::HandleChange(source, theuser, adding, channel, parameter);
}
-
+
char isoverride=0;
Module *Override = ServerInstance->Modules->FindFeature("Override");
if (Override)
user->WriteNumeric(996, "%s %s :You cannot add yourself to your own DCCALLOW list!", user->nick.c_str(), user->nick.c_str());
return CMD_FAILURE;
}
-
+
if (!user->GetExt("dccallow_list", dl))
{
dl = new dccallowlist;
// add this user to the userlist
ul.push_back(user);
}
-
+
for (dccallowlist::const_iterator k = dl->begin(); k != dl->end(); ++k)
{
if (k->nickname == target->nick)
return 0;
}
}
-
+
user->WriteServ("NOTICE %s :The user %s is not accepting DCC SENDs from you. Your file %s was not sent.", user->nick.c_str(), u->nick.c_str(), filename.c_str());
u->WriteServ("NOTICE %s :%s (%s@%s) attempted to send you a file named %s, which was blocked.", u->nick.c_str(), user->nick.c_str(), user->ident.c_str(), user->dhost.c_str(), filename.c_str());
u->WriteServ("NOTICE %s :If you trust %s and were expecting this, you can type /DCCALLOW HELP for information on the DCCALLOW system.", u->nick.c_str(), user->nick.c_str());
};
MODULE_INIT(ModuleDCCAllow)
-
if (i != exemptfromfilter.end()) return 0;
}
if (f->action == "block")
- {
+ {
ServerInstance->SNO->WriteToSnoMask('A', std::string("FILTER: ")+user->nick+" had their message filtered, target was "+target+": "+f->reason);
user->WriteServ("NOTICE "+std::string(user->nick)+" :Your message has been filtered and opers notified: "+f->reason);
}
std::string checkline;
int replacepoint = 0;
bool parting = false;
-
+
if (command == "QUIT")
{
/* QUIT with no reason: nothing to do */
return 0;
FilterResult* f = NULL;
-
+
if (flags)
f = this->FilterMatch(user, checkline, flags);
};
MODULE_INIT(ModuleFilter)
-
/*
* Originally by Chernov-Phoenix Alexey (Phoenix@RusNet) mailto:phoenix /email address separator/ pravmail.ru
*/
-
+
/* $ModDesc: Gives opers cmode +y which provides a staff prefix. */
#include "inspircd.h"
opm = new OperPrefixMode(ServerInstance);
if ((!ServerInstance->Modes->AddMode(opm)))
throw ModuleException("Could not add a new mode!");
-
+
Implementation eventlist[] = { I_OnPostJoin, I_OnCleanup, I_OnUserQuit, I_OnUserKick, I_OnUserPart, I_OnOper };
ServerInstance->Modules->Attach(eventlist, this, 6);
}
};
MODULE_INIT(ModuleOperPrefixMode)
-
{
// If the kicker's status is less than the target's, or the kicker's status is less than or equal to voice
if ((chan->GetStatus(source) < chan->GetStatus(user)) || (chan->GetStatus(source) <= STATUS_VOICE))
- {
+ {
ServerInstance->SNO->WriteToSnoMask('G',std::string(source->nick)+" used oper override to kick "+std::string(user->nick)+" on "+std::string(chan->name)+" ("+reason+")");
}
/* Returning -1 explicitly allows the kick */
{
private:
std::string regex;
-
+
public:
Regex* result;
if(target)
{
std::string newTopic = parameters[1];
-
+
// 3rd parameter overrides access checks
target->SetTopic(user, newTopic, true);
ServerInstance->SNO->WriteToSnoMask('A', user->nick + " used SATOPIC on " + target->name + ", new topic: " + newTopic);
// user is ulined, won't be stopped from joining
return 0;
}
-
+
if (chan->IsModeSet('R'))
{
if (!is_registered)
ModeAction OnModeChange(User* source, User* dest, Channel* channel, std::string ¶meter, bool adding, bool)
{
- /* Because this returns MODEACTION_DENY all the time, there is only ONE
+ /* Because this returns MODEACTION_DENY all the time, there is only ONE
* way to add this mode and that is at client introduction in the UID command,
* as this calls OnModeChange for each mode but disregards the return values.
* The mode cannot be manually added or removed, not even by a server or by a remote
if (iter != Utils->sidlist.end())
Utils->sidlist.erase(iter);
}
-
-
bool Warned; /* True if we've warned opers about high latency on this server */
bool bursting; /* whether or not this server is bursting */
-
+
/** We don't use this constructor. Its a dummy, and won't cause any insertion
* of the TreeServer into the hash_map. See below for the two we DO use.
*/
* no socket associated with it. Its version string is our own local version.
*/
TreeServer(SpanningTreeUtilities* Util, InspIRCd* Instance, std::string Name, std::string Desc, const std::string &id);
-
+
/** When we create a new server, we call this constructor to initialize it.
* This constructor initializes the server's Route and Parent, and sets up
* its ping counters so that it will be pinged one minute from now.
/** Round trip time of last ping
*/
unsigned long rtt;
-
+
/** When we recieved BURST from this server, used to calculate total burst time at ENDBURST.
*/
unsigned long StartBurst;
* "miscreant" servers, though, so let's check anyway. -- w
*
* We also check here for totally invalid prefixes (prefixes that are neither
- * a valid SID or a valid UUID, so that invalid UUID or SID never makes it
+ * a valid SID or a valid UUID, so that invalid UUID or SID never makes it
* to the higher level functions. -- B
*/
std::string direction = prefix;
this->ServerInstance->SNO->WriteToSnoMask('l', "Connection to '\2%s\2' was established for %s", quitserver.c_str(), Utils->Creator->TimeToStr(server_uptime).c_str());
}
}
-
-
protected:
RPCValueType type;
void *value;
-
+
double *CastInteger()
{
return (double*)value;
}
-
+
std::string *CastString()
{
return (std::string*)value;
}
-
+
RPCObjectContainer *CastObject()
{
return (RPCObjectContainer*)value;
}
-
+
RPCArrayContainer *CastArray()
{
return (RPCArrayContainer*)value;
}
-
+
void DestroyValue()
{
// Some versions of GCC complain about declaration in switch statements
default:
break;
}
-
+
value = NULL;
}
-
+
void InitValue()
{
switch (type)
break;
}
}
-
+
RPCValue(const RPCValue &v) { }
-
+
public:
RPCValue *parent;
RPCValue(bool nvalue, RPCValue *rparent = NULL) : type(RPCBoolean), value((void*)nvalue), parent(rparent) { }
RPCValue(double nvalue, RPCValue *rparent = NULL) : type(RPCInteger), parent(rparent) { value = new double(nvalue); }
RPCValue(const std::string &nvalue, RPCValue *rparent = NULL) : type(RPCString), parent(rparent) { value = new std::string(nvalue); }
-
+
virtual ~RPCValue()
{
DestroyValue();
}
-
+
RPCValueType GetType()
{
return type;
}
-
+
void SetNull()
{
DestroyValue();
type = RPCNull;
}
-
+
void SetBoolean(bool nvalue)
{
DestroyValue();
value = (void*)nvalue;
type = RPCBoolean;
}
-
+
void SetInteger(double nvalue)
{
if (type == RPCInteger)
type = RPCInteger;
}
}
-
+
void SetString(const std::string &nvalue)
{
if (type == RPCString)
type = RPCString;
}
}
-
+
void SetArray()
{
if (type == RPCArray)
InitValue();
}
}
-
+
void SetObject()
{
if (type == RPCObject)
InitValue();
}
}
-
+
void ArrayAdd(RPCValue *nvalue)
{
if (type != RPCArray)
a->push_back(nvalue);
nvalue->parent = this;
}
-
+
void ObjectAdd(const std::string &key, RPCValue *nvalue)
{
if (type != RPCObject)
o->insert(std::make_pair(key, nvalue));
nvalue->parent = this;
}
-
+
RPCValue *GetArray(int i)
{
if (type != RPCArray)
return NULL;
return a->at(i);
}
-
+
int ArraySize()
{
if (type != RPCArray)
RPCArrayContainer *a = this->CastArray();
return a->size();
}
-
+
RPCValue *GetObject(const std::string &key)
{
if (type != RPCObject)
return NULL;
return it->second;
}
-
+
std::pair<RPCObjectContainer::iterator,RPCObjectContainer::iterator> GetObjectIterator()
{
if (type != RPCObject)
RPCObjectContainer *o = this->CastObject();
return std::make_pair(o->begin(), o->end());
}
-
+
std::string GetString()
{
if (type != RPCString)
return std::string();
return *this->CastString();
}
-
+
double GetInt()
{
if (type != RPCInteger)
return 0;
return *this->CastInteger();
}
-
+
bool GetBool()
{
if (type != RPCBoolean)
class RPCRequest : public classbase
{
protected:
-
+
public:
std::string method;
RPCValue *parameters;
std::string provider;
bool claimed;
std::string error;
-
+
RPCRequest(const std::string &sprovider, const std::string &smethod, RPCValue *rparameters)
: method(smethod), parameters(rparameters), provider(sprovider), claimed(false)
{
result = new RPCValue();
}
-
+
~RPCRequest()
{
if (result)
ssl_cert() : empty("")
{
}
-
+
/** Get certificate distinguished name
* @return Certificate DN
*/
};
#endif
-
for (int i = 3; i < UUID_LENGTH; i++)
{
current_uid[i] = 'A';
- pos = UUID_LENGTH - 1;
+ pos = UUID_LENGTH - 1;
}
}
else
}
SnomaskManager::~SnomaskManager()
-{
+{
for (std::map<char, Snomask *>::iterator i = SnoMasks.begin(); i != SnoMasks.end(); i++)
{
delete i->second;
/** This will bind a socket to a port. It works for UDP/TCP.
* It can only bind to IP addresses, if you wish to bind to hostnames
* you should first resolve them using class 'Resolver'.
- */
+ */
bool InspIRCd::BindSocket(int sockfd, int port, const char* addr, bool dolisten)
{
/* We allocate 2 of these, because sockaddr_in6 is larger than sockaddr (ugh, hax) */
Config->ConfValue(Config->config_data, "bind", "port", count, configToken, MAXBUF);
Config->ConfValue(Config->config_data, "bind", "address", count, Addr, MAXBUF);
Config->ConfValue(Config->config_data, "bind", "type", count, Type, MAXBUF);
-
+
if (strncmp(Addr, "::ffff:", 7) == 0)
this->Logs->Log("SOCKET",DEFAULT, "Using 4in6 (::ffff:) isn't recommended. You should bind IPv4 addresses directly instead.");
-
+
if ((!*Type) || (!strcmp(Type,"clients")))
{
irc::portparser portrange(configToken, false);
}
bool SocketEngine::BoundsCheckFd(EventHandler* eh)
-{
+{
if (!eh)
return false;
if ((eh->GetFd() < 0) || (eh->GetFd() > MAX_DESCRIPTORS))
/* decrement set size */
--CurrentSetSize;
-
+
/* success */
return true;
}
{
if (!eh)
return;
-
+
void* m_writeEvent = NULL;
int* fake_fd = NULL;
}
}
break;
-
+
case SOCKET_IO_EVENT_ACCEPT:
{
/* this is kinda messy.. :/ */
}
break;
}
-
+
delete ov;
}
Overlapped* ovl = acceptevent;
accept_overlap* ov = (accept_overlap*)ovl->m_params;
-
+
//sockaddr_in* server_address = (sockaddr_in*)&ov->buf[10];
sockaddr_in* client_address = (sockaddr_in*)&ov->buf[38];
int IOCPEngine::GetSockName(EventHandler* fd, sockaddr *name, socklen_t* namelen)
{
Overlapped* ovl = NULL;
-
+
if (!fd->GetExt("windows_acceptevent", ovl))
return -1;
{
return this->Close(fd->GetFd());
}
-
-
/*
* The only bad thing about kqueue is that its fd cant survive a fork and is not inherited.
* BUM HATS.
- *
+ *
*/
EngineHandle = kqueue();
if (EngineHandle == -1)
{
std::vector<Timer *>::iterator i = Timers.begin();
Timer *t = (*i);
-
+
// Probable fix: move vector manipulation to *before* we modify the vector.
Timers.erase(i);
{
return (one->GetTimer()) < (two->GetTimer());
}
-
-
this->bound_user->dns_done = true;
}
}
-
+
// Save some memory by freeing this up; it's never used again in the user's lifetime.
this->bound_user->stored_host.resize(0);
}
local_clones.erase(x);
}
}
-
+
clonemap::iterator y = global_clones.find(user->GetCIDRMask(range));
if (y != global_clones.end())
{
else
return 0;
}
-
-
-
if (mode < 'A' || mode > ('A' + 64)) return false;
return ((type == MODETYPE_USER ? AllowedUserModes : AllowedChanModes))[(mode - 'A')];
-
+
}
bool User::HasPermission(const std::string &command)
bool User::CheckLines(bool doZline)
{
const char* check[] = { "G" , "K", (doZline) ? "Z" : NULL, NULL };
-
+
if (!this->exempt)
{
for (int n = 0; check[n]; ++n)
* Don't remove this! -- w00t
*/
this->SetClass();
-
+
/* Check the password, if one is required by the user's connect class.
* This CANNOT be in CheckClass(), because that is called prior to PASS as well!
*/
sockaddr_in6* sin;
int i, bytestozero, extrabits;
char buffer[40];
-
+
if(range > 128)
throw "CIDR mask width greater than address width (IPv6, 128 bit)";
* which must be set to zero.
*/
bytestozero = (128 - range) / 8;
-
+
/* Some of the least significant bits of the next most significant byte may also have to
* be zeroed. The number of bits is the remainder of the above division.
*/
extrabits = (128 - range) % 8;
-
+
/* Populate our working struct with the parts of the user's IP which are required in the
* final CIDR mask. Set all the subsequent bytes to zero.
* (16 - bytestozero) is the number of bytes which must be populated with actual IP data.
{
v6.s6_addr[i] = sin->sin6_addr.s6_addr[i];
}
-
+
/* And zero all the remaining bytes in the IP. */
for(; i < 16; i++)
{
v6.s6_addr[i] = 0;
}
-
+
/* And finally, zero the extra bits required. */
v6.s6_addr[15 - bytestozero] = (v6.s6_addr[15 - bytestozero] >> extrabits) << extrabits;
this->cachedip = temp;
return temp;
}
-
+
this->cachedip = buf;
return buf;
}
default:
break;
}
-
+
// Unreachable, probably
return "";
}
}
/* check if host matches.. */
- if (!InspIRCd::MatchCIDR(this->GetIPString(), c->GetHost(), NULL) &&
+ if (!InspIRCd::MatchCIDR(this->GetIPString(), c->GetHost(), NULL) &&
!InspIRCd::MatchCIDR(this->host, c->GetHost(), NULL))
{
ServerInstance->Logs->Log("CONNECTCLASS", DEBUG, "No host match (for %s)", c->GetHost().c_str());
{
return true;
}
-
#include "bancache.h"
/*
- * This is now version 3 of the XLine subsystem, let's see if we can get it as nice and
+ * This is now version 3 of the XLine subsystem, let's see if we can get it as nice and
* efficient as we can this time so we can close this file and never ever touch it again ..
*
* Background:
lookup_lines[line->type][line->Displayable()] = line;
line->OnAdd();
- FOREACH_MOD(I_OnAddLine,OnAddLine(user, line));
+ FOREACH_MOD(I_OnAddLine,OnAddLine(user, line));
return true;
}
i->second.clear();
}
lookup_lines.clear();
-
+
}
void XLine::Apply(User* u)
}
void GLine::Apply(User* u)
-{
+{
DefaultApply(u, "G", (strcmp(this->identmask, "*") == 0) ? true : false);
}
}
void ZLine::Apply(User* u)
-{
+{
DefaultApply(u, "Z", true);
}
}
void QLine::Apply(User* u)
-{
+{
/* Force to uuid on apply of qline, no need to disconnect any more :) */
u->ForceNickChange(u->uuid.c_str());
}
return n->second;
}
-