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.
This commit is contained in:
Sadie Powell 2022-10-29 15:44:01 +01:00
parent 5a508c19ff
commit 6fc111ccb6
40 changed files with 139 additions and 142 deletions

View File

@ -221,11 +221,11 @@
# #
# Connect blocks are searched twice for each user - once when the TCP #
# connection is accepted, and once when the user completes their #
# registration. Most of the information (hostname, ident response, #
# connection. Most of the information (hostname, ident response, #
# password, TLS when using STARTTLS, etc) is only available during #
# the second search. If you are trying to make a closed server you #
# will probably need a connect block just for user registration. This #
# can be done by using <connect registered="no"> #
# will probably need a connect block just for user connection. This #
# can be done by using <connect connected="no"> #
# To enable IRCCloud on your network uncomment this:
#<include file="examples/providers/irccloud.conf.example">

View File

@ -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("*");

View File

@ -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

View File

@ -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

View File

@ -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, "*");

View File

@ -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("*");

View File

@ -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);

View File

@ -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
/** Return a count of local unknown (not fully connected) users.
* @return The number of local unknown (not fully connected) users.
*/
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
*/
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->UnregisteredUserCount()); }
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 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

View File

@ -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();

View File

@ -174,7 +174,7 @@ Channel* Channel::JoinUser(LocalUser* user, std::string cname, bool override, co
{
if (!user->IsFullyConnected())
{
ServerInstance->Logs.Debug("CHANNELS", "Attempted to join unregistered user " + user->uuid + " to channel " + cname);
ServerInstance->Logs.Debug("CHANNELS", "Attempted to join partially connected user " + user->uuid + " to channel " + cname);
return nullptr;
}

View File

@ -314,7 +314,7 @@ void CommandParser::ProcessCommand(LocalUser* user, std::string& command, Comman
if (!user->IsFullyConnected() && !handler->works_before_reg)
{
user->CommandFloodPenalty += failpenalty;
handler->TellNotRegistered(user, command_p);
handler->TellNotFullyConnected(user, command_p);
FOREACH_MOD(OnCommandBlocked, (command, command_p, user));
}
else

View File

@ -76,9 +76,9 @@ void Command::TellNotEnoughParameters(LocalUser* user, const Params& parameters)
}
}
void Command::TellNotRegistered(LocalUser* user, const Params& parameters)
void Command::TellNotFullyConnected(LocalUser* user, const Params& parameters)
{
user->WriteNumeric(ERR_NOTREGISTERED, name, "You have not registered.");
user->WriteNumeric(ERR_NOTREGISTERED, name, "You must be fully connected to use this command.");
}
SplitCommand::SplitCommand(Module* me, const std::string& cmd, unsigned int minpara, unsigned int maxpara)

View File

@ -127,7 +127,7 @@ void ISupportManager::Build()
{
for (LocalUser* user : ServerInstance->Users.GetLocalUsers())
{
if (!(user->registered & REG_ALL))
if (!(user->connected & User::CONN_FULL))
continue; // User hasn't received 005 yet.
auto numerics = diffnumerics.find(user->GetClass());

View File

@ -47,7 +47,7 @@ struct LusersCounters final
LusersCounters(UserModeReference& invisiblemode)
: max_local(ServerInstance->Users.LocalUserCount())
, max_global(ServerInstance->Users.RegisteredUserCount())
, max_global(ServerInstance->Users.GlobalUserCount())
{
for (const auto& [_, u] : ServerInstance->Users.GetUsers())
{
@ -62,7 +62,7 @@ struct LusersCounters final
if (current > max_local)
max_local = current;
current = ServerInstance->Users.RegisteredUserCount();
current = ServerInstance->Users.GlobalUserCount();
if (current > max_global)
max_global = current;
}
@ -86,7 +86,7 @@ public:
CmdResult CommandLusers::Handle(User* user, const Params& parameters)
{
size_t n_users = ServerInstance->Users.RegisteredUserCount();
size_t n_users = ServerInstance->Users.GlobalUserCount();
ProtocolInterface::ServerList serverlist;
ServerInstance->PI->GetServerList(serverlist);
size_t n_serv = serverlist.size();
@ -110,8 +110,8 @@ CmdResult CommandLusers::Handle(User* user, const Params& parameters)
if (opercount)
user->WriteNumeric(RPL_LUSEROP, opercount, "operator(s) online");
if (ServerInstance->Users.UnregisteredUserCount())
user->WriteNumeric(RPL_LUSERUNKNOWN, ServerInstance->Users.UnregisteredUserCount(), "unknown connections");
if (ServerInstance->Users.UnknownUserCount())
user->WriteNumeric(RPL_LUSERUNKNOWN, ServerInstance->Users.UnknownUserCount(), "unknown connections");
user->WriteNumeric(RPL_LUSERCHANNELS, ServerInstance->Channels.GetChans().size(), "channels formed");
user->WriteNumeric(RPL_LUSERME, InspIRCd::Format("I have %zu clients and %zu servers", ServerInstance->Users.LocalUserCount(), n_local_servs));

View File

@ -196,7 +196,7 @@ private:
for (auto* luser : ServerInstance->Users.GetLocalUsers())
{
// Don't send to unregistered users or the user who is the source.
// Don't send to partially connected users or the user who is the source.
if (!luser->IsFullyConnected() || luser == source)
continue;
@ -238,7 +238,7 @@ private:
if (!target)
{
// The target user does not exist or is not fully registered.
// The target user does not exist or is not fully connected.
source->WriteNumeric(Numerics::NoSuchNick(parameters[0]));
return CmdResult::FAILURE;
}
@ -379,7 +379,7 @@ public:
if (!target || !target->server->IsService())
{
// The target user does not exist, is not fully registered, or is not a service.
// The target user does not exist, is not fully connected, or is not a service.
user->WriteRemoteNumeric(ERR_NOSUCHSERVICE, parameters[0], "No such service");
return CmdResult::FAILURE;
}

View File

@ -52,7 +52,7 @@ void DieRestart::SendError(const std::string& message)
}
else
{
// Unregistered connections receive ERROR, not a NOTICE
// Partially connected users receive ERROR, not a NOTICE
user->Send(errorevent);
}
}

View File

@ -25,7 +25,7 @@
namespace DieRestart
{
/** Send an ERROR to unregistered users and a NOTICE to all registered local users
/** Send an ERROR to partially connected users and a NOTICE to fully connected users
* @param message Message to send
*/
void SendError(const std::string& message);

View File

@ -161,7 +161,7 @@ void CommandStats::DoStats(Stats::Context& stats)
{
for (const auto& host : c->GetHosts())
stats.AddRow(215, 'i', "NOMATCH", '*', host, (c->limit ? c->limit : SocketEngine::GetMaxFds()), idx, ServerInstance->Config->ServerName, '*');
stats.AddRow(218, 'Y', idx, c->pingtime, '0', c->hardsendqmax, ConvToStr(c->recvqmax) + " " + ConvToStr(c->registration_timeout));
stats.AddRow(218, 'Y', idx, c->pingtime, '0', c->hardsendqmax, ConvToStr(c->recvqmax) + " " + ConvToStr(c->connection_timeout));
idx++;
}
}

View File

@ -40,7 +40,7 @@ public:
CmdResult Handle(User* user, const Params& parameters) override
{
if (user->registered == REG_NONE)
if (user->connected == User::CONN_NONE)
{
// The CAPAB command is used in the server protocol for negotiating
// the protocol version when initiating a server connection. There

View File

@ -92,9 +92,9 @@ CmdResult CommandNick::HandleLocal(LocalUser* user, const Params& parameters)
if (!user->ChangeNick(newnick))
return CmdResult::FAILURE;
if (user->registered < REG_NICKUSER)
if (user->connected < User::CONN_NICKUSER)
{
user->registered = (user->registered | REG_NICK);
user->connected |= User::CONN_NICK;
return CommandUser::CheckRegister(user);
}

View File

@ -44,7 +44,7 @@ CommandUser::CommandUser(Module* parent)
CmdResult CommandUser::HandleLocal(LocalUser* user, const Params& parameters)
{
/* A user may only send the USER command once */
if (!(user->registered & REG_USER))
if (!(user->connected & User::CONN_USER))
{
if (!ServerInstance->IsIdent(parameters[0]))
{
@ -55,12 +55,12 @@ CmdResult CommandUser::HandleLocal(LocalUser* user, const Params& parameters)
{
user->ChangeIdent(parameters[0]);
user->ChangeRealName(parameters[3]);
user->registered = (user->registered | REG_USER);
user->connected |= User::CONN_USER;
}
}
else
{
user->WriteNumeric(ERR_ALREADYREGISTERED, "You may not reregister");
user->WriteNumeric(ERR_ALREADYREGISTERED, "You may not resend the USER command");
user->CommandFloodPenalty += 1000;
return CmdResult::FAILURE;
}
@ -71,9 +71,10 @@ CmdResult CommandUser::HandleLocal(LocalUser* user, const Params& parameters)
CmdResult CommandUser::CheckRegister(LocalUser* user)
{
// If the user is registered, return CmdResult::SUCCESS/CmdResult::FAILURE depending on what modules say, otherwise just
// return CmdResult::SUCCESS without doing anything, knowing the other handler will call us again
if (user->registered == REG_NICKUSER)
// If the user is fully connected, return CmdResult::SUCCESS/CmdResult::FAILURE depending on
// what modules say, otherwise just return CmdResult::SUCCESS without doing anything, knowing
// the other handler will call us again
if (user->connected == User::CONN_NICKUSER)
{
ModResult MOD_RESULT;
FIRST_MOD_RESULT(OnUserRegister, MOD_RESULT, (user));

View File

@ -43,11 +43,10 @@ public:
CmdResult HandleLocal(LocalUser* user, const Params& parameters) override
{
// Check to make sure they haven't registered -- Fix by FCS
if (user->IsFullyConnected())
{
user->CommandFloodPenalty += 1000;
user->WriteNumeric(ERR_ALREADYREGISTERED, "You may not reregister");
user->WriteNumeric(ERR_ALREADYREGISTERED, "You may not resend the PASS command");
return CmdResult::FAILURE;
}
user->password = parameters[0];

View File

@ -119,7 +119,7 @@ public:
CommandUser(Module* parent);
CmdResult HandleLocal(LocalUser* user, const Params& parameters) override;
/** Run the OnUserRegister hook if the user has sent both NICK and USER. Called after an unregistered user
/** Run the OnUserRegister hook if the user has sent both NICK and USER. Called after a partially connected user
* successfully executes the USER or the NICK command.
* @param user User to inspect and possibly pass to the OnUserRegister hook
* @return CmdResult::FAILURE if OnUserRegister was called and it returned MOD_RES_DENY, CmdResult::SUCCESS in every other case

View File

@ -258,7 +258,7 @@ bool CommandWho::MatchChannel(LocalUser* source, Membership* memb, WhoData& data
bool CommandWho::MatchUser(LocalUser* source, User* user, WhoData& data)
{
// Users who are not fully registered can never match.
// Users who are not fully connected can never match.
if (!user->IsFullyConnected())
return false;

View File

@ -145,7 +145,7 @@ public:
if (!xline)
return MOD_RES_PASSTHRU; // No match
// A Q-line matched the new nick, tell opers if the user is registered
// A Q-line matched the new nick, tell opers if the user is fully connected
if (user->IsFullyConnected())
{
ServerInstance->SNO.WriteGlobalSno('x', "Q-lined nickname %s from %s: %s",

View File

@ -160,9 +160,7 @@ public:
ModResult OnPreCommand(std::string& command, CommandBase::Params& parameters, LocalUser* user, bool validated) override
{
/* If they're not registered yet, we dont want
* to know.
*/
// If they're not fully connected yet, we dont want to know.
if (!user->IsFullyConnected())
return MOD_RES_PASSTHRU;

View File

@ -77,7 +77,7 @@ public:
ModResult OnPreCommand(std::string& command, CommandBase::Params& parameters, LocalUser* user, bool validated) override
{
// Don't do anything with unregistered users
// Don't do anything with partially connected users
if (!user->IsFullyConnected())
return MOD_RES_PASSTHRU;

View File

@ -59,7 +59,7 @@ public:
auto dest = ServerInstance->Users.Find(parameters[0]);
// Allow services to change the host of unregistered users
// Allow services to change the host of partially connected users.
if (!dest || (!dest->IsFullyConnected() && !user->server->IsService()))
{
user->WriteNumeric(Numerics::NoSuchNick(parameters[0]));

View File

@ -57,7 +57,7 @@ public:
}
if(sendsnotice)
user->WriteNotice("*** If you are having problems connecting due to registration timeouts type /quote PONG " + pingrpl + " or /raw PONG " + pingrpl + " now.");
user->WriteNotice("*** If you are having problems connecting due to connection timeouts type /quote PONG " + pingrpl + " or /raw PONG " + pingrpl + " now.");
ext.Set(user, pingrpl);
return MOD_RES_PASSTHRU;
@ -79,7 +79,7 @@ public:
else
{
if(killonbadreply)
ServerInstance->Users.QuitUser(user, "Incorrect ping reply for registration");
ServerInstance->Users.QuitUser(user, "Incorrect ping reply for connection");
return MOD_RES_DENY;
}
}

View File

@ -141,7 +141,7 @@ public:
ModResult OnPreCommand(std::string& command, CommandBase::Params& parameters, LocalUser* user, bool validated) override
{
// If a command is unvalidated or the source is not registered we do nothing.
// If a command is unvalidated or the source is not fully connected we do nothing.
if (!validated || !user->IsFullyConnected())
return MOD_RES_PASSTHRU;
@ -169,7 +169,7 @@ public:
ModResult OnRawMode(User* user, Channel* chan, const Modes::Change& change) override
{
// If a mode change is remote or the source is not registered we do nothing.
// If a mode change is remote or the source is not fully connected we do nothing.
if (!IS_LOCAL(user) || !user->IsFullyConnected())
return MOD_RES_PASSTHRU;

View File

@ -28,7 +28,7 @@
enum
{
// Either the ident lookup has not started yet or the user is registered.
// Either the ident lookup has not started yet or the user is fully connected.
IDENT_UNKNOWN = 0,
// Ident lookups are not enabled and a user has been marked as being skipped.
@ -380,7 +380,7 @@ public:
}
else if (!isock->HasResult())
{
// time still good, no result yet... hold the registration
// time still good, no result yet... hold the connection
return MOD_RES_DENY;
}

View File

@ -146,7 +146,7 @@ public:
void OnAccountChange(User* user, const std::string& newaccount) override
{
if (!(user->registered & REG_NICKUSER))
if (!(user->connected & User::CONN_NICKUSER))
return;
// Logged in: 1 parameter which is the account name

View File

@ -30,7 +30,7 @@ class ModuleIRCv3ChgHost final
void DoChgHost(User* user, const std::string& ident, const std::string& host)
{
if (!(user->registered & REG_NICKUSER))
if (!(user->connected & User::CONN_NICKUSER))
return;
ClientProtocol::Message msg("CHGHOST", user);

View File

@ -133,7 +133,7 @@ private:
message.SetSideEffect(true);
for (auto* luser : ServerInstance->Users.GetLocalUsers())
{
// Don't send to unregistered users or the user who is the source.
// Don't send to partially connected users or the user who is the source.
if (!luser->IsFullyConnected() || luser == source)
continue;
@ -185,7 +185,7 @@ private:
if (!target)
{
// The target user does not exist or is not fully registered.
// The target user does not exist or is not fully connected.
source->WriteNumeric(Numerics::NoSuchNick(parameters[0]));
return CmdResult::FAILURE;
}

View File

@ -443,7 +443,7 @@ public:
void OnUserConnect(LocalUser* user) override
{
// If the client completes registration (with CAP END, NICK, USER and
// If the client completes connection (with CAP END, NICK, USER and
// any other necessary messages) while the SASL authentication is still
// in progress, the server SHOULD abort it and send a 906 numeric, then
// register the client without authentication.

View File

@ -95,7 +95,7 @@ public:
void OnChangeRealName(User* user, const std::string& real) override
{
if (!(user->registered & REG_NICKUSER))
if (!(user->connected & User::CONN_NICKUSER))
return;
ClientProtocol::Message msg("SETNAME", user);

View File

@ -51,14 +51,14 @@ CmdResult CommandUID::HandleServer(TreeServer* remoteserver, CommandBase::Params
auto collideswith = ServerInstance->Users.FindNick(params[2]);
if (collideswith && !collideswith->IsFullyConnected())
{
// User that the incoming user is colliding with is not fully registered, we force nick change the
// unregistered user to their uuid and tell them what happened
// User that the incoming user is colliding with is not fully connected, we force nick change the
// partially connected user to their uuid and tell them what happened
LocalUser* const localuser = static_cast<LocalUser*>(collideswith);
localuser->OverruleNick();
}
else if (collideswith)
{
// The user on this side is registered, handle the collision
// The user on this side is fully connected, handle the collision
bool they_change = Utils->DoCollision(collideswith, remoteserver, nickchanged, params[5], params[6], params[0], "UID");
if (they_change)
{
@ -85,7 +85,7 @@ CmdResult CommandUID::HandleServer(TreeServer* remoteserver, CommandBase::Params
_new->ident = params[5];
_new->ChangeRemoteAddress(sa);
_new->ChangeRealName(params.back());
_new->registered = REG_ALL;
_new->connected = User::CONN_FULL;
_new->signon = signon;
_new->nickchanged = nickchanged;

View File

@ -55,7 +55,7 @@ public:
if (user->IsFullyConnected())
{
user->WriteNumeric(ERR_STARTTLS, "STARTTLS is not permitted after client registration is complete");
user->WriteNumeric(ERR_STARTTLS, "STARTTLS is not permitted once you are fully connected");
return CmdResult::FAILURE;
}
@ -70,7 +70,7 @@ public:
* otherwise we'll be sending this line inside the TLS session - which
* won't start its handshake until the client gets this line. Currently,
* we assume the write will not block here; this is usually safe, as
* STARTTLS is sent very early on in the registration phase, where the
* STARTTLS is sent very early on in the connection phase, where the
* user hasn't built up much sendq. Handling a blocked write here would
* be very annoying.
*/

View File

@ -80,13 +80,13 @@ namespace
user->nextping = ServerInstance->Time() + user->GetClass()->pingtime;
}
void CheckRegistrationTimeout(LocalUser* user)
void CheckConnectionTimeout(LocalUser* user)
{
if (user->GetClass() && (ServerInstance->Time() > static_cast<time_t>(user->signon + user->GetClass()->registration_timeout)))
if (user->GetClass() && (ServerInstance->Time() > static_cast<time_t>(user->signon + user->GetClass()->connection_timeout)))
{
// Either the user did not send NICK/USER or a module blocked registration in
// Either the user did not send NICK/USER or a module blocked connection in
// OnCheckReady until the client timed out.
ServerInstance->Users.QuitUser(user, "Registration timeout");
ServerInstance->Users.QuitUser(user, "Connection timeout");
}
}
@ -104,7 +104,7 @@ namespace
// If the user has been quit in OnCheckReady then we shouldn't quit
// them again for having a registration timeout.
if (!user->quitting)
CheckRegistrationTimeout(user);
CheckConnectionTimeout(user);
}
}
@ -127,7 +127,7 @@ void UserManager::AddUser(int socket, ListenSocket* via, irc::sockets::sockaddrs
ServerInstance->Logs.Debug("USERS", "New user fd: %d", socket);
this->unregistered_count++;
this->unknown_count++;
this->clientlist[New->nick] = New;
this->AddClone(New);
this->local_users.push_front(New);
@ -283,7 +283,7 @@ void UserManager::QuitUser(User* user, const std::string& quitmessage, const std
WriteCommonQuit(user, quitmsg, operquitmsg);
}
else
unregistered_count--;
unknown_count--;
if (IS_LOCAL(user))
{
@ -351,7 +351,7 @@ const UserManager::CloneCounts& UserManager::GetCloneCounts(User* user) const
/**
* This function is called once a second from the mainloop.
* It is intended to do background checking on all the users, e.g. do
* ping checks, registration timeouts, etc.
* ping checks, connection timeouts, etc.
*/
void UserManager::DoBackgroundUserStuff()
{
@ -371,18 +371,18 @@ void UserManager::DoBackgroundUserStuff()
curr->eh.OnDataReady();
}
switch (curr->registered)
switch (curr->connected)
{
case REG_ALL:
case User::CONN_FULL:
CheckPingTimeout(curr);
break;
case REG_NICKUSER:
case User::CONN_NICKUSER:
CheckModulesReady(curr);
break;
default:
CheckRegistrationTimeout(curr);
CheckConnectionTimeout(curr);
break;
}
}

View File

@ -91,7 +91,7 @@ User::User(const std::string& uid, Server* srv, Type type)
, nickchanged(ServerInstance->Time())
, uuid(uid)
, server(srv)
, registered(REG_NONE)
, connected(CONN_NONE)
, quitting(false)
, uniqueusername(false)
, usertype(type)
@ -566,15 +566,15 @@ void LocalUser::FullConnect()
return;
/*
* We don't set REG_ALL until triggering OnUserConnect, so some module events don't spew out stuff
* We don't set CONN_FULL until triggering OnUserConnect, so some module events don't spew out stuff
* for a user that doesn't exist yet.
*/
FOREACH_MOD(OnUserConnect, (this));
/* Now registered */
if (ServerInstance->Users.unregistered_count)
ServerInstance->Users.unregistered_count--;
this->registered = REG_ALL;
// The user is now fully connected.
if (ServerInstance->Users.unknown_count)
ServerInstance->Users.unknown_count--;
this->connected = CONN_FULL;
FOREACH_MOD(OnPostConnect, (this));
@ -671,7 +671,7 @@ void LocalUser::OverruleNick()
this->WriteNumeric(ERR_NICKNAMEINUSE, this->nick, "Nickname overruled.");
// Clear the bit before calling ChangeNick() to make it NOT run the OnUserPostNick() hook
this->registered &= ~REG_NICK;
this->connected &= ~CONN_NICK;
this->ChangeNick(this->uuid);
}
@ -998,7 +998,7 @@ bool User::ChangeDisplayedHost(const std::string& shost)
this->InvalidateCache();
if (IS_LOCAL(this) && this->registered != REG_NONE)
if (IS_LOCAL(this) && connected != User::CONN_NONE)
this->WriteNumeric(RPL_YOURDISPLAYEDHOST, this->GetDisplayedHost(), "is now your displayed host");
return true;
@ -1105,11 +1105,11 @@ void LocalUser::SetClass(const std::string& explicit_name)
continue;
}
bool regdone = (registered != REG_NONE);
if (c->config->getBool("registered", regdone) != regdone)
bool conndone = connected != User::CONN_NONE;
if (c->config->getBool("connected", c->config->getBool("registered", conndone)) != conndone)
{
ServerInstance->Logs.Debug("CONNECTCLASS", "The %s connect class is not suitable as it requires that the user is %s",
c->GetName().c_str(), regdone ? "not fully connected" : "fully connected");
c->GetName().c_str(), conndone ? "not fully connected" : "fully connected");
continue;
}
@ -1150,7 +1150,7 @@ void LocalUser::SetClass(const std::string& explicit_name)
continue;
}
if (regdone && !c->password.empty() && !ServerInstance->PassCompare(this, c->password, password, c->passwordhash))
if (conndone && !c->password.empty() && !ServerInstance->PassCompare(this, c->password, password, c->passwordhash))
{
ServerInstance->Logs.Debug("CONNECTCLASS", "The %s connect class is not suitable as requires a password and %s",
c->GetName().c_str(), password.empty() ? "one was not provided" : "the provided password was incorrect");
@ -1273,7 +1273,7 @@ void ConnectClass::Configure(const std::string& classname, std::shared_ptr<Confi
penaltythreshold = tag->getUInt("threshold", penaltythreshold, 1);
pingtime = tag->getDuration("pingfreq", pingtime);
recvqmax = tag->getUInt("recvq", recvqmax, ServerInstance->Config->Limits.MaxLine);
registration_timeout = tag->getDuration("timeout", registration_timeout);
connection_timeout = tag->getDuration("timeout", connection_timeout);
resolvehostnames = tag->getBool("resolvehostnames", resolvehostnames);
softsendqmax = tag->getUInt("softsendq", softsendqmax, ServerInstance->Config->Limits.MaxLine);
uniqueusername = tag->getBool("uniqueusername", uniqueusername);
@ -1299,7 +1299,7 @@ void ConnectClass::Update(const ConnectClass::Ptr src)
pingtime = src->pingtime;
ports = src->ports;
recvqmax = src->recvqmax;
registration_timeout = src->registration_timeout;
connection_timeout = src->connection_timeout;
resolvehostnames = src->resolvehostnames;
softsendqmax = src->softsendqmax;
type = src->type;