From 5706b80cb2664a72aaecde262df47de6ddc93811 Mon Sep 17 00:00:00 2001 From: Andrew Resch Date: Wed, 30 Jul 2008 06:52:20 +0000 Subject: [PATCH] Implement #296 ability to change peer TOS byte --- ChangeLog | 2 +- deluge/core/core.py | 15 +++- .../ui/gtkui/glade/preferences_dialog.glade | 87 ++++++++++++++----- deluge/ui/gtkui/preferences.py | 5 +- .../bindings/python/src/session_settings.cpp | 1 + 5 files changed, 84 insertions(+), 26 deletions(-) diff --git a/ChangeLog b/ChangeLog index 217d720ff..b98112bb6 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,4 +1,4 @@ Deluge 1.1.0 - "" (In Development) Core: * Implement #79 ability to change outgoing port range - + * Implement #296 ability to change peer TOS byte diff --git a/deluge/core/core.py b/deluge/core/core.py index b9d42d5e0..5803f8fca 100644 --- a/deluge/core/core.py +++ b/deluge/core/core.py @@ -117,7 +117,8 @@ DEFAULT_PREFS = { "proxy_password" : "", "proxy_port": 8080, "outgoing_ports": [0, 0], - "random_outgoing_ports": True + "random_outgoing_ports": True, + "peer_tos": "0x00", } class Core( @@ -239,6 +240,8 @@ class Core( self._on_set_outgoing_ports) self.config.register_set_function("random_outgoing_ports", self._on_set_random_outgoing_ports) + self.config.register_set_function("peer_tos", + self._on_set_peer_tos) self.config.register_set_function("dht", self._on_set_dht) self.config.register_set_function("upnp", self._on_set_upnp) self.config.register_set_function("natpmp", self._on_set_natpmp) @@ -773,6 +776,16 @@ class Core( if value: self.session.outgoing_ports(0, 0) + def _on_set_peer_tos(self, key, value): + log.debug("setting peer_tos to: %s", value) + try: + self.settings.peer_tos = str(int(value, 16)) + except ValueError, e: + log.debug("Invalid tos byte: %s", e) + return + + self.session.set_settings(self.settings) + def _on_set_dht(self, key, value): log.debug("dht value set to %s", value) state_file = deluge.common.get_default_config_dir('dht.state') diff --git a/deluge/ui/gtkui/glade/preferences_dialog.glade b/deluge/ui/gtkui/glade/preferences_dialog.glade index f74d48a06..77526e3ad 100644 --- a/deluge/ui/gtkui/glade/preferences_dialog.glade +++ b/deluge/ui/gtkui/glade/preferences_dialog.glade @@ -1,6 +1,6 @@ - + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK @@ -913,14 +913,33 @@ True - + True - True - Distributed hash table may improve the amount of active connections. - Enable Mainline DHT - True - 0 - True + 5 + + + True + The TOS byte set in the IP header of every packet sent to peers (including web seeds). Expects a Hex value. + Peer TOS Byte: + + + False + False + + + + + True + True + 4 + 0x00 + + + False + False + 1 + + @@ -930,7 +949,7 @@ True - <b>DHT</b> + <b>TOS</b> True @@ -956,9 +975,14 @@ 2 12 - + True - 10 + 2 + 3 + 5 + + + True @@ -971,8 +995,7 @@ True - False - 2 + GTK_FILL @@ -987,9 +1010,9 @@ True - False - 2 - 1 + 1 + 2 + GTK_FILL @@ -1004,9 +1027,9 @@ True - False - 2 - 2 + 2 + 3 + GTK_FILL @@ -1020,9 +1043,27 @@ True - False - False - 3 + 1 + 2 + GTK_FILL + + + + + True + True + Distributed hash table may improve the amount of active connections. + DHT + True + 0 + True + + + 1 + 2 + 1 + 2 + GTK_FILL @@ -1893,7 +1934,7 @@ Disabled True True GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK - Classic Mode will hide most of the daemon functionality and will make Deluge appear to be a single application. Use this if you do not want to take advantage of running Deluge as a daemon. + Classic Mode will hide most of the daemon functionality and will make Deluge appear to be a single application. Use this if you do not want to take advantage of running Deluge as a daemon. You need to restart Deluge for this setting to take effect. Enable 0 True diff --git a/deluge/ui/gtkui/preferences.py b/deluge/ui/gtkui/preferences.py index d8725ca09..9d5560a58 100644 --- a/deluge/ui/gtkui/preferences.py +++ b/deluge/ui/gtkui/preferences.py @@ -217,6 +217,7 @@ class Preferences(component.Component): "spin_outgoing_port_min": ("value", self.core_config["outgoing_ports"][0]), "spin_outgoing_port_max": ("value", self.core_config["outgoing_ports"][1]), "chk_random_outgoing_ports": ("active", self.core_config["random_outgoing_ports"]), + "entry_peer_tos": ("text", self.core_config["peer_tos"]), "chk_dht": ("active", self.core_config["dht"]), "chk_upnp": ("active", self.core_config["upnp"]), "chk_natpmp": ("active", self.core_config["natpmp"]), @@ -352,6 +353,7 @@ class Preferences(component.Component): "spin_outgoing_port_min", "spin_outgoing_port_max", "chk_random_outgoing_ports", + "entry_peer_tos", "chk_dht", "chk_upnp", "chk_natpmp", @@ -534,7 +536,8 @@ class Preferences(component.Component): new_core_config["outgoing_ports"] = outgoing_ports new_core_config["random_outgoing_ports"] = \ self.glade.get_widget("chk_random_outgoing_ports").get_active() - + + new_core_config["peer_tos"] = self.glade.get_widget("entry_peer_tos").get_text() new_core_config["dht"] = self.glade.get_widget("chk_dht").get_active() new_core_config["upnp"] = self.glade.get_widget("chk_upnp").get_active() new_core_config["natpmp"] = \ diff --git a/libtorrent/bindings/python/src/session_settings.cpp b/libtorrent/bindings/python/src/session_settings.cpp index 814c1ad58..3f2a7b632 100755 --- a/libtorrent/bindings/python/src/session_settings.cpp +++ b/libtorrent/bindings/python/src/session_settings.cpp @@ -43,6 +43,7 @@ void bind_session_settings() .def_readwrite("seed_time_ratio_limit", &session_settings::seed_time_ratio_limit) .def_readwrite("seed_time_limit", &session_settings::seed_time_limit) .def_readwrite("auto_scraped_interval", &session_settings::auto_scrape_interval) + .def_readwrite("peer_tos", &session_settings::peer_tos) #ifndef TORRENT_DISABLE_DHT .def_readwrite("use_dht_as_fallback", &session_settings::use_dht_as_fallback) #endif