I previously posted a fix for this defect in ticket 1681, which has disappeared from the Trac. It's also mentioned in ticket 1384 (which led me here). I tried to post my patch as a comment to 1384, but the Trac permissions wouldn't let me. Who is the cretin who thinks it's a good idea to keep community members from contributing code? And who is responsible for deleting the previous ticket?
Once again, here's the patch. Sigh.
Code: Select all
Index: docs/man/deluged.1
--- docs/man/deluged.1.orig 2010-08-20 15:20:51.000000000 -0600
+++ docs/man/deluged.1 2011-03-31 18:06:24.000000000 -0600
@@ -48,6 +48,11 @@
.TP
.I -q --quiet
Sets the log level to 'none', this is the same as `\-L none`
+.TP
+.I -T NAME=VALUE, --libtorrent=NAME=VALUE, --lib-torrent=NAME=VALUE
+Sets the libtorrent option NAME to the given value.
+For example, `\-T announce_ip=10.0.0.1' causes deluged to announce itself with the given IP address.
+For a complete list of options, see the libtorrent documentation.
.SH SEE ALSO
.B Homepage:
====================
Index: deluge/core/core.py
--- deluge/core/core.py.orig 2010-08-20 15:20:51.000000000 -0600
+++ deluge/core/core.py 2011-03-31 17:36:35.000000000 -0600
@@ -69,7 +69,7 @@
from deluge.core.rpcserver import export
class Core(component.Component):
- def __init__(self, listen_interface=None):
+ def __init__(self, listen_interface=None, settings={}):
log.debug("Core init..")
component.Component.__init__(self, "Core")
@@ -90,8 +90,18 @@
self.settings = lt.session_settings()
self.settings.user_agent = "Deluge %s" % deluge.common.get_version()
- # Set session settings
+ # Set other default settings
self.settings.send_redundant_have = True
+
+ # Set passed settings
+ for key in settings.keys():
+ if hasattr(self.settings, key):
+ setattr(self.settings, key, settings[key])
+ else:
+ log.error("Illegal settings key %s" % key)
+ raise KeyError
+
+ # Set session settings
self.session.set_settings(self.settings)
# Load metadata extension
====================
Index: deluge/core/daemon.py
--- deluge/core/daemon.py.orig 2010-08-20 15:20:51.000000000 -0600
+++ deluge/core/daemon.py 2011-03-31 01:01:32.000000000 -0600
@@ -47,7 +47,7 @@
import deluge.error
class Daemon(object):
- def __init__(self, options=None, args=None, classic=False):
+ def __init__(self, parser, options=None, args=None, classic=False):
# Check for another running instance of the daemon
if os.path.isfile(deluge.configmanager.get_config_dir("deluged.pid")):
# Get the PID and the port of the supposedly running daemon
@@ -133,9 +133,18 @@
if options and options.config:
deluge.configmanager.set_config_dir(options.config)
+ # Handle any libtorrent settings
+ if options and options.libtorrent_settings:
+ settings_dict = {}
+ for setting in options.libtorrent_settings:
+ opt = setting.split('=', 1)
+ if len(opt) != 2:
+ parser.error('--libtorrent requires name=value')
+ settings_dict[opt[0]] = opt[1]
+
from deluge.core.core import Core
# Start the core as a thread and join it until it's done
- self.core = Core()
+ self.core = Core(settings=settings_dict)
port = self.core.config["daemon_port"]
if options and options.port:
====================
Index: deluge/main.py
--- deluge/main.py.orig 2011-03-31 00:49:22.000000000 -0600
+++ deluge/main.py 2011-03-31 02:10:26.000000000 -0600
@@ -152,6 +152,9 @@
help="Set the log level: none, info, warning, error, critical, debug", action="store", type="str")
parser.add_option("-q", "--quiet", dest="quiet",
help="Sets the log level to 'none', this is the same as `-L none`", action="store_true", default=False)
+ parser.add_option("-T", "--libtorrent", "--lib-torrent",
+ dest="libtorrent_settings", action="append", metavar="NAME=VALUE",
+ help="Sets the libtorrent option NAME to VALUE")
parser.add_option("--profile", dest="profile", action="store_true", default=False,
help="Profiles the daemon")
@@ -211,7 +214,7 @@
hsp.start()
try:
from deluge.core.daemon import Daemon
- Daemon(options, args)
+ Daemon(parser, options, args)
except deluge.error.DaemonRunningError, e:
log.error(e)
log.error("You cannot run multiple daemons with the same config directory set.")
====================
Index: libtorrent/include/libtorrent/session_settings.hpp
--- libtorrent/include/libtorrent/session_settings.hpp.orig 2010-11-03 22:44:40.000000000 -0600
+++ libtorrent/include/libtorrent/session_settings.hpp 2011-03-31 05:52:14.000000000 -0600
@@ -109,6 +109,7 @@
, inactivity_timeout(600)
, unchoke_interval(15)
, optimistic_unchoke_multiplier(4)
+ , announce_ip()
, num_want(200)
, initial_picker_threshold(4)
, allowed_fast_set_size(10)
@@ -287,7 +288,7 @@
// if this is set, this IP will be reported do the
// tracker in the ip= parameter.
- address announce_ip;
+ std::string announce_ip;
// the num want sent to trackers
int num_want;
====================
Index: libtorrent/src/udp_tracker_connection.cpp
--- libtorrent/src/udp_tracker_connection.cpp.orig 2010-11-03 22:44:43.000000000 -0600
+++ libtorrent/src/udp_tracker_connection.cpp 2011-03-31 06:04:42.000000000 -0600
@@ -506,8 +506,14 @@
detail::write_int64(req.uploaded, out); // uploaded
detail::write_int32(req.event, out); // event
// ip address
- if (m_settings.announce_ip != address() && m_settings.announce_ip.is_v4())
- detail::write_uint32(m_settings.announce_ip.to_v4().to_ulong(), out);
+ if (m_settings.announce_ip != "")
+ {
+ address announce_ip = address::from_string(m_settings.announce_ip);
+ if (announce_ip.is_v4())
+ detail::write_uint32(announce_ip.to_v4().to_ulong(), out);
+ else
+ detail::write_int32(0, out);
+ }
else
detail::write_int32(0, out);
detail::write_int32(req.key, out); // key
====================
Index: libtorrent/src/http_tracker_connection.cpp
--- libtorrent/src/http_tracker_connection.cpp.orig 2010-11-03 22:44:43.000000000 -0600
+++ libtorrent/src/http_tracker_connection.cpp 2011-03-31 05:59:08.000000000 -0600
@@ -160,12 +160,8 @@
url += "&numwant=";
url += to_string((std::min)(tracker_req().num_want, 999)).elems;
- if (m_settings.announce_ip != address())
- {
- error_code ec;
- std::string ip = m_settings.announce_ip.to_string(ec);
- if (!ec) url += "&ip=" + ip;
- }
+ if (m_settings.announce_ip != "")
+ url += "&ip=" + m_settings.announce_ip;
#ifndef TORRENT_DISABLE_ENCRYPTION
url += "&supportcrypto=1";
====================
Index: libtorrent/docs/manual.html
--- libtorrent/docs/manual.html.orig 2010-11-03 22:44:48.000000000 -0600
+++ libtorrent/docs/manual.html 2011-03-31 18:01:51.000000000 -0600
@@ -3058,7 +3058,7 @@
int inactivity_timeout;
int unchoke_interval;
int optimistic_unchoke_multiplier;
- address announce_ip;
+ string announce_ip;
int num_want;
int initial_picker_threshold;
int allowed_fast_set_size;
====================
Index: libtorrent/docs/manual.rst
--- libtorrent/docs/manual.rst.orig 2010-11-03 22:44:48.000000000 -0600
+++ libtorrent/docs/manual.rst 2011-03-31 18:02:13.000000000 -0600
@@ -3018,7 +3018,7 @@
int inactivity_timeout;
int unchoke_interval;
int optimistic_unchoke_multiplier;
- address announce_ip;
+ string announce_ip;
int num_want;
int initial_picker_threshold;
int allowed_fast_set_size;
====================
Index: libtorrent/bindings/python/src/session_settings.cpp
--- libtorrent/bindings/python/src/session_settings.cpp.orig 2010-11-03 22:44:48.000000000 -0600
+++ libtorrent/bindings/python/src/session_settings.cpp 2011-03-31 03:47:10.000000000 -0600
@@ -38,6 +38,7 @@
.def_readwrite("inactivity_timeout", &session_settings::inactivity_timeout)
.def_readwrite("unchoke_interval", &session_settings::unchoke_interval)
.def_readwrite("optimistic_unchoke_multiplier", &session_settings::optimistic_unchoke_multiplier)
+ .def_readwrite("announce_ip", &session_settings::announce_ip)
.def_readwrite("num_want", &session_settings::num_want)
.def_readwrite("initial_picker_threshold", &session_settings::initial_picker_threshold)
.def_readwrite("allowed_fast_set_size", &session_settings::allowed_fast_set_size)