81 |
[ |
[ |
82 |
NetworkHasMultinet; |
NetworkHasMultinet; |
83 |
NetworkHasUpload; |
NetworkHasUpload; |
84 |
|
NetworkHasStats; |
85 |
] |
] |
86 |
|
|
87 |
let connection_manager = network.network_connection_manager |
let connection_manager = network.network_connection_manager |
183 |
file.file_trackers <- (List.map (fun url -> { |
file.file_trackers <- (List.map (fun url -> { |
184 |
tracker_url = url; |
tracker_url = url; |
185 |
tracker_interval = 600; |
tracker_interval = 600; |
186 |
|
tracker_min_interval = 600; |
187 |
tracker_last_conn = 0; |
tracker_last_conn = 0; |
188 |
tracker_last_clients_num = 0; |
tracker_last_clients_num = 0; |
189 |
|
tracker_torrent_downloaded = 0; |
190 |
|
tracker_torrent_complete = 0; |
191 |
|
tracker_torrent_incomplete = 0; |
192 |
|
tracker_torrent_total_clients_count = 0; |
193 |
|
tracker_torrent_last_dl_req = 0; |
194 |
|
tracker_id = ""; |
195 |
|
tracker_key = ""; |
196 |
} ) file_trackers) @ file.file_trackers |
} ) file_trackers) @ file.file_trackers |
197 |
|
|
198 |
let new_file file_id t torrent_diskname file_temp file_state = |
let new_file file_id t torrent_diskname file_temp file_state = |
199 |
try |
try |
200 |
Hashtbl.find files_by_uid file_id |
Hashtbl.find files_by_uid file_id |
206 |
file_piece_size = t.torrent_piece_size; |
file_piece_size = t.torrent_piece_size; |
207 |
file_id = file_id; |
file_id = file_id; |
208 |
file_name = t.torrent_name; |
file_name = t.torrent_name; |
209 |
|
file_comment = t.torrent_comment; |
210 |
|
file_created_by = t.torrent_created_by; |
211 |
|
file_creation_date = t.torrent_creation_date; |
212 |
|
file_modified_by = t.torrent_modified_by; |
213 |
|
file_encoding = t.torrent_encoding; |
214 |
file_clients_num = 0; |
file_clients_num = 0; |
215 |
file_clients = Hashtbl.create 113; |
file_clients = Hashtbl.create 113; |
216 |
file_swarmer = None; |
file_swarmer = None; |
233 |
impl_file_best_name = t.torrent_name; |
impl_file_best_name = t.torrent_name; |
234 |
} |
} |
235 |
in |
in |
236 |
set_trackers file [t.torrent_announce]; |
if List.length t.torrent_announce_list > 1 then |
237 |
|
set_trackers file t.torrent_announce_list |
238 |
|
else |
239 |
|
set_trackers file [t.torrent_announce]; |
240 |
if file_state <> FileShared then begin |
if file_state <> FileShared then begin |
241 |
let kernel = Int64Swarmer.create_swarmer file_temp (file_size file) |
let kernel = Int64Swarmer.create_swarmer file_temp (file_size file) |
242 |
(min max_range_len file.file_piece_size) in |
(min max_range_len file.file_piece_size) in |
259 |
if (bitmap.[num] <> '1') then |
if (bitmap.[num] <> '1') then |
260 |
send_client c (Have (Int64.of_int num)); |
send_client c (Have (Int64.of_int num)); |
261 |
check_if_interesting file c |
check_if_interesting file c |
262 |
end |
end |
263 |
) file.file_clients |
) file.file_clients |
264 |
|
|
265 |
); |
); |
340 |
let ch = char_of_int c in |
let ch = char_of_int c in |
341 |
List.for_all (fun i -> s.[i] = ch) l |
List.for_all (fun i -> s.[i] = ch) l |
342 |
|
|
343 |
|
(* Old decoding routines *) |
344 |
|
|
345 |
(* from azureus/gpl *) |
(* from azureus/gpl *) |
346 |
let decode_az_style s = |
let decode_az_style s = |
347 |
if check_all s 45 [0;7] then begin |
if check_all s 45 [0;7] then begin |
348 |
let s_id = (String.sub s 1 2) in |
let s_id = (String.sub s 1 2) in |
349 |
let result = ref |
let result = ref |
350 |
(match s_id with |
(match s_id with |
351 |
|
| "AR" -> "Arctic" |
352 |
| "AZ" -> "Azureus" |
| "AZ" -> "Azureus" |
353 |
| "BB" -> "BitBuddy" |
| "BB" -> "BitBuddy" |
354 |
| "BX" -> "Bittorrent X" |
| "BC" -> "BitComet" |
355 |
| "BS" -> "BTSlave" |
| "BS" -> "BTSlave" |
356 |
|
| "BX" -> "Bittorrent X" |
357 |
| "CT" -> "CTorrent" |
| "CT" -> "CTorrent" |
358 |
| "LT" -> "libTorrent" |
| "LT" -> "libTorrent" |
359 |
|
| "MT" -> "MoonlightTorrent" |
360 |
|
| "SB" -> "Swiftbit" |
361 |
|
| "SN" -> "ShareNET" |
362 |
|
| "SS" -> "SwarmScope" |
363 |
| "TN" -> "Torrent.NET" |
| "TN" -> "Torrent.NET" |
364 |
| "TS" -> "TorrentStorm" |
| "TS" -> "TorrentStorm" |
|
| "SS" -> "SwarmScope" |
|
|
| "SN" -> "ShareNET" |
|
|
| "MT" -> "MoonlightTorrent" |
|
365 |
| "XT" -> "XanTorrent" |
| "XT" -> "XanTorrent" |
|
| "bk" -> "BitKitten (libtorrent)" |
|
366 |
| "ZT" -> "ZipTorrent" |
| "ZT" -> "ZipTorrent" |
367 |
| "AR" -> "Arctic" |
| "bk" -> "BitKitten (libtorrent)" |
|
| "SB" -> "Swiftbit" |
|
368 |
| _ -> "") |
| _ -> "") |
369 |
in |
in |
370 |
if not (!result = "") then |
(if (s_id = "BC") then |
371 |
result := !result ^ " " ^ (dot_string (String.sub s 3 4)); |
result := !result ^ " " ^ (String.sub s 4 1) ^ "." ^ (String.sub s 5 2) |
372 |
|
else |
373 |
|
if not (!result = "") then |
374 |
|
result := !result ^ " " ^ (dot_string (String.sub s 3 4))); |
375 |
!result; |
!result; |
376 |
end else "" |
end else "" |
377 |
|
|
499 |
"UPnP " ^ (dot_string (String.sub s 1 3)) |
"UPnP " ^ (dot_string (String.sub s 1 3)) |
500 |
else "" |
else "" |
501 |
|
|
502 |
let decode_bitcomet s = |
let decode_old_bitcomet s = |
503 |
if "exbc" = String.sub s 0 4 then |
if "exbc" = String.sub s 0 4 then |
504 |
Printf.sprintf "BitComet %d.%d%d" |
let bit_sub = if "LORD" = String.sub s 6 4 then |
505 |
|
"Lord" else "Comet" in |
506 |
|
Printf.sprintf "Bit%s %d.%d%d" |
507 |
|
(bit_sub) |
508 |
(int_of_char s.[4]) |
(int_of_char s.[4]) |
509 |
((int_of_char s.[5]) / 10) |
((int_of_char s.[5]) / 10) |
510 |
((int_of_char s.[5]) mod 10) |
((int_of_char s.[5]) mod 10) |
552 |
); |
); |
553 |
!result |
!result |
554 |
|
|
555 |
|
(* format is : "-ML" ^ version ( of unknown length) ^ "-" ^ random bytes ( of unknown length) *) |
556 |
|
let decode_mldonkey_style s = |
557 |
|
if check_all s 45 [0] then begin |
558 |
|
let s_id = String.sub s 1 2 in |
559 |
|
let result = ref |
560 |
|
(match s_id with |
561 |
|
| "ML" -> "MLDonkey" |
562 |
|
| _ -> "") |
563 |
|
in |
564 |
|
if !result != "" then |
565 |
|
result := !result ^ " " ^ String.sub s 3 (( |
566 |
|
try String.index_from s 1 s.[0] with Not_found -> 3) - 3); |
567 |
|
!result |
568 |
|
end else "" |
569 |
|
|
570 |
let parse_software s = |
let parse_software s = |
571 |
try |
try |
572 |
let rec try_styles i = |
let rec try_styles i = |
573 |
if i > 16 then "UNKNOWN" else begin |
if i > 17 then |
574 |
|
begin |
575 |
|
lprintf_nl () "Unknown BT client found please report the next line to the dev team :\nBTUC:\"%s\"" (String.escaped s); |
576 |
|
"UNKNOWN" |
577 |
|
end |
578 |
|
else begin |
579 |
let res = ref |
let res = ref |
580 |
(match i with |
(match i with |
581 |
| 0 -> decode_az_style s |
| 0 -> decode_az_style s |
591 |
| 10 -> decode_shadow s |
| 10 -> decode_shadow s |
592 |
| 11 -> decode_bitspirit s |
| 11 -> decode_bitspirit s |
593 |
| 12 -> decode_upnp s |
| 12 -> decode_upnp s |
594 |
| 13 -> decode_bitcomet s |
| 13 -> decode_old_bitcomet s |
595 |
| 14 -> decode_shareaza s |
| 14 -> decode_shareaza s |
596 |
| 15 -> decode_non_zero s |
| 15 -> decode_non_zero s |
597 |
| 16 -> if (Sha1.null) = (Sha1.direct_of_string s) then |
| 16 -> decode_mldonkey_style s |
598 |
|
| 17 -> if (Sha1.null) = (Sha1.direct_of_string s) then |
599 |
"NULL" else "" |
"NULL" else "" |
600 |
| _ -> "ERROR" |
| _ -> "ERROR" |
601 |
) |
) |
606 |
try_styles 0 |
try_styles 0 |
607 |
with _ -> "ERROR" |
with _ -> "ERROR" |
608 |
|
|
609 |
|
(* new decoding routines *) |
610 |
|
|
611 |
|
let brand_to_int b = |
612 |
|
match b with |
613 |
|
Brand_unknown -> 0 |
614 |
|
| Brand_abc -> 1 |
615 |
|
| Brand_arctic -> 2 |
616 |
|
| Brand_azureus -> 3 |
617 |
|
| Brand_bitbuddy -> 4 |
618 |
|
| Brand_bitcomet -> 5 |
619 |
|
| Brand_bitkitten -> 6 |
620 |
|
| Brand_bitlord -> 7 |
621 |
|
| Brand_bitsonwheels -> 8 |
622 |
|
| Brand_bitspirit -> 9 |
623 |
|
| Brand_bittornado -> 10 |
624 |
|
| Brand_bittorrentx -> 11 |
625 |
|
| Brand_btplus -> 12 |
626 |
|
| Brand_btslave -> 13 |
627 |
|
| Brand_btugaxp -> 14 |
628 |
|
| Brand_burst -> 15 |
629 |
|
| Brand_ctorrent -> 16 |
630 |
|
| Brand_deadmanwalking -> 17 |
631 |
|
| Brand_exeem -> 18 |
632 |
|
| Brand_experimental -> 19 |
633 |
|
| Brand_g3torrent -> 20 |
634 |
|
| Brand_libtorrent -> 21 |
635 |
|
| Brand_mainline -> 22 |
636 |
|
| Brand_martiniman -> 23 |
637 |
|
| Brand_mldonkey -> 24 |
638 |
|
| Brand_moonlighttorrent -> 25 |
639 |
|
| Brand_plus -> 26 |
640 |
|
| Brand_shadow -> 27 |
641 |
|
| Brand_sharenet -> 28 |
642 |
|
| Brand_shareaza -> 29 |
643 |
|
| Brand_simplebt -> 30 |
644 |
|
| Brand_snark -> 31 |
645 |
|
| Brand_swarmscope -> 32 |
646 |
|
| Brand_swarmy -> 33 |
647 |
|
| Brand_swiftbit -> 34 |
648 |
|
| Brand_teeweety -> 35 |
649 |
|
| Brand_torrentdotnet -> 36 |
650 |
|
| Brand_torrentstorm -> 37 |
651 |
|
| Brand_turbobt -> 38 |
652 |
|
| Brand_upnp -> 39 |
653 |
|
| Brand_xantorrent -> 40 |
654 |
|
| Brand_xbt -> 41 |
655 |
|
| Brand_ziptorrent -> 42 |
656 |
|
|
657 |
|
|
658 |
|
let brand_of_int b = |
659 |
|
match b with |
660 |
|
0 -> Brand_unknown |
661 |
|
| 1 -> Brand_abc |
662 |
|
| 2 -> Brand_arctic |
663 |
|
| 3 -> Brand_azureus |
664 |
|
| 4 -> Brand_bitbuddy |
665 |
|
| 5 -> Brand_bitcomet |
666 |
|
| 6 -> Brand_bitkitten |
667 |
|
| 7 -> Brand_bitlord |
668 |
|
| 8 -> Brand_bitsonwheels |
669 |
|
| 9 -> Brand_bitspirit |
670 |
|
| 10 -> Brand_bittornado |
671 |
|
| 11 -> Brand_bittorrentx |
672 |
|
| 12 -> Brand_btplus |
673 |
|
| 13 -> Brand_btslave |
674 |
|
| 14 -> Brand_btugaxp |
675 |
|
| 15 -> Brand_burst |
676 |
|
| 16 -> Brand_ctorrent |
677 |
|
| 17 -> Brand_deadmanwalking |
678 |
|
| 18 -> Brand_exeem |
679 |
|
| 19 -> Brand_experimental |
680 |
|
| 20 -> Brand_g3torrent |
681 |
|
| 21 -> Brand_libtorrent |
682 |
|
| 22 -> Brand_mainline |
683 |
|
| 23 -> Brand_martiniman |
684 |
|
| 24 -> Brand_mldonkey |
685 |
|
| 25 -> Brand_moonlighttorrent |
686 |
|
| 26 -> Brand_plus |
687 |
|
| 27 -> Brand_shadow |
688 |
|
| 28 -> Brand_sharenet |
689 |
|
| 29 -> Brand_shareaza |
690 |
|
| 30 -> Brand_simplebt |
691 |
|
| 31 -> Brand_snark |
692 |
|
| 32 -> Brand_swarmscope |
693 |
|
| 33 -> Brand_swarmy |
694 |
|
| 34 -> Brand_swiftbit |
695 |
|
| 35 -> Brand_teeweety |
696 |
|
| 36 -> Brand_torrentdotnet |
697 |
|
| 37 -> Brand_torrentstorm |
698 |
|
| 38 -> Brand_turbobt |
699 |
|
| 39 -> Brand_upnp |
700 |
|
| 40 -> Brand_xantorrent |
701 |
|
| 41 -> Brand_xbt |
702 |
|
| 42 -> Brand_ziptorrent |
703 |
|
| _ -> raise Not_found |
704 |
|
|
705 |
|
let brand_to_string b = |
706 |
|
match b with |
707 |
|
Brand_unknown -> "unknown" |
708 |
|
| Brand_abc -> "ABC" |
709 |
|
| Brand_arctic -> "Arctic" |
710 |
|
| Brand_azureus -> "Azureus" |
711 |
|
| Brand_bitbuddy -> "Bitbuddy" |
712 |
|
| Brand_bitcomet -> "BitComet" |
713 |
|
| Brand_bitkitten -> "BitKitten (libTorrent)" |
714 |
|
| Brand_bitlord -> "BitLord" |
715 |
|
| Brand_bitsonwheels -> "BitsOnWheels" |
716 |
|
| Brand_bitspirit -> "BitSpirit" |
717 |
|
| Brand_bittornado -> "BitTornado" |
718 |
|
| Brand_bittorrentx -> "BitTorrent X" |
719 |
|
| Brand_btplus -> "BitTorrent Plus!" |
720 |
|
| Brand_btslave -> "BTSlave" |
721 |
|
| Brand_btugaxp -> "BTugaXP" |
722 |
|
| Brand_burst -> "Burst !" |
723 |
|
| Brand_ctorrent -> "CTorrent" |
724 |
|
| Brand_deadmanwalking -> "Deadman Walking" |
725 |
|
| Brand_exeem -> "eXeem" |
726 |
|
| Brand_experimental -> "Experimental" |
727 |
|
| Brand_g3torrent -> "G3 Torrent" |
728 |
|
| Brand_libtorrent -> "libTorrent" |
729 |
|
| Brand_mainline -> "Mainline" |
730 |
|
| Brand_martiniman -> "Martini Man" |
731 |
|
| Brand_mldonkey -> "MLdonkey" |
732 |
|
| Brand_moonlighttorrent -> "MoonlightTorrent" |
733 |
|
| Brand_plus -> "Plus" |
734 |
|
| Brand_shadow -> "Shad0w" |
735 |
|
| Brand_sharenet -> "Sharenet" |
736 |
|
| Brand_shareaza -> "Shareaza" |
737 |
|
| Brand_simplebt -> "SimpleBT" |
738 |
|
| Brand_snark -> "Snark" |
739 |
|
| Brand_swarmscope -> "SwarmScope" |
740 |
|
| Brand_swarmy -> "Swarmy" |
741 |
|
| Brand_swiftbit -> "SwiftBit" |
742 |
|
| Brand_teeweety -> "Teeweety" |
743 |
|
| Brand_torrentdotnet -> "Torrent.NET" |
744 |
|
| Brand_torrentstorm -> "TorrentStorm" |
745 |
|
| Brand_turbobt -> "TurboBT" |
746 |
|
| Brand_upnp -> "UPNP" |
747 |
|
| Brand_xantorrent -> "XanTorrent" |
748 |
|
| Brand_xbt -> "XBT" |
749 |
|
| Brand_ziptorrent -> "ZipTorrent" |
750 |
|
|
751 |
|
let parse_brand s = |
752 |
|
try |
753 |
|
let the_answer s = |
754 |
|
(* azureus *) |
755 |
|
if check_all s 45 [0;7] then begin |
756 |
|
let s_id = (String.sub s 1 2) in |
757 |
|
let result = ref |
758 |
|
(match s_id with |
759 |
|
| "AR" -> Brand_arctic |
760 |
|
| "AZ" -> Brand_azureus |
761 |
|
| "BB" -> Brand_bitbuddy |
762 |
|
| "BC" -> Brand_bitcomet |
763 |
|
| "BS" -> Brand_btslave |
764 |
|
| "BX" -> Brand_bittorrentx |
765 |
|
| "CT" -> Brand_ctorrent |
766 |
|
| "LT" -> Brand_libtorrent |
767 |
|
| "MT" -> Brand_moonlighttorrent |
768 |
|
| "SB" -> Brand_swiftbit |
769 |
|
| "SN" -> Brand_sharenet |
770 |
|
| "SS" -> Brand_swarmscope |
771 |
|
| "TN" -> Brand_torrentdotnet |
772 |
|
| "TS" -> Brand_torrentstorm |
773 |
|
| "XT" -> Brand_xantorrent |
774 |
|
| "ZT" -> Brand_ziptorrent |
775 |
|
| "bk" -> Brand_bitkitten |
776 |
|
| _ -> Brand_unknown) |
777 |
|
in |
778 |
|
!result; |
779 |
|
end |
780 |
|
else |
781 |
|
(* mainline *) |
782 |
|
if check_all s 45 [2;4;6;7] then begin |
783 |
|
let s_id = String.sub s 0 1 in |
784 |
|
let result = ref |
785 |
|
(match s_id with |
786 |
|
| "M" -> Brand_mainline |
787 |
|
| _ -> Brand_unknown) |
788 |
|
in |
789 |
|
(* if !result != "" then |
790 |
|
result := !result ^ " " ^ dot_string_of_list s [1;3;5]; |
791 |
|
*) |
792 |
|
!result; |
793 |
|
end |
794 |
|
else |
795 |
|
(* simple style *) |
796 |
|
let simple_list = ref |
797 |
|
[ |
798 |
|
(5, "Azureus", Brand_azureus); |
799 |
|
(0, "A", Brand_abc); |
800 |
|
(14, "HTTPBT", Brand_bitcomet); |
801 |
|
(16, "UDP0", Brand_bitcomet); |
802 |
|
(6, "LORD", Brand_bitlord); |
803 |
|
(0, "exbc", Brand_bitcomet); |
804 |
|
(0, "BOW", Brand_bitsonwheels); |
805 |
|
(0, "BS", Brand_bitspirit); |
806 |
|
(0, "T03", Brand_bittornado); |
807 |
|
(0, "Plus", Brand_btplus); |
808 |
|
(0, "PRC.P---", Brand_btplus); |
809 |
|
(0, "P87.P---", Brand_btplus); |
810 |
|
(0, "S587Plus", Brand_btplus); |
811 |
|
(0, "oernu", Brand_btugaxp); |
812 |
|
(0, "btuga", Brand_btugaxp); |
813 |
|
(4, "btuga", Brand_btugaxp); |
814 |
|
(0, "BTDWV-", Brand_deadmanwalking); |
815 |
|
(0, "Deadman Walking-", Brand_deadmanwalking); |
816 |
|
(0, "eX", Brand_exeem); |
817 |
|
(0, "-G3", Brand_g3torrent); |
818 |
|
(0, "martini", Brand_martiniman); |
819 |
|
(0, "Mbrst", Brand_burst); |
820 |
|
(0, "S", Brand_shadow); |
821 |
|
(4, "btfans", Brand_simplebt); |
822 |
|
(0, "a00---0", Brand_swarmy); |
823 |
|
(0, "a02---0", Brand_swarmy); |
824 |
|
(0, "turbobt", Brand_turbobt); |
825 |
|
(0, "T00---0", Brand_teeweety); |
826 |
|
(0, "U", Brand_upnp); |
827 |
|
(0, "DansClient", Brand_xantorrent); |
828 |
|
(0, "XBT", Brand_xbt); |
829 |
|
] |
830 |
|
in |
831 |
|
let len = List.length !simple_list in |
832 |
|
let rec check pos = |
833 |
|
if pos >= len then Brand_unknown |
834 |
|
else |
835 |
|
let (x,y,z) = List.nth !simple_list pos in |
836 |
|
if (String.sub s x (String.length y)) = y then z |
837 |
|
else check (pos+1); |
838 |
|
in |
839 |
|
if (check 0) != Brand_unknown then |
840 |
|
check 0 |
841 |
|
else |
842 |
|
(* shareaza *) |
843 |
|
let rec not_zeros pos = |
844 |
|
if pos > 15 then true else |
845 |
|
if s.[pos] = (char_of_int 0) then false else not_zeros (pos+1) |
846 |
|
in |
847 |
|
let rec weird_crap pos = |
848 |
|
if pos > 19 then true else |
849 |
|
let i1 = (int_of_char s.[pos]) in |
850 |
|
let i2 = (int_of_char s.[(pos mod 16)]) in |
851 |
|
let i3 = (int_of_char s.[(15 - (pos mod 16))]) in |
852 |
|
if not (i1 = (i2 lxor i3)) then false else weird_crap (pos+1) |
853 |
|
in |
854 |
|
if (not_zeros 0) && (weird_crap 16) then Brand_shareaza |
855 |
|
else |
856 |
|
if check_all s 3 [9;10;11] then Brand_snark |
857 |
|
else |
858 |
|
(* mldonkey style *) |
859 |
|
if check_all s 45 [0] then begin |
860 |
|
let s_id = String.sub s 1 2 in |
861 |
|
let result = ref |
862 |
|
(match s_id with |
863 |
|
| "ML" -> Brand_mldonkey |
864 |
|
| _ -> Brand_unknown) |
865 |
|
in |
866 |
|
(* if !result != "" then |
867 |
|
result := !result ^ " " ^ String.sub s 3 (( |
868 |
|
try String.index_from s 1 s.[0] with Not_found -> 3) - 3); |
869 |
|
*) |
870 |
|
!result; |
871 |
|
end |
872 |
|
else |
873 |
|
Brand_unknown |
874 |
|
in |
875 |
|
the_answer s |
876 |
|
with _ -> Brand_unknown |
877 |
|
|
878 |
let new_client file peer_id kind = |
let new_client file peer_id kind = |
879 |
try |
try |
880 |
let c = Hashtbl.find file.file_clients kind in |
let c = Hashtbl.find file.file_clients kind in |
898 |
client_range_waiting = None; |
client_range_waiting = None; |
899 |
client_block = None; |
client_block = None; |
900 |
client_uid = peer_id; |
client_uid = peer_id; |
901 |
|
client_brand = if peer_id != Sha1.null then |
902 |
|
(parse_brand (Sha1.direct_to_string peer_id)) |
903 |
|
else Brand_unknown; |
904 |
|
client_release = ""; |
905 |
client_bitmap = None; |
client_bitmap = None; |
906 |
client_allowed_to_write = zero; |
client_allowed_to_write = zero; |
907 |
client_uploaded = zero; |
client_uploaded = zero; |
934 |
file.file_clients_num <- file.file_clients_num + 1; |
file.file_clients_num <- file.file_clients_num + 1; |
935 |
file_add_source (as_file file) (as_client c); |
file_add_source (as_file file) (as_client c); |
936 |
c |
c |
937 |
|
|
938 |
let remove_file file = |
let remove_file file = |
939 |
Hashtbl.remove files_by_uid file.file_id; |
Hashtbl.remove files_by_uid file.file_id; |
940 |
current_files := List2.removeq file !current_files |
current_files := List2.removeq file !current_files |
941 |
|
|
942 |
let remove_client c = |
let remove_client c = |
943 |
Hashtbl.remove c.client_file.file_clients c.client_host ; |
Hashtbl.remove c.client_file.file_clients c.client_host ; |
944 |
c.client_file.file_clients_num <- c.client_file.file_clients_num - 1; |
c.client_file.file_clients_num <- c.client_file.file_clients_num - 1; |
945 |
file_remove_source (as_file c.client_file) (as_client c) |
file_remove_source (as_file c.client_file) (as_client c) |
946 |
|
|
947 |
let old_torrents_directory = "torrents" |
let remove_tracker url file = |
948 |
let downloads_directory = Filename.concat old_torrents_directory "downloads" |
if !verbose_msg_servers then |
949 |
let tracked_directory = Filename.concat old_torrents_directory "tracked" |
List.iter (fun tracker -> |
950 |
let seeded_directory = Filename.concat old_torrents_directory "seeded" |
lprintf_nl () "Old tracker list :%s" tracker.tracker_url |
951 |
|
) file.file_trackers; |
952 |
|
List.iter (fun bad_tracker -> |
953 |
|
if bad_tracker.tracker_url = url then |
954 |
|
file.file_trackers <- List2.remove_first bad_tracker file.file_trackers; |
955 |
|
) file.file_trackers; |
956 |
|
if !verbose_msg_servers then |
957 |
|
List.iter (fun tracker -> |
958 |
|
lprintf_nl () "New tracker list :%s" tracker.tracker_url |
959 |
|
) file.file_trackers |
960 |
|
|
961 |
|
let torrents_directory = "torrents" |
962 |
|
let downloads_directory = Filename.concat torrents_directory "downloads" |
963 |
|
let tracked_directory = Filename.concat torrents_directory "tracked" |
964 |
|
let seeded_directory = Filename.concat torrents_directory "seeded" |
965 |
|
let old_directory = Filename.concat torrents_directory "old" |