[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Mldonkey-commits] mldonkey distrib/ChangeLog src/daemon/common/co...
From: |
mldonkey-commits |
Subject: |
[Mldonkey-commits] mldonkey distrib/ChangeLog src/daemon/common/co... |
Date: |
Sun, 26 Nov 2006 16:36:30 +0000 |
CVSROOT: /sources/mldonkey
Module name: mldonkey
Changes by: spiralvoice <spiralvoice> 06/11/26 16:36:29
Modified files:
distrib : ChangeLog
src/daemon/common: commonServer.ml commonTypes.ml guiEncoding.ml
src/networks/donkey: donkeyClient.ml donkeyComplexOptions.ml
donkeyGlobals.ml donkeyInteractive.ml
donkeyMain.ml donkeyOptions.ml
donkeyProtoClient.ml donkeyProtoServer.ml
donkeyProtoUdp.ml donkeyServers.ml
donkeyTypes.ml donkeyUdp.ml
Log message:
patch #5581
CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/mldonkey/distrib/ChangeLog?cvsroot=mldonkey&r1=1.1113&r2=1.1114
http://cvs.savannah.gnu.org/viewcvs/mldonkey/src/daemon/common/commonServer.ml?cvsroot=mldonkey&r1=1.38&r2=1.39
http://cvs.savannah.gnu.org/viewcvs/mldonkey/src/daemon/common/commonTypes.ml?cvsroot=mldonkey&r1=1.63&r2=1.64
http://cvs.savannah.gnu.org/viewcvs/mldonkey/src/daemon/common/guiEncoding.ml?cvsroot=mldonkey&r1=1.60&r2=1.61
http://cvs.savannah.gnu.org/viewcvs/mldonkey/src/networks/donkey/donkeyClient.ml?cvsroot=mldonkey&r1=1.109&r2=1.110
http://cvs.savannah.gnu.org/viewcvs/mldonkey/src/networks/donkey/donkeyComplexOptions.ml?cvsroot=mldonkey&r1=1.59&r2=1.60
http://cvs.savannah.gnu.org/viewcvs/mldonkey/src/networks/donkey/donkeyGlobals.ml?cvsroot=mldonkey&r1=1.109&r2=1.110
http://cvs.savannah.gnu.org/viewcvs/mldonkey/src/networks/donkey/donkeyInteractive.ml?cvsroot=mldonkey&r1=1.138&r2=1.139
http://cvs.savannah.gnu.org/viewcvs/mldonkey/src/networks/donkey/donkeyMain.ml?cvsroot=mldonkey&r1=1.62&r2=1.63
http://cvs.savannah.gnu.org/viewcvs/mldonkey/src/networks/donkey/donkeyOptions.ml?cvsroot=mldonkey&r1=1.56&r2=1.57
http://cvs.savannah.gnu.org/viewcvs/mldonkey/src/networks/donkey/donkeyProtoClient.ml?cvsroot=mldonkey&r1=1.39&r2=1.40
http://cvs.savannah.gnu.org/viewcvs/mldonkey/src/networks/donkey/donkeyProtoServer.ml?cvsroot=mldonkey&r1=1.22&r2=1.23
http://cvs.savannah.gnu.org/viewcvs/mldonkey/src/networks/donkey/donkeyProtoUdp.ml?cvsroot=mldonkey&r1=1.15&r2=1.16
http://cvs.savannah.gnu.org/viewcvs/mldonkey/src/networks/donkey/donkeyServers.ml?cvsroot=mldonkey&r1=1.67&r2=1.68
http://cvs.savannah.gnu.org/viewcvs/mldonkey/src/networks/donkey/donkeyTypes.ml?cvsroot=mldonkey&r1=1.51&r2=1.52
http://cvs.savannah.gnu.org/viewcvs/mldonkey/src/networks/donkey/donkeyUdp.ml?cvsroot=mldonkey&r1=1.25&r2=1.26
Patches:
Index: distrib/ChangeLog
===================================================================
RCS file: /sources/mldonkey/mldonkey/distrib/ChangeLog,v
retrieving revision 1.1113
retrieving revision 1.1114
diff -u -b -r1.1113 -r1.1114
--- distrib/ChangeLog 26 Nov 2006 13:54:09 -0000 1.1113
+++ distrib/ChangeLog 26 Nov 2006 16:36:29 -0000 1.1114
@@ -15,6 +15,23 @@
=========
2006/11/26
+5581: EDK: Improve server logins, send fewer data, minor improvements
+- Copied eMule behaviour:
+ - send fewer data to server during login, support server capability
"newtags",
+ same opcodes as in eMule are used
+ - UDP ping servers once per 4,5h - (random of 1s-1h)
+ - UDP server statistic request during every second UDP ping
+ (~9h, not once per hour like before)
+ - request serverlist from server only when ED2K_update_server_list_server
true
+ - ping one server per 5s
+ - remove servers after 10 unsuccessful UDP pings
+ - save challenge values sent with UDP server statistic and description
request
+ and dismiss answers containing wrong challenge
+- New functions, restructurings:
+ - new server status "Server full"
+ - support new tag emule_miscoptions2 (empty atm.)
+ - remove server descriptions from servers.ini
+ - clean donkeyTypes.server definitions
5588: Cleanup commonNetwork (pango)
5582: EDK: Improve CryptoPP logging (Schlumpf)
5584: EDK: Remove removed servers from walker server lists
Index: src/daemon/common/commonServer.ml
===================================================================
RCS file: /sources/mldonkey/mldonkey/src/daemon/common/commonServer.ml,v
retrieving revision 1.38
retrieving revision 1.39
diff -u -b -r1.38 -r1.39
--- src/daemon/common/commonServer.ml 19 Nov 2006 23:04:25 -0000 1.38
+++ src/daemon/common/commonServer.ml 26 Nov 2006 16:36:29 -0000 1.39
@@ -448,6 +448,7 @@
(
let not_connected =
match impl.impl_server_state with
+ | ServerFull
| NotConnected _ -> true
| _ -> false
in
Index: src/daemon/common/commonTypes.ml
===================================================================
RCS file: /sources/mldonkey/mldonkey/src/daemon/common/commonTypes.ml,v
retrieving revision 1.63
retrieving revision 1.64
diff -u -b -r1.63 -r1.64
--- src/daemon/common/commonTypes.ml 26 Nov 2006 13:54:09 -0000 1.63
+++ src/daemon/common/commonTypes.ml 26 Nov 2006 16:36:29 -0000 1.64
@@ -325,10 +325,10 @@
| Connected of int (* >= 0 Queued *)
| Connected_downloading of int
(* | ConnectionWaiting of int *)
-
| NewHost
| RemovedHost
| BlackListedHost
+| ServerFull
type compressor =
Deflate of Zlib.stream * Zlib.stream
@@ -827,6 +827,7 @@
| Connecting
| NewHost
| BlackListedHost
+ | ServerFull
| RemovedHost -> false
let string_of_connection_state s =
@@ -850,6 +851,7 @@
| RemovedHost -> "Removed"
| BlackListedHost -> "Black"
| NewHost -> "New"
+ | ServerFull -> "Server full"
let short_string_of_connection_state s =
match s with
@@ -867,6 +869,7 @@
| RemovedHost -> "Rem"
| BlackListedHost -> "BL"
| NewHost -> "New"
+ | ServerFull -> "Full"
exception IgnoreNetwork
Index: src/daemon/common/guiEncoding.ml
===================================================================
RCS file: /sources/mldonkey/mldonkey/src/daemon/common/guiEncoding.ml,v
retrieving revision 1.60
retrieving revision 1.61
diff -u -b -r1.60 -r1.61
--- src/daemon/common/guiEncoding.ml 26 Nov 2006 13:54:09 -0000 1.60
+++ src/daemon/common/guiEncoding.ml 26 Nov 2006 16:36:29 -0000 1.61
@@ -211,6 +211,7 @@
if proto < 12 then
buf_int8 buf (
match t with
+ | ServerFull
| NotConnected _ -> 0
| Connecting -> 1
| Connected_initiating -> 2
@@ -222,6 +223,7 @@
| BlackListedHost -> if proto < 10 then 0 else 8)
else
match t with
+ | ServerFull
| NotConnected (_, -1) -> buf_int8 buf 0
| Connecting -> buf_int8 buf 1
| Connected_initiating -> buf_int8 buf 2
Index: src/networks/donkey/donkeyClient.ml
===================================================================
RCS file: /sources/mldonkey/mldonkey/src/networks/donkey/donkeyClient.ml,v
retrieving revision 1.109
retrieving revision 1.110
diff -u -b -r1.109 -r1.110
--- src/networks/donkey/donkeyClient.ml 21 Nov 2006 22:34:33 -0000 1.109
+++ src/networks/donkey/donkeyClient.ml 26 Nov 2006 16:36:29 -0000 1.110
@@ -677,11 +677,16 @@
DonkeyProtoClient.update_emule_proto_from_miscoptions1
c.client_emule_proto i
)
+ | Field_UNKNOWN "emule_miscoptions2" ->
+ for_int64_tag tag (fun i ->
+ DonkeyProtoClient.update_emule_proto_from_miscoptions2
+ c.client_emule_proto i
+ )
| Field_UNKNOWN "emule_compatoptions" ->
for_int_tag tag (fun i ->
DonkeyProtoClient.update_emule_proto_from_compatoptions
c.client_emule_proto i
- );
+ )
| Field_UNKNOWN "emule_version" ->
for_int_tag tag (fun i ->
c.client_emule_proto.emule_version <- i;
@@ -2159,12 +2164,12 @@
c.client_requests_sent <- 0;
c.client_slot <- SlotNotAsked
-let read_first_message overnet m sock =
+let read_first_message overnet server m sock =
let module M = DonkeyProtoClient in
- if !verbose_msg_clients then begin
- lprintf_nl "Message from incoming client %s:%d"
- (Ip.to_string (peer_ip sock)) (peer_port sock);
+ if (not server && !verbose_msg_clients) || (server && !verbose_msg_servers)
then begin
+ lprintf_nl "Message from incoming %s %s:%d"
+ (if server then "server" else "client") (Ip.to_string (peer_ip sock))
(peer_port sock);
M.print m;
end;
@@ -2262,7 +2267,8 @@
end
end;
- if supports_eep c.client_brand then
+(* Lugdunum servers are not interested in our EmuleClientInfo *)
+ if supports_eep c.client_brand && not server then
begin
(* lprintf "Emule Extended Protocol query\n"; *)
let module M = DonkeyProtoClient in
@@ -2290,7 +2296,8 @@
C.md4 = !!client_md4;
C.ip = client_ip (Some sock);
C.port = !!donkey_port;
- C.tags = !client_to_client_tags;
+ (* Lugdunum servers need fewer infos than clients *)
+ C.tags = if server then !client_to_server_reply_tags else
!client_to_client_tags;
C.server_info = Some (get_server_ip_port ());
C.left_bytes = left_bytes;
C.hash_len = 16;
@@ -2500,10 +2507,12 @@
(if is_connecting_server then
( try
let s = Hashtbl.find servers_by_key from_ip in
+ set_server_state s Connected_initiating;
Printf.sprintf " %s (%s)" s.server_name (string_of_server s)
with _ ->
try
let s = Hashtbl.find servers_by_key connecting_server in
+ set_server_state s Connected_initiating;
Printf.sprintf " %s (%s)" s.server_name (string_of_server s)
with _ -> "Unknown server"
)
@@ -2535,7 +2544,7 @@
);
(try
set_reader sock
- (DonkeyProtoCom.client_handler2 c (read_first_message
overnet)
+ (DonkeyProtoCom.client_handler2 c (read_first_message
overnet is_connecting_server)
(client_to_client []));
with e -> lprintf_nl "Exception %s in init_connection"
Index: src/networks/donkey/donkeyComplexOptions.ml
===================================================================
RCS file:
/sources/mldonkey/mldonkey/src/networks/donkey/donkeyComplexOptions.ml,v
retrieving revision 1.59
retrieving revision 1.60
diff -u -b -r1.59 -r1.60
--- src/networks/donkey/donkeyComplexOptions.ml 21 Nov 2006 22:34:33 -0000
1.59
+++ src/networks/donkey/donkeyComplexOptions.ml 26 Nov 2006 16:36:29 -0000
1.60
@@ -183,9 +183,6 @@
let l = DonkeyGlobals.new_server ip port in
(try
- l.server_description <- get_value "server_desc" value_to_string
- with _ -> ());
- (try
l.server_name <- get_value "server_name" value_to_string
with _ -> ());
(try
@@ -208,11 +205,6 @@
in
let fields =
- if c.server_description <> "" then
- ("server_desc", string_to_value c.server_description) :: fields
- else fields in
-
- let fields =
if c.server_name <> "" then
("server_name", string_to_value c.server_name) :: fields
else fields in
Index: src/networks/donkey/donkeyGlobals.ml
===================================================================
RCS file: /sources/mldonkey/mldonkey/src/networks/donkey/donkeyGlobals.ml,v
retrieving revision 1.109
retrieving revision 1.110
diff -u -b -r1.109 -r1.110
--- src/networks/donkey/donkeyGlobals.ml 26 Nov 2006 13:54:09 -0000
1.109
+++ src/networks/donkey/donkeyGlobals.ml 26 Nov 2006 16:36:29 -0000
1.110
@@ -131,6 +131,7 @@
let client_to_client_tags = ref ([] : tag list)
let client_to_server_tags = ref ([] : tag list)
+let client_to_server_reply_tags = ref ([] : tag list)
let emule_info =
let module E = DonkeyProtoClient.EmuleClientInfo in
{
@@ -496,7 +497,6 @@
server_port = port;
server_realport = None;
server_sock = NoConnection;
- server_nqueries = 0;
server_search_queries = Fifo.create ();
server_users_queries = Fifo.create ();
server_connection_control = new_connection_control ();
@@ -510,7 +510,6 @@
server_users = [];
server_master = false;
server_preferred = false;
- server_last_message = 0;
server_queries_credit = 0;
server_waiting_queries = [];
server_sent_all_queries = false;
@@ -522,20 +521,24 @@
server_has_related_search = false;
server_has_tag_integer = false;
server_has_largefiles = false;
- server_has_udp_obfuscation = false;
- server_has_tcp_obfuscation = false;
server_version = "";
server_lowid_users = None;
server_soft_limit = None;
server_hard_limit = None;
- server_obfuscation_port_tcp = None;
- server_obfuscation_port_udp = None;
- server_udp_key = None;
- server_udp_keyip = None;
+ server_obfuscation_tcp = None;
+ server_obfuscation_udp = None;
server_sent_shared = [];
server_max_users = None;
server_last_ping = 0.;
+ server_next_ping = 0.;
+ server_descping_counter = 0;
server_ping = 0;
+ server_failed_count = 0;
+ server_udp_ping_challenge = None;
+ server_udp_desc_challenge = None;
+ server_has_get_sources = false;
+ server_has_get_files = false;
+ server_has_get_sources2 = false;
server_dynip = "";
server_auxportslist = "";
@@ -1012,15 +1015,6 @@
end
)
-let server_accept_multiple_getsources s =
- (s.server_flags land DonkeyProtoUdp.PingServerReplyUdp.multiple_getsources)
<> 0
-
-let server_send_multiple_replies s =
- (s.server_flags land DonkeyProtoUdp.PingServerReplyUdp.multiple_replies) <> 0
-
-let server_send_getsources2 s =
- (s.server_flags land DonkeyProtoUdp.PingServerReplyUdp.getsources2) <> 0
-
let full_client_identifier c =
Printf.sprintf "%s (%s%s) '%s'"
(Ip.to_string c.client_ip)
Index: src/networks/donkey/donkeyInteractive.ml
===================================================================
RCS file: /sources/mldonkey/mldonkey/src/networks/donkey/donkeyInteractive.ml,v
retrieving revision 1.138
retrieving revision 1.139
diff -u -b -r1.138 -r1.139
--- src/networks/donkey/donkeyInteractive.ml 20 Nov 2006 22:48:43 -0000
1.138
+++ src/networks/donkey/donkeyInteractive.ml 26 Nov 2006 16:36:29 -0000
1.139
@@ -145,11 +145,9 @@
(match server.server_lowid_users with
| None -> server.server_lowid_users <- Some s | _ -> ())
| { tag_name = Field_UNKNOWN "tcpportobfuscation" ; tag_value =
Uint64 s } ->
- (match server.server_obfuscation_port_tcp with
- | None -> server.server_obfuscation_port_tcp <- Some
(Int64.to_int s) | _ -> ())
+ server.server_obfuscation_tcp <- Some (Int64.to_int s)
| { tag_name = Field_UNKNOWN "udpportobfuscation" ; tag_value =
Uint64 s } ->
- (match server.server_obfuscation_port_udp with
- | None -> server.server_obfuscation_port_udp <- Some
(Int64.to_int s) | _ -> ())
+ server.server_obfuscation_udp <- Some (Int64.to_int s)
| { tag_name = Field_UNKNOWN "country" ; tag_value = String s }
-> ()
| { tag_name = Field_UNKNOWN "udpflags" ; tag_value = Uint64 s
} -> ()
| { tag_name = Field_UNKNOWN "refs" ; tag_value = Uint64 s }
-> ()
@@ -758,7 +756,7 @@
Printf.sprintf "%s does not exist, ignoring..." filename
end
else
- Printf.sprintf "ED2K_update_server_list_met is disabled, ignoring..."
+ Printf.sprintf "ED2K-update_server_list_server_met is disabled,
ignoring..."
), "<filename|URL> :\t\tadd the servers from a server.met file or URL";
"id", Arg_none (fun o ->
@@ -1132,10 +1130,13 @@
if s.server_has_related_search then Printf.bprintf temp_buf
"related_search ";
if s.server_has_tag_integer then Printf.bprintf temp_buf
"tag_integer ";
if s.server_has_largefiles then Printf.bprintf temp_buf
"largefiles ";
- (match s.server_obfuscation_port_tcp with
- | Some p -> Printf.bprintf temp_buf "tcp_obfuscation(%d) " p | _
-> ());
- (match s.server_obfuscation_port_udp with
- | Some p -> Printf.bprintf temp_buf "udp_obfuscation(%d) " p | _
-> ());
+ if s.server_has_get_sources then Printf.bprintf temp_buf
"getsources ";
+ if s.server_has_get_sources2 then Printf.bprintf temp_buf
"getsources2 ";
+ if s.server_has_get_files then Printf.bprintf temp_buf "getfiles ";
+ (match s.server_obfuscation_tcp with
+ | Some p when p <> 0 -> Printf.bprintf temp_buf
"tcp_obfuscation(%d) " p | _ -> ());
+ (match s.server_obfuscation_udp with
+ | Some p when p <> 0 -> Printf.bprintf temp_buf
"udp_obfuscation(%d) " p | _ -> ());
if s.server_auxportslist <> "" then Printf.bprintf temp_buf
"auxportslist %s " s.server_auxportslist;
if s.server_dynip <> "" then Printf.bprintf temp_buf "dynip %s "
s.server_dynip;
if Buffer.contents temp_buf <> "" then Some (Buffer.contents
temp_buf) else None;
@@ -1818,7 +1819,7 @@
if not !!enable_donkey then
lprintf_nl "eDonkey module is disabled, ignoring..."
else
- lprintf_nl "ED2K_update_server_list_met is disabled, ignoring..."
+ lprintf_nl "ED2K-update_server_list_server_met is disabled,
ignoring..."
);
CommonWeb.add_web_kind "comments.met" "List of edonkey files comments"
(fun _ filename ->
Index: src/networks/donkey/donkeyMain.ml
===================================================================
RCS file: /sources/mldonkey/mldonkey/src/networks/donkey/donkeyMain.ml,v
retrieving revision 1.62
retrieving revision 1.63
diff -u -b -r1.62 -r1.63
--- src/networks/donkey/donkeyMain.ml 26 Nov 2006 13:54:09 -0000 1.62
+++ src/networks/donkey/donkeyMain.ml 26 Nov 2006 16:36:29 -0000 1.63
@@ -78,13 +78,13 @@
if !verbose_sources > 2 then
lprintf_nl "Exception %s while checking sources"
(Printexc2.to_string e)
- );
- DonkeyServers.udp_walker_timer ()
+ )
let five_second_timer timer =
DonkeyServers.check_server_connections ();
DonkeyServers.walker_timer ();
DonkeyOneFile.check_files_downloaded ();
+ DonkeyServers.udp_walker_timer ();
DonkeyShare.check_shared_files ()
let min_timer timer =
@@ -133,6 +133,7 @@
m.emule_features <- secident;
let emule_miscoptions1 = D.emule_miscoptions1 m in
+ let emule_miscoptions2 = D.emule_miscoptions2 m in
let emule_compatoptions = D.emule_compatoptions m in
client_to_client_tags :=
[
@@ -142,21 +143,40 @@
int_tag (Field_UNKNOWN "emule_udpports") (!!donkey_port+4);
int_tag (Field_UNKNOWN "emule_version") m.emule_version;
int64_tag (Field_UNKNOWN "emule_miscoptions1") emule_miscoptions1;
+ int64_tag (Field_UNKNOWN "emule_miscoptions2") emule_miscoptions2;
int_tag (Field_UNKNOWN "emule_compatoptions") emule_compatoptions;
];
- let extended = ref 0x04 in (* support of auxport *)
+(* server capabilities *)
+ let extended = ref 0x0 in
extended := !extended lor 0x01; (* support of compression *)
+(*extended := !extended lor 0x02; IP in login, deprecated *)
+ extended := !extended lor 0x04; (* support of auxport *)
+ extended := !extended lor 0x08; (* newtags *)
+(*extended := !extended lor 0x10; (* unicode *) *)
+(*extended := !extended lor 0x100; (* files > 4GB *) *)
+(*extended := !extended lor 0x200; (* support crypt *) *)
+(*extended := !extended lor 0x400; (* request crypt *) *)
+(*extended := !extended lor 0x800; (* require crypt *) *)
client_to_server_tags :=
[
string_tag (Field_UNKNOWN "name") (local_login ());
int_tag (Field_UNKNOWN "version") protocol_version;
- int_tag (Field_UNKNOWN "port") !!donkey_port;
int_tag (Field_UNKNOWN "extended") !extended;
int_tag (Field_UNKNOWN "emule_version") m.emule_version;
];
+ client_to_server_reply_tags :=
+ [
+ string_tag (Field_UNKNOWN "name") (local_login ());
+ int_tag (Field_UNKNOWN "version") protocol_version;
+ int_tag (Field_UNKNOWN "emule_udpports") (!!donkey_port+4);
+ int64_tag (Field_UNKNOWN "emule_miscoptions1") emule_miscoptions1;
+ int64_tag (Field_UNKNOWN "emule_miscoptions2") emule_miscoptions2;
+ int_tag (Field_UNKNOWN "emule_version") m.emule_version;
+ ];
+
emule_info.DonkeyProtoClient.EmuleClientInfo.tags <- [
int_tag (Field_UNKNOWN "compression") m.emule_compression;
int_tag (Field_UNKNOWN "udpver") m.emule_udpver;
Index: src/networks/donkey/donkeyOptions.ml
===================================================================
RCS file: /sources/mldonkey/mldonkey/src/networks/donkey/donkeyOptions.ml,v
retrieving revision 1.56
retrieving revision 1.57
diff -u -b -r1.56 -r1.57
--- src/networks/donkey/donkeyOptions.ml 21 Nov 2006 22:34:34 -0000
1.56
+++ src/networks/donkey/donkeyOptions.ml 26 Nov 2006 16:36:29 -0000
1.57
@@ -250,7 +250,7 @@
int_option 500
let min_users_on_server = define_option donkey_section ["min_users_on_server"]
- "min connected users for each server"
+ "disconnect if server users is smaller"
int_option 0
let max_published_files = define_option donkey_section ["max_published_files"]
Index: src/networks/donkey/donkeyProtoClient.ml
===================================================================
RCS file: /sources/mldonkey/mldonkey/src/networks/donkey/donkeyProtoClient.ml,v
retrieving revision 1.39
retrieving revision 1.40
diff -u -b -r1.39 -r1.40
--- src/networks/donkey/donkeyProtoClient.ml 31 Oct 2006 15:40:06 -0000
1.39
+++ src/networks/donkey/donkeyProtoClient.ml 26 Nov 2006 16:36:29 -0000
1.40
@@ -74,6 +74,15 @@
in
Int64.of_int o
+let emule_miscoptions2 m =
+(*
+ let o =
+ (m.emule_largefiles lsl 4)
+ in
+ Int64.of_int o
+*)
+ Int64.zero
+
let update_emule_proto_from_miscoptions1 m o =
let o = Int64.to_int o in
m.emule_udpver <- (o lsr 24) land 0xf;
@@ -86,6 +95,12 @@
m.emule_multipacket <- (o lsr 1) land 0x1;
m.emule_supportpreview <- (o lsr 0) land 0x1
+let update_emule_proto_from_miscoptions2 m o = ()
+(*
+ let o = Int64.to_int o in
+ m.emule_largefiles <- (o lsr 4) land 0x1
+*)
+
let emule_compatoptions m =
(m.emule_osinfosupport lsl 0)
Index: src/networks/donkey/donkeyProtoServer.ml
===================================================================
RCS file: /sources/mldonkey/mldonkey/src/networks/donkey/donkeyProtoServer.ml,v
retrieving revision 1.22
retrieving revision 1.23
diff -u -b -r1.22 -r1.23
--- src/networks/donkey/donkeyProtoServer.ml 14 Nov 2006 18:42:59 -0000
1.22
+++ src/networks/donkey/donkeyProtoServer.ml 26 Nov 2006 16:36:29 -0000
1.23
@@ -63,11 +63,10 @@
let names_of_tag =
[
- "\001", Field_UNKNOWN "name";
- "\017", Field_UNKNOWN "version";
- "\015", Field_UNKNOWN "port";
- "\032", Field_UNKNOWN "extended";
- "\251", Field_UNKNOWN "emule_version";
+ "\001", Field_UNKNOWN "name"; (* CT_NAME 0x01 *)
+ "\017", Field_UNKNOWN "version"; (* CT_VERSION 0x11 *)
+ "\032", Field_UNKNOWN "extended"; (* CT_SERVER_FLAGS 0x20 *)
+ "\251", Field_UNKNOWN "emule_version"; (* CT_EMULE_VERSION 0xfb *)
]
let parse len s =
@@ -181,17 +180,21 @@
}
let print t =
- lprintf "SET_ID: %s id: %s %s"
+ lprintf "SET_ID: %s id: %s %s\n"
(if t.zlib then "Zlib" else "")
(Ip.to_string t.ip)
(match t.port with
None -> Printf.sprintf ""
| Some port ->
- Printf.sprintf "Real Port: %d" port)
+ Printf.sprintf "Real Port: %d" port);
+ lprintf "SET_ID: newtags %b unicode %b related_search %b tag_integer %b
largefiles %b udp_obfuscation %b tcp_obfuscation %b"
+ t.newtags t.unicode t.related_search t.tag_integer t.largefiles
t.udp_obfuscation t.tcp_obfuscation
let bprint oc t =
Printf.bprintf oc "SET_ID: %s\n" (if t.zlib then "Zlib" else "");
- Printf.bprintf oc "id: %s\n" (Ip.to_string t.ip)
+ Printf.bprintf oc "SET_ID id: %s\n" (Ip.to_string t.ip);
+ Printf.bprintf oc "SET_ID: newtags %b unicode %b related_search %b
tag_integer %b largefiles %b udp_obfuscation %b tcp_obfuscation %b\n"
+ t.newtags t.unicode t.related_search t.tag_integer t.largefiles
t.udp_obfuscation t.tcp_obfuscation
let write buf t =
if t.zlib then buf_int buf 1;
@@ -201,16 +204,16 @@
let unit = ()
-module AckID = struct
+module QueryServerList = struct
type t = unit
let parse len s = ()
let print t =
- lprintf_nl "ACK_ID:"
+ lprintf_nl "QUERY_SERVER_LIST:"
let bprint oc t =
- Printf.bprintf oc "ACK_ID\n"
+ Printf.bprintf oc "QUERY_SERVER_LIST\n"
let write (buf: Buffer.t) (t: t) = unit
@@ -1039,7 +1042,7 @@
type t =
| ConnectReq of Connect.t
| SetIDReq of SetID.t
-| AckIDReq of AckID.t
+| QueryServerListReq of QueryServerList.t
| BadProtocolVersionReq
| MessageReq of Message.t
| ShareReq of Share.t
@@ -1106,7 +1109,7 @@
match opcode with
| 1 -> ConnectReq (Connect.parse len s)
| 5 -> BadProtocolVersionReq
- | 20 -> AckIDReq (AckID.parse len s)
+ | 20 -> QueryServerListReq (QueryServerList.parse len s) (*
OP_GETSERVERLIST 0x14 *)
| 21 -> ShareReq (Share.parse len s)
| 22 -> QueryReq (Query.parse len s)
| 25 -> QueryLocationReq (QueryLocation.parse len s)
@@ -1164,7 +1167,7 @@
match t with
ConnectReq t -> Connect.print t
| SetIDReq t -> SetID.print t
- | AckIDReq t -> AckID.print t
+ | QueryServerListReq t -> QueryServerList.print t
| MessageReq t -> Message.print t
| BadProtocolVersionReq -> lprintf_nl "BAD PROTOCOL VERSION"
| ShareReq t -> Share.print t
@@ -1227,7 +1230,7 @@
match t with
ConnectReq t -> Connect.bprint oc t
| SetIDReq t -> SetID.bprint oc t
- | AckIDReq t -> AckID.bprint oc t
+ | QueryServerListReq t -> QueryServerList.bprint oc t
| MessageReq t -> Message.bprint oc t
| BadProtocolVersionReq -> Printf.bprintf oc "BAD PROTOCOL VERSION\n"
| ShareReq t -> Share.bprint oc t
@@ -1294,9 +1297,9 @@
| SetIDReq t ->
buf_int8 buf 64;
SetID.write buf t
- | AckIDReq t ->
+ | QueryServerListReq t ->
buf_int8 buf 20;
- AckID.write buf t
+ QueryServerList.write buf t
| MessageReq t ->
buf_int8 buf 56;
Message.write buf t
Index: src/networks/donkey/donkeyProtoUdp.ml
===================================================================
RCS file: /sources/mldonkey/mldonkey/src/networks/donkey/donkeyProtoUdp.ml,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -b -r1.15 -r1.16
--- src/networks/donkey/donkeyProtoUdp.ml 1 Oct 2006 17:54:00 -0000
1.15
+++ src/networks/donkey/donkeyProtoUdp.ml 26 Nov 2006 16:36:29 -0000
1.16
@@ -130,10 +130,6 @@
module PingServerReplyUdp = struct (* reponse du serveur a 150 *)
- let multiple_getsources = 1
- let multiple_replies = 2
- let getsources2 = 32
-
type t = {
challenge : int64;
users : int64;
@@ -141,10 +137,17 @@
soft_limit : int64 option;
hard_limit : int64 option;
max_users : int64 option;
- flags : int option;
lowid_users : int64 option;
+ get_sources : bool;
+ get_files : bool;
+ newtags : bool;
+ unicode : bool;
+ get_sources2 : bool;
+ largefiles : bool;
+ udp_obfuscation : bool;
+ tcp_obfuscation : bool;
}
-(* <E3><97><users><files><softLimit><hardLimit><maxUsers><flags> *)
+
let parse len s =
let challenge = get_uint64_32 s 1 in
let users = get_uint64_32 s 5 in
@@ -152,7 +155,7 @@
let max_users = if len >= 17 then Some (get_uint64_32 s 13) else None in
let soft_limit = if len >= 21 then Some (get_uint64_32 s 17) else None in
let hard_limit = if len >= 25 then Some (get_uint64_32 s 21) else None in
- let flags = if len >= 29 then Some (get_int s 25) else None in
+ let flags = if len >= 29 then get_int s 25 else 0 in
let lowid_users = if len >= 33 then Some (get_uint64_32 s 29) else None
in
{
@@ -162,8 +165,15 @@
soft_limit = soft_limit;
hard_limit = hard_limit;
max_users = max_users;
- flags = flags;
lowid_users = lowid_users;
+ get_sources = 0x01 land flags = 0x01;
+ get_files = 0x02 land flags = 0x02;
+ newtags = 0x08 land flags = 0x08;
+ unicode = 0x10 land flags = 0x10;
+ get_sources2 = 0x20 land flags = 0x20;
+ largefiles = 0x100 land flags = 0x100;
+ udp_obfuscation = 0x200 land flags = 0x200;
+ tcp_obfuscation = 0x200 land flags = 0x200;
}
let bprint oc t =
@@ -172,46 +182,35 @@
(match t.soft_limit with Some x -> Printf.bprintf oc " Soft limit:
%Ld\n" x | None -> ());
(match t.hard_limit with Some x -> Printf.bprintf oc " Hard limit:
%Ld\n" x | None -> ());
(match t.max_users with Some x -> Printf.bprintf oc " Max nusers:
%Ld\n" x | None -> ());
- (match t.flags with Some x -> Printf.bprintf oc " Flags: %x\n" x |
None -> ());
- Printf.bprintf oc "\n"
+ (match t.lowid_users with Some x -> Printf.bprintf oc " LowId nusers:
%Ld\n" x | None -> ());
+ Printf.bprintf oc " get_sources %b, get_files %b, newtags %b, unicode
%b, get_sources2 %b, largefiles %b, udp_obfuscation %b, tcp_obfuscation %b"
+ t.get_sources t.get_files t.newtags t.unicode t.get_sources2
t.largefiles t.udp_obfuscation t.tcp_obfuscation
let write buf t =
buf_int64_32 buf t.challenge;
buf_int64_32 buf t.users;
buf_int64_32 buf t.files;
- (match t.soft_limit, t.hard_limit, t.max_users, t.flags with
- None, None, None, None -> ()
+ (match t.soft_limit, t.hard_limit, t.max_users with
+ None, None, None -> ()
| _ ->
buf_int64_32 buf (
match t.soft_limit with Some x -> x | None -> 0L);
buf_int64_32 buf (
match t.hard_limit with Some x -> x | None -> 0L);
buf_int64_32 buf (
- match t.max_users with Some x -> x | None -> 0L);
- match t.flags with Some x -> buf_int buf x | None -> ()
+ match t.max_users with Some x -> x | None -> 0L)
)
end
module ServerDescUdp = struct
- type t = {
- ip : Ip.t;
- }
+ type t = int64
let invalid_len = Int64.of_int 0xF0FF
- let parse len s =
- try
- let ip = get_ip s 1 in
- {
- ip = ip
- }
- with _ ->
- {
- ip = Ip.null
- }
+ let parse len s = Int64.of_string s
let bprint b t =
- Printf.bprintf b "ServerDescUdpReq %s\n" (Ip.to_string t.ip)
+ Printf.bprintf b "ServerDescUdpReq\n"
(*
// eserver 16.45+ supports a new OP_SERVER_DESC_RES answer, if the
OP_SERVER_DESC_REQ contains a uint32
@@ -221,9 +220,7 @@
*)
let write buf t =
- let rand16 = Int64.of_int (Random.int 65535) in
- let challenge = (left64 rand16 16) ++ invalid_len in
- buf_int64_32 buf challenge
+ buf_int64_32 buf t
end
@@ -232,9 +229,9 @@
name : string;
desc : string;
tags : tag list;
+ challenge : int64;
}
-
let names_of_tag = [
"\001", Field_UNKNOWN "servername";
"\011", Field_UNKNOWN "description";
@@ -254,28 +251,40 @@
"\148", Field_UNKNOWN "lowidusers";
]
- let parse1 len s =
+ let parse1 len s challenge =
let name, pos = get_string s 1 in
let desc, pos = get_string s pos in
{
tags = [];
name = name;
desc = desc;
+ challenge = challenge;
}
- let parse2 len s =
+ let parse2 len s challenge =
let stags,pos = get_tags s 5 names_of_tag in
+ let name = ref "" in
+ let desc = ref "" in
+ List.iter (fun tag ->
+ match tag with
+ | { tag_name = Field_UNKNOWN "servername"; tag_value = String v } ->
+ name := v
+ | { tag_name = Field_UNKNOWN "description"; tag_value = String v } ->
+ desc := v
+ | _ -> ()
+ ) stags;
{
tags = stags;
- name = "";
- desc = "";
+ name = !name;
+ desc = !desc;
+ challenge = challenge;
}
let parse len s =
let challenge = get_uint64_32 s 1 in
let test = right64 (left64 challenge 48) 48 in
let f = if test = ServerDescUdp.invalid_len then parse2 else parse1 in
- f len s
+ f len s challenge
let bprint b t =
Printf.bprintf b "ServerDescReplyUdpReq\n";
Index: src/networks/donkey/donkeyServers.ml
===================================================================
RCS file: /sources/mldonkey/mldonkey/src/networks/donkey/donkeyServers.ml,v
retrieving revision 1.67
retrieving revision 1.68
diff -u -b -r1.67 -r1.68
--- src/networks/donkey/donkeyServers.ml 26 Nov 2006 13:22:04 -0000
1.67
+++ src/networks/donkey/donkeyServers.ml 26 Nov 2006 16:36:29 -0000
1.68
@@ -165,7 +165,7 @@
> last_time () &&
s.server_next_udp <= last_time () then
begin
- if server_accept_multiple_getsources s then
+ if s.server_has_get_sources then
new_servers := s :: !new_servers
else
old_servers := s :: !old_servers;
@@ -209,7 +209,6 @@
with e ->
lprintf_nl "udp_query_sources: %s" (Printexc2.to_string e)
-
let disconnect_server s reason =
let choose_new_master_server s =
match !DonkeyGlobals.master_server with
@@ -253,6 +252,9 @@
s.server_sock <- NoConnection;
s.server_score <- s.server_score - 1;
s.server_users <- [];
+ if server_state s = Connecting && String2.subcontains s.server_banner
"This server is full" then
+ set_server_state s ServerFull
+ else
set_server_state s (NotConnected (reason, -1));
s.server_master <- false;
s.server_banner <- "";
@@ -268,16 +270,44 @@
close sock Closed_for_timeout
| _ -> ()
+let server_udp_ping_statreq s =
+ s.server_last_ping <- Unix.gettimeofday ();
+ s.server_failed_count <- s.server_failed_count + 1;
+ s.server_descping_counter <- s.server_descping_counter + 1;
+ if !verbose_msg_servers then
+ lprintf_nl "send UDP server ping to %s, try %d"
+ (string_of_server s) s.server_failed_count;
+ let module M = DonkeyProtoUdp in
+ let module E = M.ServerDescUdp in
+ let c = Int64.of_int (Random.int 65535) in
+ let challenge = 1437204480L ++ c in (* 0x55AA0000 *)
+ s.server_udp_ping_challenge <- Some challenge;
+(* next ping in 4,5h (16200s) - random value between 1s and 1h to avoid ping
storms
+ eMule Changelog: August, 30. 2005
+ Unk: When a very large popular server come online,
+ it experienced ping storms every 4 hours.. Fixed (Lug) *)
+ s.server_next_ping <- s.server_last_ping +. 16200. -. (Random.float 3600.);
+ udp_server_send_ping s (M.PingServerUdpReq challenge);
+ if s.server_descping_counter < 2 then
+ begin
+ if !verbose_msg_servers then
+ lprintf_nl "send UDP server description request to %s"
(string_of_server s);
+ let rand16 = Int64.of_int (Random.int 65535) in
+ let challenge = (left64 rand16 16) ++ M.ServerDescUdp.invalid_len in
+ s.server_udp_desc_challenge <- Some challenge;
+ udp_server_send s (M.ServerDescUdpReq challenge);
+ end
+ else
+ s.server_descping_counter <- 0
let last_message_sender = ref (-1)
let client_to_server s t sock =
let module M = DonkeyProtoServer in
-
- s.server_last_message <- last_time ();
+ s.server_failed_count <- 0;
if !verbose_msg_servers then begin
- lprintf_nl "Message from server:";
+ lprintf_nl "Message from server %s:" (string_of_server s);
DonkeyProtoServer.print t; lprint_newline ()
end;
@@ -289,8 +319,12 @@
s.server_has_related_search <- t.M.SetID.related_search;
s.server_has_tag_integer <- t.M.SetID.tag_integer;
s.server_has_largefiles <- t.M.SetID.largefiles;
- s.server_has_udp_obfuscation <- t.M.SetID.udp_obfuscation;
- s.server_has_tcp_obfuscation <- t.M.SetID.tcp_obfuscation;
+ (match s.server_obfuscation_tcp with
+ | None -> if t.M.SetID.tcp_obfuscation then s.server_obfuscation_tcp
<- Some 0
+ | Some p -> if not t.M.SetID.tcp_obfuscation then
s.server_obfuscation_tcp <- None);
+ (match s.server_obfuscation_udp with
+ | None -> if t.M.SetID.udp_obfuscation then s.server_obfuscation_udp
<- Some 0
+ | Some p -> if not t.M.SetID.udp_obfuscation then
s.server_obfuscation_udp <- None);
if low_id t.M.SetID.ip && !!force_high_id then
disconnect_server s (Closed_for_error "Low ID")
else begin
@@ -298,26 +332,40 @@
s.server_realport <- t.M.SetID.port;
(* disconnect after (connected_server_timeout) seconds of silence *)
set_rtimeout sock !!connected_server_timeout;
- set_server_state s Connected_initiating;
remove_connecting_server s;
s.server_score <- s.server_score + 5;
connection_ok (s.server_connection_control);
+ if !!update_server_list_server then
server_send sock (
- let module A = M.AckID in
- M.AckIDReq A.t
+ let module Q = M.QueryServerList in
+ M.QueryServerListReq Q.t
);
if not (low_id t.M.SetID.ip) && !!use_server_ip then
last_high_id := t.M.SetID.ip;
+
+ (* nice and ugly, but it doesn't require any new fields *)
+ set_server_state s (Connected
+ ( match s.server_cid with
+ Some t -> if low_id t then (-1) else (-2)
+ | _ -> (-1)
+ ));
+
+ if s.server_next_ping = 0. then server_udp_ping_statreq s;
+
+ (* fill list with queries for the server *)
+ fill_query_queue s;
+ s.server_sent_all_queries <- false;
+ s.server_queries_credit <- 0
end
| M.MessageReq msg ->
if msg <> "" then begin
if !last_message_sender <> server_num s then begin
- let server_header = Printf.sprintf "\n+-- From server %s [%s] ------"
+ let server_header = Printf.sprintf "+-- From server %s [%s] ------"
s.server_name (string_of_server s) in
- CommonEvent.add_event (Console_message_event (Printf.sprintf "%s\n"
server_header));
+ CommonEvent.add_event (Console_message_event (Printf.sprintf
"\n%s\n" server_header));
if !CommonOptions.verbose_msg_servers then
lprintf_nl "%s" server_header;
last_message_sender := server_num s
@@ -325,7 +373,11 @@
s.server_banner <- s.server_banner ^ Printf.sprintf "%s\n" msg;
let msg = Printf.sprintf "| %s" msg in
CommonEvent.add_event (Console_message_event (Printf.sprintf "%s\n"
msg));
- if !CommonOptions.verbose_msg_servers then lprintf_nl "%s" msg
+ if !CommonOptions.verbose_msg_servers then
+ begin
+ lprintf "%s: %s" (string_of_server s) msg;
+ lprint_newline ()
+ end
end
| M.ServerListReq l ->
@@ -352,20 +404,7 @@
| { tag_name = Field_UNKNOWN "description"; tag_value = String
desc } ->
s.server_description <- desc
| _ -> lprintf_nl "parsing donkeyServers.ServerInfo, unknown field
%s" (string_of_tag tag)
- ) s.server_tags;
-
- (* nice and ugly, but it doesn't require any new fields *)
- set_server_state s (Connected
- ( match s.server_cid with
- Some t -> if low_id t then (-1) else (-2)
- | _ -> (-1)
- )
- );
-
- (* fill list with queries for the server *)
- fill_query_queue s;
- s.server_sent_all_queries <- false;
- s.server_queries_credit <- 0
+ ) s.server_tags
| M.InfoReq (users, files) ->
s.server_nusers <- Some (Int64.of_int users);
@@ -374,8 +413,6 @@
begin
lprintf_nl "%s remove server min_users_on_server limit hit!"
(string_of_server s);
-
- disconnect_server s Closed_for_timeout;
server_remove (as_server s.server_server);
end;
server_must_update s
@@ -715,42 +752,28 @@
end
| _ -> ()
-(* Keep connecting to servers in the background. Don't stay connected to
- them , and don't send your shared files list *)
-let udp_walker_list = ref []
-let next_udp_walker_start = ref 0
-
-(* one call every second, so 3600/hour, must wait one hour before
-restarting
-Each client issues 1 packet/4hour, so 100000 clients means 25000/hour,
-7 packets/second = 7 * 40 bytes = 280 B/s ...
-*)
-
-
-let udp_walker_timer () =
- match !udp_walker_list with
- [] ->
- if last_time () > !next_udp_walker_start then begin
- next_udp_walker_start := last_time () + 4*3600;
+let udp_walker_timer () = (* called every 5s *)
+ if !!enable_servers then
+ let now = Unix.gettimeofday () in
+ try
Hashtbl.iter (fun _ s ->
- udp_walker_list := s :: !udp_walker_list
- ) servers_by_key;
+ if not (server_blocked (as_server s.server_server)) then
+ begin
+ if s.server_failed_count > 9 then
+ begin
+ lprintf_nl "remove dead server %s after %d not answered UDP
pings"
+ (string_of_server s) s.server_failed_count;
+ server_remove (as_server s.server_server);
+ raise Exit
+ end;
+ if s.server_next_ping < now then
+ begin
+ server_udp_ping_statreq s;
+ raise Exit
end
- | s :: tail ->
- udp_walker_list := tail;
- let c = Int64.of_int (Random.int 65535) in
- let challenge = 1437204480L ++ c in (* 0x55AA0000 *)
- s.server_last_ping <- Unix.gettimeofday ();
- udp_server_send_ping s (DonkeyProtoUdp.PingServerUdpReq challenge);
-
- let module M = DonkeyProtoUdp in
- let module E = M.ServerDescUdp in
- udp_server_send s (M.ServerDescUdpReq {
- E.ip = Ip.null;
- })
-
-(* UdpSocket.write (get_udp_sock ())
- true udp_ping s.server_ip (s.server_port + 4) *)
+ end
+ ) servers_by_key
+ with Exit -> ()
(* sort the servers by preferred first
then users count with decreasing order
Index: src/networks/donkey/donkeyTypes.ml
===================================================================
RCS file: /sources/mldonkey/mldonkey/src/networks/donkey/donkeyTypes.ml,v
retrieving revision 1.51
retrieving revision 1.52
diff -u -b -r1.51 -r1.52
--- src/networks/donkey/donkeyTypes.ml 14 Nov 2006 18:42:59 -0000 1.51
+++ src/networks/donkey/donkeyTypes.ml 26 Nov 2006 16:36:29 -0000 1.52
@@ -452,7 +452,6 @@
mutable server_port : int;
mutable server_realport : int option; (* in case we connect through
auxport; this is the true one *)
mutable server_sock : tcp_connection;
- mutable server_nqueries : int;
mutable server_search_queries : CommonTypes.search Fifo.t;
mutable server_users_queries : bool Fifo.t;
mutable server_connection_control : connection_control;
@@ -467,10 +466,14 @@
mutable server_next_udp : int;
mutable server_master : bool;
mutable server_preferred : bool;
- mutable server_last_message : int; (* used only by mldonkey server *)
-
- mutable server_last_ping : float;
+ mutable server_last_ping : float; (* time last PingServerUdpReq was sent *)
+ mutable server_next_ping : float; (* time next PingServerUdpReq will be
sent *)
+ mutable server_descping_counter : int;
mutable server_ping : int;
+ mutable server_udp_ping_challenge : int64 option;
+ mutable server_udp_desc_challenge : int64 option;
+(* reset after answer received, increased after UDP ping sent, server deleted
after 10 attempts *)
+ mutable server_failed_count : int;
mutable server_id_requests : file option Fifo.t;
@@ -483,14 +486,13 @@
mutable server_has_related_search : bool;
mutable server_has_tag_integer : bool;
mutable server_has_largefiles : bool;
- mutable server_has_udp_obfuscation : bool;
- mutable server_has_tcp_obfuscation : bool;
- mutable server_obfuscation_port_tcp : int option;
- mutable server_obfuscation_port_udp : int option;
- mutable server_udp_key : int option;
- mutable server_udp_keyip : Ip.t option;
+ mutable server_obfuscation_tcp : int option;
+ mutable server_obfuscation_udp : int option;
mutable server_dynip : string;
mutable server_auxportslist : string;
+ mutable server_has_get_sources : bool;
+ mutable server_has_get_files : bool;
+ mutable server_has_get_sources2 : bool;
mutable server_flags : int;
mutable server_version : string;
Index: src/networks/donkey/donkeyUdp.ml
===================================================================
RCS file: /sources/mldonkey/mldonkey/src/networks/donkey/donkeyUdp.ml,v
retrieving revision 1.25
retrieving revision 1.26
diff -u -b -r1.25 -r1.26
--- src/networks/donkey/donkeyUdp.ml 15 Nov 2006 12:34:30 -0000 1.25
+++ src/networks/donkey/donkeyUdp.ml 26 Nov 2006 16:36:29 -0000 1.26
@@ -47,7 +47,7 @@
module Udp = DonkeyProtoUdp
let udp_server_send_query_location s l =
- if server_send_getsources2 s then
+ if s.server_has_get_sources2 then
udp_server_send s (Udp.QueryLocationUdpReq2 l)
else
udp_server_send s (Udp.QueryLocationUdpReq (List.map (fun (md4,_) -> md4)
l))
@@ -239,6 +239,7 @@
connection_set_last_conn s.server_connection_control (
last_time () - 121);
s.server_score <- s.server_score + 3;
+ s.server_failed_count <- 0;
s
| _ -> raise Not_found
in
@@ -259,20 +260,36 @@
) t
| Udp.PingServerReplyUdpReq t ->
- let module M = Udp.PingServerReplyUdp in
let s = udp_from_server p in
+ let module M = Udp.PingServerReplyUdp in
+ let check_challenge, challenge_v =
+ match s.server_udp_ping_challenge with
+ | Some challenge when challenge = t.M.challenge -> true, challenge
+ | Some challenge -> false, challenge
+ | _ -> false, 0L
+ in
+ if check_challenge then begin
UdpSocket.declare_pong s.server_ip;
let now = Unix.gettimeofday() in
s.server_ping <- int_of_float ((now -. s.server_last_ping) *. 1000.);
- s.server_last_message <- last_time ();
+ s.server_udp_ping_challenge <- None;
+ s.server_has_get_sources <- t.M.get_sources;
+ s.server_has_get_files <- t.M.get_files;
+ s.server_has_newtags <- t.M.newtags;
+ s.server_has_unicode <- t.M.unicode;
+ s.server_has_get_sources2 <- t.M.get_sources2;
+ s.server_has_largefiles <- t.M.largefiles;
+ (match s.server_obfuscation_udp with
+ | None -> if t.M.udp_obfuscation then s.server_obfuscation_udp <- Some 0
+ | Some p -> if not t.M.udp_obfuscation then s.server_obfuscation_udp
<- None);
+ (match s.server_obfuscation_tcp with
+ | None -> if t.M.tcp_obfuscation then s.server_obfuscation_tcp <- Some 0
+ | Some p -> if not t.M.tcp_obfuscation then s.server_obfuscation_tcp
<- None);
if t.M.files > 0L then s.server_nfiles <- Some t.M.files;
if t.M.users > 0L then s.server_nusers <- Some t.M.users;
(match t.M.max_users with
Some x when x > 0L -> s.server_max_users <- Some x
| _ -> ());
- (match t.M.flags with
- Some x -> s.server_flags <- x
- | _ -> ());
(match t.M.lowid_users with
Some x when x > 0L -> s.server_lowid_users <- Some x
| _ -> ());
@@ -283,30 +300,48 @@
Some x when x > 0L -> s.server_hard_limit <- Some x
| _ -> ());
server_must_update s
+ end else
+ begin
+ lprintf_nl "received PingServerReply from %s with invalid challenge:
%Ld <> %Ld"
+ (string_of_server s) challenge_v t.M.challenge;
+ s.server_udp_ping_challenge <- None;
+ end
| Udp.ServerDescReplyUdpReq t ->
let module M = Udp.ServerDescReplyUdp in
let s = udp_from_server p in
+ let check_challenge, challenge_v =
+ match s.server_udp_desc_challenge with
+ | Some challenge when challenge = t.M.challenge -> true, challenge
+ | Some challenge -> false, challenge
+ | _ -> false, 0L
+ in
+ if check_challenge then begin
+ s.server_name <- t.M.name;
+ s.server_description <- t.M.desc;
+ s.server_udp_desc_challenge <- None;
List.iter (fun tag ->
match tag with
{ tag_name = Field_UNKNOWN "version"; tag_value = Uint64 i } ->
let i = Int64.to_int i in
s.server_version <- Printf.sprintf "%d.%d" (i lsr 16) (i land
0xFFFF);
- | { tag_name = Field_UNKNOWN "servername"; tag_value = String name
} ->
- s.server_name <- name
- | { tag_name = Field_UNKNOWN "description"; tag_value = String
desc } ->
- s.server_description <- desc
| { tag_name = Field_UNKNOWN "auxportslist" ; tag_value = String
aux } ->
s.server_auxportslist <- aux
| { tag_name = Field_UNKNOWN "dynip" ; tag_value = String dynip }
->
s.server_dynip <- dynip
- | _ -> lprintf_nl "parsing Udp.ServerDescReplyUdp, unknown field
%s" (string_of_tag tag)
+ | _ -> ()
) t.M.tags;
if s.server_tags = [] then
s.server_tags <- t.M.tags;
server_must_update s
+ end else
+ begin
+ lprintf_nl "received ServerDescReply from %s with invalid challenge:
%Ld <> %Ld"
+ (string_of_server s) challenge_v t.M.challenge;
+ s.server_udp_desc_challenge <- None;
+ end
| Udp.EmuleReaskFilePingUdpReq t -> ()
- [Mldonkey-commits] mldonkey distrib/ChangeLog src/daemon/common/co..., (continued)
- [Mldonkey-commits] mldonkey distrib/ChangeLog src/daemon/common/co..., mldonkey-commits, 2006/11/13
- [Mldonkey-commits] mldonkey distrib/ChangeLog src/daemon/common/co..., mldonkey-commits, 2006/11/14
- [Mldonkey-commits] mldonkey distrib/ChangeLog src/daemon/common/co..., mldonkey-commits, 2006/11/14
- [Mldonkey-commits] mldonkey distrib/ChangeLog src/daemon/common/co..., mldonkey-commits, 2006/11/14
- [Mldonkey-commits] mldonkey distrib/ChangeLog src/daemon/common/co..., mldonkey-commits, 2006/11/14
- [Mldonkey-commits] mldonkey distrib/ChangeLog src/daemon/common/co..., mldonkey-commits, 2006/11/15
- [Mldonkey-commits] mldonkey distrib/ChangeLog src/daemon/common/co..., mldonkey-commits, 2006/11/19
- [Mldonkey-commits] mldonkey distrib/ChangeLog src/daemon/common/co..., mldonkey-commits, 2006/11/19
- [Mldonkey-commits] mldonkey distrib/ChangeLog src/daemon/common/co..., mldonkey-commits, 2006/11/21
- [Mldonkey-commits] mldonkey distrib/ChangeLog src/daemon/common/co..., mldonkey-commits, 2006/11/26
- [Mldonkey-commits] mldonkey distrib/ChangeLog src/daemon/common/co...,
mldonkey-commits <=
- [Mldonkey-commits] mldonkey distrib/ChangeLog src/daemon/common/co..., mldonkey-commits, 2006/11/28
- [Mldonkey-commits] mldonkey distrib/ChangeLog src/daemon/common/co..., mldonkey-commits, 2006/11/28