Skip to content

Commit

Permalink
Added embed cacert.pem.
Browse files Browse the repository at this point in the history
████ ███  To request new features or in case this commit breaks something for you,
████ ███  please, create a new github issue with all possible information for me,
▓███▀█▄   but never share your API Keys!
▒▓██ ███
░▒▓█ ███  Signed-off-by: Carles Tubio <[email protected]>
 _________________________________________
/ Hello, WORLD!                           \
|                                         |
\ pssst.. 1.00000000 BTC = 57009.59 EUR.  /
 -----------------------------------------
        \   ^__^
         \  (oo)\_______
            (__)\       )\/\
                ||----w |
                ||     ||
  • Loading branch information
ctubio committed Sep 23, 2024
1 parent 608f5f6 commit 1027974
Show file tree
Hide file tree
Showing 6 changed files with 40 additions and 25 deletions.
5 changes: 3 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ K ?= K.sh
MAJOR = 0
MINOR = 7
PATCH = 0
BUILD = 10
BUILD = 11

OBLIGATORY = DISCLAIMER: This is strict non-violent software: \n$\
if you hurt other living creatures, please stop; \n$\
Expand Down Expand Up @@ -48,7 +48,8 @@ KARGS := -std=c++23 -O3 -pthread \
)"' -I$(KBUILD)/include \
$(addprefix $(KBUILD)/lib/, \
K-$(KHOST).$(ABI).a \
libsqlite3.a libcurl.a libssl.a libcrypto.a libz.a \
libcurl.a libssl.a libcrypto.a libz.a libsqlite3.a \
cacert_embed.o \
) \
$(wildcard $(addprefix $(KBUILD)/lib/, \
K-$(KSRC)-client.o \
Expand Down
18 changes: 9 additions & 9 deletions src/lib/Krypto.ninja-apis.h
Original file line number Diff line number Diff line change
Expand Up @@ -625,7 +625,7 @@ class GwApiWsFix: public GwApiWs,
webMarket = "https://www.binance.com/en/trade/";
webOrders = "https://www.binance.com/en/my/orders/exchange";
};
string web(const string &base, const string &quote) const {
string web(const string &base, const string &quote) const override {
return webMarket + base + "_" + quote + "?layout=pro";
};
protected:
Expand Down Expand Up @@ -716,7 +716,7 @@ class GwApiWsFix: public GwApiWs,
webMarket = "https://www.bitmex.com/app/trade/";
webOrders = "https://www.bitmex.com/app/orderHistory";
};
string web(const string &base, const string &quote) const {
string web(const string &base, const string &quote) const override {
return webMarket + base + quote;
};
protected:
Expand Down Expand Up @@ -770,7 +770,7 @@ class GwApiWsFix: public GwApiWs,
webMarket = "https://www.gate.io/trade/";
webOrders = "https://www.gate.io/myaccount/myorders";
};
string web(const string &base, const string &quote) const {
string web(const string &base, const string &quote) const override {
return webMarket + base + "_" + quote;
};
protected:
Expand Down Expand Up @@ -832,7 +832,7 @@ class GwApiWsFix: public GwApiWs,
webMarket = "https://hitbtc.com/exchange/";
webOrders = "https://hitbtc.com/reports/orders";
};
string web(const string &base, const string &quote) const {
string web(const string &base, const string &quote) const override {
return webMarket + base + "-to-" + quote;
};
protected:
Expand Down Expand Up @@ -891,7 +891,7 @@ class GwApiWsFix: public GwApiWs,
webMarket = "https://www.coinbase.com/advanced-trade/spot/";
webOrders = "https://www.coinbase.com/orders/";
};
string web(const string &base, const string &quote) const {
string web(const string &base, const string &quote) const override {
return webMarket + base + "-" + quote;
};
protected:
Expand Down Expand Up @@ -951,7 +951,7 @@ class GwApiWsFix: public GwApiWs,
webMarket = "https://www.bitfinex.com/trading/";
webOrders = "https://www.bitfinex.com/reports/orders";
};
string web(const string &base, const string &quote) const {
string web(const string &base, const string &quote) const override {
return webMarket + base + quote;
};
protected:
Expand Down Expand Up @@ -1041,7 +1041,7 @@ class GwApiWsFix: public GwApiWs,
webMarket = "https://trade.kucoin.com/";
webOrders = "https://www.kucoin.com/order/trade";
};
string web(const string &base, const string &quote) const {
string web(const string &base, const string &quote) const override {
return webMarket + base + "-" + quote;
};
protected:
Expand Down Expand Up @@ -1123,7 +1123,7 @@ class GwApiWsFix: public GwApiWs,
webMarket = "https://trade.kraken.com/charts/KRAKEN:";
webOrders = "https://www.kraken.com/u/trade";
};
string web(const string &base, const string &quote) const {
string web(const string &base, const string &quote) const override {
return webMarket + base + "-" + quote;
};
protected:
Expand Down Expand Up @@ -1178,7 +1178,7 @@ class GwApiWsFix: public GwApiWs,
webMarket = "https://poloniex.com/exchange/";
webOrders = "https://poloniex.com/tradeHistory";
};
string web(const string &base, const string &quote) const {
string web(const string &base, const string &quote) const override {
return webMarket + quote + "_" + base;
};
protected:
Expand Down
3 changes: 3 additions & 0 deletions src/lib/Krypto.ninja-bots.h
Original file line number Diff line number Diff line change
Expand Up @@ -553,17 +553,20 @@ namespace ₿ {
if (!arg<string>("interface").empty() and !arg<int>("ipv6"))
args_easy_setopt = [inet = arg<string>("interface")](CURL *curl) {
curl_easy_setopt(curl, CURLOPT_USERAGENT, "K");
curl_easy_setopt_nowin32(curl, CURLOPT_CAINFO_BLOB, &curl_ca_embed_blob);
curl_easy_setopt(curl, CURLOPT_INTERFACE, inet.data());
curl_easy_setopt(curl, CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V4);
};
else if (!arg<string>("interface").empty())
args_easy_setopt = [inet = arg<string>("interface")](CURL *curl) {
curl_easy_setopt(curl, CURLOPT_USERAGENT, "K");
curl_easy_setopt_nowin32(curl, CURLOPT_CAINFO_BLOB, &curl_ca_embed_blob);
curl_easy_setopt(curl, CURLOPT_INTERFACE, inet.data());
};
else if (!arg<int>("ipv6"))
args_easy_setopt = [](CURL *curl) {
curl_easy_setopt(curl, CURLOPT_USERAGENT, "K");
curl_easy_setopt_nowin32(curl, CURLOPT_CAINFO_BLOB, &curl_ca_embed_blob);
curl_easy_setopt(curl, CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V4);
};
};
Expand Down
8 changes: 7 additions & 1 deletion src/lib/Krypto.ninja-data.h
Original file line number Diff line number Diff line change
Expand Up @@ -439,8 +439,15 @@ namespace ₿ {
};
#endif

static struct curl_blob curl_ca_embed_blob = {
(void*)curl_ca_embed,
strlen((const char*)curl_ca_embed),
CURL_BLOB_NOCOPY
};

static function<void(CURL*)> args_easy_setopt = [](CURL *curl) {
curl_easy_setopt(curl, CURLOPT_USERAGENT, "K");
curl_easy_setopt_nowin32(curl, CURLOPT_CAINFO_BLOB, &curl_ca_embed_blob);
};

class Curl {
Expand Down Expand Up @@ -609,7 +616,6 @@ namespace ₿ {
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, &write);
curl_easy_setopt(curl, CURLOPT_WRITEDATA, &reply);
curl_easy_setopt(curl, CURLOPT_TIMEOUT, 21L);
// curl_easy_setopt(curl, CURLOPT_VERBOSE, 1);
rc = curl_easy_perform(curl);
curl_easy_cleanup(curl);
if (slist) curl_slist_free_all(slist);
Expand Down
1 change: 1 addition & 0 deletions src/lib/Krypto.ninja-lang.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@
#include <sqlite3.h>

#include <curl/curl.h>
#include <curl/cacert_embed.h>

#include <openssl/ssl.h>
#include <openssl/bio.h>
Expand Down
30 changes: 17 additions & 13 deletions src/lib/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -62,19 +62,23 @@ openssl:
--prefix=$(KBUILD) --cross-compile-prefix=$(CHOST)- && make install_dev )

curl:
test -d $(KBUILD)/var/curl-$(V_CURL) || ( \
curl -L https://curl.haxx.se/download/curl-$(V_CURL).tar.gz | tar xz -C $(KBUILD)/var \
&& cd $(KBUILD)/var/curl-$(V_CURL) && mkdir -p ssl && curl --etag-compare ssl/cacert.etag \
--etag-save ssl/cacert.etag https://curl.se/ca/cacert.pem -o ssl/cacert.pem \
&& PKG_CONFIG="pkg-config --static" PKG_CONFIG_PATH=$(KBUILD)/lib/pkgconfig ./configure \
--host=$(CHOST) --prefix=$(KBUILD) --with-zlib=$(KBUILD) --disable-manual --disable-docs \
--disable-file --disable-telnet --disable-ftp --disable-smtp --disable-ldap --disable-ares \
$(if $(findstring mingw32,$(CHOST)),--with-schannel,--with-openssl=$(KBUILD) \
--with-ca-embed=$(KBUILD)/var/ssl/curl-ca-bundle.crt) --disable-imap --disable-pop3 \
--disable-rtsp --without-libidn2 --without-librtmp --without-nghttp2 --without-zstd \
--disable-tftp --disable-smb --disable-sspi --disable-dict --without-libpsl \
--without-brotli --without-libssh2 --disable-gopher --disable-shared --enable-static \
&& make && (cd lib && make install) && (cd include && make install) )
test -d $(KBUILD)/var/curl-$(V_CURL) || ( \
curl -L https://curl.haxx.se/download/curl-$(V_CURL).tar.gz | tar xz -C $(KBUILD)/var \
&& cd $(KBUILD)/var/curl-$(V_CURL) && mkdir -p ssl && curl --etag-compare ssl/cacert.etag \
--etag-save ssl/cacert.etag https://curl.se/ca/cacert.pem -o ssl/cacert.pem \
&& PKG_CONFIG="pkg-config --static" PKG_CONFIG_PATH=$(KBUILD)/lib/pkgconfig ./configure \
--host=$(CHOST) --prefix=$(KBUILD) --with-zlib=$(KBUILD) \
$(if $(findstring mingw32,$(CHOST)),--with-schannel,--with-openssl=$(KBUILD) \
--with-ca-embed=$(KBUILD)/var/curl-$(V_CURL)/ssl/cacert.pem) \
--disable-docs --disable-manual --disable-gopher --disable-imap --disable-ftp \
--disable-file --without-librtmp --disable-telnet --disable-pop3 --disable-smb \
--disable-rtsp --without-libidn2 --without-zstd --disable-smtp --disable-ldap \
--disable-tftp --without-libssh2 --without-libpsl --disable-sspi --disable-ares \
--disable-dict --without-nghttp2 --without-brotli --disable-shared --enable-static \
&& make && (cd lib && make install) && (cd include && make install) \
&& (echo "#define curl_easy_setopt_nowin32(a, b, c) $(if $(findstring mingw32,$(CHOST)), \
,curl_easy_setopt(a, b, c))" && echo "`grep extern src/tool_ca_embed.c | cut -d';' -f1`;") > \
$(KBUILD)/include/curl/cacert_embed.h && cp -v src/tool_ca_embed.o $(KBUILD)/lib/cacert_embed.o )

sqlite:
test -d $(KBUILD)/var/sqlite-autoconf-$(V_SQL) || ( \
Expand Down

0 comments on commit 1027974

Please sign in to comment.