00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017 #include "inspircd_config.h"
00018 #include "channels.h"
00019 #include "inspstring.h"
00020 #include "connection.h"
00021 #include <string>
00022 #ifdef THREADED_DNS
00023 #include <pthread.h>
00024 #endif
00025
00026 #ifndef __USERS_H__
00027 #define __USERS_H__
00028
00029 #include "hashcomp.h"
00030
00031 #define STATUS_OP 4
00032 #define STATUS_HOP 2
00033 #define STATUS_VOICE 1
00034 #define STATUS_NORMAL 0
00035
00036 #define CC_ALLOW 0
00037 #define CC_DENY 1
00038
00039 template<typename T> inline string ConvToStr(const T &in);
00040
00043 class Invited : public classbase
00044 {
00045 public:
00046 irc::string channel;
00047 };
00048
00049
00052 class ConnectClass : public classbase
00053 {
00054 public:
00057 char type;
00060 int registration_timeout;
00063 int flood;
00066 char host[MAXBUF];
00069 int pingtime;
00072 char pass[MAXBUF];
00073
00076 int threshold;
00077
00080 long sendqmax;
00081
00084 long recvqmax;
00085
00086 ConnectClass()
00087 {
00088 registration_timeout = 0;
00089 flood = 0;
00090 pingtime = 0;
00091 threshold = 0;
00092 sendqmax = 0;
00093 recvqmax = 0;
00094 strlcpy(host,"",MAXBUF);
00095 strlcpy(pass,"",MAXBUF);
00096 }
00097 };
00098
00101 typedef std::vector<Invited> InvitedList;
00102
00103
00104
00107 typedef std::vector<ConnectClass> ClassVector;
00108
00115 class userrec : public connection
00116 {
00117 private:
00118
00121 InvitedList invites;
00122 public:
00123
00128 char nick[NICKMAX];
00129
00133 char ident[IDENTMAX+2];
00134
00138 char dhost[160];
00139
00142 char fullname[MAXGECOS+1];
00143
00151 char modes[54];
00152
00153 std::vector<ucrec> chans;
00154
00157 char* server;
00158
00162 char awaymsg[MAXAWAY+1];
00163
00168 int flood;
00169
00174 unsigned int timeout;
00175
00181 char oper[NICKMAX];
00182
00185 bool dns_done;
00186
00189 unsigned int pingmax;
00190
00195 char password[MAXBUF];
00196
00201 std::string recvq;
00202
00206 std::string sendq;
00207
00210 int lines_in;
00211 time_t reset_due;
00212 long threshold;
00213
00214
00215
00216 std::string WriteError;
00217
00220 long sendqmax;
00221
00224 long recvqmax;
00225
00226 userrec();
00227
00232 virtual char* GetFullHost();
00233
00239 virtual char* GetFullRealHost();
00240
00243 virtual bool IsInvited(irc::string &channel);
00244
00247 virtual void InviteTo(irc::string &channel);
00248
00253 virtual void RemoveInvite(irc::string &channel);
00254
00259 bool HasPermission(std::string &command);
00260
00263 int ReadData(void* buffer, size_t size);
00264
00272 bool AddBuffer(std::string a);
00273
00277 bool BufferIsReady();
00278
00281 void ClearBuffer();
00282
00290 std::string GetBuffer();
00291
00297 void SetWriteError(std::string error);
00298
00302 std::string GetWriteError();
00303
00309 void AddWriteBuf(std::string data);
00310
00317 void FlushWriteBuf();
00318
00321 InvitedList* GetInviteList();
00322
00325 void CloseSocket();
00326
00327 virtual ~userrec();
00328
00329 #ifdef THREADED_DNS
00330 pthread_t dnsthread;
00331 #endif
00332 };
00333
00336 class WhoWasUser
00337 {
00338 public:
00339 char nick[NICKMAX];
00340 char ident[IDENTMAX+1];
00341 char dhost[160];
00342 char host[160];
00343 char fullname[MAXGECOS+1];
00344 char server[256];
00345 time_t signon;
00346 };
00347
00348 void AddOper(userrec* user);
00349 void DeleteOper(userrec* user);
00350 void kill_link(userrec *user,const char* r);
00351 void kill_link_silent(userrec *user,const char* r);
00352 void AddWhoWas(userrec* u);
00353 void AddClient(int socket, char* host, int port, bool iscached, char* ip);
00354 void FullConnectUser(userrec* user);
00355 void ConnectUser(userrec *user);
00356 userrec* ReHashNick(char* Old, char* New);
00357 void force_nickchange(userrec* user,const char* newnick);
00358
00359 #endif