56 |
let full_client_identifier c = |
let full_client_identifier c = |
57 |
Printf.sprintf "%s (%s) '%s'" (Ip.to_string c.client_ip) (gbrand_to_string c.client_brand) c.client_name |
Printf.sprintf "%s (%s) '%s'" (Ip.to_string c.client_ip) (gbrand_to_string c.client_brand) c.client_name |
58 |
|
|
59 |
|
(* prints a new logline with date, module and starts newline *) |
60 |
|
let lprintf_nl () = |
61 |
|
lprintf "%s[EDK]: " |
62 |
|
(log_time ()); lprintf_nl2 |
63 |
|
|
64 |
|
(* prints a new logline with date, module and does not start newline *) |
65 |
|
let lprintf_n () = |
66 |
|
lprintf "%s[EDK]: " |
67 |
|
(log_time ()); lprintf |
68 |
|
|
69 |
(* Lifetime of a socket after sending interesting messages *) |
(* Lifetime of a socket after sending interesting messages *) |
70 |
let active_lifetime = 1200. |
let active_lifetime = 1200. |
71 |
|
|
127 |
let module M = DonkeyProtoClient in |
let module M = DonkeyProtoClient in |
128 |
|
|
129 |
if !verbose then |
if !verbose then |
130 |
lprintf "donkeyclient has been banned: %s %s\n" msg (full_client_identifier c); |
lprintf_nl () "donkeyclient has been banned: %s %s" msg (full_client_identifier c); |
131 |
|
|
132 |
count_banned c; |
count_banned c; |
133 |
c.client_banned <- true; |
c.client_banned <- true; |
161 |
raise Exit; |
raise Exit; |
162 |
end; |
end; |
163 |
if !verbose then |
if !verbose then |
164 |
lprintf "donkeyUploader has been warned: %s\n" |
lprintf_nl () "donkeyUploader has been warned: %s" |
165 |
(full_client_identifier c); |
(full_client_identifier c); |
166 |
if !!send_warning_messages then |
if !!send_warning_messages then |
167 |
client_send c ( M.SayReq ( |
client_send c ( M.SayReq ( |
196 |
M.AvailableSlotReq Q.t); |
M.AvailableSlotReq Q.t); |
197 |
|
|
198 |
if !verbose then |
if !verbose then |
199 |
lprintf "New uploader %s\n" |
lprintf_nl () "New uploader %s" |
200 |
(full_client_identifier c); |
(full_client_identifier c); |
201 |
|
|
202 |
) |
) |
247 |
(try |
(try |
248 |
c.client_comp <- None; |
c.client_comp <- None; |
249 |
if c.client_debug then begin |
if c.client_debug then begin |
250 |
CommonGlobals.print_localtime (); |
lprintf_nl () "Client[%d]: disconnected" (client_num c); |
|
lprintf "Client[%d]: disconnected" (client_num c); |
|
251 |
end; |
end; |
252 |
(try if c.client_checked then count_seen c with _ -> ()); |
(try if c.client_checked then count_seen c with _ -> ()); |
253 |
(try if !!log_clients_on_console && c.client_name <> "" then |
(try if !!log_clients_on_console && c.client_name <> "" then |
287 |
c.client_file_queue <- []; |
c.client_file_queue <- []; |
288 |
if c.client_upload != None then CommonUploads.refill_upload_slots (); |
if c.client_upload != None then CommonUploads.refill_upload_slots (); |
289 |
|
|
290 |
with e -> lprintf "Exception %s in disconnect_client\n" |
with e -> lprintf_nl () "Exception %s in disconnect_client" |
291 |
(Printexc2.to_string e)); |
(Printexc2.to_string e)); |
292 |
(* lprintf "Client %d to source:" (client_num c); |
(* lprintf "Client %d to source:" (client_num c); |
293 |
List.iter (fun r -> |
List.iter (fun r -> |
382 |
) group.group; |
) group.group; |
383 |
if !list <> [] then begin |
if !list <> [] then begin |
384 |
if !verbose_sources > 2 then begin |
if !verbose_sources > 2 then begin |
385 |
lprintf "Send %d sources from file groups to mldonkey peer\n" (List.length !list); |
lprintf_nl () "Send %d sources from file groups to mldonkey peer" (List.length !list); |
386 |
end; |
end; |
387 |
let msg = |
let msg = |
388 |
let module Q = DonkeyProtoClient.Sources in |
let module Q = DonkeyProtoClient.Sources in |
405 |
UdpClientMap.iter (fun _ uc -> |
UdpClientMap.iter (fun _ uc -> |
406 |
if uc.udp_client_can_receive then begin |
if uc.udp_client_can_receive then begin |
407 |
if !verbose_sources > 2 then |
if !verbose_sources > 2 then |
408 |
lprintf "Send new source to file groups UDP peers\n"; |
lprintf_nl () "Send new source to file groups UDP peers"; |
409 |
udp_client_send uc ( |
udp_client_send uc ( |
410 |
Udp.QueryLocationReplyUdpReq ( |
Udp.QueryLocationReplyUdpReq ( |
411 |
let module Q = DonkeyProtoServer.QueryLocationReply in |
let module Q = DonkeyProtoServer.QueryLocationReply in |
632 |
| 6 -> Brand_hydranode |
| 6 -> Brand_hydranode |
633 |
| 10 -> Brand_mldonkey3 |
| 10 -> Brand_mldonkey3 |
634 |
| 20 -> Brand_lphant |
| 20 -> Brand_lphant |
635 |
| _ -> lprintf_nl "EDK: unknown compatibleclient %d (please report to dev team)" num; Brand_unknown |
| _ -> lprintf_nl () "unknown compatibleclient %d (please report to dev team)" num; Brand_unknown |
636 |
|
|
637 |
let identify_emule_release num brand = |
let identify_emule_release num brand = |
638 |
let s = Misc.dec2bin num 32 in |
let s = Misc.dec2bin num 32 in |
738 |
end |
end |
739 |
| _ -> |
| _ -> |
740 |
if !verbose_msg_clients then |
if !verbose_msg_clients then |
741 |
lprintf "Unknown Emule tag: [%s]\n" (escaped_string_of_field tag) |
lprintf_nl () "Unknown Emule tag: [%s]" (escaped_string_of_field tag) |
742 |
) tags |
) tags |
743 |
|
|
744 |
let fight_disguised_mods c = |
let fight_disguised_mods c = |
846 |
(* ask for more sources *) |
(* ask for more sources *) |
847 |
begin |
begin |
848 |
if !verbose_location then |
if !verbose_location then |
849 |
lprintf "donkeyClient: Requesting sources from client %s that queried file %s\n" |
lprintf_nl () "donkeyClient: Requesting sources from client %s that queried file %s" |
850 |
(full_client_identifier c) (file_best_name file); |
(full_client_identifier c) (file_best_name file); |
851 |
let module E = M.EmuleRequestSources in |
let module E = M.EmuleRequestSources in |
852 |
client_send c (M.EmuleRequestSourcesReq file.file_md4) |
client_send c (M.EmuleRequestSourcesReq file.file_md4) |
884 |
let module M = DonkeyProtoClient in |
let module M = DonkeyProtoClient in |
885 |
|
|
886 |
if !verbose_msg_clients then begin |
if !verbose_msg_clients then begin |
887 |
lprintf "Compared to:\n"; |
lprintf_nl () "Compared to:"; |
888 |
match file.file_swarmer with |
match file.file_swarmer with |
889 |
None -> () |
None -> () |
890 |
| Some swarmer -> |
| Some swarmer -> |
891 |
lprintf " %s\n" (Int64Swarmer.verified_bitmap swarmer); |
lprintf_nl () " %s" (Int64Swarmer.verified_bitmap swarmer); |
892 |
end; |
end; |
893 |
|
|
894 |
let chunks = |
let chunks = |
898 |
Array.create file.file_nchunks true |
Array.create file.file_nchunks true |
899 |
else |
else |
900 |
if Array.length chunks <> file.file_nchunks then begin |
if Array.length chunks <> file.file_nchunks then begin |
901 |
lprintf "BAD BAD BAD: number of chunks is different %d/%d for %s:%Ld on peer\n" (Array.length chunks) file.file_nchunks (Md4.to_string file.file_md4) (file_size file); |
lprintf_nl () "BAD BAD BAD: number of chunks is different %d/%d for %s:%Ld on peer" (Array.length chunks) file.file_nchunks (Md4.to_string file.file_md4) (file_size file); |
902 |
lprintf "Peer info: name=[%s] md4=[%s] overnet=[%s] brand=[%s]\n" |
lprintf_nl () "Peer info: name=[%s] md4=[%s] overnet=[%s] brand=[%s]" |
903 |
c.client_name |
c.client_name |
904 |
(Md4.to_string c.client_md4) |
(Md4.to_string c.client_md4) |
905 |
(string_of_bool (DonkeySources.source_brand c.client_source)) |
(string_of_bool (DonkeySources.source_brand c.client_source)) |
968 |
let module M = DonkeyProtoClient in |
let module M = DonkeyProtoClient in |
969 |
|
|
970 |
if !verbose_msg_clients || c.client_debug then begin |
if !verbose_msg_clients || c.client_debug then begin |
971 |
CommonGlobals.print_localtime (); |
lprintf_n () "Message from %s" (string_of_client c); |
|
lprintf "Message from %s" (string_of_client c); |
|
972 |
M.print t; |
M.print t; |
973 |
lprintf_nl "" |
lprint_newline () |
974 |
end; |
end; |
975 |
|
|
976 |
match t with |
match t with |
1019 |
let s1 = c.client_emule_proto.emule_release in |
let s1 = c.client_emule_proto.emule_release in |
1020 |
let s2 = gbrand_mod_to_string c.client_mod_brand in |
let s2 = gbrand_mod_to_string c.client_mod_brand in |
1021 |
if s1 <> "" then |
if s1 <> "" then |
1022 |
lprintf_nl " [%s%s %s]\n" |
lprintf_nl () " [%s%s %s]" |
1023 |
(gbrand_to_string c.client_brand) |
(gbrand_to_string c.client_brand) |
1024 |
(if s2 <> "" then Printf.sprintf "(%s)" s2 else "") |
(if s2 <> "" then Printf.sprintf "(%s)" s2 else "") |
1025 |
s1 |
s1 |
1026 |
else |
else |
1027 |
lprintf_nl "\n" |
lprint_newline () |
1028 |
end; |
end; |
1029 |
|
|
1030 |
begin |
begin |
1080 |
update_emule_proto_from_tags c t.CI.tags; |
update_emule_proto_from_tags c t.CI.tags; |
1081 |
|
|
1082 |
if !verbose_msg_clienttags then |
if !verbose_msg_clienttags then |
1083 |
lprintf "Message from client[%d] %s %s tags: %s\n" |
lprintf_nl () "Message from client[%d] %s %s tags: %s" |
1084 |
(client_num c) |
(client_num c) |
1085 |
(match c.client_kind with |
(match c.client_kind with |
1086 |
Indirect_address _ | Invalid_address _ -> "" |
Indirect_address _ | Invalid_address _ -> "" |
1122 |
if !sources <> [] then |
if !sources <> [] then |
1123 |
begin |
begin |
1124 |
if !verbose_location then |
if !verbose_location then |
1125 |
lprintf "donkeyClient: EmuleRequestSourcesReq: Sending %d Sources to %s for file %s\n" |
lprintf_nl () "donkeyClient: EmuleRequestSourcesReq: Sending %d Sources to %s for file %s" |
1126 |
(List.length !sources) (full_client_identifier c) (file_best_name file); |
(List.length !sources) (full_client_identifier c) (file_best_name file); |
1127 |
client_send c ( |
client_send c ( |
1128 |
M.EmuleRequestSourcesReplyReq { |
M.EmuleRequestSourcesReplyReq { |
1139 |
let module Q = M.ViewFilesReply in |
let module Q = M.ViewFilesReply in |
1140 |
begin |
begin |
1141 |
if !verbose_msg_clients then |
if !verbose_msg_clients then |
1142 |
lprintf "Received ViewFilesReply\n"; |
lprintf_nl () "Received ViewFilesReply"; |
1143 |
try |
try |
1144 |
let list = ref [] in |
let list = ref [] in |
1145 |
List.iter (fun f -> |
List.iter (fun f -> |
1154 |
client_must_update c |
client_must_update c |
1155 |
|
|
1156 |
with e -> |
with e -> |
1157 |
lprintf "Exception in ViewFilesReply %s\n" |
lprintf_nl () "Exception in ViewFilesReply %s" |
1158 |
(Printexc2.to_string e); |
(Printexc2.to_string e); |
1159 |
end; |
end; |
1160 |
|
|
1173 |
match c.client_download with |
match c.client_download with |
1174 |
| Some (file,up) -> |
| Some (file,up) -> |
1175 |
if !verbose_download then begin |
if !verbose_download then begin |
1176 |
lprintf "DonkeyClient: Clear download\n"; |
lprintf_nl () "Clear download"; |
1177 |
end; |
end; |
1178 |
Int64Swarmer.clear_uploader_ranges up; |
Int64Swarmer.clear_uploader_ranges up; |
1179 |
c.client_download <- None |
c.client_download <- None |
1186 |
let files, _ = try |
let files, _ = try |
1187 |
let v = Hashtbl.find join_queue_by_md4 c.client_md4 in |
let v = Hashtbl.find join_queue_by_md4 c.client_md4 in |
1188 |
if c.client_debug then |
if c.client_debug then |
1189 |
lprintf "Recovered file queue by md4\n"; |
lprintf_nl () "Recovered file queue by md4"; |
1190 |
v |
v |
1191 |
with _ -> |
with _ -> |
1192 |
let id = client_id c in |
let id = client_id c in |
1193 |
let v = Hashtbl.find join_queue_by_id id in |
let v = Hashtbl.find join_queue_by_id id in |
1194 |
if c.client_debug then |
if c.client_debug then |
1195 |
lprintf "Recovered file queue by md4\n"; |
lprintf_nl () "Recovered file queue by md4"; |
1196 |
v |
v |
1197 |
in |
in |
1198 |
List.iter (fun (file, chunks) -> |
List.iter (fun (file, chunks) -> |
1201 |
(* DonkeyOneFile.restart_download c *) |
(* DonkeyOneFile.restart_download c *) |
1202 |
with _ -> |
with _ -> |
1203 |
if c.client_debug then |
if c.client_debug then |
1204 |
lprintf "AvailableSlot received, but not file to download !!\n"; |
lprintf_nl () "AvailableSlot received, but not file to download!"; |
1205 |
(* TODO: ask for the files now *) |
(* TODO: ask for the files now *) |
1206 |
end; |
end; |
1207 |
(* now, we can forget we have asked for a slot *) |
(* now, we can forget we have asked for a slot *) |
1253 |
end else *) |
end else *) |
1254 |
CommonUploads.add_pending_slot (as_client c); |
CommonUploads.add_pending_slot (as_client c); |
1255 |
if !verbose then |
if !verbose then |
1256 |
lprintf "donkeyClient: uploader couldn't get a slot: %s\n" |
lprintf_nl () "donkeyClient: uploader couldn't get a slot: %s" |
1257 |
(full_client_identifier c); |
(full_client_identifier c); |
1258 |
(* end *) |
(* end *) |
1259 |
|
|
1265 |
None -> () |
None -> () |
1266 |
| Some (file,up) -> |
| Some (file,up) -> |
1267 |
if !verbose_download then begin |
if !verbose_download then begin |
1268 |
lprintf "Slot closed during download\n"; |
lprintf_nl () "Slot closed during download"; |
1269 |
end; |
end; |
1270 |
Int64Swarmer.clear_uploader_ranges up |
Int64Swarmer.clear_uploader_ranges up |
1271 |
end; |
end; |
1277 |
[] -> () |
[] -> () |
1278 |
| _ -> |
| _ -> |
1279 |
if !verbose_download then begin |
if !verbose_download then begin |
1280 |
lprintf "CloseSlotReq\n"; |
lprintf_nl () "CloseSlotReq"; |
1281 |
end; |
end; |
1282 |
DonkeyOneFile.request_slot c; |
DonkeyOneFile.request_slot c; |
1283 |
set_rtimeout sock !!queued_timeout; |
set_rtimeout sock !!queued_timeout; |
1338 |
let file = find_file t.Q.md4 in |
let file = find_file t.Q.md4 in |
1339 |
received_client_bitmap c file t.Q.chunks |
received_client_bitmap c file t.Q.chunks |
1340 |
with e -> |
with e -> |
1341 |
lprintf "Exception %s in Query Chunks Reply file-md4: %s client was %s\n" |
lprintf_nl () "Exception %s in Query Chunks Reply file-md4: %s client was %s" |
1342 |
(Printexc2.to_string e) (Md4.to_string t.Q.md4) |
(Printexc2.to_string e) (Md4.to_string t.Q.md4) |
1343 |
(full_client_identifier c) |
(full_client_identifier c) |
1344 |
end |
end |
1350 |
|
|
1351 |
let module Q = M.QueryChunkMd4Reply in |
let module Q = M.QueryChunkMd4Reply in |
1352 |
if !verbose then begin |
if !verbose then begin |
1353 |
lprintf "MD4 FOR CHUNKS RECEIVED\n"; |
lprintf_nl () "MD4 FOR CHUNKS RECEIVED"; |
1354 |
end; |
end; |
1355 |
|
|
1356 |
if file.file_computed_md4s <> [||] then begin |
if file.file_computed_md4s <> [||] then begin |
1357 |
if !verbose_hidden_errors then |
if !verbose_hidden_errors then |
1358 |
lprintf "[WARNING] Discarding Chunks Md4: already here\n"; |
lprintf_nl () "[WARNING] Discarding Chunks Md4: already here"; |
1359 |
end else |
end else |
1360 |
if file.file_nchunks = 1 then begin |
if file.file_nchunks = 1 then begin |
1361 |
lprintf "[ERROR]: one chunk file without md4\n"; |
lprintf_nl () "[ERROR]: one chunk file without md4"; |
1362 |
file.file_computed_md4s <- [|file.file_md4|]; |
file.file_computed_md4s <- [|file.file_md4|]; |
1363 |
match file.file_swarmer with |
match file.file_swarmer with |
1364 |
None -> () |
None -> () |
1367 |
(Verification [| Ed2k file.file_md4 |]) |
(Verification [| Ed2k file.file_md4 |]) |
1368 |
end else |
end else |
1369 |
if t.Q.chunks = [||] then begin |
if t.Q.chunks = [||] then begin |
1370 |
lprintf "[ERROR]: empty multiple chunks message\n"; |
lprintf_nl () "[ERROR]: empty multiple chunks message"; |
1371 |
end |
end |
1372 |
else |
else |
1373 |
if Array.length t.Q.chunks <> file.file_nchunks then begin |
if Array.length t.Q.chunks <> file.file_nchunks then begin |
1374 |
lprintf "BAD BAD BAD (2): number of chunks is different %d/%d for %s:%Ld on peer\n" (Array.length t.Q.chunks) file.file_nchunks (Md4.to_string file.file_md4) (file_size file); |
lprintf_nl () "BAD BAD BAD (2): number of chunks is different %d/%d for %s:%Ld on peer" (Array.length t.Q.chunks) file.file_nchunks (Md4.to_string file.file_md4) (file_size file); |
1375 |
(* What should we do ? |
(* What should we do ? |
1376 |
|
|
1377 |
1) Try to recover the correct size of the file: we can use |
1) Try to recover the correct size of the file: we can use |
1390 |
let md4s = t.Q.chunks in |
let md4s = t.Q.chunks in |
1391 |
let md4 = DonkeyShare.md4_of_array md4s in |
let md4 = DonkeyShare.md4_of_array md4s in |
1392 |
if md4 <> file.file_md4 then begin |
if md4 <> file.file_md4 then begin |
1393 |
lprintf "[ERROR]: Bad list of MD4s, discarding\n"; |
lprintf_nl () "[ERROR]: Bad list of MD4s, discarding"; |
1394 |
end else begin |
end else begin |
1395 |
file_md4s_to_register := file :: !file_md4s_to_register; |
file_md4s_to_register := file :: !file_md4s_to_register; |
1396 |
file.file_computed_md4s <- md4s; |
file.file_computed_md4s <- md4s; |
1413 |
set_lifetime sock active_lifetime; |
set_lifetime sock active_lifetime; |
1414 |
if !!reliable_sources && |
if !!reliable_sources && |
1415 |
client_reliability c = Reliability_suspicious 0 then begin |
client_reliability c = Reliability_suspicious 0 then begin |
1416 |
lprintf "Receiving data from unreliable client, disconnect\n"; |
lprintf_nl () "Receiving data from unreliable client, disconnect"; |
1417 |
corruption_warning c; |
corruption_warning c; |
1418 |
disconnect_client c (Closed_for_error "Unreliable Source"); |
disconnect_client c (Closed_for_error "Unreliable Source"); |
1419 |
raise Not_found |
raise Not_found |
1437 |
|
|
1438 |
(* lprintf "Comp bloc: %d/%d\n" comp.comp_len comp.comp_total; *) |
(* lprintf "Comp bloc: %d/%d\n" comp.comp_len comp.comp_total; *) |
1439 |
if comp.comp_len = comp.comp_total then begin |
if comp.comp_len = comp.comp_total then begin |
1440 |
if !verbose_download then begin |
if !verbose_download then |
1441 |
lprintf "Complete Compressed bloc received !!!!!!\n"; |
lprintf_nl () "Complete compressed block received!"; |
|
end; |
|
1442 |
|
|
1443 |
let s = String.create comp.comp_len in |
let s = String.create comp.comp_len in |
1444 |
let rec iter list = |
let rec iter list = |
1454 |
assert (pos = comp.comp_len); |
assert (pos = comp.comp_len); |
1455 |
if Autoconf.has_zlib then |
if Autoconf.has_zlib then |
1456 |
let s = Autoconf.zlib__uncompress_string2 s in |
let s = Autoconf.zlib__uncompress_string2 s in |
1457 |
if !verbose then begin |
if !verbose then |
1458 |
lprintf "Decompressed: %d/%d\n" (String.length s) comp.comp_len; |
lprintf_nl () "Decompressed: %d/%d" (String.length s) comp.comp_len; |
|
end; |
|
1459 |
|
|
1460 |
DonkeyOneFile.block_received c comp.comp_md4 |
DonkeyOneFile.block_received c comp.comp_md4 |
1461 |
comp.comp_pos s 0 (String.length s) |
comp.comp_pos s 0 (String.length s) |
1462 |
else |
else |
1463 |
lprintf "ERROR: No Zlib to uncompress packet"; |
lprintf_nl () "ERROR: No Zlib to uncompress packet"; |
1464 |
|
|
1465 |
c.client_comp <- None; |
c.client_comp <- None; |
1466 |
end else |
end else |
1467 |
if comp.comp_len > comp.comp_total then begin |
if comp.comp_len > comp.comp_total then begin |
1468 |
if !verbose_hidden_errors then |
if !verbose_hidden_errors then |
1469 |
lprintf "ERROR: more data than compressed!!!\n"; |
lprintf_nl () "ERROR: more data than compressed!"; |
1470 |
c.client_comp <- None; |
c.client_comp <- None; |
1471 |
end |
end |
1472 |
|
|
1475 |
set_lifetime sock active_lifetime; |
set_lifetime sock active_lifetime; |
1476 |
if !!reliable_sources && |
if !!reliable_sources && |
1477 |
client_reliability c = Reliability_suspicious 0 then begin |
client_reliability c = Reliability_suspicious 0 then begin |
1478 |
lprintf "Receiving data from unreliable client, disconnect\n"; |
lprintf_nl () "Receiving data from unreliable client, disconnect"; |
1479 |
corruption_warning c; |
corruption_warning c; |
1480 |
disconnect_client c (Closed_for_error "Unreliable Source"); |
disconnect_client c (Closed_for_error "Unreliable Source"); |
1481 |
raise Not_found |
raise Not_found |
1488 |
let end_pos = t.Q.end_pos in |
let end_pos = t.Q.end_pos in |
1489 |
let len = Int64.sub end_pos begin_pos in |
let len = Int64.sub end_pos begin_pos in |
1490 |
if Int64.to_int len <> t.Q.bloc_len then begin |
if Int64.to_int len <> t.Q.bloc_len then begin |
1491 |
lprintf "%d: inconsistent packet sizes\n" (client_num c); |
lprintf_nl () "%d: inconsistent packet sizes" (client_num c); |
1492 |
raise Not_found |
raise Not_found |
1493 |
end; |
end; |
1494 |
|
|
1512 |
lprintf "ASK VIEW FILES\n"; |
lprintf "ASK VIEW FILES\n"; |
1513 |
*) |
*) |
1514 |
if !verbose_msg_clients then |
if !verbose_msg_clients then |
1515 |
lprintf "Sending %d Files in ViewFilesReqReply\n" (List.length !published_files); |
lprintf_nl () "Sending %d Files in ViewFilesReqReply" (List.length !published_files); |
1516 |
client_send_files sock !published_files |
client_send_files sock !published_files |
1517 |
|
|
1518 |
| M.QueryFileReq t -> |
| M.QueryFileReq t -> |
1529 |
c.client_brand <- Brand_mldonkey1; |
c.client_brand <- Brand_mldonkey1; |
1530 |
if c.client_brand = Brand_mldonkey1 || c.client_brand = Brand_mldonkey2 then begin |
if c.client_brand = Brand_mldonkey1 || c.client_brand = Brand_mldonkey2 then begin |
1531 |
if !verbose then |
if !verbose then |
1532 |
lprintf "donkeyClient:QueryFileReq: Client %s is really old mldonkey1/2 and queried file %s\n" |
lprintf_nl () "donkeyClient:QueryFileReq: Client %s is really old mldonkey1/2 and queried file %s" |
1533 |
(full_client_identifier c) (Md4.to_string md4); |
(full_client_identifier c) (Md4.to_string md4); |
1534 |
if Random.int 100 < 3 && !!send_warning_messages then |
if Random.int 100 < 3 && !!send_warning_messages then |
1535 |
client_send c ( |
client_send c ( |
1569 |
|
|
1570 |
with Not_found -> |
with Not_found -> |
1571 |
if !verbose_unexpected_messages then |
if !verbose_unexpected_messages then |
1572 |
lprintf "donkeyClient: QueryFileReq: Client %s queried unpublished file %s\n" (full_client_identifier c) (Md4.to_string md4); |
lprintf_nl () "donkeyClient: QueryFileReq: Client %s queried unpublished file %s" (full_client_identifier c) (Md4.to_string md4); |
1573 |
client_send c ( |
client_send c ( |
1574 |
M.NoSuchFileReq md4); |
M.NoSuchFileReq md4); |
1575 |
|
|
1576 |
if !verbose then begin |
if !verbose then begin |
1577 |
lprintf "DUMPING File table\n"; |
lprintf_nl () "DUMPING File table"; |
1578 |
Hashtbl.iter (fun md4 _ -> |
Hashtbl.iter (fun md4 _ -> |
1579 |
lprintf " %s\n" (Md4.to_string md4) |
lprintf_nl () " %s" (Md4.to_string md4) |
1580 |
) files_by_md4; |
) files_by_md4; |
1581 |
end |
end |
1582 |
| e -> |
| e -> |
1583 |
lprintf "Exception %s in QueryFileReq\n" |
lprintf_nl () "Exception %s in QueryFileReq" |
1584 |
(Printexc.to_string e) |
(Printexc.to_string e) |
1585 |
end; |
end; |
1586 |
|
|
1598 |
|
|
1599 |
end else *) |
end else *) |
1600 |
if !verbose_location then |
if !verbose_location then |
1601 |
lprintf "donkeyClient: EmuleRequestSourcesReply: Received %d sources from %s for %s\n" |
lprintf_nl () "donkeyClient: EmuleRequestSourcesReply: Received %d sources from %s for %s" |
1602 |
(Array.length t.Q.sources) (full_client_identifier c) (file_best_name file); |
(Array.length t.Q.sources) (full_client_identifier c) (file_best_name file); |
1603 |
|
|
1604 |
Array.iter (fun s -> |
Array.iter (fun s -> |
1621 |
|
|
1622 |
end else *) |
end else *) |
1623 |
if !verbose_location then |
if !verbose_location then |
1624 |
lprintf "donkeyClient: SourcesReq: Received %d sources from %s for %s\n" |
lprintf_nl () "donkeyClient: SourcesReq: Received %d sources from %s for %s" |
1625 |
(List.length t.Q.sources) (full_client_identifier c) (file_best_name file); |
(List.length t.Q.sources) (full_client_identifier c) (file_best_name file); |
1626 |
List.iter (fun (ip1, port, ip2) -> |
List.iter (fun (ip1, port, ip2) -> |
1627 |
add_source file ip1 port Ip.null 0 |
add_source file ip1 port Ip.null 0 |
1715 |
with |
with |
1716 |
| _ -> |
| _ -> |
1717 |
if !verbose_unexpected_messages then |
if !verbose_unexpected_messages then |
1718 |
lprintf "donkeyClient:QueryChunksReq: chunks of unpublished file %s queried from %s\n" |
lprintf_nl () "donkeyClient:QueryChunksReq: chunks of unpublished file %s queried from %s" |
1719 |
(Md4.to_string t) (full_client_identifier c); |
(Md4.to_string t) (full_client_identifier c); |
1720 |
client_send c ( M.NoSuchFileReq t ); |
client_send c ( M.NoSuchFileReq t ); |
1721 |
end |
end |
1724 |
client_has_a_slot (as_client c) -> |
client_has_a_slot (as_client c) -> |
1725 |
|
|
1726 |
if !verbose then |
if !verbose then |
1727 |
lprintf "donkeyClient: uploader %s ask for block\n" (full_client_identifier c); |
lprintf_nl () "donkeyClient: uploader %s ask for block" (full_client_identifier c); |
1728 |
|
|
1729 |
let module Q = M.QueryBloc in |
let module Q = M.QueryBloc in |
1730 |
let file = find_file t.Q.md4 in |
let file = find_file t.Q.md4 in |
1785 |
up.up_waiting <- true |
up.up_waiting <- true |
1786 |
end |
end |
1787 |
end; |
end; |
1788 |
if !verbose_upload then lprintf "QueryBloc treated\n" |
if !verbose_upload then lprintf_nl () "QueryBloc treated" |
1789 |
|
|
1790 |
| M.NoSuchFileReq t -> |
| M.NoSuchFileReq t -> |
1791 |
begin |
begin |
1792 |
try |
try |
1793 |
let file = find_file t in |
let file = find_file t in |
1794 |
if !verbose_location then |
if !verbose_location then |
1795 |
lprintf "donkeyClient: NoSuchFileReq: from %s for file %s\n" |
lprintf_nl () "donkeyClient: NoSuchFileReq: from %s for file %s" |
1796 |
(full_client_identifier c) (file_best_name file); |
(full_client_identifier c) (file_best_name file); |
1797 |
DonkeySources.set_request_result c.client_source |
DonkeySources.set_request_result c.client_source |
1798 |
file.file_sources File_not_found; |
file.file_sources File_not_found; |
1801 |
|
|
1802 |
| _ -> |
| _ -> |
1803 |
if !verbose_unknown_messages then begin |
if !verbose_unknown_messages then begin |
1804 |
lprintf "Unused Client Message:\n"; |
lprintf_nl () "Unused Client Message:"; |
1805 |
M.print t; |
M.print t; |
1806 |
lprintf_nl "" |
lprint_newline () |
1807 |
end |
end |
1808 |
|
|
1809 |
let client_handler c sock event = |
let client_handler c sock event = |
1892 |
let module M = DonkeyProtoClient in |
let module M = DonkeyProtoClient in |
1893 |
|
|
1894 |
if !verbose_msg_clients then begin |
if !verbose_msg_clients then begin |
1895 |
CommonGlobals.print_localtime (); |
lprintf_n () "Message from incoming client"; |
|
lprintf "Message from incoming client"; |
|
1896 |
M.print m; |
M.print m; |
1897 |
lprintf_nl "" |
lprint_newline () |
1898 |
end; |
end; |
1899 |
|
|
1900 |
match m with |
match m with |
1939 |
let c = new_client kind in |
let c = new_client kind in |
1940 |
|
|
1941 |
if c.client_debug || !verbose_msg_clients || !verbose_msg_clienttags then begin |
if c.client_debug || !verbose_msg_clients || !verbose_msg_clienttags then begin |
1942 |
lprintf "First Message: "; |
lprintf_n () "First Message: "; |
1943 |
M.print m; |
M.print m; |
1944 |
lprintf_nl "\n" |
lprint_newline () |
1945 |
end; |
end; |
1946 |
|
|
1947 |
Hashtbl.add connected_clients t.CR.md4 c; |
Hashtbl.add connected_clients t.CR.md4 c; |
1987 |
Some (ip, port) -> if !!update_server_list_client then safe_add_server ip port |
Some (ip, port) -> if !!update_server_list_client then safe_add_server ip port |
1988 |
| None -> |
| None -> |
1989 |
if overnet then begin |
if overnet then begin |
1990 |
lprintf "incoming Overnet client\n"; |
lprintf_nl () "incoming Overnet client"; |
1991 |
DonkeySources.set_source_brand c.client_source overnet; |
DonkeySources.set_source_brand c.client_source overnet; |
1992 |
end |
end |
1993 |
end; |
end; |
2042 |
Some c |
Some c |
2043 |
|
|
2044 |
| M.NewUserIDReq _ -> |
| M.NewUserIDReq _ -> |
2045 |
lprintf "NewUserIDReq: "; M.print m; lprintf_nl ""; |
lprintf_n () "NewUserIDReq: "; M.print m; lprint_newline (); |
2046 |
None |
None |
2047 |
|
|
2048 |
| _ -> |
| _ -> |
2049 |
if !verbose_hidden_errors then |
if !verbose_hidden_errors then |
2050 |
begin |
begin |
2051 |
lprintf "BAD MESSAGE FROM CONNECTING CLIENT with ip:%s port:%i overnet:%b\n" |
lprintf_nl () "BAD MESSAGE FROM CONNECTING CLIENT with ip:%s port:%i overnet:%b" |
2052 |
(Ip.to_string (peer_ip sock)) (peer_port sock) overnet; |
(Ip.to_string (peer_ip sock)) (peer_port sock) overnet; |
2053 |
M.print m; lprintf "\n"; |
M.print m; lprint_newline (); |
2054 |
end; |
end; |
2055 |
close sock (Closed_for_error "bad connecting message"); |
close sock (Closed_for_error "bad connecting message"); |
2056 |
raise Not_found |
raise Not_found |
2152 |
) |
) |
2153 |
|
|
2154 |
with e -> |
with e -> |
2155 |
lprintf "Exception %s in client connection\n" |
lprintf_nl () "Exception %s in client connection" |
2156 |
(Printexc2.to_string e); |
(Printexc2.to_string e); |
2157 |
(* connection_failed c.client_connection_control; *) |
(* connection_failed c.client_connection_control; *) |
2158 |
set_client_disconnected c (Closed_for_exception e); |
set_client_disconnected c (Closed_for_exception e); |
2171 |
let nlocs = List.length t.Q.locs in |
let nlocs = List.length t.Q.locs in |
2172 |
|
|
2173 |
if !verbose_location then |
if !verbose_location then |
2174 |
lprintf "EDK: Received %d sources from server %s:%s for %s\n" |
lprintf_nl () "EDK: Received %d sources from server %s:%s for %s" |
2175 |
nlocs (Ip.to_string s.server_ip) (string_of_int s.server_port) (file_best_name file); |
nlocs (Ip.to_string s.server_ip) (string_of_int s.server_port) (file_best_name file); |
2176 |
|
|
2177 |
s.server_score <- s.server_score + 3; |
s.server_score <- s.server_score + 3; |
2231 |
(DonkeyProtoCom.client_handler2 c (read_first_message overnet) |
(DonkeyProtoCom.client_handler2 c (read_first_message overnet) |
2232 |
(client_to_client [])); |
(client_to_client [])); |
2233 |
|
|
2234 |
with e -> lprintf "Exception %s in init_connection\n" |
with e -> lprintf_nl () "Exception %s in init_connection" |
2235 |
(Printexc2.to_string e); |
(Printexc2.to_string e); |
2236 |
); |
); |
2237 |
with e -> |
with e -> |
2238 |
lprintf "Exception %s in client_connection_handler\n" |
lprintf_nl () "Exception %s in client_connection_handler" |
2239 |
(Printexc2.to_string e); |
(Printexc2.to_string e); |
2240 |
Unix.close s) |
Unix.close s) |
2241 |
end |
end |
2299 |
ignore (DonkeySources.add_request c.client_source |
ignore (DonkeySources.add_request c.client_source |
2300 |
file.file_sources (last_time ())) |
file.file_sources (last_time ())) |
2301 |
with e -> |
with e -> |
2302 |
if !verbose then begin |
if !verbose then |
2303 |
lprintf "DonkeyClient.query_source: exception %s\n" |
lprintf_nl () "query_source: exception %s" |
2304 |
(Printexc2.to_string e); |
(Printexc2.to_string e) |
|
end |
|
2305 |
); |
); |
2306 |
|
|
2307 |
DonkeySources.functions.DonkeySources.function_connect <- |
DonkeySources.functions.DonkeySources.function_connect <- |
2320 |
|
|
2321 |
with e -> |
with e -> |
2322 |
if !verbose then begin |
if !verbose then begin |
2323 |
lprintf "DonkeyClient.connect_source: exception %s\n" |
lprintf_nl () "connect_source: exception %s" |
2324 |
(Printexc2.to_string e); |
(Printexc2.to_string e); |
2325 |
end |
end |
2326 |
); |
); |
2355 |
|
|
2356 |
with e -> |
with e -> |
2357 |
if !verbose then begin |
if !verbose then begin |
2358 |
lprintf "DonkeyClient.add_location: exception %s\n" |
lprintf_nl () "add_location: exception %s" |
2359 |
(Printexc2.to_string e); |
(Printexc2.to_string e); |
2360 |
end |
end |
2361 |
); |
); |
2370 |
|
|
2371 |
with e -> |
with e -> |
2372 |
if !verbose then begin |
if !verbose then begin |
2373 |
lprintf "DonkeyClient.remove_location: exception %s\n" |
lprintf_nl () "remove_location: exception %s" |
2374 |
(Printexc2.to_string e); |
(Printexc2.to_string e); |
2375 |
end |
end |
2376 |
) |
) |