mirror of
https://github.com/rakshasa/rtorrent.git
synced 2026-08-11 12:42:31 +00:00
Improved listen/dht port handling and added 'dht.override_port.set' command.
This commit is contained in:
+1
-18
@@ -33,16 +33,6 @@ DhtManager::~DhtManager() {
|
||||
torrent::this_thread::scheduler()->erase(&m_stop_timeout);
|
||||
}
|
||||
|
||||
void
|
||||
DhtManager::set_port(uint16_t port) {
|
||||
if (torrent::dht_controller()->is_active()) {
|
||||
LT_LOG_ERROR("cannot change port while DHT is active", 0);
|
||||
throw torrent::input_error("cannot change port while DHT is active");
|
||||
}
|
||||
|
||||
m_port = port;
|
||||
}
|
||||
|
||||
void
|
||||
DhtManager::load_dht_cache() {
|
||||
if (m_start == dht_disable || !control->core()->download_store()->is_enabled()) {
|
||||
@@ -95,14 +85,7 @@ DhtManager::start_dht() {
|
||||
torrent::dht_controller()->set_upload_throttle(throttles.first);
|
||||
torrent::dht_controller()->set_download_throttle(throttles.second);
|
||||
|
||||
if (m_port <= 0) {
|
||||
LT_LOG("server start skipped, port not set", 0);
|
||||
return;
|
||||
}
|
||||
|
||||
LT_LOG("starting server : port=%" PRIu16, m_port);
|
||||
|
||||
if (!torrent::dht_controller()->start(m_port)) {
|
||||
if (!torrent::dht_controller()->start()) {
|
||||
m_start = dht_off;
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -10,9 +10,6 @@ class DhtManager {
|
||||
public:
|
||||
~DhtManager();
|
||||
|
||||
uint16_t port() const { return m_port; }
|
||||
void set_port(uint16_t port);
|
||||
|
||||
void load_dht_cache();
|
||||
void save_dht_cache();
|
||||
torrent::Object dht_statistics();
|
||||
@@ -49,9 +46,7 @@ private:
|
||||
torrent::utils::SchedulerEntry m_stop_timeout;
|
||||
|
||||
bool m_warned{};
|
||||
|
||||
int m_start{dht_off};
|
||||
uint16_t m_port{0};
|
||||
|
||||
std::string m_throttleName;
|
||||
};
|
||||
|
||||
+1
-1
@@ -196,7 +196,7 @@ Manager::set_bind_address(const std::string& addr) {
|
||||
|
||||
try {
|
||||
|
||||
if (torrent::connection_manager()->listen_port() != 0) {
|
||||
if (torrent::connection_manager()->is_listen_open()) {
|
||||
torrent::connection_manager()->listen_close();
|
||||
torrent::config::network_config()->set_bind_address(ai->address()->c_sockaddr());
|
||||
|
||||
|
||||
Reference in New Issue
Block a user