Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

d #298

Draft
wants to merge 136 commits into
base: master
Choose a base branch
from
Draft

d #298

Changes from 8 commits
Commits
Show all changes
136 commits
Select commit Hold shift + click to select a range
e0e36b8
WIP integration of CC
Bendr0id Jul 5, 2018
c08ee3f
Integrate CC client and wip config
Bendr0id Jul 5, 2018
7ba9f71
WIP config file
Bendr0id Jul 6, 2018
bb90777
WIP config
Bendr0id Jul 6, 2018
2ff1b77
Fix config file parsing
Bendr0id Jul 7, 2018
79d8a76
Fix publish of stats
Bendr0id Jul 7, 2018
72d7bec
Fixed windows build
Bendr0id Jul 14, 2018
bddb7a7
Merge branch 'develop'
Bendr0id Jul 14, 2018
3047e65
Merge remote-tracking branch 'xmrig/dev'
Bendr0id Jul 14, 2018
778c528
Fixed config file storage
Bendr0id Jul 16, 2018
86677da
Update version.h
Bendr0id Jul 16, 2018
7137a51
Update CMakeLists.txt
Bendr0id Jul 16, 2018
8e7d903
Update README.md
Bendr0id Jul 17, 2018
36e11e1
Update README.md
Bendr0id Jul 17, 2018
bfb7634
Update README.md
Bendr0id Jul 17, 2018
795dffe
Update README.md
Bendr0id Jul 17, 2018
907d2d4
Update README.md
Bendr0id Jul 17, 2018
86ca235
Update README.md
Bendr0id Jul 17, 2018
86295b0
Update README.md
Bendr0id Jul 17, 2018
c2af444
Update README.md
Bendr0id Jul 17, 2018
b23b478
Merge remote-tracking branch 'xmrig/master'
Bendr0id Jul 22, 2018
c039803
Fixed merge conflicts
Bendr0id Jul 22, 2018
22f9a64
Default disable old HTTP API
Bendr0id Jul 22, 2018
c5b6c36
Update Config.cpp
Bendr0id Jul 24, 2018
784035a
Fix parsing of CC config params
Bendr0id Jul 25, 2018
766dd41
Update version.h
Bendr0id Jul 25, 2018
45ef21e
Update README.md
Bendr0id Jul 25, 2018
b393bb6
Update README.md
Bendr0id Jul 25, 2018
b336cfd
Add remote logging and config property to enable/disable config uploa…
Bendr0id Aug 2, 2018
df8b30d
Merge remote-tracking branch 'origin/master'
Bendr0id Aug 2, 2018
c7106f3
Merge remote-tracking branch 'origin/master' into develop
Bendr0id Aug 3, 2018
718c3ce
Merge remote-tracking branch 'xmrig/dev' into develop
Bendr0id Aug 3, 2018
5006a9e
Merged XMRigCC-cpu changes
Bendr0id Aug 3, 2018
9627825
WIP GPUInfo on Dashboard
Bendr0id Aug 8, 2018
8713b30
WIP adding GPUInfo to Dashboard
Bendr0id Aug 9, 2018
e513641
WIP
Bendr0id Aug 9, 2018
56bc4a6
Add gpuInfo parseFromJson and toJson
Bendr0id Aug 13, 2018
8d9dbe2
Refactoring to use common CC code on cpu/gpu
Bendr0id Aug 14, 2018
dd4ffa4
Merge pull request #8 from Bendr0id/gpuinfo_on_dashboard
Bendr0id Aug 14, 2018
b6dfbd8
1.7.0-beta1 preparation
Bendr0id Aug 16, 2018
5b56cae
Fix mvc build
Bendr0id Aug 16, 2018
9dafc88
Fix mvc build
Bendr0id Aug 16, 2018
67d3355
Merge branch '1.7.0_beta1'
Bendr0id Aug 17, 2018
debdebc
Merge branch 'master' into develop
Bendr0id Aug 17, 2018
5b38657
Update README.md
Bendr0id Aug 20, 2018
779d4ea
Merge branch 'develop'
Bendr0id Aug 27, 2018
c9416f0
1.7.0 Preparation
Bendr0id Aug 27, 2018
ec405a7
Merge remote-tracking branch 'xmrig/dev'
Bendr0id Sep 12, 2018
bf40994
Merge branch 'master' into develop
Bendr0id Sep 12, 2018
9e891d1
Fix compile issue
Bendr0id Sep 12, 2018
57cd16e
Merge branch 'develop'
Bendr0id Sep 12, 2018
72bd3d8
RapidJSON fix, the same as for xmrigCC.
djfinch Sep 12, 2018
8fac4ff
Merge pull request #9 from djfinch/master
Bendr0id Sep 12, 2018
8e93f10
Merge remote-tracking branch 'origin/master' into monerov8_aka_cn2
Bendr0id Oct 5, 2018
dab0d1c
Merge branch 'master' into monerov8_aka_cn2
Bendr0id Oct 18, 2018
54cec9d
Merged 2.8.1 changes
Bendr0id Oct 18, 2018
4d241bb
Merge remote-tracking branch 'xmrig/master' into monerov8_aka_cn2
Bendr0id Oct 19, 2018
0082bfd
Merge remote-tracking branch 'origin/monerov8_aka_cn2' into monerov8_…
Bendr0id Oct 19, 2018
ee37a25
Merge remote-tracking branch 'xmrig/dev' into monerov8_aka_cn2
Bendr0id Oct 19, 2018
ceb8036
Fixed merge conflicts/build
Bendr0id Oct 19, 2018
bbd849d
Changed version
Bendr0id Oct 19, 2018
4e3b609
Merge conflicts on CMakeLists
Bendr0id Oct 19, 2018
940e7dd
Cleanup
Bendr0id Oct 20, 2018
9b9b06c
Merge remote-tracking branch 'xmrig/dev' into monerov8_aka_cn2
Bendr0id Oct 20, 2018
af5c138
Merge remote-tracking branch 'xmrig/master' into monerov8_aka_cn2
Bendr0id Oct 21, 2018
ed1652b
Merge pull request #12 from Bendr0id/monerov8_aka_cn2
Bendr0id Oct 21, 2018
cd7a451
Bendr0id Oct 21, 2018
a1c6ca0
Fixed compile issues
Bendr0id Oct 21, 2018
b0de702
Update README.md
Bendr0id Oct 21, 2018
69b7e52
Update README.md
Bendr0id Oct 21, 2018
465dcc7
Fix memory leak in client status
Bendr0id Nov 15, 2018
8215ccf
Merge remote-tracking branch 'origin/master'
Bendr0id Nov 15, 2018
4eefc90
Merge remote-tracking branch 'xmrig/master'
Bendr0id Nov 15, 2018
1052ac1
Merge remote-tracking branch 'xmrig/master'
Bendr0id Nov 19, 2018
572e634
Fixed merge issues
Bendr0id Nov 21, 2018
b4f8daf
increased version
Bendr0id Nov 21, 2018
83f05f9
WIP
Bendr0id Nov 21, 2018
805648e
Cleanup
Bendr0id Nov 22, 2018
c70a570
Merge pull request #17 from Bendr0id/swap_support
Bendr0id Nov 22, 2018
6d554b2
#1.8.4 Preparation
Bendr0id Nov 22, 2018
eb2dead
Fix parsing cn/xfh algo send from pool
Bendr0id Nov 26, 2018
21ffbee
Integrated remote reboot feature
Bendr0id Nov 27, 2018
bbc13cd
Updated default config file
Bendr0id Nov 27, 2018
ff60b54
Merge pull request #18 from Bendr0id/remote_reboot
Bendr0id Nov 28, 2018
8923d56
#1.8.5 preparation
Bendr0id Nov 28, 2018
4f95253
Integrated Hashrate monitor
Bendr0id Dec 6, 2018
f8ac7cd
Merge remote-tracking branch 'xmrig/dev' into hashrate_monitoring
Bendr0id Dec 7, 2018
dc0c3f4
Fixed config writer
Bendr0id Dec 7, 2018
e8a9c9b
Improved hashrate monitor
Bendr0id Dec 9, 2018
eb483b8
#1.8.6 Preparation
Bendr0id Dec 10, 2018
d898a59
Merge pull request #19 from Bendr0id/hashrate_monitoring
Bendr0id Dec 10, 2018
6489619
Changelog
Bendr0id Dec 10, 2018
55a804a
Default enable API
Bendr0id Dec 10, 2018
2e092ad
Bendr0id Dec 28, 2018
f177a03
Fixed --version && --help
Bendr0id Dec 30, 2018
3d65623
Integrated cn-fast2/xtlv9
Bendr0id Jan 3, 2019
611870a
WIP upx
Bendr0id Jan 3, 2019
d8e3e21
Bendr0id Jan 4, 2019
d2af32c
Merge pull request #22 from Bendr0id/new_algos
Bendr0id Jan 4, 2019
e49bd14
Improved auto detection for XTLv9/cn-half
Bendr0id Jan 15, 2019
9ad4348
Update CHANGELOG.md
Bendr0id Jan 15, 2019
06a1a9c
Merge remote-tracking branch 'xmrig/dev'
Bendr0id Jan 23, 2019
9e76e68
Integrated cn-ultralite/turtle
Bendr0id Jan 24, 2019
5ed8cd0
Merge remote-tracking branch 'xmrig/master'
Bendr0id Jan 24, 2019
18f9b50
Increased version
Bendr0id Jan 24, 2019
99b0836
Bendr0id Jan 24, 2019
e7e4832
Update CHANGELOG.md
Bendr0id Jan 24, 2019
fc410b9
Fixed xmrig-proxy usage for cn-ultralite/turtle/pico
Bendr0id Jan 28, 2019
ea6a695
#1.8.12 Preparation
Bendr0id Jan 28, 2019
8c42943
Added more names to the algo parse CN-Turtle/Ultralite
Bendr0id Jan 31, 2019
888aa22
Update CHANGELOG.md
Bendr0id Jan 31, 2019
b1a7359
Merge remote-tracking branch 'xmrig/master' into cn_gpu
Bendr0id Feb 11, 2019
b696ead
Fix for GPU variant
Bendr0id Feb 12, 2019
9201a4c
Fixed build
Bendr0id Feb 13, 2019
81e7c29
Merge branch 'cn_gpu'
Bendr0id Feb 13, 2019
a58d7da
#1.8.14 Preparation
Bendr0id Feb 13, 2019
75e1dff
Fixed crash when remote logging is disabled
Bendr0id Feb 16, 2019
ffc18c2
Fixed startup loop when using -h parameter
Bendr0id Feb 17, 2019
882e210
Rebase/Merge latest xmrig master/dev
Bendr0id Feb 22, 2019
9098d24
Merge remote-tracking branch 'xmrig/master'
Bendr0id Feb 22, 2019
b7843fa
Fixed segfault on stop
Bendr0id Feb 22, 2019
ea5de9b
Cleanup
Bendr0id Feb 22, 2019
c88de43
WIP Integration XCASH/Zelerius
Bendr0id Mar 5, 2019
054e3e0
Integrated RWZ (Graft) algo
Bendr0id Mar 6, 2019
36a0571
Updated Changelog
Bendr0id Mar 6, 2019
1c26fee
Merge pull request #25 from Bendr0id/feature_cn_r_and_wow
Bendr0id Mar 6, 2019
52ed1c0
Preparation #1.9.1
Bendr0id Mar 6, 2019
9e5a32d
Windows build fixes
Bendr0id Mar 6, 2019
789cc82
Cleanup
Bendr0id Mar 6, 2019
414cb8c
Fixed compile issue
Bendr0id Mar 7, 2019
05986a5
Moved more kernels to 2nd file
Bendr0id Mar 7, 2019
82c88c4
Update README.md
Bendr0id Mar 18, 2019
b3924c1
Integrated UPX2 / cn-extremelite
Bendr0id Apr 29, 2019
5363dc8
Rebase remote-tracking branch 'xmrig/master' 2.14.5
Bendr0id Aug 14, 2019
d760c1b
Upgraded version
Bendr0id Aug 14, 2019
1b9937a
Update README.md
Bendr0id Dec 27, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
78 changes: 65 additions & 13 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,11 +1,16 @@
cmake_minimum_required(VERSION 2.8)
project(xmrig-amd)
project(xmrigMiner-amd)

