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);
};
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);
/** 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.
*/
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;
*/
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;
*/
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
*/
/** 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);
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<WhoWasGroup*> whowas_set;
-
- /** Sets of users in the whowas system
- */
- typedef std::map<irc::string,whowas_set*> whowas_users;
-
- /** Sets of time and users in whowas list
- */
- typedef std::map<time_t,irc::string> 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;