home *** CD-ROM | disk | FTP | other *** search
/ Computer Shopper 217 / DPCS0306DVD.ISO / Toolkit / Internet / FileZilla / Server / FileZilla_Server-0.9.11.exe / source / ServerThread.h < prev    next >
Encoding:
C/C++ Source or Header  |  2005-04-13  |  4.0 KB  |  142 lines

  1. // FileZilla Server - a Windows ftp server
  2.  
  3. // Copyright (C) 2002-2004 - Tim Kosse <tim.kosse@gmx.de>
  4.  
  5. // This program is free software; you can redistribute it and/or
  6. // modify it under the terms of the GNU General Public License
  7. // as published by the Free Software Foundation; either version 2
  8. // of the License, or (at your option) any later version.
  9.  
  10. // This program is distributed in the hope that it will be useful,
  11. // but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  13. // GNU General Public License for more details.
  14.  
  15. // You should have received a copy of the GNU General Public License
  16. // along with this program; if not, write to the Free Software
  17. // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
  18.  
  19. #if !defined(AFX_SERVERTHREAD_H__4F566540_62DF_4338_85DE_EC699EB6640C__INCLUDED_)
  20. #define AFX_SERVERTHREAD_H__4F566540_62DF_4338_85DE_EC699EB6640C__INCLUDED_
  21.  
  22. #include "Thread.h"
  23. #if _MSC_VER > 1000
  24. #pragma once
  25. #endif // _MSC_VER > 1000
  26. // ServerThread.h : Header-Datei
  27. //
  28.  
  29. class CControlSocket;
  30. class CServerThread;
  31. class COptions;
  32. class CPermissions;
  33. class t_user;
  34. class CExternalIpCheck;
  35.  
  36. typedef struct
  37. {
  38.     CControlSocket *pSocket;
  39.     CServerThread *pThread;
  40. } t_socketdata;
  41.  
  42. /////////////////////////////////////////////////////////////////////////////
  43. // Thread CServerThread 
  44.  
  45. class CServerThread : public CThread
  46. {
  47. public:
  48.     virtual CStdString GetExternalIP();
  49.     virtual void ExternalIPFailed();
  50.     CServerThread(int nNotificationMessageId);
  51.  
  52.     CPermissions *m_pPermissions;
  53.     COptions *m_pOptions;
  54.     void IncRecvCount(int count);
  55.     void IncSendCount(int count);
  56.     void IncIpCount(const CStdString &ip);
  57.     void DecIpCount(const CStdString &ip);
  58.     int GetIpCount(const CStdString &ip) const;
  59.     BOOL IsReady();
  60.     static const int GetGlobalNumConnections();
  61.     void AddSocket(SOCKET sockethandle, bool ssl);
  62.     const int GetNumConnections();
  63.  
  64.     struct t_Notification
  65.     {
  66.         WPARAM wParam;
  67.         LPARAM lParam;
  68.     };
  69.  
  70.     void SendNotification(WPARAM wParam, LPARAM lParam);
  71.  
  72.     /*
  73.      * The parameter should be an empty list, since m_pendingNotifications and 
  74.      * list get swapped to increase performance.
  75.      */
  76.     void GetNotifications(std::list<CServerThread::t_Notification>& list);
  77.  
  78.     void AntiHammerIncrease(DWORD ip);
  79.     
  80. // Implementierung
  81.  
  82. protected:
  83.     virtual ~CServerThread();
  84.  
  85.     void GatherTransferedBytes();
  86.     void ProcessNewSlQuota();
  87.     virtual BOOL InitInstance();
  88.     virtual DWORD ExitInstance();
  89.  
  90.     virtual int OnThreadMessage(UINT Msg, WPARAM wParam, LPARAM lParam);
  91.     void OnTimer(WPARAM wParam, LPARAM lParam);    
  92.     
  93.     void ProcessControlMessage(t_controlmessage *msg);
  94.     CControlSocket * GetControlSocket(int userid);
  95.     std::map<int, CControlSocket *> m_LocalUserIDs;
  96.     void AddNewSocket(SOCKET sockethandle, bool ssl);
  97.     static int CalcUserID();
  98.     static std::map<int, t_socketdata> m_userids;
  99.     static std::map<CStdString, int> m_userIPs;
  100.     void AntiHammerDecrease();
  101.  
  102.     int m_nRecvCount;
  103.     int m_nSendCount;
  104.     UINT m_nRateTimer;
  105.     BOOL m_bQuit;
  106.  
  107.     CCriticalSectionWrapper m_threadsync;
  108.     static CCriticalSectionWrapper m_GlobalThreadsync;
  109.     unsigned int m_timerid;
  110.  
  111.     //Speed limit code
  112.     static std::list<CServerThread *> m_sInstanceList; //First instance is the SL master
  113.     BOOL m_bIsMaster;
  114.     int m_nLoopCount;
  115.  
  116.     int m_lastLimits[2];
  117.     typedef struct {
  118.         int nBytesAllowedToTransfer;
  119.         int nTransferred;
  120.     } t_Quota;
  121.     t_Quota m_SlQuotas[2];
  122.  
  123.     CStdString m_RawWelcomeMessage;
  124.     std::list<CStdString> m_ParsedWelcomeMessage;
  125.     CExternalIpCheck *m_pExternalIpCheck;
  126.  
  127.     std::list<t_Notification> m_pendingNotifications;
  128.     int m_throttled;
  129.  
  130.     int m_nNotificationMessageId;
  131.  
  132.     static std::map<DWORD, int> m_antiHammerInfo;
  133.     int m_antiHammerTimer;
  134. };
  135.  
  136. /////////////////////////////////////////////////////////////////////////////
  137.  
  138. //{{AFX_INSERT_LOCATION}}
  139. // Microsoft Visual C++ fⁿgt unmittelbar vor der vorhergehenden Zeile zusΣtzliche Deklarationen ein.
  140.  
  141. #endif // AFX_SERVERTHREAD_H__4F566540_62DF_4338_85DE_EC699EB6640C__INCLUDED_
  142.