UM_WALLOPS = 'w'-65,
UM_INVISIBLE = 'i'-65,
UM_OPERATOR = 'o'-65,
+ UM_SNOMASK = 'n'-65,
};
enum RegistrationState {
irc::string channel;
};
-
-
class InspIRCd;
/** Derived from Resolver, and performs user forward/reverse lookups.
/** Holds all information about a user
* This class stores all information about a user connected to the irc server. Everything about a
* connection is stored here primarily, from the user's socket ID (file descriptor) through to the
- * user's nickname and hostname. Use the Find method of the server class to locate a specific user
- * by nickname.
+ * user's nickname and hostname. Use the FindNick method of the InspIRCd class to locate a specific user
+ * by nickname, or the FindDescriptor method of the InspIRCd class to find a specific user by their
+ * file descriptor value.
*/
class userrec : public connection
{
private:
- /** Pointer to creator
+ /** Pointer to creator.
+ * This is required to make use of core functions
+ * from within the userrec class.
*/
InspIRCd* ServerInstance;
/** A list of channels the user has a pending invite to.
+ * Upon INVITE channels are added, and upon JOIN, the
+ * channels are removed from this list.
*/
InvitedList invites;
+
+ /** Number of channels this user is currently on
+ */
+ unsigned int ChannelCount;
public:
- /** Resolvers for looking up this users hostname
+ /** Resolvers for looking up this users IP address
+ * This will occur if and when res_reverse completes.
+ * When this class completes its lookup, userrec::dns_done
+ * will be set from false to true.
*/
UserResolver* res_forward;
/** Resolvers for looking up this users hostname
+ * This is instantiated by userrec::StartDNSLookup(),
+ * and on success, instantiates userrec::res_reverse.
*/
UserResolver* res_reverse;
std::string stored_host;
/** Starts a DNS lookup of the user's IP.
- * When complete, sets userrec::dns_done to true.
+ * This will cause two UserResolver classes to be instantiated.
+ * When complete, these objects set userrec::dns_done to true.
*/
void StartDNSLookup();
/** The users nickname.
* An invalid nickname indicates an unregistered connection prior to the NICK command.
+ * Use InspIRCd::IsNick() to validate nicknames.
*/
-
char nick[NICKMAX];
/** The users ident reply.
*/
char dhost[65];
- /** The users full name.
+ /** The users full name (GECOS).
*/
char fullname[MAXGECOS+1];
*/
char oper[NICKMAX];
- /** True when DNS lookups are completed.
- */
- bool dns_done;
+ /** True when DNS lookups are completed.
+ * The UserResolver classes res_forward and res_reverse will
+ * set this value once they complete.
+ */
+ bool dns_done;
/** Number of seconds between PINGs for this user (set from <connect:allow> tag
*/
*/
std::string sendq;
- /** Flood counters
+ /** Flood counters - lines received
*/
int lines_in;
+
+ /** Flood counters - time lines_in is due to be reset
+ */
time_t reset_due;
+
+ /** Flood counters - Highest value lines_in may reach before the user gets disconnected
+ */
long threshold;
- /** IPV4 ip address
+ /** IPV4 or IPV6 ip address
*/
sockaddr* ip;
/** Process a snomask modifier string, e.g. +abc-de
* @param sm A sequence of notice mask characters
- * @return True if the notice masks were successfully applied
+ * @return The cleaned mode sequence which can be output,
+ * e.g. in the above example if masks c and e are not
+ * valid, this function will return +ab-d
*/
- bool userrec::ProcessNoticeMasks(const char *sm);
+ std::string ProcessNoticeMasks(const char *sm);
/** Returns true if a notice mask is set
* @param sm A notice mask character to check
* @param a The string to add to the users read buffer
* @return True if the string was successfully added to the read buffer
*/
- bool AddBuffer(const std::string &a);
+ bool AddBuffer(std::string a);
/** This method returns true if the buffer contains at least one carriage return
* character (e.g. one complete line may be read)
void MakeHost(char* nhost);
/** Shuts down and closes the user's socket
+ * This will not cause the user to be deleted. Use InspIRCd::QuitUser for this,
+ * which will call CloseSocket() for you.
*/
void CloseSocket();
/** Disconnect a user gracefully
* @param user The user to remove
* @param r The quit reason
+ * @return Although this function has no return type, on exit the user provided will no longer exist.
*/
static void QuitUser(InspIRCd* Instance, userrec *user, const std::string &r);
* value of 'this' will be pushed onto this CullList. This is used by
* the core to connect many users in rapid succession without invalidating
* iterators.
+ * @param Goners a CullList to use for failed connections
*/
void FullConnect(CullList* Goners);
/** Add a client to the system.
* This will create a new userrec, insert it into the user_hash,
* initialize it as not yet registered, and add it to the socket engine.
+ * @param Instance a pointer to the server instance
+ * @param socket The socket id (file descriptor) this user is on
+ * @param port The port number this user connected on
+ * @param iscached This variable is reserved for future use
+ * @param ip The IP address of the user
+ * @return This function has no return value, but a call to AddClient may remove the user.
*/
static void AddClient(InspIRCd* Instance, int socket, int port, bool iscached, insp_inaddr ip);
void UnOper();
/** Return the number of global clones of this user
+ * @return The global clone count of this user
*/
long GlobalCloneCount();
/** Return the number of local clones of this user
+ * @return The local clone count of this user
*/
long LocalCloneCount();
/** Write text to this user, appending CR/LF.
* @param text A std::string to send to the user
*/
- void Write(const std::string &text);
+ void Write(std::string text);
/** Write text to this user, appending CR/LF.
* @param text The format string for text to send to the user
*/
void WriteCommonExcept(const std::string &text);
+ /** Write a WALLOPS message from this user to all local opers.
+ * If this user is not opered, the function will return without doing anything.
+ * @param text The format string to send in the WALLOPS message
+ * @param ... Format arguments
+ */
void WriteWallOps(const char* text, ...);
+ /** Write a WALLOPS message from this user to all local opers.
+ * If this user is not opered, the function will return without doing anything.
+ * @param text The text to send in the WALLOPS message
+ */
void WriteWallOps(const std::string &text);
+ /** Return true if the user shares at least one channel with another user
+ * @param other The other user to compare the channel list against
+ * @return True if the given user shares at least one channel with this user
+ */
bool SharesChannelWith(userrec *other);
+ /** Change the displayed host of a user.
+ * ALWAYS use this function, rather than writing userrec::dhost directly,
+ * as this triggers module events allowing the change to be syncronized to
+ * remote servers. This will also emulate a QUIT and rejoin (where configured)
+ * before setting their host field.
+ * @param host The new hostname to set
+ * @return True if the change succeeded, false if it didn't
+ */
bool ChangeDisplayedHost(const char* host);
+ /** Change the ident (username) of a user.
+ * ALWAYS use this function, rather than writing userrec::ident directly,
+ * as this correctly causes the user to seem to quit (where configured)
+ * before setting their ident field.
+ * @param host The new ident to set
+ * @return True if the change succeeded, false if it didn't
+ */
+ bool ChangeIdent(const char* newident);
+
+ /** Change a users realname field.
+ * ALWAYS use this function, rather than writing userrec::fullname directly,
+ * as this triggers module events allowing the change to be syncronized to
+ * remote servers.
+ * @param gecos The user's new realname
+ * @return True if the change succeeded, false if otherwise
+ */
bool ChangeName(const char* gecos);
+ /** Return the total number of channels this user is on.
+ * @return The number of channels the user is on
+ */
int CountChannels();
+ /** Modify the number of channels this user is on (used by CountChannels).
+ * Pass a positive number to increment the counter, or a negative number
+ * to decrement it.
+ */
+ void ModChannelCount(int n);
+
+ /** Send a notice to all local users from this user
+ * @param text The text format string to send
+ * @param ... Format arguments
+ */
void NoticeAll(char* text, ...);
+ /** Compile a channel list for this user, and send it to the user 'source'
+ * Used internally by WHOIS
+ * @param The user to send the channel list to if it is not too long
+ * @return This user's channel list
+ */
std::string ChannelList(userrec* source);
+ /** Split the channel list in cl which came from dest, and spool it to this user
+ * Used internally by WHOIS
+ * @param dest The user the original channel list came from
+ * @param cl The channel list as a string obtained from userrec::ChannelList()
+ */
void SplitChanList(userrec* dest, const std::string &cl);
+ /** Remove this user from all channels they are on, and delete any that are now empty.
+ * This is used by QUIT, and will not send part messages!
+ */
void PurgeEmptyChannels();
+ /** Get the connect class which matches this user's host or IP address
+ * @return A reference to this user's connect class
+ */
ConnectClass& GetClass();
+ /** Show the message of the day to this user
+ */
+ void ShowMOTD();
+
+ /** Show the server RULES file to this user
+ */
+ void ShowRULES();
+
+ /** Handle socket event.
+ * From EventHandler class.
+ */
+ void HandleEvent(EventType et);
+
/** Default destructor
*/
virtual ~userrec();
/** Called every hour by the core to remove expired entries
*/
- void MaintainWhoWas(time_t TIME);
+ void MaintainWhoWas(InspIRCd* ServerInstance, time_t TIME);
};
};