X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;f=include%2Fusers.h;h=bfe21f116500e7ddbee7ae6a70bdbc773915d90f;hb=6b23783b71e98bae6aced7144c6730f028873cb6;hp=80fbf43e0d09850b6db1ee1b75ca51b5ea37e7b9;hpb=089cf1f5fd2ca1d2ca9d49db3c646ecbede67167;p=user%2Fhenk%2Fcode%2Finspircd.git diff --git a/include/users.h b/include/users.h index 80fbf43e0..bfe21f116 100644 --- a/include/users.h +++ b/include/users.h @@ -67,9 +67,9 @@ class UserResolver : public Resolver int bound_fd; bool fwd; public: - UserResolver(InspIRCd* Instance, userrec* user, std::string to_resolve, QueryType qt); + UserResolver(InspIRCd* Instance, userrec* user, std::string to_resolve, QueryType qt, bool &cache); - void OnLookupComplete(const std::string &result); + void OnLookupComplete(const std::string &result, unsigned int ttl, bool cached); void OnError(ResolverError e, const std::string &errormessage); }; @@ -120,68 +120,107 @@ class ConnectClass : public classbase public: + /** Create a new connect class with no settings. + */ ConnectClass() : type(CC_DENY), registration_timeout(0), flood(0), host(""), pingtime(0), pass(""), threshold(0), sendqmax(0), recvqmax(0), maxlocal(0), maxglobal(0) { } + /** Create a new connect class to ALLOW connections. + * @param timeout The registration timeout + * @param fld The flood value + * @param hst The IP mask to allow + * @param ping The ping frequency + * @param pas The password to be used + * @param thres The flooding threshold + * @param sendq The maximum sendq value + * @param recvq The maximum recvq value + * @param maxl The maximum local sessions + * @param maxg The maximum global sessions + */ ConnectClass(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) : type(CC_ALLOW), registration_timeout(timeout), flood(fld), host(hst), pingtime(ping), pass(pas), threshold(thres), sendqmax(sendq), recvqmax(recvq), maxlocal(maxl), maxglobal(maxg) { } + /** Create a new connect class to DENY connections + * @param hst The IP mask to deny + */ ConnectClass(const std::string &hst) : type(CC_DENY), registration_timeout(0), flood(0), host(hst), pingtime(0), pass(""), threshold(0), sendqmax(0), recvqmax(0), maxlocal(0), maxglobal(0) { } + /** Returns the type, CC_ALLOW or CC_DENY + */ char GetType() { return (type == CC_ALLOW ? CC_ALLOW : CC_DENY); } + /** Returns the registration timeout + */ unsigned int GetRegTimeout() { return (registration_timeout ? registration_timeout : 90); } + /** Returns the flood limit + */ unsigned int GetFlood() { return (threshold ? flood : 999); } + /** Returns the allowed or denied IP mask + */ const std::string& GetHost() { return host; } + /** Returns the ping frequency + */ unsigned int GetPingTime() { return (pingtime ? pingtime : 120); } + /** Returns the password or an empty string + */ const std::string& GetPass() { return pass; } + /** Returns the flood threshold value + */ unsigned int GetThreshold() { return (threshold ? threshold : 1); } + /** Returns the maximum sendq value + */ unsigned long GetSendqMax() { return (sendqmax ? sendqmax : 262114); } + /** Returns the maximum recvq value + */ unsigned long GetRecvqMax() { return (recvqmax ? recvqmax : 4096); } + /** Returusn the maximum number of local sessions + */ unsigned long GetMaxLocal() { return (maxlocal ? maxlocal : 1); } + /** Returns the maximum number of global sessions + */ unsigned long GetMaxGlobal() { return (maxglobal ? maxglobal : 1); @@ -226,6 +265,25 @@ class userrec : public connection /** Number of channels this user is currently on */ unsigned int ChannelCount; + + /** Cached nick!ident@host value using the real hostname + */ + char* cached_fullhost; + + /** Cached nick!ident@ip value using the real IP address + */ + char* cached_hostip; + + /** Cached nick!ident@host value using the masked hostname + */ + char* cached_makehost; + char* cached_fullrealhost; + + /** When we erase the user (in the destructor), + * we call this method to subtract one from all + * mode characters this user is making use of. + */ + void DecrementModes(); public: /** Resolvers for looking up this users IP address * This will occur if and when res_reverse completes. @@ -357,7 +415,8 @@ class userrec : public connection */ long threshold; - /** IPV4 or IPV6 ip address + /** IPV4 or IPV6 ip address. Use SetSockAddr to set this and GetProtocolFamily/ + * GetIPString/GetPort to obtain its values. */ sockaddr* ip; @@ -393,11 +452,13 @@ class userrec : public connection */ std::string WriteError; - /** Maximum size this user's sendq can become + /** Maximum size this user's sendq can become. + * Copied from the connect class on connect. */ long sendqmax; - /** Maximum size this user's recvq can become + /** Maximum size this user's recvq can become. + * Copied from the connect class on connect. */ long recvqmax; @@ -429,6 +490,11 @@ class userrec : public connection */ virtual char* GetFullRealHost(); + /** This clears any cached results that are used for GetFullRealHost() etc. + * The results of these calls are cached as generating them can be generally expensive. + */ + void InvalidateCache(); + /** Create a displayable mode string for this users snomasks * @return The notice mask character sequence */ @@ -822,6 +888,8 @@ class userrec : public connection /** Handle socket event. * From EventHandler class. + * @param et Event type + * @param errornum Error number for EVENT_ERROR events */ void HandleEvent(EventType et, int errornum = 0); @@ -830,69 +898,6 @@ class userrec : public connection virtual ~userrec(); }; - -namespace irc -{ - /** Holds whowas related functions and classes - */ - namespace whowas - { - - /** Used to hold WHOWAS information - */ - class WhoWasGroup : public classbase - { - public: - /** Real host - */ - char* host; - /** Displayed host - */ - char* dhost; - /** Ident - */ - char* ident; - /** Server name - */ - const char* server; - /** Fullname (GECOS) - */ - char* gecos; - /** Signon time - */ - time_t signon; - - /** Initialize this WhoQasFroup with a user - */ - WhoWasGroup(userrec* user); - /** Destructor - */ - ~WhoWasGroup(); - }; - - /** A group of users related by nickname - */ - typedef std::deque whowas_set; - - /** Sets of users in the whowas system - */ - typedef std::map whowas_users; - - /** Sets of time and users in whowas list - */ - typedef std::map whowas_users_fifo; - - /** Called every hour by the core to remove expired entries - */ - void MaintainWhoWas(InspIRCd* ServerInstance, time_t TIME); - - /** Prune for WhoWasGroupSize, WhoWasMaxGroups and - * WhoWasMaxKeep on rehash - */ - void PruneWhoWas(InspIRCd* ServerInstance, time_t TIME); - }; -}; - /* Configuration callbacks */ class ServerConfig;