2 // This file is part of the aMule Project.
4 // Copyright (c) 2003-2008 aMule Team ( admin@amule.org / http://www.amule.org )
5 // Copyright (c) 2002-2008 Merkur ( devs@emule-project.net / http://www.emule-project.net )
7 // Any parts of this program derived from the xMule, lMule or eMule project,
8 // or contributed by third-party developers are copyrighted by their
11 // This program is free software; you can redistribute it and/or modify
12 // it under the terms of the GNU General Public License as published by
13 // the Free Software Foundation; either version 2 of the License, or
14 // (at your option) any later version.
16 // This program is distributed in the hope that it will be useful,
17 // but WITHOUT ANY WARRANTY; without even the implied warranty of
18 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 // GNU General Public License for more details.
21 // You should have received a copy of the GNU General Public License
22 // along with this program; if not, write to the Free Software
23 // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
30 #include "OtherStructs.h"
31 #include <ec/cpp/ECID.h> // Needed for CECID
33 #include <protocol/ed2k/Client2Server/TCP.h>
34 #include <protocol/ed2k/Client2Server/UDP.h>
40 #define SRV_PR_NORMAL 0
42 // Server priority max and min values
47 class CServer
: public CECID
49 friend class CServerListRem
;
51 CServer(ServerMet_Struct
* in_data
);
52 CServer(uint16 in_port
, const wxString i_addr
);
53 CServer(CServer
* pOld
);
54 CServer(class CEC_Server_Tag
*);
57 void AddTag(CTag
* in_tag
) {m_taglist
.push_back(in_tag
);}
58 const wxString
&GetListName() const {return listname
;}
59 const wxString
&GetFullIP() const {return ipfull
;}
61 const wxString
&GetAddress() const {
62 if (!dynip
.IsEmpty()) {
70 uint16
GetPort() const {return realport
? realport
: port
;}
71 // the connection port
72 uint16
GetConnPort() const {return port
;}
73 void SetPort(uint32 val
) {realport
= val
;}
74 bool AddTagFromFile(CFileDataIO
* servermet
);
75 void SetListName(const wxString
& newname
);
76 void SetDescription(const wxString
& newdescription
);
77 uint32
GetIP() const {return ip
;}
78 uint32
GetFiles() const {return files
;}
79 uint32
GetUsers() const {return users
;}
80 const wxString
&GetDescription() const {return description
;}
81 uint32
GetPing() const {return ping
;}
82 uint32
GetPreferences() const {return preferences
;}
83 uint32
GetMaxUsers() const {return maxusers
;}
84 void SetMaxUsers(uint32 in_maxusers
) {maxusers
= in_maxusers
;}
85 void SetUserCount(uint32 in_users
) {users
= in_users
;}
86 void SetFileCount(uint32 in_files
) {files
= in_files
;}
87 void ResetFailedCount() {failedcount
= 0;}
88 void AddFailedCount() {failedcount
++;}
89 uint32
GetFailedCount() const {return failedcount
;}
90 void SetID(uint32 newip
);
91 const wxString
&GetDynIP() const {return dynip
;}
92 bool HasDynIP() const {return !dynip
.IsEmpty() ;}
93 void SetDynIP(const wxString
& newdynip
);
95 uint32
GetLastPingedTime() const {return lastpingedtime
;}
96 void SetLastPingedTime(uint32 in_lastpingedtime
) {lastpingedtime
= in_lastpingedtime
;}
98 uint32
GetRealLastPingedTime() const {return m_dwRealLastPingedTime
;} // last pinged time without any random modificator
99 void SetRealLastPingedTime(uint32 in_lastpingedtime
) {m_dwRealLastPingedTime
= in_lastpingedtime
;}
101 uint32
GetLastPinged() const {return lastpinged
;}
102 void SetLastPinged(uint32 in_lastpinged
) {lastpinged
= in_lastpinged
;}
104 void SetPing(uint32 in_ping
) {ping
= in_ping
;}
105 void SetPreference(uint32 in_preferences
) {preferences
= in_preferences
;}
106 void SetIsStaticMember(bool in
) {staticservermember
=in
;}
107 bool IsStaticMember() const {return staticservermember
;}
108 uint32
GetChallenge() const {return challenge
;}
109 void SetChallenge(uint32 in_challenge
) {challenge
= in_challenge
;}
110 uint32
GetSoftFiles() const {return softfiles
;}
111 void SetSoftFiles(uint32 in_softfiles
) {softfiles
= in_softfiles
;}
112 uint32
GetHardFiles() const {return hardfiles
;}
113 void SetHardFiles(uint32 in_hardfiles
) {hardfiles
= in_hardfiles
;}
114 const wxString
&GetVersion() const {return m_strVersion
;}
115 void SetVersion(const wxString
&pszVersion
) {m_strVersion
= pszVersion
;}
116 void SetTCPFlags(uint32 uFlags
) {m_uTCPFlags
= uFlags
;}
117 uint32
GetTCPFlags() const {return m_uTCPFlags
;}
118 void SetUDPFlags(uint32 uFlags
) {m_uUDPFlags
= uFlags
;}
119 uint32
GetUDPFlags() const {return m_uUDPFlags
;}
120 uint32
GetLowIDUsers() const {return m_uLowIDUsers
;}
121 void SetLowIDUsers(uint32 uLowIDUsers
) {m_uLowIDUsers
= uLowIDUsers
;}
122 uint32
GetDescReqChallenge() const {return m_uDescReqChallenge
;}
123 void SetDescReqChallenge(uint32 uDescReqChallenge
) {m_uDescReqChallenge
= uDescReqChallenge
;}
124 uint8
GetLastDescPingedCount() const {return lastdescpingedcout
;}
125 void SetLastDescPingedCount(bool reset
);
127 uint16
GetObfuscationPortTCP() const {return m_nObfuscationPortTCP
;}
128 void SetObfuscationPortTCP(uint16 nPort
) {m_nObfuscationPortTCP
= nPort
;}
130 uint16
GetObfuscationPortUDP() const {return m_nObfuscationPortUDP
;}
131 void SetObfuscationPortUDP(uint16 nPort
) {m_nObfuscationPortUDP
= nPort
;}
133 uint32
GetServerKeyUDP(bool bForce
= false) const;
134 void SetServerKeyUDP(uint32 dwServerKeyUDP
);
136 bool GetCryptPingReplyPending() const {return m_bCryptPingReplyPending
;}
137 void SetCryptPingReplyPending(bool bVal
) {m_bCryptPingReplyPending
= bVal
;}
139 uint32
GetServerKeyUDPIP() const {return m_dwIPServerKeyUDP
;}
141 bool GetUnicodeSupport() const {return (GetTCPFlags() & SRV_TCPFLG_UNICODE
) != 0;}
142 bool GetRelatedSearchSupport() const {return (GetTCPFlags() & SRV_TCPFLG_RELATEDSEARCH
) != 0;}
143 bool SupportsLargeFilesTCP() const {return (GetTCPFlags() & SRV_TCPFLG_LARGEFILES
) != 0;}
144 bool SupportsLargeFilesUDP() const {return (GetUDPFlags() & SRV_UDPFLG_LARGEFILES
) != 0;}
145 bool SupportsObfuscationUDP() const {return (GetUDPFlags() & SRV_UDPFLG_UDPOBFUSCATION
) != 0;}
146 bool SupportsObfuscationTCP() const {return (GetObfuscationPortTCP() != 0) && (((GetUDPFlags() & SRV_UDPFLG_TCPOBFUSCATION
) != 0) || ((GetTCPFlags() & SRV_TCPFLG_TCPOBFUSCATION
) != 0));}
147 bool SupportsGetSourcesObfuscation() const {return (GetTCPFlags() & SRV_TCPFLG_TCPOBFUSCATION
) != 0;} // mapped to TCPFLAG_TCPOBFU
149 const wxString
& GetAuxPortsList() const {return m_auxPorts
;}
150 void SetAuxPortsList(const wxString
& val
) {m_auxPorts
= val
;}
152 uint64
GetLastDNSSolve() const { return m_lastdnssolve
; }
153 void SetLastDNSSolve(uint64 value
) { m_lastdnssolve
= value
; }
155 bool GetDNSError() const { return m_dnsfailure
; }
156 void SetDNSError(bool value
) { m_dnsfailure
= value
; }
160 uint32 lastpinged
; //This is to get the ping delay.
161 uint32 lastpingedtime
; //This is to decided when we retry the ping.
169 wxString description
;
178 uint32 m_uDescReqChallenge
;
179 uint8 lastdescpingedcout
;
180 TagPtrList m_taglist
;
181 bool staticservermember
;
182 wxString m_strVersion
;
185 uint32 m_uLowIDUsers
;
188 uint64 m_lastdnssolve
;
191 bool m_bCryptPingReplyPending
;
192 uint32 m_dwServerKeyUDP
;
193 uint32 m_dwIPServerKeyUDP
;
194 uint16 m_nObfuscationPortTCP
;
195 uint16 m_nObfuscationPortUDP
;
197 uint32 m_dwRealLastPingedTime
;
203 // File_checked_for_headers