Skip to content

Commit

Permalink
Merge branch 'develop' into 'master'
Browse files Browse the repository at this point in the history
Develop

See merge request in3/c/in3-core!345
  • Loading branch information
simon-jentzsch committed Aug 30, 2020
2 parents 987f853 + 9b4e86d commit f09df5d
Show file tree
Hide file tree
Showing 41 changed files with 1,501 additions and 739 deletions.
9 changes: 9 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ option(GCC_ANALYZER "GCC10 static code analyses" OFF)
option(PAY_ETH "support for direct Eth-Payment" OFF)
option(USE_SCRYPT "integrate scrypt into the build in order to allow decrypt_key for scrypt encoded keys." ON)
option(USE_CURL "if true the curl transport will be built (with a dependency to libcurl)" ON)
option(USE_WINHTTP "if true the winhttp transport will be built (with a dependency to winhttp)" OFF)
option(DEV_NO_INTRN_PTR "(*dev option*) if true the client will NOT include a void pointer (named internal) for use by devs)" ON)
option(LEDGER_NANO "include support for nano ledger" OFF)
option(ESP_IDF "include support for ESP-IDF microcontroller framework" OFF)
Expand Down Expand Up @@ -117,6 +118,10 @@ elseif(ETH_NANO)
set(IN3_VERIFIER eth_nano)
endif()

if (ETH_NANO)
set(WASM_MODULES ${WASM_MODULES} eth)
endif()

if(IN3API)
ADD_DEFINITIONS(-DETH_API)
set(IN3_API ${IN3_API} eth_api)
Expand All @@ -134,6 +139,8 @@ endif()
if(IPFS)
ADD_DEFINITIONS(-DIPFS)
set(IN3_VERIFIER ${IN3_VERIFIER} ipfs)
set(WASM_MODULES ${WASM_MODULES} ipfs)

if(IN3API)
set(IN3_API ${IN3_API} ipfs_api)
endif()
Expand All @@ -142,6 +149,7 @@ endif()
if(BTC)
ADD_DEFINITIONS(-DBTC)
set(IN3_VERIFIER ${IN3_VERIFIER} btc)
set(WASM_MODULES ${WASM_MODULES} btc)
if(IN3API)
set(IN3_API ${IN3_API} btc_api)
endif()
Expand Down Expand Up @@ -211,6 +219,7 @@ IF (WASM)
set(IN3_LIB false)
set(CMD false)
set(USE_CURL false)
set(USE_WINHTTP false)
ADD_DEFINITIONS(-DWASM)
add_subdirectory(wasm/src)
ENDIF (WASM)
Expand Down
3 changes: 3 additions & 0 deletions c/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,9 @@ IF (TRANSPORTS)
if (CURL_BLOCKING)
ADD_DEFINITIONS(-DCURL_BLOCKING)
endif (CURL_BLOCKING)
elseif(USE_WINHTTP)
ADD_DEFINITIONS(-DUSE_WINHTTP)
set(IN3_TRANSPORT ${IN3_TRANSPORT} transport_winhttp)
else ()
set(IN3_TRANSPORT ${IN3_TRANSPORT} transport_http)
endif (USE_CURL)
Expand Down
2 changes: 1 addition & 1 deletion c/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ win_mingw:
- .conanbuild
- .only_full
variables:
CONAN_OPTS: "-DLIBCURL_LINKTYPE=static -DJAVA=false"
CONAN_OPTS: "-DUSE_CURL=false -DUSE_WINHTTP=true -DJAVA=false"
BUILD: "win_build"

win_jni:
Expand Down
22 changes: 11 additions & 11 deletions c/include/in3/client.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,17 +53,17 @@

#define IN3_PROTO_VER "2.1.0" /**< the protocol version used when sending requests from the this client */

#define CHAIN_ID_MULTICHAIN 0x0 /**< chain_id working with all known chains */
#define CHAIN_ID_MAINNET 0x01 /**< chain_id for mainnet */
#define CHAIN_ID_KOVAN 0x2a /**< chain_id for kovan */
#define CHAIN_ID_TOBALABA 0x44d /**< chain_id for tobalaba */
#define CHAIN_ID_GOERLI 0x5 /**< chain_id for goerlii */
#define CHAIN_ID_EVAN 0x4b1 /**< chain_id for evan */
#define CHAIN_ID_EWC 0xf6 /**< chain_id for ewc */
#define CHAIN_ID_IPFS 0x7d0 /**< chain_id for ipfs */
#define CHAIN_ID_BTC 0x99 /**< chain_id for btc */
#define CHAIN_ID_LOCAL 0xFFFF /**< chain_id for local chain */
#define DEF_REPL_LATEST_BLK 6 /**< default replace_latest_block */
#define CHAIN_ID_MULTICHAIN 0x0 /**< chain_id working with all known chains */
#define CHAIN_ID_MAINNET 0x01 /**< chain_id for mainnet */
#define CHAIN_ID_KOVAN 0x2a /**< chain_id for kovan */
#define CHAIN_ID_TOBALABA 0x44d /**< chain_id for tobalaba */
#define CHAIN_ID_GOERLI 0x5 /**< chain_id for goerlii */
#define CHAIN_ID_EVAN 0x4b1 /**< chain_id for evan */
#define CHAIN_ID_EWC 0xf6 /**< chain_id for ewc */
#define CHAIN_ID_IPFS 0x7d0 /**< chain_id for ipfs */
#define CHAIN_ID_BTC 0x99 /**< chain_id for btc */
#define CHAIN_ID_LOCAL 0x11 /**< chain_id for local chain */
#define DEF_REPL_LATEST_BLK 6 /**< default replace_latest_block */

