]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - include/users.h
Add fixes to stop people changing the SID of a live server - certain configuration...
[user/henk/code/inspircd.git] / include / users.h
index 3d98f963211f208e11ffeffe383b1bf686eaeab8..a63dd7cc67a95b882eb29a5e985cc9f3eaea19ff 100644 (file)
 #ifndef __USERS_H__
 #define __USERS_H__
 
-#include <string>
-#include "inspircd_config.h"
 #include "socket.h"
-#include "channels.h"
-#include "inspstring.h"
 #include "connection.h"
-#include "hashcomp.h"
 #include "dns.h"
 
 /** Channel status for a user
@@ -76,47 +71,8 @@ enum RegistrationState {
 };
 
 /* Required forward declaration */
-class InspIRCd;
-
-/** Derived from Resolver, and performs user forward/reverse lookups.
- */
-class CoreExport UserResolver : public Resolver
-{
- private:
-       /** User this class is 'attached' to.
-        */
-       User* bound_user;
-       /** File descriptor teh lookup is bound to
-        */
-       int bound_fd;
-       /** True if the lookup is forward, false if is a reverse lookup
-        */
-       bool fwd;
- public:
-       /** Create a resolver.
-        * @param Instance The creating instance
-        * @param user The user to begin lookup on
-        * @param to_resolve The IP or host to resolve
-        * @param qt The query type
-        * @param cache Modified by the constructor if the result was cached
-        */
-       UserResolver(InspIRCd* Instance, User* user, std::string to_resolve, QueryType qt, bool &cache);
-
-       /** Called on successful lookup
-        * @param result Result string
-        * @param ttl Time to live for result
-        * @param cached True if the result was found in the cache
-        * @param resultnum Result number, we are only interested in result 0
-        */
-       void OnLookupComplete(const std::string &result, unsigned int ttl, bool cached, int resultnum = 0);
-
-       /** Called on failed lookup
-        * @param e Error code
-        * @param errormessage Error message string
-        */
-       void OnError(ResolverError e, const std::string &errormessage);
-};
-
+class Channel;
+class UserResolver;
 
 /** Holds information relevent to &lt;connect allow&gt; and &lt;connect deny&gt; tags in the config file.
  */
@@ -251,7 +207,7 @@ public:
         */
        void Update(unsigned int timeout, unsigned int fld, const std::string &hst, unsigned int ping,
                                const std::string &pas, unsigned int thres, unsigned long sendq, unsigned long recvq,
-                               unsigned long maxl, unsigned long maxg, unsigned int maxc, int p, unsigned long limit)
+                               unsigned long maxl, unsigned long maxg, unsigned int maxc, int p, unsigned long llimit)
        {
                if (timeout)
                        registration_timeout = timeout;
@@ -278,7 +234,7 @@ public:
                if (p)
                        port = p;
 
-               this->limit = limit;
+               this->limit = llimit;
        }
 
        /** Reference counter. Contains an int as to how many users are connected to this class. :)
@@ -404,9 +360,9 @@ public:
        }
 };
 
-/** Holds a complete list of all channels to which a user has been invited and has not yet joined.
+/** Holds a complete list of all channels to which a user has been invited and has not yet joined, and the time at which they'll expire.
  */
-typedef std::vector<irc::string> InvitedList;
+typedef std::vector< std::pair<irc::string, time_t> > InvitedList;
 
 /** Holds a complete list of all allow and deny tags from the configuration file (connection classes)
  */
@@ -655,6 +611,10 @@ class CoreExport User : public connection
         * GetIPString/GetPort to obtain its values.
         */
        sockaddr* ip;
+       
+       /** Set by GetIPString() to avoid constantly re-grabbing IP via sockets voodoo.
+        */
+       std::string cachedip;
 
        /** Initialize the clients sockaddr
         * @param protocol_family The protocol family of the IP address, AF_INET or AF_INET6
@@ -776,8 +736,9 @@ class CoreExport User : public connection
 
        /** Adds a channel to a users invite list (invites them to a channel)
         * @param channel A channel name to add
+        * @param timeout When the invite should expire (0 == never)
         */
-       virtual void InviteTo(const irc::string &channel);
+       virtual void InviteTo(const irc::string &channel, time_t timeout);
 
        /** Removes a channel from a users invite list.
         * This member function is called on successfully joining an invite only channel
@@ -1072,7 +1033,7 @@ class CoreExport User : public connection
         * @param text The text format string to send
         * @param ... Format arguments
         */
-       void SendAll(const char* command, char* text, ...);
+       void SendAll(const char* command, const char* text, ...);
 
        /** Compile a channel list for this user, and send it to the user 'source'
         * Used internally by WHOIS
@@ -1142,8 +1103,47 @@ class CoreExport User : public connection
        virtual ~User();
 };
 
+/** Derived from Resolver, and performs user forward/reverse lookups.
+ */
+class CoreExport UserResolver : public Resolver
+{
+ private:
+       /** User this class is 'attached' to.
+        */
+       User* bound_user;
+       /** File descriptor teh lookup is bound to
+        */
+       int bound_fd;
+       /** True if the lookup is forward, false if is a reverse lookup
+        */
+       bool fwd;
+ public:
+       /** Create a resolver.
+        * @param Instance The creating instance
+        * @param user The user to begin lookup on
+        * @param to_resolve The IP or host to resolve
+        * @param qt The query type
+        * @param cache Modified by the constructor if the result was cached
+        */
+       UserResolver(InspIRCd* Instance, User* user, std::string to_resolve, QueryType qt, bool &cache);
+
+       /** Called on successful lookup
+        * @param result Result string
+        * @param ttl Time to live for result
+        * @param cached True if the result was found in the cache
+        * @param resultnum Result number, we are only interested in result 0
+        */
+       void OnLookupComplete(const std::string &result, unsigned int ttl, bool cached, int resultnum = 0);
+
+       /** Called on failed lookup
+        * @param e Error code
+        * @param errormessage Error message string
+        */
+       void OnError(ResolverError e, const std::string &errormessage);
+};
+
 /* Configuration callbacks */
-class ServerConfig;
+//class ServerConfig;
 
 #endif