option(WITH_AEON "CryptoNight-Lite support" ON)
option(WITH_SUMO "CryptoNight-Heavy support" ON)
option(WITH_HTTPD "HTTP REST API" ON)
option(WITH_CC_CLIENT "CC Client" ON)
option(WITH_TLS "TLS support" ON)
option(BUILD_STATIC "Build static binary" OFF)

set(MINER_EXECUTABLE_NAME "xmrigMiner-amd" CACHE STRING "Miner executable file name")
set(DAEMON_EXECUTABLE_NAME "xmrigDaemon-amd" CACHE STRING "Daemon executable file name")

include (CheckIncludeFile)
include (cmake/cpu.cmake)

@@ -94,24 +99,14 @@ set(SOURCES
src/amd/OclGPU.cpp
src/api/NetworkState.cpp
src/App.cpp
src/common/config/CommonConfig.cpp
src/common/config/ConfigLoader.cpp
src/common/config/ConfigWatcher.cpp
src/common/Console.cpp
src/common/crypto/Algorithm.cpp
src/common/crypto/keccak.cpp
src/common/log/ConsoleLog.cpp
src/common/log/FileLog.cpp
src/common/log/Log.cpp
src/common/net/Client.cpp
src/common/net/Job.cpp
src/common/net/Pool.cpp
src/common/net/strategies/FailoverStrategy.cpp
src/common/net/strategies/SinglePoolStrategy.cpp
src/common/net/SubmitResult.cpp
src/common/Platform.cpp
src/core/Config.cpp
src/core/Controller.cpp
src/net/Network.cpp
src/net/strategies/DonateStrategy.cpp
src/Summary.cpp
@@ -123,6 +118,20 @@ set(SOURCES
src/xmrig.cpp
)

set(SOURCES_COMMON
src/common/Console.cpp
src/common/config/CommonConfig.cpp
src/common/config/ConfigLoader.cpp
src/common/config/ConfigWatcher.cpp
src/common/log/ConsoleLog.cpp
src/common/log/FileLog.cpp
src/common/log/Log.cpp
src/common/Platform.cpp
src/core/Config.cpp
src/core/Controller.cpp
)


set(SOURCES_CRYPTO
src/crypto/c_groestl.c
src/crypto/c_blake256.c
@@ -144,7 +153,7 @@ if (WIN32)
endif()

add_definitions(/DWIN32)
set(EXTRA_LIBS ws2_32 psapi iphlpapi userenv)
set(EXTRA_LIBS ws2_32 psapi iphlpapi userenv crypt32)
elseif (APPLE)
set(SOURCES_OS
src/amd/OclCache_unix.cpp
@@ -179,6 +188,7 @@ add_definitions(/DUNICODE)
#add_definitions(/DAPP_DEBUG)
add_definitions(/DXMRIG_AMD_PROJECT)
add_definitions(/DXMRIG_NO_LIBCPUID)
add_definitions(/DMINER_EXECUTABLE_NAME=${MINER_EXECUTABLE_NAME})

set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake")

@@ -237,13 +247,55 @@ else()
add_definitions(/DXMRIG_NO_API)
endif()

if (WITH_TLS)
find_package(OpenSSL)

add_definitions(/DCPPHTTPLIB_OPENSSL_SUPPORT)

if (OPENSSL_FOUND)
include_directories(${OPENSSL_INCLUDE_DIR})
#set(SOURCES_SSL_TLS src/net/BoostTlsConnection.cpp)
else()
message(FATAL_ERROR "OpenSSL NOT found: use `-DWITH_TLS=OFF` to build without TLS support")
endif()
else()
add_definitions(/DXMRIG_NO_TLS)
endif()

if (WITH_CC_CLIENT)
set(SOURCES_CC_CLIENT
src/cc/CCClient.cpp)
endif()

if (WITH_CC_CLIENT)
set(SOURCES_CC_COMMON
src/cc/ControlCommand.cpp
src/cc/ClientStatus.cpp)
else()
add_definitions(/DXMRIG_NO_CC)
endif()

include_directories(src)
include_directories(src/3rdparty)
include_directories(${UV_INCLUDE_DIR})

if (WITH_TLS)
#add_library(xmrig_tls STATIC ${SOURCES_SSL_TLS})
endif (WITH_TLS)

if (BUILD_STATIC)
set(CMAKE_EXE_LINKER_FLAGS " -static")
endif()

add_executable(${PROJECT_NAME} ${HEADERS} ${SOURCES} ${SOURCES_OS} ${SOURCES_CPUID} ${HEADERS_CRYPTO} ${SOURCES_CRYPTO} ${SOURCES_SYSLOG} ${HTTPD_SOURCES})
add_executable(${PROJECT_NAME} ${HEADERS} ${SOURCES_CC_COMMON} ${SOURCES} ${SOURCES_COMMON} ${SOURCES_OS} ${SOURCES_CPUID} ${HEADERS_CRYPTO} ${SOURCES_CRYPTO} ${SOURCES_SYSLOG} ${HTTPD_SOURCES} ${SOURCES_CC_CLIENT})
set_target_properties(${PROJECT_NAME} PROPERTIES OUTPUT_NAME ${MINER_EXECUTABLE_NAME})
target_link_libraries(${PROJECT_NAME} ${UV_LIBRARIES} ${MHD_LIBRARY} ${EXTRA_LIBS} ${LIBS} ${OpenCL_LIBRARY})

if (WITH_TLS)
#target_link_libraries(${PROJECT_NAME} xmrig_tls ${OPENSSL_LIBRARIES} ${EXTRA_LIBS})
target_link_libraries(${PROJECT_NAME} ${OPENSSL_LIBRARIES} ${EXTRA_LIBS})
endif (WITH_TLS)


add_executable(xmrigDaemon-amd src/cc/XMRigd.cpp res/app.rc)
set_target_properties(xmrigDaemon-amd PROPERTIES OUTPUT_NAME ${DAEMON_EXECUTABLE_NAME})
Binary file modified res/app.ico
Binary file not shown.
73 changes: 36 additions & 37 deletions res/app.rc
Original file line number Diff line number Diff line change
@@ -1,37 +1,36 @@
#include <windows.h>
#include "../src/version.h"

IDI_ICON1 ICON DISCARDABLE "app.ico"

VS_VERSION_INFO VERSIONINFO
FILEVERSION APP_VER_MAJOR,APP_VER_MINOR,APP_VER_PATCH,0
PRODUCTVERSION APP_VER_MAJOR,APP_VER_MINOR,APP_VER_PATCH,0
FILEFLAGSMASK 0x3fL
#ifdef _DEBUG
FILEFLAGS VS_FF_DEBUG
#else
FILEFLAGS 0x0L
#endif
FILEOS VOS__WINDOWS32
FILETYPE VFT_APP
FILESUBTYPE 0x0L
BEGIN
BLOCK "StringFileInfo"
BEGIN
BLOCK "000004b0"
BEGIN
VALUE "CompanyName", APP_SITE
VALUE "FileDescription", APP_DESC
VALUE "FileVersion", APP_VERSION
VALUE "LegalCopyright", APP_COPYRIGHT
VALUE "OriginalFilename", "xmrig.exe"
VALUE "ProductName", APP_NAME
VALUE "ProductVersion", APP_VERSION
END
END
BLOCK "VarFileInfo"
BEGIN
VALUE "Translation", 0x0, 1200
END
END

#include <windows.h>
#include "../src/version.h"

IDI_ICON1 ICON DISCARDABLE "app.ico"

VS_VERSION_INFO VERSIONINFO
FILEVERSION APP_VER_MAJOR,APP_VER_MINOR,APP_VER_PATCH,0
PRODUCTVERSION APP_VER_MAJOR,APP_VER_MINOR,APP_VER_PATCH,0
FILEFLAGSMASK 0x3fL
#ifdef _DEBUG
FILEFLAGS VS_FF_DEBUG
#else
FILEFLAGS 0x0L
#endif
FILEOS VOS__WINDOWS32
FILETYPE VFT_APP
FILESUBTYPE 0x0L
BEGIN
BLOCK "StringFileInfo"
BEGIN
BLOCK "000004b0"
BEGIN
VALUE "CompanyName", APP_SITE
VALUE "FileDescription", APP_DESC
VALUE "FileVersion", APP_VERSION
VALUE "LegalCopyright", APP_COPYRIGHT
VALUE "OriginalFilename", "xmrig.exe"
VALUE "ProductName", APP_NAME
VALUE "ProductVersion", APP_VERSION
END
END
BLOCK "VarFileInfo"
BEGIN
VALUE "Translation", 0x0, 1200
END
END
20 changes: 20 additions & 0 deletions src/3rdparty/cpp-httplib/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
tags

example/server
example/client
example/hello
example/simplesvr
test/test
test/test.xcodeproj/xcuser*
test/test.xcodeproj/*/xcuser*

*.swp

Debug
Release
*.vcxproj.user
*.sdf
*.suo
*.opensdf
ipch
*.dSYM
68 changes: 68 additions & 0 deletions src/3rdparty/cpp-httplib/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
cpp-httplib
===========

A C++11 header-only HTTP library.

[The Boost Software License 1.0](http://www.boost.org/LICENSE_1_0.txt)

It's extremely easy to setup. Just include **httplib.h** file in your code!

Server Example
--------------

Inspired by [Sinatra](http://www.sinatrarb.com/) and [express](https://github.com/visionmedia/express).

```c++
#include <httplib.h>

int main(void)
{
using namespace httplib;

Server svr;

svr.get("/hi", [](const Request& req, const Response& res) {
res.set_content("Hello World!", "text/plain");
});

svr.get(R"(/numbers/(\d+))", [&](const Request& req, const Response& res) {
auto numbers = req.matches[1];
res.set_content(numbers, "text/plain");
});

svr.listen("localhost", 1234);
}
```

Client Example
--------------

```c++
#include <httplib.h>
#include <iostream>

int main(void)
{
httplib::Client cli("localhost", 1234);

auto res = cli.get("/hi");
if (res && res->status == 200) {
std::cout << res->body << std::endl;
}
}
```

OpenSSL Support
---------------

SSL support is available with `CPPHTTPLIB_OPENSSL_SUPPORT`. `libssl` and `libcrypto` should be linked.

```c++
#define CPPHTTPLIB_OPENSSL_SUPPORT

SSLServer svr("./cert.pem", "./key.pem");

SSLClient cli("localhost", 8080);
```

Copyright (c) 2017 Yuji Hirose. All rights reserved.
28 changes: 28 additions & 0 deletions src/3rdparty/cpp-httplib/example/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@

CC = clang++
CFLAGS = -std=c++14 -I..
#OPENSSL_SUPPORT = -DCPPHTTPLIB_OPENSSL_SUPPORT -I/usr/local/opt/openssl/include -L/usr/local/opt/openssl/lib -lssl -lcrypto

all: server client hello simplesvr benchmark

server : server.cc ../httplib.h Makefile
$(CC) -o server $(CFLAGS) server.cc $(OPENSSL_SUPPORT)

client : client.cc ../httplib.h Makefile
$(CC) -o client $(CFLAGS) client.cc $(OPENSSL_SUPPORT)

hello : hello.cc ../httplib.h Makefile
$(CC) -o hello $(CFLAGS) hello.cc $(OPENSSL_SUPPORT)

simplesvr : simplesvr.cc ../httplib.h Makefile
$(CC) -o simplesvr $(CFLAGS) simplesvr.cc $(OPENSSL_SUPPORT)

benchmark : benchmark.cc ../httplib.h Makefile
$(CC) -o benchmark $(CFLAGS) benchmark.cc $(OPENSSL_SUPPORT)

pem:
openssl genrsa 2048 > key.pem
openssl req -new -key key.pem | openssl x509 -days 3650 -req -signkey key.pem > cert.pem

clean:
rm server client hello simplesvr *.pem
33 changes: 33 additions & 0 deletions src/3rdparty/cpp-httplib/example/benchmark.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#include <httplib.h>
#include <chrono>
#include <iostream>

using namespace std;

struct StopWatch {
StopWatch(const string& label) : label_(label) {
start_ = chrono::system_clock::now();
}
~StopWatch() {
auto end = chrono::system_clock::now();
auto diff = end - start_;
auto count = chrono::duration_cast<chrono::milliseconds>(diff).count();
cout << label_ << ": " << count << " millisec." << endl;
}
string label_;
chrono::system_clock::time_point start_;
};

int main(int argc, char* argv[]) {
string body(1024 * 5, 'a');

httplib::Client cli("httpbin.org", 80);

for (int i = 0; i < 3; i++) {
StopWatch sw(to_string(i).c_str());
auto res = cli.post("/post", body, "application/octet-stream");
assert(res->status == 200);
}

return 0;
}
31 changes: 31 additions & 0 deletions src/3rdparty/cpp-httplib/example/client.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
//
// client.cc
//
// Copyright (c) 2012 Yuji Hirose. All rights reserved.
// The Boost Software License 1.0
//

#include <httplib.h>
#include <iostream>

using namespace std;

int main(void)
{
#ifdef CPPHTTPLIB_OPENSSL_SUPPORT
httplib::SSLClient cli("localhost", 8080);
#else
httplib::Client cli("localhost", 8080);
#endif

auto res = cli.get("/hi");
if (res) {
cout << res->status << endl;
cout << res->get_header_value("Content-Type") << endl;
cout << res->body << endl;
}

return 0;
}

// vim: et ts=4 sw=4 cin cino={1s ff=unix
Loading