├── README ├── Randomize.egg-info ├── PKG-INFO ├── SOURCES.txt ├── dependency_links.txt ├── entry_points.txt └── top_level.txt ├── create_dev_link.sh ├── dist └── Randomize-0.1-py2.7.egg ├── randomize ├── __init__.py ├── common.py ├── core.py ├── data │ ├── randomize.glade │ └── randomize.js ├── gtkui.py └── webui.py └── setup.py /README: -------------------------------------------------------------------------------- 1 | Randomize 2 | ========= 3 | 4 | A plugin for deluge (torrent client) which when enabled will check whether the incoming port is firewalled every configurable interval and it finds the current listen port to be firewalled it will choose another random port and force a reannounce for all the current torrents. It gets enabled only if user has chosen to use random incoming ports in the core config (Network). 5 | -------------------------------------------------------------------------------- /Randomize.egg-info/PKG-INFO: -------------------------------------------------------------------------------- 1 | Metadata-Version: 1.0 2 | Name: Randomize 3 | Version: 0.1 4 | Summary: UNKNOWN 5 | Home-page: UNKNOWN 6 | Author: Pradeep Jindal 7 | Author-email: praddyjindal@gmail.com 8 | License: GPLv3 9 | Description: UNKNOWN 10 | Platform: UNKNOWN 11 | -------------------------------------------------------------------------------- /Randomize.egg-info/SOURCES.txt: -------------------------------------------------------------------------------- 1 | setup.py 2 | Randomize.egg-info/PKG-INFO 3 | Randomize.egg-info/SOURCES.txt 4 | Randomize.egg-info/dependency_links.txt 5 | Randomize.egg-info/entry_points.txt 6 | Randomize.egg-info/top_level.txt 7 | randomize/__init__.py 8 | randomize/common.py 9 | randomize/core.py 10 | randomize/gtkui.py 11 | randomize/webui.py -------------------------------------------------------------------------------- /Randomize.egg-info/dependency_links.txt: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /Randomize.egg-info/entry_points.txt: -------------------------------------------------------------------------------- 1 | 2 | [deluge.plugin.core] 3 | Randomize = randomize:CorePlugin 4 | [deluge.plugin.gtkui] 5 | Randomize = randomize:GtkUIPlugin 6 | [deluge.plugin.web] 7 | Randomize = randomize:WebUIPlugin 8 | -------------------------------------------------------------------------------- /Randomize.egg-info/top_level.txt: -------------------------------------------------------------------------------- 1 | randomize 2 | -------------------------------------------------------------------------------- /create_dev_link.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | cd /home/praddy/src/randomize 3 | mkdir temp 4 | export PYTHONPATH=./temp 5 | python setup.py build develop --install-dir ./temp 6 | cp ./temp/Randomize.egg-link /home/praddy/.config/deluge/plugins 7 | rm -fr ./temp 8 | -------------------------------------------------------------------------------- /dist/Randomize-0.1-py2.7.egg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/praddy/Randomize/8d004d05c2ec2e21b0d89f32c97eff1cea7a2445/dist/Randomize-0.1-py2.7.egg -------------------------------------------------------------------------------- /randomize/__init__.py: -------------------------------------------------------------------------------- 1 | # 2 | # __init__.py 3 | # 4 | # Copyright (C) 2009 Pradeep Jindal 5 | # 6 | # Basic plugin template created by: 7 | # Copyright (C) 2008 Martijn Voncken 8 | # Copyright (C) 2007-2009 Andrew Resch 9 | # Copyright (C) 2009 Damien Churchill 10 | # 11 | # Deluge is free software. 12 | # 13 | # You may redistribute it and/or modify it under the terms of the 14 | # GNU General Public License, as published by the Free Software 15 | # Foundation; either version 3 of the License, or (at your option) 16 | # any later version. 17 | # 18 | # deluge is distributed in the hope that it will be useful, 19 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 20 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 21 | # See the GNU General Public License for more details. 22 | # 23 | # You should have received a copy of the GNU General Public License 24 | # along with deluge. If not, write to: 25 | # The Free Software Foundation, Inc., 26 | # 51 Franklin Street, Fifth Floor 27 | # Boston, MA 02110-1301, USA. 28 | # 29 | # In addition, as a special exception, the copyright holders give 30 | # permission to link the code of portions of this program with the OpenSSL 31 | # library. 32 | # You must obey the GNU General Public License in all respects for all of 33 | # the code used other than OpenSSL. If you modify file(s) with this 34 | # exception, you may extend this exception to your version of the file(s), 35 | # but you are not obligated to do so. If you do not wish to do so, delete 36 | # this exception statement from your version. If you delete this exception 37 | # statement from all source files in the program, then also delete it here. 38 | # 39 | 40 | from deluge.plugins.init import PluginInitBase 41 | 42 | class CorePlugin(PluginInitBase): 43 | def __init__(self, plugin_name): 44 | from core import Core as _plugin_cls 45 | self._plugin_cls = _plugin_cls 46 | super(CorePlugin, self).__init__(plugin_name) 47 | 48 | class GtkUIPlugin(PluginInitBase): 49 | def __init__(self, plugin_name): 50 | from gtkui import GtkUI as _plugin_cls 51 | self._plugin_cls = _plugin_cls 52 | super(GtkUIPlugin, self).__init__(plugin_name) 53 | 54 | class WebUIPlugin(PluginInitBase): 55 | def __init__(self, plugin_name): 56 | from webui import WebUI as _plugin_cls 57 | self._plugin_cls = _plugin_cls 58 | super(WebUIPlugin, self).__init__(plugin_name) 59 | -------------------------------------------------------------------------------- /randomize/common.py: -------------------------------------------------------------------------------- 1 | # 2 | # common.py 3 | # 4 | # Copyright (C) 2009 Pradeep Jindal 5 | # 6 | # Basic plugin template created by: 7 | # Copyright (C) 2008 Martijn Voncken 8 | # Copyright (C) 2007-2009 Andrew Resch 9 | # Copyright (C) 2009 Damien Churchill 10 | # 11 | # Deluge is free software. 12 | # 13 | # You may redistribute it and/or modify it under the terms of the 14 | # GNU General Public License, as published by the Free Software 15 | # Foundation; either version 3 of the License, or (at your option) 16 | # any later version. 17 | # 18 | # deluge is distributed in the hope that it will be useful, 19 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 20 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 21 | # See the GNU General Public License for more details. 22 | # 23 | # You should have received a copy of the GNU General Public License 24 | # along with deluge. If not, write to: 25 | # The Free Software Foundation, Inc., 26 | # 51 Franklin Street, Fifth Floor 27 | # Boston, MA 02110-1301, USA. 28 | # 29 | # In addition, as a special exception, the copyright holders give 30 | # permission to link the code of portions of this program with the OpenSSL 31 | # library. 32 | # You must obey the GNU General Public License in all respects for all of 33 | # the code used other than OpenSSL. If you modify file(s) with this 34 | # exception, you may extend this exception to your version of the file(s), 35 | # but you are not obligated to do so. If you do not wish to do so, delete 36 | # this exception statement from your version. If you delete this exception 37 | # statement from all source files in the program, then also delete it here. 38 | # 39 | 40 | def get_resource(filename): 41 | import pkg_resources, os 42 | return pkg_resources.resource_filename("randomize", os.path.join("data", filename)) 43 | -------------------------------------------------------------------------------- /randomize/core.py: -------------------------------------------------------------------------------- 1 | # 2 | # core.py 3 | # 4 | # Copyright (C) 2009 Pradeep Jindal 5 | # 6 | # Basic plugin template created by: 7 | # Copyright (C) 2008 Martijn Voncken 8 | # Copyright (C) 2007-2009 Andrew Resch 9 | # Copyright (C) 2009 Damien Churchill 10 | # 11 | # Deluge is free software. 12 | # 13 | # You may redistribute it and/or modify it under the terms of the 14 | # GNU General Public License, as published by the Free Software 15 | # Foundation; either version 3 of the License, or (at your option) 16 | # any later version. 17 | # 18 | # deluge is distributed in the hope that it will be useful, 19 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 20 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 21 | # See the GNU General Public License for more details. 22 | # 23 | # You should have received a copy of the GNU General Public License 24 | # along with deluge. If not, write to: 25 | # The Free Software Foundation, Inc., 26 | # 51 Franklin Street, Fifth Floor 27 | # Boston, MA 02110-1301, USA. 28 | # 29 | # In addition, as a special exception, the copyright holders give 30 | # permission to link the code of portions of this program with the OpenSSL 31 | # library. 32 | # You must obey the GNU General Public License in all respects for all of 33 | # the code used other than OpenSSL. If you modify file(s) with this 34 | # exception, you may extend this exception to your version of the file(s), 35 | # but you are not obligated to do so. If you do not wish to do so, delete 36 | # this exception statement from your version. If you delete this exception 37 | # statement from all source files in the program, then also delete it here. 38 | # 39 | 40 | from deluge.log import LOG as log 41 | from deluge.plugins.pluginbase import CorePluginBase 42 | import deluge.component as component 43 | import deluge.configmanager 44 | from deluge.core.rpcserver import export 45 | from twisted.internet.task import LoopingCall 46 | 47 | DEFAULT_PREFS = { 48 | "poll_interval": 60 49 | } 50 | 51 | class Core(CorePluginBase): 52 | def enable(self): 53 | self.config = deluge.configmanager.ConfigManager("randomize.conf", DEFAULT_PREFS) 54 | self.core_config = deluge.configmanager.ConfigManager("core.conf") 55 | self.enabled = False 56 | if not self.core_config["random_port"]: 57 | log.info("incoming port randomization is disabled in the core config, not doing anything") 58 | return 59 | self.check_timer = LoopingCall(self.rand_if_firewalled) 60 | self.check_timer.start(int(self.config['poll_interval'])) 61 | self.enabled = True 62 | 63 | 64 | def disable(self): 65 | self.config.save() 66 | if self.enable: 67 | self.check_timer.stop() 68 | 69 | def update(self): 70 | pass 71 | 72 | def rand_if_firewalled(self): 73 | core = component.get("Core") 74 | log.info("Current listen port: %d" % core.get_listen_port()) 75 | def rand_port(is_open): 76 | firewalled = not is_open 77 | log.info("Its %s" % (firewalled and "firewalled, gonna try to change port" or "not firewalled")) 78 | if firewalled: 79 | core.set_config({"random_port": False}) 80 | core.set_config({"random_port": True}) 81 | log.info("Listen port changed to: %d" % core.get_listen_port()) 82 | torrents = core.get_session_state() 83 | core.force_reannounce(torrents) 84 | core.test_listen_port().addCallback(rand_port) 85 | 86 | @export 87 | def set_config(self, config): 88 | """Sets the config dictionary""" 89 | changed = False 90 | if self.config != config: 91 | changed = True 92 | for key in config.keys(): 93 | self.config[key] = config[key] 94 | if changed: 95 | # calling disable will also save the config 96 | self.disable() 97 | self.enable() 98 | 99 | @export 100 | def get_config(self): 101 | """Returns the config dictionary""" 102 | return self.config.config 103 | -------------------------------------------------------------------------------- /randomize/data/randomize.glade: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | False 7 | 8 | 9 | True 10 | False 11 | 12 | 13 | True 14 | False 15 | How frequently to check whether the incoming port is firewalled or not 16 | Poll Interval (seconds) 17 | 18 | 19 | True 20 | True 21 | 0 22 | 23 | 24 | 25 | 26 | True 27 | True 28 | Interval in seconds 29 | 30 | False 31 | False 32 | True 33 | True 34 | 35 | 36 | True 37 | True 38 | 1 39 | 40 | 41 | 42 | 43 | 44 | 45 | -------------------------------------------------------------------------------- /randomize/data/randomize.js: -------------------------------------------------------------------------------- 1 | /* 2 | Script: randomize.js 3 | The client-side javascript code for the Randomize plugin. 4 | 5 | Copyright: 6 | (C) Pradeep Jindal 2009 7 | This program is free software; you can redistribute it and/or modify 8 | it under the terms of the GNU General Public License as published by 9 | the Free Software Foundation; either version 3, or (at your option) 10 | any later version. 11 | 12 | This program is distributed in the hope that it will be useful, 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | GNU General Public License for more details. 16 | 17 | You should have received a copy of the GNU General Public License 18 | along with this program. If not, write to: 19 | The Free Software Foundation, Inc., 20 | 51 Franklin Street, Fifth Floor 21 | Boston, MA 02110-1301, USA. 22 | 23 | In addition, as a special exception, the copyright holders give 24 | permission to link the code of portions of this program with the OpenSSL 25 | library. 26 | You must obey the GNU General Public License in all respects for all of 27 | the code used other than OpenSSL. If you modify file(s) with this 28 | exception, you may extend this exception to your version of the file(s), 29 | but you are not obligated to do so. If you do not wish to do so, delete 30 | this exception statement from your version. If you delete this exception 31 | statement from all source files in the program, then also delete it here. 32 | */ 33 | 34 | RandomizePlugin = Ext.extend(Deluge.Plugin, { 35 | constructor: function(config) { 36 | config = Ext.apply({ 37 | name: "Randomize" 38 | }, config); 39 | RandomizePlugin.superclass.constructor.call(this, config); 40 | }, 41 | 42 | onDisable: function() { 43 | 44 | }, 45 | 46 | onEnable: function() { 47 | 48 | } 49 | }); 50 | new RandomizePlugin(); 51 | -------------------------------------------------------------------------------- /randomize/gtkui.py: -------------------------------------------------------------------------------- 1 | # 2 | # gtkui.py 3 | # 4 | # Copyright (C) 2009 Pradeep Jindal 5 | # 6 | # Basic plugin template created by: 7 | # Copyright (C) 2008 Martijn Voncken 8 | # Copyright (C) 2007-2009 Andrew Resch 9 | # Copyright (C) 2009 Damien Churchill 10 | # 11 | # Deluge is free software. 12 | # 13 | # You may redistribute it and/or modify it under the terms of the 14 | # GNU General Public License, as published by the Free Software 15 | # Foundation; either version 3 of the License, or (at your option) 16 | # any later version. 17 | # 18 | # deluge is distributed in the hope that it will be useful, 19 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 20 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 21 | # See the GNU General Public License for more details. 22 | # 23 | # You should have received a copy of the GNU General Public License 24 | # along with deluge. If not, write to: 25 | # The Free Software Foundation, Inc., 26 | # 51 Franklin Street, Fifth Floor 27 | # Boston, MA 02110-1301, USA. 28 | # 29 | # In addition, as a special exception, the copyright holders give 30 | # permission to link the code of portions of this program with the OpenSSL 31 | # library. 32 | # You must obey the GNU General Public License in all respects for all of 33 | # the code used other than OpenSSL. If you modify file(s) with this 34 | # exception, you may extend this exception to your version of the file(s), 35 | # but you are not obligated to do so. If you do not wish to do so, delete 36 | # this exception statement from your version. If you delete this exception 37 | # statement from all source files in the program, then also delete it here. 38 | # 39 | 40 | import gtk 41 | 42 | from deluge.log import LOG as log 43 | from deluge.ui.client import client 44 | from deluge.plugins.pluginbase import GtkPluginBase 45 | import deluge.component as component 46 | import deluge.common 47 | 48 | from common import get_resource 49 | 50 | class GtkUI(GtkPluginBase): 51 | def enable(self): 52 | self.glade = gtk.glade.XML(get_resource("randomize.glade")) 53 | 54 | component.get("Preferences").add_page("Randomize", self.glade.get_widget("hbox1")) 55 | component.get("PluginManager").register_hook("on_apply_prefs", self.on_apply_prefs) 56 | component.get("PluginManager").register_hook("on_show_prefs", self.on_show_prefs) 57 | self.on_show_prefs() 58 | 59 | def disable(self): 60 | component.get("Preferences").remove_page("Randomize") 61 | component.get("PluginManager").deregister_hook("on_apply_prefs", self.on_apply_prefs) 62 | component.get("PluginManager").deregister_hook("on_show_prefs", self.on_show_prefs) 63 | 64 | def on_apply_prefs(self): 65 | log.debug("applying prefs for Randomize") 66 | config = { 67 | "poll_interval":self.glade.get_widget("poll_interval_txt").get_text() 68 | } 69 | client.randomize.set_config(config) 70 | 71 | def on_show_prefs(self): 72 | client.randomize.get_config().addCallback(self.cb_get_config) 73 | 74 | def cb_get_config(self, config): 75 | "callback for on show_prefs" 76 | self.glade.get_widget("poll_interval_txt").set_text(str(config["poll_interval"])) 77 | -------------------------------------------------------------------------------- /randomize/webui.py: -------------------------------------------------------------------------------- 1 | # 2 | # webui.py 3 | # 4 | # Copyright (C) 2009 Pradeep Jindal 5 | # 6 | # Basic plugin template created by: 7 | # Copyright (C) 2008 Martijn Voncken 8 | # Copyright (C) 2007-2009 Andrew Resch 9 | # Copyright (C) 2009 Damien Churchill 10 | # 11 | # Deluge is free software. 12 | # 13 | # You may redistribute it and/or modify it under the terms of the 14 | # GNU General Public License, as published by the Free Software 15 | # Foundation; either version 3 of the License, or (at your option) 16 | # any later version. 17 | # 18 | # deluge is distributed in the hope that it will be useful, 19 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 20 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 21 | # See the GNU General Public License for more details. 22 | # 23 | # You should have received a copy of the GNU General Public License 24 | # along with deluge. If not, write to: 25 | # The Free Software Foundation, Inc., 26 | # 51 Franklin Street, Fifth Floor 27 | # Boston, MA 02110-1301, USA. 28 | # 29 | # In addition, as a special exception, the copyright holders give 30 | # permission to link the code of portions of this program with the OpenSSL 31 | # library. 32 | # You must obey the GNU General Public License in all respects for all of 33 | # the code used other than OpenSSL. If you modify file(s) with this 34 | # exception, you may extend this exception to your version of the file(s), 35 | # but you are not obligated to do so. If you do not wish to do so, delete 36 | # this exception statement from your version. If you delete this exception 37 | # statement from all source files in the program, then also delete it here. 38 | # 39 | 40 | from deluge.log import LOG as log 41 | from deluge.ui.client import client 42 | from deluge import component 43 | from deluge.plugins.pluginbase import WebPluginBase 44 | 45 | from common import get_resource 46 | 47 | class WebUI(WebPluginBase): 48 | 49 | scripts = [get_resource("randomize.js")] 50 | 51 | def enable(self): 52 | pass 53 | 54 | def disable(self): 55 | pass 56 | -------------------------------------------------------------------------------- /setup.py: -------------------------------------------------------------------------------- 1 | # 2 | # setup.py 3 | # 4 | # Copyright (C) 2009 Pradeep Jindal 5 | # 6 | # Basic plugin template created by: 7 | # Copyright (C) 2008 Martijn Voncken 8 | # Copyright (C) 2007-2009 Andrew Resch 9 | # Copyright (C) 2009 Damien Churchill 10 | # 11 | # Deluge is free software. 12 | # 13 | # You may redistribute it and/or modify it under the terms of the 14 | # GNU General Public License, as published by the Free Software 15 | # Foundation; either version 3 of the License, or (at your option) 16 | # any later version. 17 | # 18 | # deluge is distributed in the hope that it will be useful, 19 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 20 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 21 | # See the GNU General Public License for more details. 22 | # 23 | # You should have received a copy of the GNU General Public License 24 | # along with deluge. If not, write to: 25 | # The Free Software Foundation, Inc., 26 | # 51 Franklin Street, Fifth Floor 27 | # Boston, MA 02110-1301, USA. 28 | # 29 | # In addition, as a special exception, the copyright holders give 30 | # permission to link the code of portions of this program with the OpenSSL 31 | # library. 32 | # You must obey the GNU General Public License in all respects for all of 33 | # the code used other than OpenSSL. If you modify file(s) with this 34 | # exception, you may extend this exception to your version of the file(s), 35 | # but you are not obligated to do so. If you do not wish to do so, delete 36 | # this exception statement from your version. If you delete this exception 37 | # statement from all source files in the program, then also delete it here. 38 | # 39 | 40 | from setuptools import setup 41 | 42 | __plugin_name__ = "Randomize" 43 | __author__ = "Pradeep Jindal" 44 | __author_email__ = "praddyjindal@gmail.com" 45 | __version__ = "0.1" 46 | __url__ = "" 47 | __license__ = "GPLv3" 48 | __description__ = "" 49 | __long_description__ = """""" 50 | __pkg_data__ = {__plugin_name__.lower(): ["template/*", "data/*"]} 51 | 52 | setup( 53 | name=__plugin_name__, 54 | version=__version__, 55 | description=__description__, 56 | author=__author__, 57 | author_email=__author_email__, 58 | url=__url__, 59 | license=__license__, 60 | long_description=__long_description__ if __long_description__ else __description__, 61 | 62 | packages=[__plugin_name__.lower()], 63 | package_data = __pkg_data__, 64 | 65 | entry_points=""" 66 | [deluge.plugin.core] 67 | %s = %s:CorePlugin 68 | [deluge.plugin.gtkui] 69 | %s = %s:GtkUIPlugin 70 | [deluge.plugin.web] 71 | %s = %s:WebUIPlugin 72 | """ % ((__plugin_name__, __plugin_name__.lower())*3) 73 | ) 74 | --------------------------------------------------------------------------------