diff options
| author | 2022-10-29 15:44:01 +0100 | |
|---|---|---|
| committer | 2022-10-29 15:54:59 +0100 | |
| commit | 6fc111ccb6650a67f014977b2e7ebc2fb5b16790 (patch) | |
| tree | ea56149af9bf3e2226e32385ad6989355266090d /include | |
| parent | Use User::IsFullyConnected instead of checking for REG_ALL. (diff) | |
Rename session registration to connection to avoid a semantic conflict.
We previously referred to both session registration and user registration
as "registration" which is confusing for users who aren't familiar with
how IRC works.
Diffstat (limited to 'include')
| -rw-r--r-- | include/clientprotocolmsg.h | 6 | ||||
| -rw-r--r-- | include/ctables.h | 4 | ||||
| -rw-r--r-- | include/modules.h | 6 | ||||
| -rw-r--r-- | include/modules/cap.h | 2 | ||||
| -rw-r--r-- | include/modules/ctctags.h | 2 | ||||
| -rw-r--r-- | include/numerichelper.h | 6 | ||||
| -rw-r--r-- | include/usermanager.h | 38 | ||||
| -rw-r--r-- | include/users.h | 55 |
8 files changed, 59 insertions, 60 deletions
diff --git a/include/clientprotocolmsg.h b/include/clientprotocolmsg.h index 7c6c809de..fb60d74cb 100644 --- a/include/clientprotocolmsg.h +++ b/include/clientprotocolmsg.h @@ -67,12 +67,12 @@ class ClientProtocol::Messages::Numeric public: /** Constructor, target is a User. * @param num Numeric object to send. Must remain valid as long as this object is alive and must not be modified. - * @param user User to send the numeric to. May be unregistered, must remain valid as long as this object is alive. + * @param user User to send the numeric to. May be partially connected, must remain valid as long as this object is alive. */ Numeric(const ::Numeric::Numeric& num, User* user) : ClientProtocol::Message(nullptr, (num.GetServer() ? num.GetServer() : ServerInstance->FakeClient->server)->GetPublicName()) { - if (user->registered & REG_NICK) + if (user->connected & User::CONN_NICK) PushParamRef(user->nick); else PushParam("*"); @@ -432,7 +432,7 @@ class ClientProtocol::Messages::Privmsg void PushTargetUser(const User* targetuser) { - if (targetuser->registered & REG_NICK) + if (targetuser->connected & User::CONN_NICK) PushParamRef(targetuser->nick); else PushParam("*"); diff --git a/include/ctables.h b/include/ctables.h index e95a68d39..6273650a3 100644 --- a/include/ctables.h +++ b/include/ctables.h @@ -271,11 +271,11 @@ public: */ virtual void TellNotEnoughParameters(LocalUser* user, const Params& parameters); - /** Tells the user they need to be registered to execute this command. + /** Tells the user they need to be fully connected to execute this command. * @param user The user who issued the command. * @param parameters The parameters for the command. */ - virtual void TellNotRegistered(LocalUser* user, const Params& parameters); + virtual void TellNotFullyConnected(LocalUser* user, const Params& parameters); }; class CoreExport SplitCommand diff --git a/include/modules.h b/include/modules.h index dfb3a70e5..123177372 100644 --- a/include/modules.h +++ b/include/modules.h @@ -301,7 +301,7 @@ public: /** Called when before a user quits. * The details of the exiting user are available to you in the parameter User* user - * This event is only called when the user is fully registered when they quit. To catch + * This event is only called when the user is fully connected when they quit. To catch * raw disconnections, use the OnUserDisconnect method. * @param user The user who is quitting * @param message The user's quit message (as seen by non-opers) @@ -311,7 +311,7 @@ public: /** Called when a user quits. * The details of the exiting user are available to you in the parameter User* user - * This event is only called when the user is fully registered when they quit. To catch + * This event is only called when the user is fully connected when they quit. To catch * raw disconnections, use the OnUserDisconnect method. * @param user The user who is quitting * @param message The user's quit message (as seen by non-opers) @@ -754,7 +754,7 @@ public: * If any modules return false for this function, the user is held in the waiting * state until all modules return true. For example a module which implements ident * lookups will continue to return false for a user until their ident lookup is completed. - * Note that the registration timeout for a user overrides these checks, if the registration + * Note that the connection timeout for a user overrides these checks, if the connection * timeout is reached, the user is disconnected even if modules report that the user is * not ready to connect. * @param user The user to check diff --git a/include/modules/cap.h b/include/modules/cap.h index 77434642a..c5b07f04c 100644 --- a/include/modules/cap.h +++ b/include/modules/cap.h @@ -342,7 +342,7 @@ namespace Cap void SetUser(LocalUser* user) { - if (user->registered & REG_NICK) + if (user->connected & User::CONN_NICK) ReplaceParamRef(0, user->nick); else ReplaceParam(0, "*"); diff --git a/include/modules/ctctags.h b/include/modules/ctctags.h index c6724ed13..6433720bd 100644 --- a/include/modules/ctctags.h +++ b/include/modules/ctctags.h @@ -66,7 +66,7 @@ public: TagMessage(User* source, const User* targetuser, const ClientProtocol::TagMap& Tags) : ClientProtocol::Message("TAGMSG", source) { - if (targetuser->registered & REG_NICK) + if (targetuser->connected & User::CONN_NICK) PushParamRef(targetuser->nick); else PushParam("*"); diff --git a/include/numerichelper.h b/include/numerichelper.h index 842ce620f..6b5f6c52a 100644 --- a/include/numerichelper.h +++ b/include/numerichelper.h @@ -69,14 +69,14 @@ public: CannotSendTo(User* user, const std::string& message) : Numeric(ERR_CANNOTSENDTOUSER) { - push(user->registered & REG_NICK ? user->nick : "*"); + push(user->connected & User::CONN_NICK ? user->nick : "*"); push(message); } CannotSendTo(User* user, const std::string& what, ModeHandler* mh, bool self = false) : Numeric(ERR_CANNOTSENDTOUSER) { - push(user->registered & REG_NICK ? user->nick : "*"); + push(user->connected & User::CONN_NICK ? user->nick : "*"); push(InspIRCd::Format("You cannot send %s to this user whilst %s have the +%c (%s) mode set.", what.c_str(), self ? "you" : "they", mh->GetModeChar(), mh->name.c_str())); } @@ -139,7 +139,7 @@ public: InvalidModeParameter(User* user, ModeHandler* mode, const std::string& parameter, const std::string& message = "") : Numeric(ERR_INVALIDMODEPARAM) { - push(user->registered & REG_NICK ? user->nick : "*"); + push(user->connected & User::CONN_NICK ? user->nick : "*"); push(mode->GetModeChar()); push(parameter); push_message(mode, message); diff --git a/include/usermanager.h b/include/usermanager.h index b2ac738f0..4aa1f1479 100644 --- a/include/usermanager.h +++ b/include/usermanager.h @@ -82,11 +82,11 @@ public: */ ~UserManager(); - /** Nickname string -> User* map. Contains all users, including unregistered ones. + /** Nickname string -> User* map. Contains all users, including partially connected ones. */ UserMap clientlist; - /** UUID -> User* map. Contains all users, including unregistered ones. + /** UUID -> User* map. Contains all users, including partially connected ones. */ UserMap uuidlist; @@ -97,19 +97,17 @@ public: /** A list of users on services servers. */ ServiceList all_services; - /** Number of unregistered users online right now. - * (Unregistered means before USER/NICK/dns) - */ - size_t unregistered_count = 0; + /** Number of local unknown (not fully connected) users. */ + size_t unknown_count = 0; - /** Perform background user events for all local users such as PING checks, registration timeouts, + /** Perform background user events for all local users such as PING checks, connection timeouts, * penalty management and recvq processing for users who have data in their recvq due to throttling. */ void DoBackgroundUserStuff(); /** Handle a client connection. * Creates a new LocalUser object, inserts it into the appropriate containers, - * initializes it as not yet registered, and adds it to the socket engine. + * initializes it as not fully connected, and adds it to the socket engine. * * The new user may immediately be quit after being created, for example if the user limit * is reached or if the user is banned. @@ -135,7 +133,7 @@ public: /** Remove all clone counts from the user, you should * use this if you change the user's IP address - * after they have registered. + * after they have fully connected. * @param user The user to remove */ void RemoveCloneCounts(User* user); @@ -157,25 +155,25 @@ public: */ const CloneMap& GetCloneMap() const { return clonemap; } - /** Return a count of fully registered connections on the network - * @return The number of registered users on the network - */ - size_t RegisteredUserCount() { return this->clientlist.size() - this->UnregisteredUserCount() - this->ServiceCount(); } - - /** Return a count of local unregistered (before NICK/USER) users - * @return The number of local unregistered (unknown) connections + /** Return a count of local unknown (not fully connected) users. + * @return The number of local unknown (not fully connected) users. */ - size_t UnregisteredUserCount() const { return this->unregistered_count; } + size_t UnknownUserCount() const { return this->unknown_count; } /** Return a count of users on a services servers. * @return The number of users on services servers. */ size_t ServiceCount() const { return this->all_services.size(); } - /** Return a count of local registered users - * @return The number of registered local users + /** Return a count of fully connected connections on this server. + * @return The number of fully connected users on this server. + */ + size_t LocalUserCount() const { return this->local_users.size() - this->UnknownUserCount(); } + + /** Return a count of fully connected connections on the network. + * @return The number of fully connected users on the network. */ - size_t LocalUserCount() const { return (this->local_users.size() - this->UnregisteredUserCount()); } + size_t GlobalUserCount() const { return this->clientlist.size() - this->UnknownUserCount() - this->ServiceCount(); } /** Get a hash map containing all users, keyed by their nickname * @return A hash map mapping nicknames to User pointers diff --git a/include/users.h b/include/users.h index 90f96c903..ebc3d8fc3 100644 --- a/include/users.h +++ b/include/users.h @@ -39,21 +39,6 @@ #include "mode.h" #include "membership.h" -/** Registration state of a user, e.g. - * have they sent USER, NICK, PASS yet? - */ -enum RegistrationState { - -#ifndef _WIN32 // Burlex: This is already defined in win32, luckily it is still 0. - REG_NONE = 0, /* Has sent nothing */ -#endif - - REG_USER = 1, /* Has sent USER */ - REG_NICK = 2, /* Has sent NICK */ - REG_NICKUSER = 3, /* Bitwise combination of REG_NICK and REG_USER */ - REG_ALL = 7 /* REG_NICKUSER plus next bit along */ -}; - /** Represents \<connect> class tags from the server config */ class CoreExport ConnectClass final { @@ -135,8 +120,8 @@ public: /** The maximum number of bytes that users in this class can have in their receive queue before they are disconnected. */ unsigned long recvqmax = 4096UL; - /** The number of seconds that connecting users have to register within in this class. */ - unsigned long registration_timeout = 90UL; + /** The number of seconds that connecting users have to fully connect within in this class. */ + unsigned long connection_timeout = 90UL; /** The maximum number of bytes that users in this class can have in their send queue before their commands stop being processed. */ unsigned long softsendqmax = 4096UL; @@ -220,6 +205,26 @@ public: virtual void Execute(LocalUser* user) = 0; }; + /** Represents the state of a connection to the server. */ + enum ConnectionState + : uint8_t + { + /** The user has not sent any commands. */ + CONN_NONE = 0, + + /** The user has sent the NICK command. */ + CONN_NICK = 1, + + /** The user has sent the USER command. */ + CONN_USER = 2, + + /** The user has sent both the NICK and USER commands and is waiting to be fully connected. */ + CONN_NICKUSER = CONN_NICK | CONN_USER, + + /** The user has sent both the NICK and USER commands and is fully connected */ + CONN_FULL = 7, + }; + /** An enumeration of all possible types of user. */ enum Type : uint8_t @@ -254,7 +259,6 @@ public: irc::sockets::sockaddrs client_sa; /** The users nickname. - * An invalid nickname indicates an unregistered connection prior to the NICK command. * Use InspIRCd::IsNick() to validate nicknames. */ std::string nick; @@ -296,11 +300,8 @@ public: */ std::shared_ptr<OperInfo> oper; - /** Used by User to indicate the registration status of the connection - * It is a bitfield of the REG_NICK, REG_USER and REG_ALL bits to indicate - * the connection state. - */ - unsigned int registered:3; + /** The connection state of the user. */ + unsigned int connected:3; /** If this is set to true, then all socket operations for the user * are dropped into the bit-bucket. @@ -560,7 +561,7 @@ public: Cullable::Result Cull() override; /** Determines whether this user is fully connected to the server .*/ - inline bool IsFullyConnected() const { return registered == REG_ALL; } + inline bool IsFullyConnected() const { return connected == CONN_FULL; } }; class CoreExport UserIOHandler final @@ -638,7 +639,7 @@ public: */ unsigned int cmds_out = 0; - /** Password specified by the user when they registered (if any). + /** Password specified by the user when they connected (if any). * This is stored even if the \<connect> block doesnt need a password, so that * modules may check it. */ @@ -738,9 +739,9 @@ public: /** @copydoc User::HasSnomaskPermission */ bool HasSnomaskPermission(char chr) const override; - /** Change nick to uuid, unset REG_NICK and send a nickname overruled numeric. + /** Change nick to uuid, unset CONN_NICK and send a nickname overruled numeric. * This is called when another user (either local or remote) needs the nick of this user and this user - * isn't registered. + * isn't fully connected. */ void OverruleNick(); |
