Skip to content

Commit

Permalink
Merge pull request #15 from tindy2013/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
tindy2013 authored Aug 27, 2019
2 parents a62716e + 873b484 commit 9feec82
Show file tree
Hide file tree
Showing 8 changed files with 79 additions and 148 deletions.
10 changes: 8 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,12 @@

## Intro
This is a C++ remake version of the original [Stair Speedtest](https://github.com/tindy2013/stairspeedtest) script. Despite its similarity to the script verion, this remake version works much more effectively, with faster node parsing, result picture rendering and even cross-platform support.

## Special Thanks
* [@NyanChanMeow](https://github.com/nyanchanmeow) for the original script [SSRSpeed](https://github.com/nyanchanmeow/ssrspeed)
* [@CareyWong](https://github.com/careywang) for Web GUI design
* [@ang830715](https://github.com/ang830715) for MacOS support
* ...and a lot of people who have helped me during the testing phase!

## Installation
### Prebuilt release
Expand Down Expand Up @@ -53,11 +59,11 @@ build.bat
## Compatibility
Tested platforms:

* Windows 10 1803 x64, Windows Server 2008 R2
* Windows 10 1803 x64, Windows Server 2008 R2 x64, Windows 7 SP1 x64
* Ubuntu 18.10
* Debian 6.3
* CentOS 7.6
* MacOS 10.14.3 Mojave
* MacOS 10.14.6 Mojave
* Android 8.0 (Termux)

Supported proxy types:
Expand Down
28 changes: 14 additions & 14 deletions build.macos.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,19 @@
mkdir obj
mkdir bin
set -e
c++ -I/usr/local/include -Wall -fexceptions -D_MACOS -DCURL_STATICLIB -g -std=c++11 -c geoip.cpp -o obj/geoip.o
c++ -I/usr/local/include -Wall -fexceptions -D_MACOS -DCURL_STATICLIB -g -std=c++11 -c logger.cpp -o obj/logger.o
c++ -I/usr/local/include -Wall -fexceptions -D_MACOS -DCURL_STATICLIB -g -std=c++11 -c main.cpp -o obj/main.o
c++ -I/usr/local/include -Wall -fexceptions -D_MACOS -DCURL_STATICLIB -g -std=c++11 -c misc.cpp -o obj/misc.o
c++ -I/usr/local/include -Wall -fexceptions -D_MACOS -DCURL_STATICLIB -g -std=c++11 -c multithread-test.cpp -o obj/multithread-test.o
c++ -I/usr/local/include -Wall -fexceptions -D_MACOS -DCURL_STATICLIB -g -std=c++11 -c printout.cpp -o obj/printout.o
c++ -I/usr/local/include -Wall -fexceptions -D_MACOS -DCURL_STATICLIB -g -std=c++11 -c processes.cpp -o obj/processes.o
c++ -I/usr/local/include -Wall -fexceptions -D_MACOS -DCURL_STATICLIB -g -std=c++11 -c renderer.cpp -o obj/renderer.o
c++ -I/usr/local/include -Wall -fexceptions -D_MACOS -DCURL_STATICLIB -g -std=c++11 -c rulematch.cpp -o obj/rulematch.o
c++ -I/usr/local/include -Wall -fexceptions -D_MACOS -DCURL_STATICLIB -g -std=c++11 -c socket.cpp -o obj/socket.o
c++ -I/usr/local/include -Wall -fexceptions -D_MACOS -DCURL_STATICLIB -g -std=c++11 -c speedtestutil.cpp -o obj/speedtestutil.o
c++ -I/usr/local/include -Wall -fexceptions -D_MACOS -DCURL_STATICLIB -g -std=c++11 -c tcping.cpp -o obj/tcping.o
c++ -I/usr/local/include -Wall -fexceptions -D_MACOS -DCURL_STATICLIB -g -std=c++11 -c webget.cpp -o obj/webget.o
c++ -g -o stairspeedtest obj/geoip.o obj/logger.o obj/main.o obj/misc.o obj/multithread-test.o obj/printout.o obj/processes.o obj/renderer.o obj/rulematch.o obj/socket.o obj/speedtestutil.o obj/tcping.o obj/webget.o -L/usr/local/lib -lcurl -lPNGwriter -lpng16 -lfreetype -lz -lssl -lcrypto -lyaml-cpp -ldl -lpthread
c++ -I/usr/local/include -I/usr/local/opt/[email protected]/include -Wall -fexceptions -D_MACOS -DCURL_STATICLIB -g -std=c++11 -c geoip.cpp -o obj/geoip.o
c++ -I/usr/local/include -I/usr/local/opt/[email protected]/include -Wall -fexceptions -D_MACOS -DCURL_STATICLIB -g -std=c++11 -c logger.cpp -o obj/logger.o
c++ -I/usr/local/include -I/usr/local/opt/[email protected]/include -Wall -fexceptions -D_MACOS -DCURL_STATICLIB -g -std=c++11 -c main.cpp -o obj/main.o
c++ -I/usr/local/include -I/usr/local/opt/[email protected]/include -Wall -fexceptions -D_MACOS -DCURL_STATICLIB -g -std=c++11 -c misc.cpp -o obj/misc.o
c++ -I/usr/local/include -I/usr/local/opt/[email protected]/include -Wall -fexceptions -D_MACOS -DCURL_STATICLIB -g -std=c++11 -c multithread-test.cpp -o obj/multithread-test.o
c++ -I/usr/local/include -I/usr/local/opt/[email protected]/include -Wall -fexceptions -D_MACOS -DCURL_STATICLIB -g -std=c++11 -c printout.cpp -o obj/printout.o
c++ -I/usr/local/include -I/usr/local/opt/[email protected]/include -Wall -fexceptions -D_MACOS -DCURL_STATICLIB -g -std=c++11 -c processes.cpp -o obj/processes.o
c++ -I/usr/local/include -I/usr/local/opt/[email protected]/include -I/usr/local/include/freetype2 -Wall -fexceptions -D_MACOS -DCURL_STATICLIB -g -std=c++11 -c renderer.cpp -o obj/renderer.o
c++ -I/usr/local/include -I/usr/local/opt/[email protected]/include -Wall -fexceptions -D_MACOS -DCURL_STATICLIB -g -std=c++11 -c rulematch.cpp -o obj/rulematch.o
c++ -I/usr/local/include -I/usr/local/opt/[email protected]/include -Wall -fexceptions -D_MACOS -DCURL_STATICLIB -g -std=c++11 -c socket.cpp -o obj/socket.o
c++ -I/usr/local/include -I/usr/local/opt/[email protected]/include -Wall -fexceptions -D_MACOS -DCURL_STATICLIB -g -std=c++11 -c speedtestutil.cpp -o obj/speedtestutil.o
c++ -I/usr/local/include -I/usr/local/opt/[email protected]/include -Wall -fexceptions -D_MACOS -DCURL_STATICLIB -g -std=c++11 -c tcping.cpp -o obj/tcping.o
c++ -I/usr/local/include -I/usr/local/opt/[email protected]/include -Wall -fexceptions -D_MACOS -DCURL_STATICLIB -g -std=c++11 -c webget.cpp -o obj/webget.o
c++ -g -o stairspeedtest obj/geoip.o obj/logger.o obj/main.o obj/misc.o obj/multithread-test.o obj/printout.o obj/processes.o obj/renderer.o obj/rulematch.o obj/socket.o obj/speedtestutil.o obj/tcping.o obj/webget.o -L/usr/local/opt/[email protected]/lib -lcurl -lPNGwriter -lpng -lfreetype -lz -lssl -lcrypto -lyaml-cpp -ldl -lpthread
chmod +x stairspeedtest

160 changes: 37 additions & 123 deletions config.macos.sh
Original file line number Diff line number Diff line change
@@ -1,123 +1,37 @@
#!/bin/bash
set -e
#initialize sudo so that no password entering during installation
sudo -v

echo installing brew
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

echo preconfigure compiler
brew install gcc

#don't remove these for non-xcode user
#cd /usr/bin
#sudo rm -f g++ gcc c++ cpp cc
#sudo ln -s /usr/local/Cellar/gcc/9.1.0/bin/c++-9 /usr/bin/c++
#sudo ln -s /usr/local/Cellar/gcc/9.1.0/bin/cpp-9 /usr/bin/cpp
#sudo ln -s /usr/local/Cellar/gcc/9.1.0/bin/g++-9 /usr/bin/g++
#sudo ln -s /usr/local/Cellar/gcc/9.1.0/bin/gcc-9 /usr/bin/gcc
#sudo ln -s /usr/local/Cellar/gcc/9.1.0/bin/gcc-9 /usr/bin/cc
#fix for cmake which uses a different path
#sudo rm -f g++ gcc c++ cpp cc
#sudo ln -s /usr/local/Cellar/gcc/9.1.0/bin/c++-9 /Library/Developer/CommandLineTools/usr/bin/c++
#sudo ln -s /usr/local/Cellar/gcc/9.1.0/bin/cpp-9 /Library/Developer/CommandLineTools/usr/bin/cpp
#sudo ln -s /usr/local/Cellar/gcc/9.1.0/bin/g++-9 /Library/Developer/CommandLineTools/usr/bin/g++
#sudo ln -s /usr/local/Cellar/gcc/9.1.0/bin/gcc-9 /Library/Developer/CommandLineTools/usr/bin/gcc
#sudo ln -s /usr/local/Cellar/gcc/9.1.0/bin/gcc-9 /Library/Developer/CommandLineTools/usr/bin/cc

echo installing tools with brew
brew install wget cmake zlib

echo downloading and compiling openssl-1.1.1c
wget https://www.openssl.org/source/openssl-1.1.1c.tar.gz
tar xvf openssl-1.1.1c.tar.gz
cd openssl-1.1.1c
#override compiler
CC=cc ./config --prefix=/usr/local
#don't install docs since we don't need them
sudo make install_sw -j8
#fix install error
sudo install libssl.a /usr/local/lib/
sudo install libssl.dylib /usr/local/lib/
sudo install libcrypto.a /usr/local/lib/
sudo install libcrypto.dylib /usr/local/lib/
cd ..

#using system-default libcurl
#echo downloading and compiling curl-7.65.1
#wget https://curl.haxx.se/download/curl-7.65.1.tar.gz
#tar xvf curl-7.65.1.tar.gz
#cd curl-7.65.1
#./configure --disable-shared --disable-ldap --disable-ldaps --disable-smtp --disable-pop3 --disable-rtmp --disable-imap --disable-gopher --disable-telnet --disable-tftp
#sudo make install -j8
#cd ..

echo downloading and compiling libpng-1.6.37
wget https://nchc.dl.sourceforge.net/project/libpng/libpng16/1.6.37/libpng-1.6.37.tar.gz
tar xvf libpng-1.6.37.tar.gz
cd libpng-1.6.37
CC=cc ./configure
sudo make install -j8
cd ..

echo downloading and compiling freetype-2.10.1
wget https://nchc.dl.sourceforge.net/project/freetype/freetype2/2.10.1/freetype-2.10.1.tar.xz
tar xvf freetype-2.10.1.tar.xz
cd freetype-2.10.1
CC=cc ./configure
sudo make install -j8
#a fix for incorrect file path
sudo mv /usr/local/include/freetype2/* /usr/local/include
sudo rmdir /usr/local/include/freetype2
cd ..

echo downloading and compiling pngwriter
git clone https://github.com/pngwriter/pngwriter
cd pngwriter
CC=cc cmake .
sudo make install -j8
#fix install error
#sudo install libPNGwriter.a /usr/local/lib/
cd ..

echo downloading and installing rapidjson
git clone https://github.com/tencent/rapidjson
cd rapidjson
CC=cc cmake .
sudo make install -j8
cd ..

#install ss-local from brew
echo installing shadowsocks-libev from brew
brew install shadowsocks-libev

#extra tools for ssr-local
#but ss-libev has already covered these

#brew install asciidoc xmlto pcre

#use brew version is okay
#echo downloading and compiling pcre-8.43
#wget https://ftp.pcre.org/pub/pcre/pcre-8.43.tar.gz
#tar xvf pcre-8.43.tar.gz
#cd pcre-8.43
#./configure
#make -j8
#sudo make install -j8
#cd ..

echo downloading and compiling shadowsocksr-libev
git clone https://github.com/shadowsocksrr/shadowsocksr-libev
cd shadowsocksr-libev
#override some warning settings
CC="cc" CFLAGS+="-Wno-format-overflow -Wno-format-truncation -Wno-sizeof-pointer-memaccess" ./configure --with-openssl-lib=/usr/local/lib --with-openssl-include=/usr/local/include --disable-documentation
make -j8
#will not directly install this one, use another method
sudo install src/ss-local /usr/local/bin/ssr-local
cd ..

echo installing v2ray from brew
brew tap v2ray/v2ray
brew install v2ray-core

echo all done!
#!/bin/bash
set -e
#initialize sudo so that no password entering during installation
sudo -v

echo installing brew
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

#install most libraries and client through brew
brew install cmake git wget [email protected] libpng yaml-cpp freetype rapidjson shadowsocks-libev

echo downloading and compiling pngwriter
git clone https://github.com/pngwriter/pngwriter
cd pngwriter
cmake .
sudo make install -j8
#fix install error
#sudo install libPNGwriter.a /usr/local/lib/
cd ..

echo downloading and compiling shadowsocksr-libev
git clone https://github.com/shadowsocksrr/shadowsocksr-libev
cd shadowsocksr-libev
./configure --with-openssl-lib=/usr/local/opt/openssl/lib --with-openssl-include=/usr/local/opt/openssl/include --disable-documentation
make -j8
#fix dynamic lib reference error
install_name_tool -change @rpath/libssl.1.1.dylib /usr/local/opt/[email protected]/lib/libssl.1.1.dylib src/ss-local
install_name_tool -change @rpath/libcrypto.1.1.dylib /usr/local/opt/[email protected]/lib/libcrypto.1.1.dylib src/ss-local
#will not directly install this one, use another method
sudo install src/ss-local /usr/local/bin/ssr-local
cd ..

echo installing v2ray from brew
brew tap v2ray/v2ray
brew install v2ray-core

echo all done!
2 changes: 1 addition & 1 deletion logger.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ string getTime(int type)
format = "%Y/%m/%d %a %H:%M:%S." + string(cMillis);
break;
case 3:
format = "%Y-%m-%d %H:%M:%S." + string(cMillis);
format = "%Y-%m-%d %H:%M:%S." + string(cMillis).substr(0, 3);
break;
}
strftime(tmpbuf, 32, format.data(), local);
Expand Down
11 changes: 7 additions & 4 deletions main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -572,7 +572,7 @@ void batchTest(vector<nodeInfo> *nodes)
resultEOF(speedCalc(tottraffic * 1.0), onlines, nodes->size());
writeLog(LOG_TYPE_INFO, "All nodes tested. Total/Online nodes: " + to_string(node_count) + "/" + to_string(onlines) + " Traffic used: " + speedCalc(tottraffic * 1.0));
exportHTML();
if(!multilink && !multilink_export_as_one_image)
if(!multilink || (multilink && !multilink_export_as_one_image))
{
printMsgDirect(SPEEDTEST_MESSAGE_PICSAVING, rpcmode);
writeLog(LOG_TYPE_INFO, "Now exporting result...");
Expand Down Expand Up @@ -788,7 +788,7 @@ int main(int argc, char* argv[])
//intro message
printMsgDirect(SPEEDTEST_MESSAGE_WELCOME, rpcmode);
getline(cin, link);
writeLog(LOG_TYPE_INFO, "Input data: " + link);
writeLog(LOG_TYPE_INFO, "Input data: " + GBKToUTF8(link));
if(rpcmode)
{
vector<string> webargs = split(link, "^");
Expand Down Expand Up @@ -850,6 +850,7 @@ int main(int argc, char* argv[])
else
{
printMsgDirect(SPEEDTEST_MESSAGE_PICSAVING, rpcmode);
curPNGPathPrefix = replace_all_distinct(resultPath, ".log", "");
for(int i = 0; i < curGroupID; i++)
{
vector<nodeInfo>().swap(nodes);
Expand All @@ -864,7 +865,6 @@ int main(int argc, char* argv[])
printMsgWithDict(SPEEDTEST_MESSAGE_PICSAVINGMULTI, rpcmode, dict, trans);
}
writeLog(LOG_TYPE_INFO, "Now exporting result for group " + to_string(i + 1) + "...");
curPNGPathPrefix = replace_all_distinct(resultPath, ".log", "");
curPNGPath = curPNGPathPrefix + "-multilink-group" + to_string(i + 1) + ".png";
pngpath = exportRender(curPNGPath, nodes, export_with_maxspeed, export_sort_method);
{
Expand All @@ -884,7 +884,10 @@ int main(int argc, char* argv[])
}
else if(allNodes.size() == 1)
{
printMsg(SPEEDTEST_MESSAGE_GOTSERVER, &allNodes[0], rpcmode);
if(rpcmode)
{
printMsg(SPEEDTEST_MESSAGE_GOTSERVER, &allNodes[0], rpcmode);
}
singleTest(&allNodes[0]);
if(single_test_force_export)
{
Expand Down
4 changes: 1 addition & 3 deletions printout.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -170,9 +170,7 @@ void printMsgDirect(int index, bool rpcmode)
int writeToFile(string path, string content, bool overwrite)
{
fstream outfile;
ios::openmode mode = ios::out;
if(!overwrite)
mode = ios::app;
ios::openmode mode = overwrite ? ios::out : ios::app;
outfile.open(path, mode);
outfile<<content<<endl;
outfile.close();
Expand Down
10 changes: 10 additions & 0 deletions speedtestutil.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -786,6 +786,16 @@ void explodeClash(Node yamlnode, string custom_port, int local_port, vector<node
}
}
}
else if(yamlnode["Proxy"][i]["obfs"].IsDefined())
{
plugin = "obfs-local";
yamlnode["Proxy"][i]["obfs"] >> pluginopts_mode;
if(yamlnode["Proxy"][i]["obfs-host"].IsDefined())
{
yamlnode["Proxy"][i]["obfs-host"] >> pluginopts_host;
}
}

if(plugin != "")
{
pluginopts = "obfs=" + pluginopts_mode;
Expand Down
2 changes: 1 addition & 1 deletion version.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#ifndef VERSION_H_INCLUDED
#define VERSION_H_INCLUDED

#define VERSION "v0.2.12-alpha"
#define VERSION "v0.2.13-alpha"

#endif // VERSION_H_INCLUDED

0 comments on commit 9feec82

Please sign in to comment.