Author: andar
Revision: 5326
Log:
Add some command line options to the daemon to set the listen
interfaces, -i and -u
Diff:
Modified: trunk/deluge/core/core.py
===================================================================
--- trunk/deluge/core/core.py 2009-05-29 00:31:59 UTC (rev 5325)
+++ trunk/deluge/core/core.py 2009-05-30 00:22:14 UTC (rev 5326)
@@ -78,7 +78,7 @@
'tracker_status', 'trackers', 'upload_payload_rate']
class Core(component.Component):
- def __init__(self):
+ def __init__(self, listen_interface=None):
log.debug("Core init..")
component.Component.__init__(self, "Core")
@@ -141,6 +141,13 @@
# Get the core config
self.config = deluge.configmanager.ConfigManager("core.conf")
+ # If there was an interface value from the command line, use it, but
+ # store the one in the config so we can restore it on shutdown
+ self.__old_interface = None
+ if listen_interface:
+ self.__old_interface = self.config["listen_interface"]
+ self.config["listen_interface"] = listen_interface
+
def start(self):
"""Starts the core"""
# New release check information
@@ -153,6 +160,10 @@
# Save the libtorrent session state
self.__save_session_state()
+ # We stored a copy of the old interface value
+ if self.__old_interface:
+ self.config["listen_interface"] = self.__old_interface
+
# Make sure the config file has been saved
self.config.save()
Modified: trunk/deluge/core/daemon.py
===================================================================
--- trunk/deluge/core/daemon.py 2009-05-29 00:31:59 UTC (rev 5325)
+++ trunk/deluge/core/daemon.py 2009-05-30 00:22:14 UTC (rev 5326)
@@ -123,7 +123,7 @@
log.debug("options: %s", options)
log.debug("args: %s", args)
# Set the config directory
- if options:
+ if options and options.config:
deluge.configmanager.set_config_dir(options.config)
from deluge.core.core import Core
@@ -133,10 +133,16 @@
port = self.core.config["daemon_port"]
if options and options.port:
port = options.port
+ if options and options.ui_interface:
+ interface = options.ui_interface
+ else:
+ interface = ""
+
self.rpcserver = RPCServer(
port=port,
allow_remote=self.core.config["allow_remote"],
- listen=not classic
+ listen=not classic,
+ interface=interface
)
# Register the daemon and the core RPCs
Modified: trunk/deluge/core/preferencesmanager.py
===================================================================
--- trunk/deluge/core/preferencesmanager.py 2009-05-29 00:31:59 UTC (rev
5325)
+++ trunk/deluge/core/preferencesmanager.py 2009-05-30 00:22:14 UTC (rev
5326)
@@ -61,6 +61,7 @@
"compact_allocation": False,
"download_location": deluge.common.get_default_download_dir(),
"listen_ports": [6881, 6891],
+ "listen_interface": "",
"copy_torrent_file": False,
"torrentfiles_location": deluge.common.get_default_download_dir(),
"plugins_location": os.path.join(deluge.configmanager.get_config_dir(),
"plugins"),
@@ -162,6 +163,8 @@
self._on_set_state_location)
self.config.register_set_function("listen_ports",
self._on_set_listen_ports)
+ self.config.register_set_function("listen_interface",
+ self._on_set_listen_interface)
self.config.register_set_function("random_port",
self._on_set_random_port)
self.config.register_set_function("outgoing_ports",
@@ -245,8 +248,12 @@
# Only set the listen ports if random_port is not true
if self.config["random_port"] is not True:
log.debug("listen port range set to %s-%s", value[0], value[1])
- self.session.listen_on(value[0], value[1])
+ self.session.listen_on(value[0], value[1],
str(self.config["listen_interface"]))
+ def _on_set_listen_interface(self, key, value):
+ # Call the random_port callback since it'll do what we need
+ self._on_set_random_port("random_port", self.config["random_port"])
+
def _on_set_random_port(self, key, value):
log.debug("random port value set to %s", value)
# We need to check if the value has been changed to true and false
@@ -263,7 +270,7 @@
# Set the listen ports
log.debug("listen port range set to %s-%s", listen_ports[0],
listen_ports[1])
- self.session.listen_on(listen_ports[0], listen_ports[1])
+ self.session.listen_on(listen_ports[0], listen_ports[1],
str(self.config["listen_interface"]))
def _on_set_outgoing_ports(self, key, value):
if not self.config["random_outgoing_ports"]:
Modified: trunk/deluge/main.py
===================================================================
--- trunk/deluge/main.py 2009-05-29 00:31:59 UTC (rev 5325)
+++ trunk/deluge/main.py 2009-05-30 00:22:14 UTC (rev 5326)
@@ -131,6 +131,13 @@
version=deluge.common.get_version())
parser.add_option("-p", "--port", dest="port",
help="Port daemon will listen on", action="store", type="int")
+ parser.add_option("-i", "--interface", dest="interface",
+ help="Interface daemon will listen for bittorrent connections on, \
+this should be an IP address",
+ action="store", type="str")
+ parser.add_option("-u", "--ui-interface", dest="ui_interface",
+ help="Interface daemon will listen for UI connections on, this should
be\
+ an IP address", action="store", type="str")
parser.add_option("-d", "--do-not-daemonize", dest="donot",
help="Do not daemonize", action="store_true", default=False)
parser.add_option("-c", "--config", dest="config",
@@ -144,7 +151,7 @@
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("--profile", dest="profile", action="store_true",
default=False,
- help="Profiles the daemon" )
+ help="Profiles the daemon")
# Get the options and args from the OptionParser
(options, args) = parser.parse_args()
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"deluge-commit" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/deluge-commit?hl=en
-~----------~----~----~----~------~----~------~--~---