summaryrefslogtreecommitdiff
path: root/server
diff options
context:
space:
mode:
authorGluzskiy Alexandr <sss@sss.chaoslab.ru>2012-01-09 00:15:02 +0200
committerGluzskiy Alexandr <sss@sss.chaoslab.ru>2012-01-09 00:15:02 +0200
commitc7c8930a93fb9305cf5cd30cb850c0dda198f03f (patch)
tree441e9c9571bb358ca34622a8a97878c10811638a /server
parent532bdbcd4a07501e8e67a04e2af3d47e88c3b404 (diff)
speedtest corrections
Diffstat (limited to 'server')
-rw-r--r--server/server/speedtest.cpp18
1 files changed, 16 insertions, 2 deletions
diff --git a/server/server/speedtest.cpp b/server/server/speedtest.cpp
index 06aaf76..bbd97d9 100644
--- a/server/server/speedtest.cpp
+++ b/server/server/speedtest.cpp
@@ -42,6 +42,7 @@ size_t speedtest::test(config::proxy_entry *p)
case config::HTTPS:
type = CURLPROXY_HTTP; //is it correct ?
curl_easy_setopt(curl, CURLOPT_HTTPPROXYTUNNEL, 1L); //required for ssl
+ curl_easy_setopt(curl, CURLOPT_USE_SSL, CURLUSESSL_TRY); //maybe required for https proxy ?
break;
case config::SOCKS4:
type = CURLPROXY_SOCKS4;
@@ -54,16 +55,24 @@ size_t speedtest::test(config::proxy_entry *p)
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, &speedtest::curl_data_callback);
curl_easy_setopt(curl, CURLOPT_WRITEDATA, (void*)&chunk);
curl_easy_setopt(curl, CURLOPT_USERAGENT, "libcurl-speedtest/0.1");
+ curl_easy_setopt(curl, CURLOPT_CONNECTTIMEOUT, "10");
+
+
timer.restart();
- curl_easy_perform(curl);
+ bool error = curl_easy_perform(curl);
double time = timer.elapsed();
curl_easy_cleanup(curl);
free(chunk.memory);
+ if(error)
+ {
+ p->speed = -1;
+ return 0;
+ }
size_t speed = 0;
if(chunk.size)
{
@@ -115,13 +124,18 @@ size_t speedtest::test(config::static_proxy_entry *p)
timer.restart();
- curl_easy_perform(curl);
+ bool error = curl_easy_perform(curl);
double time = timer.elapsed();
curl_easy_cleanup(curl);
free(chunk.memory);
+ if(error)
+ {
+ p->speed = -1;
+ return 0;
+ }
size_t speed = 0;
if(chunk.size)
{