28
28
#ifdef HAVE_CONFIG_H
29
29
#include "config.h" // VERSION
31
33
#include <queue> // Mr Hyde
32
34
#include "Types.h" // Mr Hyde
34
#include <wx/string.h>
38
//////////////////////////////////////////////////////////////////////////////////////
40
#define ADU_MOD_NAME _T("AdunanzA")
42
#define ADU_VER_MAJ 2010
45
// IMPOSTARE LA SEG. ADU_BETA_MAJ A 0 PER LE VERSIONI RILASCIATE UFFICIALMENTE
46
#define ADU_BETA_MAJ 0
49
//////////////////////////////////////////////////////////////////////////////////////
36
53
#define V(M, m) _T(#M) _T(".") _T(#m)
37
54
#define _V(M, m) V(M,m)
39
#define B(n, l) _T(#n) _T(l)
56
// Per il momento lascio perdere _T(l)
57
// #define B(n, l) _T(#n) _T(l)
58
#define B(n, l) _T(#n)
40
60
#define _B(n, l) B(n, l)
43
#define ADU_VER_MIN 14
45
63
#define ADU_VER_RL _V(ADU_VER_MAJ, ADU_VER_MIN)
47
#define ADU_BETA_MAJ 3
48
#define ADU_BETA_MIN ""
50
65
#if ADU_BETA_MAJ > 0
51
66
#define ADU_VER ADU_VER_RL _T("b") _B(ADU_BETA_MAJ, ADU_BETA_MIN)
53
68
#define ADU_VER ADU_VER_RL
56
#define ADU_MOD_NAME _T("AdunanzA")
57
71
#define ADU_MOD ADU_MOD_NAME _T(" ") ADU_VER
73
// Mr Hyde: uso la seg. per avere "aMuleAdunanzA" invece di "aMule" come nome
74
// di directory (es: directory per preferenze diventa ~/.aMuleAdunanzA)
75
#define ADU_APPNAME "aMuleAdunanzA"
76
#define AMULE_ADUNANZA_DIR ADU_APPNAME
60
78
// Mr Hyde: usata per gestione lingue
61
// (deve corrispondere al file .pot e ai file .gmo generati)
79
// deve corrispondere:
80
// - al file .pot e ai file .gmo generati
81
// - al primo argomento della macro AC_INIT (o meglio, al lowercase del primo argomento di AC_INIT, vedi file "configure.in")
62
82
#if !defined(PACKAGE_ADUNANZA)
63
#define PACKAGE_ADUNANZA "adunanza"
83
#define PACKAGE_ADUNANZA "amuleadunanza"
66
86
// Mr Hyde: rimosse le define di MOD_VERSION_LONG perche' definite in src/include/common/ClientVersion.h
82
102
// Definizione default del numero di slots
83
103
#define ADUNANZA_DEF_UPSL 8
84
104
// Definizione default banda Adu
85
//#define ADUNANZA_BAND_PERC 85
105
#define ADUNANZA_BAND_PERC (85) // Mr Hyde allineamento 3.16, ripartitore banda
106
#define ADUNANZA_DEF_BW_EXT (6) // Mr Hyde allineamento 3.16, ripartitore banda
108
const uint32 ADU_MAX_RATIO_KADU_DOWN(3145728); // 3 mega * 1024 KB in mega * 1024 byte in KB
109
const uint32 ADUNANZA_MIN_BW_TROLLER(2);
111
const bool ADUNANZA_UP_EXT_CHECK(false); // il default per abilitare le impostazioni CUSTOM del ripartitore di banda deve essere false (ovvero: custom DISABILITATO)
113
const unsigned int ADU_EXT_FULL_WAIT_TIME(480); // 8 minuti
86
115
// Definizione connessione automatica
87
116
#define ADUNANZA_AUTO_CONN 1
88
117
// Definizione forzature upload/dl ext 1:1 - Disabilitato di default
124
153
// notare che l'URL scritto in questo modo NON rispetta il draft per gli URL IRC
125
154
// (dovrebbe avere il carattere "#" dato come %23, ci sto studiando)
127
//#define ADU_IRCHELP_URL "irc://chat.adunanza.net:6667/La_Stalla"
128
#define ADU_IRCHELP_URL "irc://chat.adunanza.net:6667/#La_Stalla"
156
// Mr Hyde, 20100125, cambiato l'indirizzo su richiesta di Hammon
157
#define ADU_IRCHELP_URL "irc://chat.adunanza.net:6667/#Linux"
130
159
// Mr Hyde: per default programma IRC (da sistemare per MAC)
131
160
#define ADU_DEFAULT_IRC "xchat"
132
#define ADU_DEFAULT_IRC_FLAGS "--url irc://chat.adunanza.net:6667/#La_Stalla"
161
// Mr Hyde, 20100125, cambiato l'indirizzo su richiesta di Hammon
162
#define ADU_DEFAULT_IRC_FLAGS "--url irc://chat.adunanza.net:6667/#Linux"
164
// Mr Hyde: per pagina da associare a F1
165
// Mr Hyde, 20100125, cambiato l'indirizzo su richiesta di Hammon
166
#define ADU_WIKI_URL "http://aduteca.adunanza.net/Amule_AdunanzA"
168
// Aggiunto test porte
169
#define ADU_PORTTEST_BASE_URL "http://adutest.adunanza.net/emule_testport/adutest.php?tcp=%d&udp=%d"
135
172
MAN Milano........................ 1.0.0.0/8
176
213
#define MAN_REGGIO_EMILIA 42
177
214
#define MAN_CAGLIARI 51
179
218
// Funzioni esportate
180
extern bool AduIsFastWebIP(uint32 ip);
181
extern bool AduIsFastWebIP(const wxString& wxip);
182
extern bool AduIsFastWebLANIP(uint32 ip);
183
extern bool AduIsFiber(uint32 ip);
184
extern uint32 AduGetTypeBand();
185
extern uint32 AduGetMaxUploadSlots(void);
186
//extern float AduGetPercBandwidth(void);
187
extern void AduStartConnection(void);
188
extern void AduUpdate(char *url);
190
extern bool AduIsValidKaduAddress( uint32 host );
192
extern float calcolaStima( float input_avail, uint32& firstPublish, uint32 publishInterval, uint32 pubkRTK, bool sameIP, uint32 now );
193
extern float normalizzaStima( float avail, uint32 from, uint32 to );
221
class CAdunanzAUtilities {
223
static inline bool AduIsFastWebLANIP(uint32 ip)
228
case MAN_MILANO_H_NORD:
229
case MAN_MILANO_H_SUD:
236
case MAN_REGGIO_EMILIA:
244
case FASTWEB_ROUTERS:
252
static bool AduIsFastWebIP(uint32 ip)
254
if (CAdunanzAUtilities::AduIsFastWebLANIP(ip))
257
// match rapido: (ip & mask) == netid
259
// netid 213.140.0.0/19 - netid (hex) 0x00008cd5 / mask 0x00e0ffff
260
if ((ip & 0x00e0ffff) == 0x00008cd5 ||
261
// netid 213.156.32.0/19 - netid (hex) 0x00209cd5 / mask 0x00e0ffff
262
(ip & 0x00e0ffff) == 0x00209cd5 ||
263
// netid 62.101.64.0/18 - netid (hex) 0x0040653e / mask 0x00c0ffff
264
(ip & 0x00c0ffff) == 0x0040653e ||
265
// netid 81.208.0.0/17 - netid (hex) 0x0000d051 / mask 0x0080ffff
266
(ip & 0x0080ffff) == 0x0000d051 ||
267
// netid 83.103.0.0/17 - netid (hex) 0x00006753 / mask 0x0080ffff
268
(ip & 0x0080ffff) == 0x00006753 ||
269
// netid 85.18.0.0/16 - netid (hex) 0x00001255 / mask 0x0000ffff
270
(ip & 0x0000ffff) == 0x00001255 ||
271
// netid 89.96.0.0/15 - netid (hex) 0x00006059 / mask 0x0000f7ff
272
(ip & 0x0000f7ff) == 0x00006059 ||
273
// netid 93.32.0.0/11 - netid (hex) 0x0000205d / mask 0x0000e0ff // Allineamento 3.15b74
274
(ip & 0x0000e0ff) == 0x0000205d)
280
static bool AduIsFastWebIP(const wxString& ipv4string);
282
static bool AduIsFiber(uint32 ip);
283
static uint32 AduGetTypeBand();
284
//extern float AduGetPercBandwidth();
285
static void AduStartConnection();
286
static void AduUpdate(char *url);
288
static bool AduIsValidKaduAddress( uint32 host );
292
static uint32 getAllowedUploadDataRate();
294
static float calcolaStima( float input_avail, uint32& firstPublish, uint32 publishInterval, uint32 pubkRTK, bool sameIP, uint32 now );
295
static float normalizzaStima( float avail, uint32 from, uint32 to );
299
static bool AduDebt();
301
static int OLDSetSlots();
302
static int SetSlots();
303
static int TotSlots();
305
static int ExtSlots();
308
static uint32 AduNextClient(int fix = 0);
309
static bool AduMaxTrans();
310
static uint32 AduGetMaxUploadSlots();
312
static void CalcolaRatio(bool bAtMomentNotUsed);
196
317
class CAduUploadSlotsManager
245
366
uint32 next() const;
247
// uint32 nextAndConsume() ;
249
368
void update(CClientPtrList& uploadingList);
251
void consume(CUpDownClient* pClient);
257
// Mr Hyde: NON PIU' USATE BEGIN
258
// extern bool IsAduServer(uint32 CurServer);
259
// extern void* AduGetNextAduServer(int value, int& num);
260
// Mr Hyde: NON PIU' USATE END
265
uint32 AduNextClient(int fix = 0);
266
bool AduMaxTrans(void);