diff options
Diffstat (limited to 'include')
-rw-r--r-- | include/configreader.h | 25 | ||||
-rw-r--r-- | include/inspircd.h | 27 | ||||
-rw-r--r-- | include/socketengine.h | 3 | ||||
-rw-r--r-- | include/users.h | 36 |
4 files changed, 42 insertions, 49 deletions
diff --git a/include/configreader.h b/include/configreader.h index 4b42bcd43..4b425e03b 100644 --- a/include/configreader.h +++ b/include/configreader.h @@ -598,4 +598,29 @@ class CoreExport ServerConfig }; +/** The background thread for config reading, so that reading from executable includes + * does not block. + */ +class CoreExport ConfigReaderThread : public Thread +{ + ServerConfig* Config; + volatile bool done; + public: + const std::string TheUserUID; + ConfigReaderThread(const std::string &useruid) + : Config(new ServerConfig), done(false), TheUserUID(useruid) + { + } + + virtual ~ConfigReaderThread() + { + delete Config; + } + + void Run(); + /** Run in the main thread to apply the configuration */ + void Finish(); + bool IsDone() { return done; } +}; + #endif diff --git a/include/inspircd.h b/include/inspircd.h index a183e1ded..2b6fc579a 100644 --- a/include/inspircd.h +++ b/include/inspircd.h @@ -79,10 +79,10 @@ CoreExport extern InspIRCd* ServerInstance; #include "filelogger.h" #include "caller.h" #include "modules.h" +#include "threadengine.h" #include "configreader.h" #include "inspstring.h" #include "protocol.h" -#include "threadengine.h" #ifndef PATH_MAX #warning Potentially broken system, PATH_MAX undefined @@ -240,31 +240,6 @@ DEFINE_HANDLER2(IsChannelHandler, bool, const char*, size_t); DEFINE_HANDLER1(IsSIDHandler, bool, const std::string&); DEFINE_HANDLER1(RehashHandler, void, const std::string&); -/** The background thread for config reading, so that reading from executable includes - * does not block. - */ -class CoreExport ConfigReaderThread : public Thread -{ - ServerConfig* Config; - volatile bool done; - public: - const std::string TheUserUID; - ConfigReaderThread(const std::string &useruid) - : Config(new ServerConfig), done(false), TheUserUID(useruid) - { - } - - virtual ~ConfigReaderThread() - { - delete Config; - } - - void Run(); - /** Run in the main thread to apply the configuration */ - void Finish(); - bool IsDone() { return done; } -}; - /** The main class of the irc server. * This class contains instances of all the other classes in this software. * Amongst other things, it contains a ModeParser, a DNS object, a CommandParser diff --git a/include/socketengine.h b/include/socketengine.h index e0512b3aa..01f66ef21 100644 --- a/include/socketengine.h +++ b/include/socketengine.h @@ -133,9 +133,6 @@ enum EventMask FD_TRIAL_NOTE_MASK = 0x5000 }; -class InspIRCd; -class Module; - /** This class is a basic I/O handler class. * Any object which wishes to receive basic I/O events * from the socketengine must derive from this class and diff --git a/include/users.h b/include/users.h index 0fc6e3723..48f2b470c 100644 --- a/include/users.h +++ b/include/users.h @@ -56,6 +56,12 @@ enum RegistrationState { REG_ALL = 7 /* REG_NICKUSER plus next bit along */ }; +enum UserType { + USERTYPE_LOCAL = 1, + USERTYPE_REMOTE = 2, + USERTYPE_SERVER = 3 +}; + /** Holds information relevent to <connect allow> and <connect deny> tags in the config file. */ struct CoreExport ConnectClass : public refcountbase @@ -357,6 +363,9 @@ class CoreExport User : public StreamSocket */ unsigned int lastping:1; + /** What type of user is this? */ + const unsigned int usertype:2; + /** Get client IP string from sockaddr, using static internal buffer * @return The IP string */ @@ -371,13 +380,10 @@ class CoreExport User : public StreamSocket */ bool SetClientIP(const char* sip); - /** Default constructor + /** Constructor * @throw CoreException if the UID allocated to the user already exists - * @param Instance Creator instance - * @param uid User UUID, or empty to allocate one automatically - * @param srv Server that this user is from */ - User(const std::string &uid, const std::string& srv); + User(const std::string &uid, const std::string& srv, int objtype); /** Check if the user matches a G or K line, and disconnect them if they do. * @param doZline True if ZLines should be checked (if IP has changed since initial connect) @@ -708,14 +714,6 @@ class CoreExport User : public StreamSocket virtual CullResult cull(); }; -/** Represents a non-local user. - * (in fact, any FD less than -1 does) - */ -#define FD_MAGIC_NUMBER -42 -/** Represents a fake user (i.e. a server) - */ -#define FD_FAKEUSER_NUMBER -7 - class CoreExport LocalUser : public User { /** A list of channels the user has a pending invite to. @@ -866,9 +864,8 @@ class CoreExport LocalUser : public User class CoreExport RemoteUser : public User { public: - RemoteUser(const std::string& uid, const std::string& srv) : User(uid, srv) + RemoteUser(const std::string& uid, const std::string& srv) : User(uid, srv, USERTYPE_REMOTE) { - SetFd(FD_MAGIC_NUMBER); } virtual void SendText(const std::string& line); }; @@ -876,9 +873,8 @@ class CoreExport RemoteUser : public User class CoreExport FakeUser : public User { public: - FakeUser(const std::string &uid, const std::string& srv) : User(uid, srv) + FakeUser(const std::string &uid, const std::string& srv) : User(uid, srv, USERTYPE_SERVER) { - SetFd(FD_FAKEUSER_NUMBER); nick = srv; } @@ -892,17 +888,17 @@ class CoreExport FakeUser : public User /** Is a local user */ inline LocalUser* IS_LOCAL(User* u) { - return u->GetFd() > -1 ? static_cast<LocalUser*>(u) : NULL; + return u->usertype == USERTYPE_LOCAL ? static_cast<LocalUser*>(u) : NULL; } /** Is a remote user */ inline RemoteUser* IS_REMOTE(User* u) { - return u->GetFd() == FD_MAGIC_NUMBER ? static_cast<RemoteUser*>(u) : NULL; + return u->usertype == USERTYPE_REMOTE ? static_cast<RemoteUser*>(u) : NULL; } /** Is a server fakeuser */ inline FakeUser* IS_SERVER(User* u) { - return u->GetFd() == FD_FAKEUSER_NUMBER ? static_cast<FakeUser*>(u) : NULL; + return u->usertype == USERTYPE_SERVER ? static_cast<FakeUser*>(u) : NULL; } /** Is an oper */ #define IS_OPER(x) (x->oper) |