diff --git a/src/gui/qt-daemon/application/mainwindow.cpp b/src/gui/qt-daemon/application/mainwindow.cpp index 370d06c4..88cb6cdd 100644 --- a/src/gui/qt-daemon/application/mainwindow.cpp +++ b/src/gui/qt-daemon/application/mainwindow.cpp @@ -1665,6 +1665,20 @@ QString MainWindow::get_log_level(const QString& param) CATCH_ENTRY_FAIL_API_RESPONCE(); } +QString set_enable_tor(const QString& param) +{ + TRY_ENTRY(); + LOG_API_TIMING(); + PREPARE_ARG_FROM_JSON(currency::struct_with_one_t_type, enabl_tor); + m_backend. + //epee::log_space::get_set_log_detalisation_level(true, enabl_tor.v); + default_ar.error_code = API_RETURN_CODE_OK; + LOG_PRINT("[LOG LEVEL]: set to " << lvl.v, LOG_LEVEL_MIN); + + return MAKE_RESPONSE(default_ar); + CATCH_ENTRY_FAIL_API_RESPONCE(); +} + // QString MainWindow::dump_all_offers() // { // LOG_API_TIMING(); diff --git a/src/gui/qt-daemon/application/mainwindow.h b/src/gui/qt-daemon/application/mainwindow.h index dfe9ae4b..79251e2a 100644 --- a/src/gui/qt-daemon/application/mainwindow.h +++ b/src/gui/qt-daemon/application/mainwindow.h @@ -137,6 +137,7 @@ public: QString stop_pos_mining(const QString& param); QString set_log_level(const QString& param); QString get_log_level(const QString& param); + QString set_enable_tor(const QString& param); // QString dump_all_offers(); QString webkit_launched_script(); QString get_smart_wallet_info(const QString& param); diff --git a/src/wallet/wallets_manager.cpp b/src/wallet/wallets_manager.cpp index 075b1bd5..015f5e7a 100644 --- a/src/wallet/wallets_manager.cpp +++ b/src/wallet/wallets_manager.cpp @@ -81,7 +81,8 @@ wallets_manager::wallets_manager():m_pview(&m_view_stub), m_is_pos_allowed(false), m_qt_logs_enbaled(false), m_dont_save_wallet_at_stop(false), - m_use_deffered_global_outputs(false) + m_use_deffered_global_outputs(false), + m_use_tor(true) { #ifndef MOBILE_WALLET_BUILD m_offers_service.set_disabled(true); @@ -791,6 +792,8 @@ void wallets_manager::init_wallet_entry(wallet_vs_options& wo, uint64_t id) m_wallet_log_prefixes.resize(id + 1); m_wallet_log_prefixes[id] = std::string("[") + epee::string_tools::num_to_string_fast(id) + ":" + wo.w->get()->get_account().get_public_address_str().substr(0, 6) + "] "; } + + wo.w->get()->set_disable_tor_relay(!m_use_tor); } @@ -1842,6 +1845,17 @@ void wallets_manager::on_pos_block_found(size_t wallet_id, const currency::block { m_pview->pos_block_found(b); } +bool wallets_manager::set_use_tor(bool use_tor) +{ + m_use_tor = use_tor; + SHARED_CRITICAL_REGION_LOCAL(m_wallets_lock); + for (auto& w : m_wallets) + { + w.second.w->get()->set_disable_tor_relay(!m_use_tor); + } + return true; +} + void wallets_manager::on_sync_progress(size_t wallet_id, const uint64_t& percents) { // do not lock m_wallets_lock down the callstack! It will lead to a deadlock, because wallet locked_object is aready locked diff --git a/src/wallet/wallets_manager.h b/src/wallet/wallets_manager.h index 5b919a0b..77656785 100644 --- a/src/wallet/wallets_manager.h +++ b/src/wallet/wallets_manager.h @@ -163,7 +163,7 @@ public: bool is_qt_logs_enabled() const { return m_qt_logs_enbaled; } std::string get_qt_dev_tools_option() const { return m_qt_dev_tools; } void set_use_deffered_global_outputs(bool use) { m_use_deffered_global_outputs = use; } - + bool set_use_tor(bool use_tor); private: void main_worker(const po::variables_map& vm); bool init_local_daemon(); @@ -226,6 +226,7 @@ private: bool m_qt_logs_enbaled; std::string m_qt_dev_tools; std::atomic m_is_pos_allowed; + std::atomic m_use_tor; std::map m_wallets;