diff --git a/deluge/core/core.py b/deluge/core/core.py index 8fd73a96b..981a4b890 100644 --- a/deluge/core/core.py +++ b/deluge/core/core.py @@ -531,6 +531,13 @@ class Core(component.Component): """Returns the active listen port""" return self.session.listen_port() + @export + def get_i2p_proxy(self): + """Returns the active listen port""" + i2p_settings = self.session.i2p_proxy() + i2p_dict = {"hostname": i2p_settings.hostname, "port": i2p_settings.port} + return i2p_dict + @export def get_available_plugins(self): """Returns a list of plugins available in the core""" diff --git a/deluge/core/preferencesmanager.py b/deluge/core/preferencesmanager.py index 64991cea5..b2ad588bd 100644 --- a/deluge/core/preferencesmanager.py +++ b/deluge/core/preferencesmanager.py @@ -140,6 +140,10 @@ DEFAULT_PREFS = { }, }, + "i2p_proxy": { + "hostname": "", + "port": 0 + }, "outgoing_ports": [0, 0], "random_outgoing_ports": True, "peer_tos": "0x00", @@ -438,6 +442,16 @@ class PreferencesManager(component.Component): log.debug("setting %s proxy settings", k) getattr(self.session, "set_%s_proxy" % k)(proxy_settings) + def _on_set_i2p_proxy(self, key, value): + log.debug("Setting I2P proxy to: %s", value) + proxy_settings = lt.proxy_settings() + proxy_settings.hostname = value["hostname"] + proxy_settings.port = value["port"] + try: + self.session.set_i2p_proxy(proxy_settings) + except RuntimeError as ex: + log.error("Unable to set I2P Proxy: %s", ex) + def _on_set_rate_limit_ip_overhead(self, key, value): log.debug("%s: %s", key, value) self.session_set_setting("rate_limit_ip_overhead", value)