diff options
| author | 2021-11-16 18:49:08 +0000 | |
|---|---|---|
| committer | 2021-11-16 18:59:18 +0000 | |
| commit | 2cdd31173504ee0fecdb2ce56c2f4f893e4b0a7b (patch) | |
| tree | be13ac99da9e7dbb58c429e6afe05a4f5d77962c | |
| parent | Allow configuring which options to trust from a WebIRC gateway. (diff) | |
Document ConnectClass and reorder it to avoid unnecessary padding.
| -rw-r--r-- | include/typedefs.h | 2 | ||||
| -rw-r--r-- | include/users.h | 121 | ||||
| -rw-r--r-- | src/users.cpp | 56 |
3 files changed, 83 insertions, 96 deletions
diff --git a/include/typedefs.h b/include/typedefs.h index 8a7b59159..063ee23cb 100644 --- a/include/typedefs.h +++ b/include/typedefs.h @@ -49,7 +49,7 @@ class User; class XLine; class XLineManager; class XLineFactory; -struct ConnectClass; +class ConnectClass; class ModResult; namespace ClientProtocol diff --git a/include/users.h b/include/users.h index d6cac1196..03e3afacc 100644 --- a/include/users.h +++ b/include/users.h @@ -71,105 +71,92 @@ enum UserType { USERTYPE_SERVER = 3 }; -/** Holds information relevant to <connect allow> and <connect deny> tags in the config file. - */ -struct CoreExport ConnectClass : public refcountbase +/** Represents \<connect> class tags from the server config */ +class CoreExport ConnectClass : public refcountbase { + public: + /** The synthesized (with all inheritance applied) config tag this class was read from. */ reference<ConfigTag> config; - /** Type of line, either CC_ALLOW or CC_DENY - */ - char type; - /** True if this class uses fake lag to manage flood, false if it kills */ - bool fakelag; + /** The hosts that this user can connect from as a string. */ + std::string host; - /** Connect class name - */ + /** The hosts that this user can connect from as a vector. */ + std::vector<std::string> hosts; + + /** The name of this connect class. */ std::string name; - /** Max time to register the connection in seconds - */ - unsigned int registration_timeout; + /** If non-empty then the password a user must specify in PASS to be assigned to this class. */ + std::string password; - /** Hosts that this user can connect from as a string. */ - std::string host; + /** If non-empty then the hash algorithm that the password field is hashed with. */ + std::string passwordhash; - /** Hosts that this user can connect from as a vector. */ - std::vector<std::string> hosts; + /** If non-empty then the server ports which a user has to be connecting on. */ + insp::flat_set<int> ports; - /** Number of seconds between pings for this line - */ - unsigned int pingtime; + /** The type of class this. */ + char type; - /** Maximum size of sendq for users in this class (bytes) - * Users cannot send commands if they go over this limit - */ - unsigned long softsendqmax; + /** Whether fake lag is used by this class. */ + bool fakelag:1; - /** Maximum size of sendq for users in this class (bytes) - * Users are killed if they go over this limit - */ - unsigned long hardsendqmax; + /** Whether to warn server operators about the limit for this class being reached. */ + bool maxconnwarn:1; - /** Maximum size of recvq for users in this class (bytes) - */ - unsigned long recvqmax; + /** Whether the DNS hostnames of users in this class should be resolved. */ + bool resolvehostnames:1; - /** Seconds worth of penalty before penalty system activates - */ - unsigned int penaltythreshold; + /** The maximum number of channels that users in this class can join. */ + unsigned int maxchans; - /** Maximum rate of commands (units: millicommands per second) */ - unsigned int commandrate; + /** The amount of penalty that a user in this class can have before the penalty system activates. */ + unsigned int penaltythreshold; - /** Local max when connecting by this connection class - */ - unsigned long maxlocal; + /** The number of seconds between keepalive checks for idle clients in this class. */ + unsigned int pingtime; - /** Global max when connecting by this connection class - */ - unsigned long maxglobal; + /** The number of seconds that connecting users have to register within in this class. */ + unsigned int registration_timeout; - /** True if max connections for this class is hit and a warning is wanted - */ - bool maxconnwarn; + /** Maximum rate of commands (units: millicommands per second) */ + unsigned int commandrate; - /** Max channels for this class - */ - unsigned int maxchans; + /** The maximum number of bytes that users in this class can have in their send queue before they are disconnected. */ + unsigned long hardsendqmax; - /** How many users may be in this connect class before they are refused? - * (0 = no limit = default) - */ + /** The maximum number of users in this class that can connect to the local server from one host. */ unsigned long limit; - /** If set to true, no user DNS lookups are to be performed - */ - bool resolvehostnames; + /** The maximum number of users in this class that can connect to the entire network from one host. */ + unsigned long maxglobal; - /** - * If non-empty the server ports which this user has to be using - */ - insp::flat_set<int> ports; + /** The maximum number of users that can be in this class on the local server. */ + unsigned long maxlocal; - /** If non-empty then the password a user must specify in PASS to be assigned to this class. */ - std::string password; + /** The maximum number of bytes that users in this class can have in their receive queue before they are disconnected. */ + unsigned long recvqmax; - /** If non-empty then the hash algorithm that the password field is hashed with. */ - std::string passwordhash; + /** 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; - /** Create a new connect class with no settings. - */ + /** Creates a new connect class from a config tag */ ConnectClass(ConfigTag* tag, char type, const std::string& mask); - /** Create a new connect class with inherited settings. - */ + + /** Creates a new connect class with a parent from a config tag. */ ConnectClass(ConfigTag* tag, char type, const std::string& mask, const ConnectClass& parent); - /** Update the settings in this block to match the given block */ + /** Update the settings in this block to match the given class */ void Update(const ConnectClass* newSettings); + /** Retrieves the name of this connect class. */ const std::string& GetName() const { return name; } + + /** Retrieves the hosts that this user can connect from as a string. */ const std::string& GetHost() const { return host; } + + /** Retrieves the hosts that this user can connect from as a vector. */ const std::vector<std::string>& GetHosts() const { return hosts; } /** Returns the registration timeout diff --git a/src/users.cpp b/src/users.cpp index 4e91c31d1..1ec7d9423 100644 --- a/src/users.cpp +++ b/src/users.cpp @@ -1259,23 +1259,23 @@ const std::string& FakeUser::GetFullRealHost() ConnectClass::ConnectClass(ConfigTag* tag, char t, const std::string& mask) : config(tag) + , host(mask) + , name("unnamed") , type(t) , fakelag(true) - , name("unnamed") - , registration_timeout(0) - , host(mask) - , pingtime(0) - , softsendqmax(0) - , hardsendqmax(0) - , recvqmax(0) - , penaltythreshold(0) - , commandrate(0) - , maxlocal(0) - , maxglobal(0) , maxconnwarn(true) + , resolvehostnames(true) , maxchans(0) + , penaltythreshold(0) + , pingtime(0) + , registration_timeout(0) + , commandrate(0) + , hardsendqmax(0) , limit(0) - , resolvehostnames(true) + , maxglobal(0) + , maxlocal(0) + , recvqmax(0) + , softsendqmax(0) { irc::spacesepstream hoststream(host); for (std::string hostentry; hoststream.GetToken(hostentry); ) @@ -1322,25 +1322,25 @@ ConnectClass::ConnectClass(ConfigTag* tag, char t, const std::string& mask, cons void ConnectClass::Update(const ConnectClass* src) { config = src->config; - type = src->type; - fakelag = src->fakelag; - name = src->name; - registration_timeout = src->registration_timeout; host = src->host; hosts = src->hosts; - pingtime = src->pingtime; - softsendqmax = src->softsendqmax; - hardsendqmax = src->hardsendqmax; - recvqmax = src->recvqmax; - penaltythreshold = src->penaltythreshold; - commandrate = src->commandrate; - maxlocal = src->maxlocal; - maxglobal = src->maxglobal; + name = src->name; + password = src->password; + passwordhash = src->passwordhash; + ports = src->ports; + type = src->type; + fakelag = src->fakelag; maxconnwarn = src->maxconnwarn; + resolvehostnames = src->resolvehostnames; maxchans = src->maxchans; + penaltythreshold = src->penaltythreshold; + pingtime = src->pingtime; + registration_timeout = src->registration_timeout; + commandrate = src->commandrate; + hardsendqmax = src->hardsendqmax; limit = src->limit; - resolvehostnames = src->resolvehostnames; - ports = src->ports; - password = src->password; - passwordhash = src->passwordhash; + maxglobal = src->maxglobal; + maxlocal = src->maxlocal; + recvqmax = src->recvqmax; + softsendqmax = src->softsendqmax; } |
