Planeshift

authentserver.h

Go to the documentation of this file.
00001 /*
00002  * AuthentServer.h by Keith Fulton <[email protected]>
00003  *
00004  * Copyright (C) 2001 Atomic Blue ([email protected], http://www.atomicblue.org)
00005  *
00006  *
00007  * This program is free software; you can redistribute it and/or
00008  * modify it under the terms of the GNU General Public License
00009  * as published by the Free Software Foundation (version 2 of the License)
00010  * This program is distributed in the hope that it will be useful,
00011  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00012  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013  * GNU General Public License for more details.
00014  * You should have received a copy of the GNU General Public License
00015  * along with this program; if not, write to the Free Software
00016  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
00017  *
00018  */
00019 #ifndef __AUTHENTICATIONSERVER_H__
00020 #define __AUTHENTICATIONSERVER_H__
00021 
00022 //=============================================================================
00023 // Crystal Space Includes
00024 //=============================================================================
00025 #include <csutil/ref.h>
00026 #include <csutil/hash.h>
00027 
00028 //=============================================================================
00029 // Local Includes
00030 //=============================================================================
00031 #include "msgmanager.h"         // Parent class
00032 
00033 class psMsgStringsMessage;
00034 class ClientConnectionSet;
00035 class UserManager;
00036 class GuildManager;
00037 class Client;
00038 
00039 struct BanEntry
00040 {
00041     AccountID account;
00042     csString  ipRange;
00043     time_t    start;
00044     time_t    end;
00045     csString  reason;
00046     bool      banIP;
00047 };
00048 
00050 class BanManager
00051 {
00052 public:
00053     BanManager();
00054     ~BanManager();
00055 
00056     bool RemoveBan(AccountID account);
00057     bool AddBan(AccountID account, csString ipRange, time_t duration, csString reason, bool banIP);
00058     BanEntry* GetBanByAccount(AccountID account);
00059     BanEntry* GetBanByIPRange(csString IPRange);
00060 
00061 protected:
00062     csHash<BanEntry*, AccountID> banList_IDHash;   
00063     csArray<BanEntry*> banList_IPRList;    
00064 };
00065 
00076 class AuthenticationServer : public MessageManager<AuthenticationServer>
00077 {
00078 public:
00079 
00096     AuthenticationServer(ClientConnectionSet* pCCS,
00097                          UserManager* usermgr,
00098                          GuildManager* gm);
00099 
00107     virtual ~AuthenticationServer();
00108 
00121     void SendDisconnect(Client* client,const char* reason);
00122 
00127     void SendMsgStrings(int cnum, bool send_digest);
00128 
00132     void HandleStatusUpdate(MsgEntry* me, Client* client);
00133 
00137     BanManager* GetBanManager()
00138     {
00139         return &banmanager;
00140     }
00141 
00142 
00143 protected:
00144 
00146     ClientConnectionSet* clients;
00147 
00149     UserManager* usermanager;
00150 
00152     GuildManager* guildmanager;
00153 
00155     BanManager banmanager;
00156 
00160     bool CheckAuthenticationPreCondition(int clientnum, bool netversionok, const char* sUser);
00161 
00174     void HandleAuthent(MsgEntry* me, Client* notused);
00175 
00179     void HandleStringsRequest(MsgEntry* me, Client* notused);
00180 
00186     void HandlePreAuthent(MsgEntry* me, Client* notused);
00187 
00197     void HandleDisconnect(MsgEntry* me,Client* notused);
00198 
00204     void HandleAuthCharacter(MsgEntry* me, Client* notused);
00205 };
00206 
00207 #endif
00208