7 "https://ria.ru/lenta/";
11 "http://en.kremlin.ru/";
12 "https://smotrim.ru/";
14 "https://tvzvezda.ru/";
15 "https://vsoloviev.ru/";
16 "https://www.1tv.ru/";
17 "https://www.vesti.ru/";
18 "https://online.sberbank.ru/";
19 "https://sberbank.ru/";
20 "https://zakupki.gov.ru/";
21 (* "https://www.gosuslugi.ru/"; *)
23 "https://www.rzd.ru/";
26 "https://www.interfax.ru/";
27 "https://www.mos.ru/uslugi/";
28 "http://government.ru/";
30 "https://www.nalog.gov.ru/";
31 "https://customs.gov.ru/";
32 "https://pfr.gov.ru/";
33 "https://rkn.gov.ru/";
34 "https://www.gazprombank.ru/";
35 "https://www.vtb.ru/";
36 "https://www.gazprom.ru/";
39 "https://www.nornickel.com/";
40 "https://www.surgutneftegas.ru/";
41 "https://www.tatneft.ru/";
42 "https://www.evraz.com/ru/";
44 "https://www.sibur.ru/";
45 "https://www.severstal.com/";
46 "https://www.metalloinvest.com/";
48 "https://rmk-group.ru/ru/";
49 "https://www.tmk-group.ru/";
50 (* "https://ya.ru/"; *)
51 "https://www.polymetalinternational.com/ru/";
52 "https://www.uralkali.com/ru/";
53 "https://www.eurosib.ru/";
60 "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/92.0.4515.131 Safari/537.36";
61 "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/92.0.4515.107 Safari/537.36";
62 "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:90.0) Gecko/20100101 Firefox/90.0";
63 "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.164 Safari/537.36";
64 "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/92.0.4515.131 Safari/537.36";
65 "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/92.0.4515.107 Safari/537.36";
66 "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.124 Safari/537.36";
67 "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/14.1.2 Safari/605.1.15";
68 "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/14.1.1 Safari/605.1.15";
69 "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101 Firefox/91.0";
79 let random a
= a
.(Random.int (Array.length a
))
83 set_useragent h
(random agents);
85 set_dnscachetimeout h
120;
86 set_connecttimeoutms h
3000;
88 set_followlocation h
true;
89 set_sslverifypeer h
false; (* ssl check must be turned off when using http_proxy, to permit https page caching*)
90 set_sslverifyhost h SSLVERIFYHOST_NONE
;
91 (* set_sslcipherlist h "DEFAULT@SECLEVEL=1"; *)
92 (* set_maxredirs h 1; *)
93 set_ipresolve h IPRESOLVE_V4
;
94 set_encoding h CURL_ENCODING_ANY
;
95 (* set_freshconnect h true; (* more connections *) *)
96 (* set_forbidreuse h true; *)
97 set_protocols h
[CURLPROTO_HTTP
; CURLPROTO_HTTPS
;];
98 set_redirprotocols h
[CURLPROTO_HTTP
; CURLPROTO_HTTPS
;];
99 (* set_maxrecvspeedlarge h (Int64.of_int (kBps*1024)); *)
102 let () = Printexc.register_printer
(function Curl.CurlException
(code
,n
,s
) -> Some
(sprintf
"%d %s %s" n s
(Curl.strerror code
)) | _
-> None
)
106 let stat = Hashtbl.create
10 in
107 targets |> Array.iter
(fun s
-> Hashtbl.add
stat s
{ ok
= 0; errors
= 0 });
110 let url = random targets in
114 set_url h
(if Random.int 3 = 0 then url else sprintf
"%s?%d" url (Random.int 2000));
115 set_writefunction h
String.length
;
117 let%lwt r
= Curl_lwt.perform h
in
118 if r
<> CURLE_OK
then failwith
@@ sprintf
"curl error %s" (Curl.strerror r
);
119 Hashtbl.replace
stat url
120 (let t = Hashtbl.find
stat url in
121 { t with ok
= t.ok
+ 1 }
125 (* print_endline @@ sprintf "FAILED: %s : %s" (Curl.get_effectiveurl h) (Printexc.to_string exn); *)
126 Hashtbl.replace
stat url
127 (let t = Hashtbl.find
stat url in
128 { t with errors
= t.errors
+ 1 }
135 let%lwt
() = Lwt_unix.sleep
1. in
136 print_endline
@@ sprintf
"%64s %10s %10s" "url" "ok" "errors";
137 targets |> Array.iter
(fun url ->
138 let { ok
; errors
} = Hashtbl.find
stat url in
139 print_endline
@@ sprintf
"%64s %10d %10d" url ok errors
144 Lwt_engine.set
(new Lwt_engine.libev
());
145 List.iter
(fun n
-> Sys.set_signal n
Sys.Signal_ignore
) [Sys.sigtstp
; Sys.sigttou
; Sys.sigttin
; Sys.sighup
; Sys.sigpipe
];
146 let (_
:int list
) = Unix.sigprocmask SIG_BLOCK
[Sys.sigtstp
; Sys.sigttou
; Sys.sigttin
; Sys.sighup
; Sys.sigpipe
] in
147 Lwt_main.run
@@ begin
148 let workers = List.init
par (fun _
-> Curl.init
()) |> List.map
worker in
149 Lwt.join
(show_stats () :: workers)
157 print_endline
@@ sprintf
"fatal exn %s" (Printexc.to_string exn
)