From 5446ccf7d37351236276484388e10ad4f6c9315a Mon Sep 17 00:00:00 2001 From: cryptozoidberg Date: Sun, 9 Jan 2022 00:07:26 +0100 Subject: [PATCH] integrated tor into wallet in a draft mode --- contrib/tor-connect | 2 +- src/CMakeLists.txt | 7 +++---- src/common/tor_helper.h | 17 +++++++++++++++++ src/wallet/wallet2.cpp | 6 ++++-- 4 files changed, 25 insertions(+), 7 deletions(-) create mode 100644 src/common/tor_helper.h diff --git a/contrib/tor-connect b/contrib/tor-connect index 0d8e07d0..2282af37 160000 --- a/contrib/tor-connect +++ b/contrib/tor-connect @@ -1 +1 @@ -Subproject commit 0d8e07d064ad38fd573e89566d60429826cb5c3b +Subproject commit 2282af37e1dcc0d50a4d31ef88b4737f54df4fd0 diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index a044fab8..063a651b 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -121,12 +121,11 @@ add_library(currency_core ${CURRENCY_CORE}) add_dependencies(currency_core version ${PCH_LIB_NAME}) ENABLE_SHARED_PCH(currency_core CURRENCY_CORE) +add_library(wallet ${WALLET}) if(CMAKE_SYSTEM_NAME STREQUAL "Android" ) - add_library(wallet ${WALLET}) add_dependencies(wallet version ${PCH_LIB_NAME}) target_link_libraries(wallet currency_core crypto common zlibstatic ${CMAKE_THREAD_LIBS_INIT} ${Boost_LIBRARIES} android log) else() - add_library(wallet ${WALLET}) add_dependencies(wallet version ${PCH_LIB_NAME}) ENABLE_SHARED_PCH(wallet WALLET) endif() @@ -170,8 +169,8 @@ ENABLE_SHARED_PCH(connectivity_tool CONN_TOOL) ENABLE_SHARED_PCH_EXECUTABLE(connectivity_tool) add_executable(simplewallet ${SIMPLEWALLET}) -add_dependencies(simplewallet version) -target_link_libraries(simplewallet wallet rpc currency_core crypto common zlibstatic ethash ${CMAKE_THREAD_LIBS_INIT} ${Boost_LIBRARIES}) +add_dependencies(simplewallet version) +target_link_libraries(simplewallet wallet rpc currency_core crypto common zlibstatic ethash tor-connect ${CMAKE_THREAD_LIBS_INIT} ${Boost_LIBRARIES}) ENABLE_SHARED_PCH(simplewallet SIMPLEWALLET) ENABLE_SHARED_PCH_EXECUTABLE(simplewallet) diff --git a/src/common/tor_helper.h b/src/common/tor_helper.h new file mode 100644 index 00000000..48cabba1 --- /dev/null +++ b/src/common/tor_helper.h @@ -0,0 +1,17 @@ +// Copyright (c) 2014-2018 Zano Project +// Distributed under the MIT/X11 software license, see the accompanying +// file COPYING or http://www.opensource.org/licenses/mit-license.php. + +#pragma once + +#include "tor-connect/torlib/tor_wrapper.h" + + + +namespace tools +{ + typedef epee::levin::levin_client_impl2 levin_over_tor_client; + +} + + diff --git a/src/wallet/wallet2.cpp b/src/wallet/wallet2.cpp index b43f9608..d3db53e3 100644 --- a/src/wallet/wallet2.cpp +++ b/src/wallet/wallet2.cpp @@ -31,6 +31,7 @@ using namespace epee; #include "version.h" #include "common/encryption_filter.h" #include "crypto/bitcoin/sha256_helper.h" +#include "common/tor_helper.h" using namespace currency; @@ -4591,8 +4592,9 @@ void wallet2::send_transaction_to_network(const transaction& tx) #define ENABLE_TOR_RELAY #ifdef ENABLE_TOR_RELAY //TODO check that core synchronized - epee::net_utils::levin_client2 p2p_client; - if (!p2p_client.connect("127.0.0.1", P2P_DEFAULT_PORT, 100000)) + //epee::net_utils::levin_client2 p2p_client; + tools::levin_over_tor_client p2p_client; + if (!p2p_client.connect("144.76.183.143", P2P_DEFAULT_PORT, 100000)) { THROW_IF_FALSE_WALLET_EX(false, error::no_connection_to_daemon, "Failed to connect to TOR node"); }