635 |
|
|
636 |
| Field_UNKNOWN "emule_miscoptions1" -> |
| Field_UNKNOWN "emule_miscoptions1" -> |
637 |
for_int64_tag tag (fun i -> |
for_int64_tag tag (fun i -> |
638 |
DonkeyProtoClient.update_emule_proto_from_miscoptions1 |
DonkeyProtoClient.update_emule_proto_from_miscoptions1 |
639 |
c.client_emule_proto i) |
c.client_emule_proto i) |
640 |
| Field_UNKNOWN "emule_version" -> |
| Field_UNKNOWN "emule_version" -> |
641 |
for_int_tag tag (fun i -> |
for_int_tag tag (fun i -> |
643 |
| _ -> () |
| _ -> () |
644 |
) tags |
) tags |
645 |
|
|
646 |
let update_emule_proto_from_tags c tags = |
let update_emule_proto_from_tags c tags = |
647 |
List.iter (fun tag -> |
List.iter (fun tag -> |
648 |
match tag.tag_name with |
match tag.tag_name with |
649 |
Field_UNKNOWN "compatibleclient" -> |
Field_UNKNOWN "compatibleclient" -> |
650 |
for_int_tag tag (fun i -> |
for_int_tag tag (fun i -> |
651 |
match i with |
match i with |
652 |
1 -> c.client_brand <- Brand_cdonkey |
1 -> c.client_brand <- Brand_cdonkey |
653 |
| 2 -> c.client_brand <- Brand_lmule |
| 2 -> c.client_brand <- Brand_lmule |
654 |
| 3 -> c.client_brand <- Brand_amule |
| 3 -> c.client_brand <- Brand_amule |
658 |
| 10 -> c.client_brand <- Brand_mldonkey3 |
| 10 -> c.client_brand <- Brand_mldonkey3 |
659 |
| 20 -> c.client_brand <- Brand_lphant |
| 20 -> c.client_brand <- Brand_lphant |
660 |
| _ -> () |
| _ -> () |
661 |
) |
) |
662 |
| Field_UNKNOWN "compression" -> |
| Field_UNKNOWN "compression" -> |
663 |
for_int_tag tag (fun i -> |
for_int_tag tag (fun i -> |
664 |
c.client_emule_proto.emule_compression <- i) |
c.client_emule_proto.emule_compression <- i) |
665 |
| Field_UNKNOWN "udpver" -> |
| Field_UNKNOWN "udpver" -> |
666 |
for_int_tag tag (fun i -> |
for_int_tag tag (fun i -> |
667 |
c.client_emule_proto.emule_udpver <- i) |
c.client_emule_proto.emule_udpver <- i) |
668 |
| Field_UNKNOWN "udpport" -> () |
| Field_UNKNOWN "udpport" -> () |
669 |
| Field_UNKNOWN "sourceexchange" -> |
| Field_UNKNOWN "sourceexchange" -> |
670 |
for_int_tag tag (fun i -> |
for_int_tag tag (fun i -> |
671 |
c.client_emule_proto.emule_sourceexchange <- i) |
c.client_emule_proto.emule_sourceexchange <- i) |
672 |
| Field_UNKNOWN "comments" -> |
| Field_UNKNOWN "comments" -> |
673 |
for_int_tag tag (fun i -> |
for_int_tag tag (fun i -> |
674 |
c.client_emule_proto.emule_comments <- i) |
c.client_emule_proto.emule_comments <- i) |
675 |
| Field_UNKNOWN "extendedrequest" -> |
| Field_UNKNOWN "extendedrequest" -> |
676 |
for_int_tag tag (fun i -> |
for_int_tag tag (fun i -> |
677 |
c.client_emule_proto.emule_extendedrequest <- i) |
c.client_emule_proto.emule_extendedrequest <- i) |
678 |
| Field_UNKNOWN "features" -> |
| Field_UNKNOWN "features" -> |
679 |
for_int_tag tag (fun i -> |
for_int_tag tag (fun i -> |
680 |
c.client_emule_proto.emule_secident <- i land 0x3) |
c.client_emule_proto.emule_secident <- i land 0x3) |
681 |
|
|
682 |
| _ -> |
| _ -> |
683 |
if !verbose_msg_clients then |
if !verbose_msg_clients then |
684 |
lprintf "Unknown Emule tag: [%s]\n" (escaped_string_of_field tag) |
lprintf "Unknown Emule tag: [%s]\n" (escaped_string_of_field tag) |
685 |
) tags |
) tags |
686 |
|
|
687 |
let query_id ip port id = |
let rec query_id ip port id = |
688 |
let client_ip = client_ip None in |
let client_ip = client_ip None in |
689 |
|
|
690 |
(* TODO: check if we are connected to this server. If yes, issue a |
(* TODO: check if we are connected to this server. If yes, issue a |
692 |
if ip_reachable client_ip then |
if ip_reachable client_ip then |
693 |
let module Q = DonkeyProtoUdp.QueryCallUdp in |
let module Q = DonkeyProtoUdp.QueryCallUdp in |
694 |
(* lprintf "Ask connection from indirect client\n"; *) |
(* lprintf "Ask connection from indirect client\n"; *) |
695 |
|
|
696 |
let s = check_add_server ip port in |
try |
697 |
|
let s = DonkeyGlobals.find_server ip port in |
698 |
match s.server_sock with |
match s.server_sock with |
699 |
NoConnection | ConnectionWaiting _ -> |
NoConnection | ConnectionWaiting _ -> () |
700 |
|
|
701 |
(* OK, this fixes the problem with Lugdunum servers, but there should be |
(* OK, this fixes the problem with Lugdunum servers, but there should be |
702 |
another better way, since this functionnality is still useful... |
another better way, since this functionnality is still useful... |
703 |
|
|
704 |
DonkeyProtoCom.udp_send (get_udp_sock ()) |
DonkeyProtoCom.udp_send (get_udp_sock ()) |
705 |
ip (port+4) |
ip (port+4) |
706 |
(DonkeyProtoUdp.QueryCallUdpReq { |
(DonkeyProtoUdp.QueryCallUdpReq { |
707 |
Q.ip = client_ip; |
Q.ip = client_ip; |
708 |
Q.port = !!donkey_port; |
Q.port = !!donkey_port; |
709 |
Q.id = id; |
Q.id = id; |
710 |
}) *) () |
}) *) |
711 |
| Connection sock -> |
| Connection sock -> |
712 |
printf_string "[QUERY ID]"; |
printf_string "[QUERY ID]"; |
713 |
server_send sock ( |
server_send sock ( |
715 |
let module C = M.QueryID in |
let module C = M.QueryID in |
716 |
M.QueryIDReq id |
M.QueryIDReq id |
717 |
); |
); |
|
(* Fifo.put s.server_id_requests file *) |
|
718 |
() |
() |
719 |
|
with _ -> |
720 |
|
if !!update_server_list_client then |
721 |
(* I think query_file was this saying from HighTime about: |
begin |
722 |
Do not ask for all files if we don't know which files it |
ignore(check_add_server ip port); |
723 |
have. It's maybe like 3~4 times that i fix this bug and |
query_id ip port id |
724 |
it will be the last time : i won't submit another patch |
end |
|
if you don't apply this one. It's not only save some |
|
|
bandwidth but also it should allow us to not be banned |
|
|
by emule which don't like to receive lots of file |
|
|
requests. |
|
|
let query_files c sock = |
|
|
|
|
|
let s = c.client_source in |
|
|
if s.DonkeySources.source_files = [] then begin |
|
|
lprintf "Unknown Incoming clients\n"; |
|
|
List.iter (fun file -> |
|
|
if file_state file = FileDownloading then begin |
|
|
DonkeySources.set_request_result s file.file_sources |
|
|
File_possible |
|
|
end |
|
|
) !current_files; |
|
|
end *) (* else |
|
|
lprintf "Client has %d requests to emit\n" |
|
|
(List.length s.DonkeySources.source_files); *) |
|
|
|
|
|
(* |
|
|
let nall_queries = ref 0 in |
|
|
let nqueries = ref 0 in |
|
|
|
|
|
(* lprintf "Client %d:\n" (client_num c); *) |
|
|
let files = ref [] in |
|
|
(if c.client_source.DonkeySources.source_files = [] then begin |
|
|
(* lprintf " query all files\n"; *) |
|
|
files := !current_files |
|
|
|
|
|
end else |
|
|
List.iter (fun r -> |
|
|
if r.request_score > File_not_found then begin |
|
|
(* lprintf " query file %s\n" (file_best_name r.request_file); |
|
|
*) |
|
|
files := r.request_file :: !files |
|
|
end; |
|
|
) c.client_source.source_files); |
|
725 |
|
|
|
(* |
|
|
if !files = [] then begin |
|
|
lprintf " No queries to send !\n"; |
|
|
end; |
|
|
*) |
|
|
|
|
|
List.iter (fun file -> |
|
|
incr nall_queries; |
|
|
DonkeySources.query_file c file) |
|
|
!files; |
|
|
if !nqueries > 0 then |
|
|
c.client_last_filereqs <- last_time (); |
|
|
if !verbose then begin |
|
|
lprintf "sent %d/%d file queries\n" !nqueries !nall_queries; |
|
|
end |
|
|
*) |
|
726 |
|
|
727 |
external hash_param : int -> int -> 'a -> int = "caml_hash_univ_param" "noalloc" |
external hash_param : int -> int -> 'a -> int = "caml_hash_univ_param" "noalloc" |
728 |
let hash x = hash_param 10 100 x |
let hash x = hash_param 10 100 x |
949 |
|
|
950 |
begin |
begin |
951 |
match t.CR.server_info with |
match t.CR.server_info with |
952 |
Some (ip, port) -> safe_add_server ip port |
Some (ip, port) -> if !!update_server_list_client then safe_add_server ip port |
953 |
| _ -> () |
| _ -> () |
954 |
end; |
end; |
955 |
|
|
1931 |
|
|
1932 |
begin |
begin |
1933 |
match t.CR.server_info with |
match t.CR.server_info with |
1934 |
Some (ip, port) -> safe_add_server ip port |
Some (ip, port) -> if !!update_server_list_client then safe_add_server ip port |
1935 |
| None -> |
| None -> |
1936 |
if overnet then begin |
if overnet then begin |
1937 |
lprintf "incoming Overnet client\n"; |
lprintf "incoming Overnet client\n"; |