/**
* type for a chain_id.
Expand Down
2 changes: 1 addition & 1 deletion c/include/in3/colors.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
*******************************************************************************/

/*Term colors*/

#pragma GCC diagnostic ignored "-Wformat-zero-length"
#ifdef LOG_USE_COLOR
#define COLORT_RESET "\033[0m"
#define COLORT_BOLD "\033[1m"
Expand Down
2 changes: 1 addition & 1 deletion c/include/in3/context.h
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ typedef struct in3_response {
* */
typedef struct in3_ctx {
uint_fast8_t signers_length; /**< number or addresses */
uint_fast16_t len; /**< the number of requests */
uint16_t len; /**< the number of requests */
uint_fast16_t attempt; /**< the number of attempts */
ctx_type_t type; /**< the type of the request */
in3_ret_t verification_state; /**< state of the verification */
Expand Down
51 changes: 51 additions & 0 deletions c/include/in3/in3_winhttp.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
/*******************************************************************************
* This file is part of the Incubed project.
* Sources: https://github.com/slockit/in3-c
*
* Copyright (C) 2018-2020 slock.it GmbH, Blockchains LLC
*
*
* COMMERCIAL LICENSE USAGE
*
* Licensees holding a valid commercial license may use this file in accordance
* with the commercial license agreement provided with the Software or, alternatively,
* in accordance with the terms contained in a written agreement between you and
* slock.it GmbH/Blockchains LLC. For licensing terms and conditions or further
* information please contact slock.it at in3@slock.it.
*
* Alternatively, this file may be used under the AGPL license as follows:
*
* AGPL LICENSE USAGE
*
* This program is free software: you can redistribute it and/or modify it under the
* terms of the GNU Affero General Public License as published by the Free Software
* Foundation, either version 3 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
* PARTICULAR PURPOSE. See the GNU Affero General Public License for more details.
* [Permissions of this strong copyleft license are conditioned on making available
* complete source code of licensed works and modifications, which include larger
* works using a licensed work, under the same license. Copyright and license notices
* must be preserved. Contributors provide an express grant of patent rights.]
* You should have received a copy of the GNU Affero General Public License along
* with this program. If not, see <https://www.gnu.org/licenses/>.
*******************************************************************************/

// @PUBLIC_HEADER
/** @file
* transport-handler using simple http.
*/

#ifndef in3_winhttp_h__
#define in3_winhttp_h__

#include "client.h"
in3_ret_t send_winhttp(void* plugin_data, in3_plugin_act_t action, void* plugin_ctx);

/**
* registers http as a default transport.
*/
in3_ret_t in3_register_winhttp(in3_t* c);

#endif // in3_http_h__
15 changes: 10 additions & 5 deletions c/src/cmd/in3/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@
#include "../../third-party/crypto/secp256k1.h"
#ifdef USE_CURL
#include "../../transport/curl/in3_curl.h"
#elif USE_WINHTTP
#include "../../transport/winhttp/in3_winhttp.h"
#else
#include "../../transport/http/in3_http.h"
#endif
Expand Down Expand Up @@ -617,6 +619,8 @@ static in3_ret_t debug_transport(void* plugin_data, in3_plugin_act_t action, voi
}
#ifdef USE_CURL
in3_ret_t r = send_curl(NULL, action, plugin_ctx);
#elif USE_WINHTTP
in3_ret_t r = send_winhttp(NULL, action, plugin_ctx);
#else
in3_ret_t r = send_http(NULL, action, plugin_ctx);
#endif
Expand All @@ -639,6 +643,8 @@ static in3_ret_t test_transport(void* plugin_data, in3_plugin_act_t action, void
in3_request_t* req = plugin_ctx;
#ifdef USE_CURL
in3_ret_t r = send_curl(NULL, action, plugin_ctx);
#elif USE_WINHTTP
in3_ret_t r = send_winhttp(NULL, action, plugin_ctx);
#else
in3_ret_t r = send_http(NULL, action, plugin_ctx);
#endif
Expand Down Expand Up @@ -722,11 +728,8 @@ int main(int argc, char* argv[]) {
bool to_eth = false;
plugin_register(c, PLGN_ACT_TRANSPORT, debug_transport, NULL, true);

#ifdef __MINGW32__
c->flags |= FLAGS_HTTP;
#endif
#ifndef USE_CURL
c->flags |= FLAGS_HTTP;
#ifndef USE_WINHTTP
c->request_count = 1;
#endif
// handle clear cache opt before initializing cache
for (i = 1; i < argc; i++)
Expand Down Expand Up @@ -1044,6 +1047,8 @@ int main(int argc, char* argv[]) {
r.payload = "";
#ifdef USE_CURL
send_curl(NULL, PLGN_ACT_TRANSPORT_SEND, &r);
#elif USE_WINHTTP
send_winhttp(NULL, PLGN_ACT_TRANSPORT_SEND, &r);
#else
send_http(NULL, PLGN_ACT_TRANSPORT_SEND, &r);
#endif
Expand Down
2 changes: 1 addition & 1 deletion c/src/core/client/context.h
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ typedef struct in3_response {
* */
typedef struct in3_ctx {
uint_fast8_t signers_length; /**< number or addresses */
uint_fast16_t len; /**< the number of requests */
uint16_t len; /**< the number of requests */
uint_fast16_t attempt; /**< the number of attempts */
ctx_type_t type; /**< the type of the request */
in3_ret_t verification_state; /**< state of the verification */
Expand Down
2 changes: 1 addition & 1 deletion c/src/core/client/execute.c
Original file line number Diff line number Diff line change
Expand Up @@ -995,7 +995,7 @@ in3_ret_t in3_ctx_execute(in3_ctx_t* ctx) {
if (ctx->error) return (ctx->verification_state && ctx->verification_state != IN3_WAITING) ? ctx->verification_state : IN3_EUNKNOWN;

// is it a valid request?
if (!ctx->request_context || !d_get(ctx->requests[0], K_METHOD)) return ctx_set_error(ctx, "No Method defined", IN3_ECONFIG);
if (!ctx->request_context || d_type(d_get(ctx->requests[0], K_METHOD)) != T_STRING) return ctx_set_error(ctx, "No Method defined", IN3_ECONFIG);

// if there is response we are done.
if (ctx->response_context && ctx->verification_state == IN3_OK) return IN3_OK;
Expand Down
2 changes: 1 addition & 1 deletion c/src/core/util/colors.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
*******************************************************************************/

/*Term colors*/

#pragma GCC diagnostic ignored "-Wformat-zero-length"
#ifdef LOG_USE_COLOR
#define COLORT_RESET "\033[0m"
#define COLORT_BOLD "\033[1m"
Expand Down
2 changes: 2 additions & 0 deletions c/src/transport/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@

IF (USE_CURL)
add_subdirectory(curl)
elseif(USE_WINHTTP)
add_subdirectory(winhttp)
else ()
add_subdirectory(http)
ENDIF ()
47 changes: 47 additions & 0 deletions c/src/transport/winhttp/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
###############################################################################
# This file is part of the Incubed project.
# Sources: https://github.com/slockit/in3-c
#
# Copyright (C) 2018-2020 slock.it GmbH, Blockchains LLC
#
#
# COMMERCIAL LICENSE USAGE
#
# Licensees holding a valid commercial license may use this file in accordance
# with the commercial license agreement provided with the Software or, alternatively,
# in accordance with the terms contained in a written agreement between you and
# slock.it GmbH/Blockchains LLC. For licensing terms and conditions or further
# information please contact slock.it at in3@slock.it.
#
# Alternatively, this file may be used under the AGPL license as follows:
#
# AGPL LICENSE USAGE
#
# This program is free software: you can redistribute it and/or modify it under the
# terms of the GNU Affero General Public License as published by the Free Software
# Foundation, either version 3 of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful, but WITHOUT ANY
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
# PARTICULAR PURPOSE. See the GNU Affero General Public License for more details.
# [Permissions of this strong copyleft license are conditioned on making available
# complete source code of licensed works and modifications, which include larger
# works using a licensed work, under the same license. Copyright and license notices
# must be preserved. Contributors provide an express grant of patent rights.]
# You should have received a copy of the GNU Affero General Public License along
# with this program. If not, see <https://www.gnu.org/licenses/>.
###############################################################################

# add lib
add_static_library(
NAME transport_winhttp

SOURCES
in3_winhttp.c

DEPENDS
core
winhttp
)


Loading

0 comments on commit f09df5d

Please sign in to comment.