Compare commits

...

1 Commits

Author SHA1 Message Date
rakshasa 4980283f38 Stuff. 2026-07-10 15:44:04 +02:00
3 changed files with 28 additions and 10 deletions
-3
View File
@@ -70,9 +70,6 @@ Control::initialize() {
display::Window::slot_unschedule([this](display::Window* w) { m_display->unschedule(w); }); display::Window::slot_unschedule([this](display::Window* w) { m_display->unschedule(w); });
display::Window::slot_adjust([this]() { m_display->adjust_layout(); }); display::Window::slot_adjust([this]() { m_display->adjust_layout(); });
torrent::net_thread::http_stack()->set_user_agent(USER_AGENT);
m_core->listen_open();
m_core->set_hashing_view(*m_view_manager->find_throw("hashing")); m_core->set_hashing_view(*m_view_manager->find_throw("hashing"));
m_ui->init(this); m_ui->init(this);
+21 -7
View File
@@ -8,6 +8,7 @@
#include <torrent/object_stream.h> #include <torrent/object_stream.h>
#include <torrent/rate.h> #include <torrent/rate.h>
#include <torrent/runtime/network_manager.h> #include <torrent/runtime/network_manager.h>
#include <torrent/runtime/runtime.h>
#include <torrent/tracker/dht_controller.h> #include <torrent/tracker/dht_controller.h>
#include <torrent/utils/log.h> #include <torrent/utils/log.h>
@@ -141,18 +142,29 @@ DhtManager::save_dht_cache() {
void void
DhtManager::set_mode_by_user(const std::string& arg) { DhtManager::set_mode_by_user(const std::string& arg) {
for (int i = 0; i < dht_settings_num; i++) { unsigned int mode = [arg]() {
if (arg == dht_settings[i]) { for (int i = 0; i < dht_settings_num; i++) {
m_set_by_user = true; if (arg == dht_settings[i])
return set_mode_directly(i); return i;
} }
throw torrent::input_error("Invalid dht mode: " + arg);
}();
m_set_by_user = true;
if (!torrent::runtime::is_network_initialized()) {
m_start = mode;
return;
} }
set_mode_directly(mode);
} }
void void
DhtManager::set_mode_directly(unsigned int mode) { DhtManager::set_mode_directly(unsigned int mode) {
if (mode >= dht_settings_num) if (mode >= dht_settings_num)
throw torrent::input_error("Invalid argument."); throw torrent::input_error("Invalid dht mode.");
m_start = mode; m_start = mode;
@@ -164,8 +176,10 @@ DhtManager::set_mode_directly(unsigned int mode) {
void void
DhtManager::set_auto_if_untouched_and_has_session() { DhtManager::set_auto_if_untouched_and_has_session() {
if (m_set_by_user) if (m_set_by_user) {
set_mode_directly(m_start);
return; return;
}
if (rpc::call_command_string("session.path").empty()) { if (rpc::call_command_string("session.path").empty()) {
LT_LOG("DHT auto-start disabled, session path not set.", 0); LT_LOG("DHT auto-start disabled, session path not set.", 0);
+7
View File
@@ -11,7 +11,9 @@
#include <torrent/exceptions.h> #include <torrent/exceptions.h>
#include <torrent/data/chunk_utils.h> #include <torrent/data/chunk_utils.h>
#include <torrent/net/fd.h> #include <torrent/net/fd.h>
#include <torrent/net/http_stack.h>
#include <torrent/runtime/memory_manager.h> #include <torrent/runtime/memory_manager.h>
#include <torrent/runtime/runtime.h>
#include <torrent/utils/chrono.h> #include <torrent/utils/chrono.h>
#include <torrent/utils/log.h> #include <torrent/utils/log.h>
@@ -450,6 +452,11 @@ main(int argc, char** argv) {
control->initialize(); control->initialize();
control->ui()->load_input_history(); control->ui()->load_input_history();
torrent::net_thread::http_stack()->set_user_agent(USER_AGENT);
torrent::runtime::initialize_network();
control->core()->listen_open();
// Load session torrents and perform scheduled tasks to ensure session torrents are loaded // Load session torrents and perform scheduled tasks to ensure session torrents are loaded
// before arg torrents. // before arg torrents.
control->dht_manager()->set_auto_if_untouched_and_has_session(); control->dht_manager()->set_auto_if_untouched_and_has_session();