proxy support

This commit is contained in:
Marcos Pinto 2008-07-22 02:51:40 +00:00
parent 4720104fe1
commit b321535601
3 changed files with 289 additions and 10 deletions

View File

@ -111,6 +111,11 @@ DEFAULT_PREFS = {
"move_completed": False, "move_completed": False,
"move_completed_path": deluge.common.get_default_download_dir(), "move_completed_path": deluge.common.get_default_download_dir(),
"new_release_check": True, "new_release_check": True,
"proxy_type" : 0,
"proxy_server" : "",
"proxy_username" : "",
"proxy_password" : "",
"proxy_port": 8080,
} }
class Core( class Core(
@ -278,6 +283,16 @@ class Core(
self._on_set_dont_count_slow_torrents) self._on_set_dont_count_slow_torrents)
self.config.register_set_function("send_info", self.config.register_set_function("send_info",
self._on_send_info) self._on_send_info)
self.config.register_set_function("proxy_type",
self._on_set_proxy)
self.config.register_set_function("proxy_username",
self._on_set_proxy)
self.config.register_set_function("proxy_password",
self._on_set_proxy)
self.config.register_set_function("proxy_server",
self._on_set_proxy)
self.config.register_set_function("proxy_port",
self._on_set_proxy)
self.new_release = None self.new_release = None
self.new_release_timer = None self.new_release_timer = None
self.config.register_set_function("new_release_check", self.config.register_set_function("new_release_check",
@ -930,3 +945,16 @@ class Core(
else: else:
if self.new_release_timer: if self.new_release_timer:
gobject.source.remove(self.new_release_timer) gobject.source.remove(self.new_release_timer)
def _on_set_proxy(self, key, value):
log.debug("Proxy value %s set to %s..", key, value)
proxy_settings = lt.proxy_settings()
proxy_settings.proxy_type = lt.proxy_type(self.config["proxy_type"])
proxy_settings.username = self.config["proxy_username"]
proxy_settings.password = self.config["proxy_password"]
proxy_settings.hostname = self.config["proxy_server"]
proxy_settings.port = int(self.config["proxy_port"])
self.session.set_peer_proxy(proxy_settings)
self.session.set_web_seed_proxy(proxy_settings)
self.session.set_tracker_proxy(proxy_settings)
self.session.set_dht_proxy(proxy_settings)

View File

@ -1,7 +1,6 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?> <?xml version="1.0"?>
<!DOCTYPE glade-interface SYSTEM "glade-2.0.dtd">
<!--Generated with glade3 3.4.5 on Sat Jul 19 17:31:21 2008 -->
<glade-interface> <glade-interface>
<requires-version lib="gtk+" version="2.12"/>
<widget class="GtkDialog" id="pref_dialog"> <widget class="GtkDialog" id="pref_dialog">
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property> <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<property name="border_width">5</property> <property name="border_width">5</property>
@ -562,8 +561,8 @@
<property name="label" translatable="yes">page 6</property> <property name="label" translatable="yes">page 6</property>
</widget> </widget>
<packing> <packing>
<property name="type">tab</property>
<property name="tab_fill">False</property> <property name="tab_fill">False</property>
<property name="type">tab</property>
</packing> </packing>
</child> </child>
<child> <child>
@ -1098,9 +1097,9 @@ Disabled</property>
<property name="label" translatable="yes">page 7</property> <property name="label" translatable="yes">page 7</property>
</widget> </widget>
<packing> <packing>
<property name="type">tab</property>
<property name="position">1</property> <property name="position">1</property>
<property name="tab_fill">False</property> <property name="tab_fill">False</property>
<property name="type">tab</property>
</packing> </packing>
</child> </child>
<child> <child>
@ -1570,9 +1569,9 @@ Disabled</property>
<property name="label" translatable="yes">page 8</property> <property name="label" translatable="yes">page 8</property>
</widget> </widget>
<packing> <packing>
<property name="type">tab</property>
<property name="position">2</property> <property name="position">2</property>
<property name="tab_fill">False</property> <property name="tab_fill">False</property>
<property name="type">tab</property>
</packing> </packing>
</child> </child>
<child> <child>
@ -2680,6 +2679,236 @@ Disabled</property>
<property name="type">tab</property> <property name="type">tab</property>
</packing> </packing>
</child> </child>
<child>
<widget class="GtkScrolledWindow" id="scrolledwindow9">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<property name="hscrollbar_policy">GTK_POLICY_AUTOMATIC</property>
<property name="vscrollbar_policy">GTK_POLICY_AUTOMATIC</property>
<child>
<widget class="GtkViewport" id="viewport10">
<property name="visible">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<property name="resize_mode">GTK_RESIZE_QUEUE</property>
<property name="shadow_type">GTK_SHADOW_NONE</property>
<child>
<widget class="GtkVBox" id="vbox22">
<property name="visible">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<child>
<widget class="GtkLabel" id="label83">
<property name="visible">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<property name="xalign">0.05000000074505806</property>
<property name="ypad">10</property>
<property name="label" translatable="yes">&lt;i&gt;&lt;b&gt;&lt;big&gt;Proxy&lt;/big&gt;&lt;/b&gt;&lt;/i&gt;</property>
<property name="use_markup">True</property>
</widget>
<packing>
<property name="expand">False</property>
</packing>
</child>
<child>
<widget class="GtkTable" id="table5">
<property name="visible">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<property name="n_rows">5</property>
<property name="n_columns">3</property>
<child>
<placeholder/>
</child>
<child>
<placeholder/>
</child>
<child>
<placeholder/>
</child>
<child>
<placeholder/>
</child>
<child>
<placeholder/>
</child>
<child>
<widget class="GtkComboBox" id="combo_proxy_type">
<property name="visible">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<property name="items" translatable="yes">None
Socksv4
Socksv5
Socksv5 W/ Auth
HTTP
HTTP W/ Auth</property>
</widget>
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
</packing>
</child>
<child>
<widget class="GtkEntry" id="txt_proxy_username">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
</widget>
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
<property name="top_attach">1</property>
<property name="bottom_attach">2</property>
</packing>
</child>
<child>
<widget class="GtkEntry" id="txt_proxy_password">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<property name="visibility">False</property>
</widget>
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
<property name="top_attach">2</property>
<property name="bottom_attach">3</property>
</packing>
</child>
<child>
<widget class="GtkSpinButton" id="spin_proxy_port">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<property name="adjustment">0 0 65000 1 10 10</property>
<property name="numeric">True</property>
</widget>
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
<property name="top_attach">4</property>
<property name="bottom_attach">5</property>
</packing>
</child>
<child>
<widget class="GtkEntry" id="txt_proxy_server">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
</widget>
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
<property name="top_attach">3</property>
<property name="bottom_attach">4</property>
</packing>
</child>
<child>
<widget class="GtkAlignment" id="alignment29">
<property name="visible">True</property>
<property name="left_padding">10</property>
<child>
<widget class="GtkLabel" id="label63">
<property name="visible">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<property name="xalign">0</property>
<property name="label" translatable="yes">Type</property>
</widget>
</child>
</widget>
</child>
<child>
<widget class="GtkAlignment" id="alignment30">
<property name="visible">True</property>
<property name="left_padding">10</property>
<child>
<widget class="GtkLabel" id="label62">
<property name="visible">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<property name="xalign">0</property>
<property name="label" translatable="yes">Username</property>
</widget>
</child>
</widget>
<packing>
<property name="top_attach">1</property>
<property name="bottom_attach">2</property>
</packing>
</child>
<child>
<widget class="GtkAlignment" id="alignment31">
<property name="visible">True</property>
<property name="left_padding">10</property>
<child>
<widget class="GtkLabel" id="label61">
<property name="visible">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<property name="xalign">0</property>
<property name="label" translatable="yes">Password</property>
</widget>
</child>
</widget>
<packing>
<property name="top_attach">2</property>
<property name="bottom_attach">3</property>
</packing>
</child>
<child>
<widget class="GtkAlignment" id="alignment32">
<property name="visible">True</property>
<property name="left_padding">10</property>
<child>
<widget class="GtkLabel" id="label60">
<property name="visible">True</property>
<property name="xalign">0</property>
<property name="label" translatable="yes">Server</property>
</widget>
</child>
</widget>
<packing>
<property name="top_attach">3</property>
<property name="bottom_attach">4</property>
</packing>
</child>
<child>
<widget class="GtkAlignment" id="alignment33">
<property name="visible">True</property>
<property name="left_padding">10</property>
<child>
<widget class="GtkLabel" id="label59">
<property name="visible">True</property>
<property name="xalign">0</property>
<property name="label" translatable="yes">Port</property>
</widget>
</child>
</widget>
<packing>
<property name="top_attach">4</property>
<property name="bottom_attach">5</property>
</packing>
</child>
</widget>
<packing>
<property name="expand">False</property>
<property name="position">1</property>
</packing>
</child>
<child>
<placeholder/>
</child>
</widget>
</child>
</widget>
</child>
</widget>
<packing>
<property name="position">7</property>
</packing>
</child>
<child>
<placeholder/>
<packing>
<property name="type">tab</property>
</packing>
</child>
<child> <child>
<widget class="GtkScrolledWindow" id="scrolledwindow5"> <widget class="GtkScrolledWindow" id="scrolledwindow5">
<property name="visible">True</property> <property name="visible">True</property>
@ -2763,7 +2992,7 @@ Disabled</property>
</child> </child>
</widget> </widget>
<packing> <packing>
<property name="position">7</property> <property name="position">8</property>
</packing> </packing>
</child> </child>
<child> <child>

View File

@ -64,7 +64,7 @@ class Preferences(component.Component):
# Add the default categories # Add the default categories
i = 0 i = 0
for category in ["Downloads", "Network", "Bandwidth", "Interface", for category in ["Downloads", "Network", "Bandwidth", "Interface",
"Other", "Daemon", "Queue", "Plugins"]: "Other", "Daemon", "Queue", "Proxy", "Plugins"]:
self.liststore.append([i, category]) self.liststore.append([i, category])
i += 1 i += 1
@ -262,7 +262,12 @@ class Preferences(component.Component):
"spin_seed_time_limit": ("value", self.core_config["seed_time_limit"]), "spin_seed_time_limit": ("value", self.core_config["seed_time_limit"]),
"chk_seed_ratio": ("active", self.core_config["stop_seed_at_ratio"]), "chk_seed_ratio": ("active", self.core_config["stop_seed_at_ratio"]),
"spin_share_ratio": ("value", self.core_config["stop_seed_ratio"]), "spin_share_ratio": ("value", self.core_config["stop_seed_ratio"]),
"chk_remove_ratio": ("active", self.core_config["remove_seed_at_ratio"]) "chk_remove_ratio": ("active", self.core_config["remove_seed_at_ratio"]),
"spin_proxy_port": ("value", self.core_config["proxy_port"]),
"combo_proxy_type": ("active", self.core_config["proxy_type"]),
"txt_proxy_server": ("text", self.core_config["proxy_server"]),
"txt_proxy_username": ("text", self.core_config["proxy_username"]),
"txt_proxy_password": ("text", self.core_config["proxy_password"])
} }
# Change a few widgets if we're connected to a remote host # Change a few widgets if we're connected to a remote host
@ -375,7 +380,12 @@ class Preferences(component.Component):
"chk_remove_ratio", "chk_remove_ratio",
"spin_share_ratio_limit", "spin_share_ratio_limit",
"spin_seed_time_ratio_limit", "spin_seed_time_ratio_limit",
"spin_seed_time_limit" "spin_seed_time_limit",
"spin_proxy_port",
"combo_proxy_type",
"txt_proxy_username",
"txt_proxy_password",
"txt_proxy_server",
] ]
# We don't appear to be connected to a daemon # We don't appear to be connected to a daemon
for key in core_widget_list: for key in core_widget_list:
@ -562,6 +572,18 @@ class Preferences(component.Component):
self.glade.get_widget("chk_allow_remote_connections").get_active() self.glade.get_widget("chk_allow_remote_connections").get_active()
new_core_config["new_release_check"] = \ new_core_config["new_release_check"] = \
self.glade.get_widget("chk_new_releases").get_active() self.glade.get_widget("chk_new_releases").get_active()
## Proxy tab ##
new_core_config["proxy_type"] = \
self.glade.get_widget("combo_proxy_type").get_active()
new_core_config["proxy_port"] = \
self.glade.get_widget("spin_proxy_port").get_value_as_int()
new_core_config["proxy_username"] = \
self.glade.get_widget("txt_proxy_username").get_text()
new_core_config["proxy_password"] = \
self.glade.get_widget("txt_proxy_password").get_text()
new_core_config["proxy_server"] = \
self.glade.get_widget("txt_proxy_server").get_text()
## Queue tab ## ## Queue tab ##
new_core_config["queue_new_to_top"] = \ new_core_config["queue_new_to_top"] = \