Skip to content

Commit

Permalink
Merge pull request #9 from tindy2013/dev
Browse files Browse the repository at this point in the history
  • Loading branch information
tindy2013 committed Aug 23, 2019
2 parents b2f6e45 + 7c2451a commit 948a382
Show file tree
Hide file tree
Showing 5 changed files with 308 additions and 272 deletions.
34 changes: 17 additions & 17 deletions main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -401,9 +401,9 @@ int singleTest(nodeInfo *node)
killClient(node->linkType);
return SPEEDTEST_ERROR_NOCONNECTION;
}
for(int i = 0; i < 6; i++)
for(auto &x : node->rawPing)
{
logdata += to_string(node->rawPing[i]) + " ";
logdata += to_string(x) + " ";
}
writeLog(LOG_TYPE_RAW, logdata);
writeLog(LOG_TYPE_INFO, "TCP Ping: " + node->avgPing + " Packet Loss: " + node->pkLoss);
Expand Down Expand Up @@ -437,9 +437,9 @@ int singleTest(nodeInfo *node)
writeLog(LOG_TYPE_INFO, "Now performing site ping...");
websitePing(node, "https://www.google.com/", testserver, testport, username, password);
logdata = "";
for(int i = 0; i < 6; i++)
for(auto &x : node->rawSitePing)
{
logdata += to_string(node->rawSitePing[i]) + " ";
logdata += to_string(x) + " ";
}
writeLog(LOG_TYPE_RAW, logdata);
writeLog(LOG_TYPE_INFO, "Site ping: " + node->sitePing);
Expand All @@ -453,9 +453,9 @@ int singleTest(nodeInfo *node)
writeLog(LOG_TYPE_INFO, "Now performing file download speed test...");
perform_test(node, testserver, testport, username, password, def_thread_count);
logdata = "";
for(int i = 0; i < 20; i++)
for(auto &x : node->rawSpeed)
{
logdata += to_string(node->rawSpeed[i]) + " ";
logdata += to_string(x) + " ";
}
writeLog(LOG_TYPE_RAW, logdata);
if(node->totalRecvBytes == 0)
Expand All @@ -464,9 +464,9 @@ int singleTest(nodeInfo *node)
printMsg(SPEEDTEST_ERROR_RETEST, node, rpcmode);
perform_test(node, testserver, testport, username, password, def_thread_count);
logdata = "";
for(int i = 0; i < 20; i++)
for(auto &x : node->rawSpeed)
{
logdata += to_string(node->rawSpeed[i]) + " ";
logdata += to_string(x) + " ";
}
writeLog(LOG_TYPE_RAW, logdata);
if(node->totalRecvBytes == 0)
Expand All @@ -490,7 +490,7 @@ int singleTest(nodeInfo *node)
void batchTest(vector<nodeInfo> nodes)
{
nodeInfo node;
unsigned int onlines = 0, index = 0;
unsigned int onlines = 0;
long long tottraffic = 0;

node_count = nodes.size();
Expand All @@ -508,20 +508,20 @@ void batchTest(vector<nodeInfo> nodes)
//first print out all nodes when in Web mode
if(rpcmode)
{
for(index = 0; index < node_count; index++)
for(auto &x : nodes)
{
printMsg(SPEEDTEST_MESSAGE_GOTSERVER, &nodes[index], rpcmode);
printMsg(SPEEDTEST_MESSAGE_GOTSERVER, &x, rpcmode);
}
}
//then we start testing nodes
for(index = 0; index < node_count; index++)
for(auto &x : nodes)
{
if(custom_group.size() != 0)
nodes[index].group = custom_group;
singleTest(&nodes[index]);
writeResult(&nodes[index], export_with_maxspeed);
tottraffic += nodes[index].totalRecvBytes;
if(nodes[index].online)
x.group = custom_group;
singleTest(&x);
writeResult(&x, export_with_maxspeed);
tottraffic += x.totalRecvBytes;
if(x.online)
onlines++;
}
resultEOF(speedCalc(tottraffic * 1.0), onlines, nodes.size());
Expand Down
4 changes: 2 additions & 2 deletions misc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ void StringToWstring(wstring& szDst, string str)

unsigned char FromHex(unsigned char x)
{
unsigned char y;
unsigned char y = '\0';
if (x >= 'A' && x <= 'Z')
y = x - 'A' + 10;
else if (x >= 'a' && x <= 'z')
Expand All @@ -103,7 +103,7 @@ string UrlDecode(const string& str)
assert(i + 2 < length);
unsigned char high = FromHex((unsigned char)str[++i]);
unsigned char low = FromHex((unsigned char)str[++i]);
strTemp += high*16 + low;
strTemp += high * 16 + low;
}
else
strTemp += str[i];
Expand Down
5 changes: 5 additions & 0 deletions printout.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,11 @@
#define SPEEDTEST_MESSAGE_FOUNDSSCONF 26
#define SPEEDTEST_MESSAGE_EOF 49

#define SS_DEFAULT_GROUP "SSProvider"
#define SSR_DEFAULT_GROUP "SSRProvider"
#define V2RAY_DEFAULT_GROUP "V2RayProvider"
#define SOCKS_DEFAULT_GROUP "SocksProvider"

using namespace std;

void printMsg(int index, nodeInfo *node, bool rpcmode);
Expand Down
Loading

0 comments on commit 948a382

Please sign in to comment.