[UI] [Core] Update and refactor proxy settings

* Combine I2P into proxy settings.
This commit is contained in:
Calum Lind 2016-11-04 15:55:42 +00:00
parent 108dd9e4b8
commit 4a344e382b
8 changed files with 310 additions and 396 deletions

View File

@ -645,28 +645,34 @@ class Core(component.Component):
"""Returns the active listen port""" """Returns the active listen port"""
return self.session.listen_port() return self.session.listen_port()
@deprecated
@export
def get_i2p_proxy(self):
"""Returns the active listen port"""
# Deprecated: Moved to proxy types
i2p_settings = self.session.i2p_proxy()
i2p_dict = {'hostname': i2p_settings.hostname, 'port': i2p_settings.port}
return i2p_dict
@export @export
def get_proxy(self): def get_proxy(self):
"""Returns the active listen port""" """Returns the proxy settings
proxy_settings = self.session.proxy()
Returns:
dict: Contains proxy settings.
Notes:
Proxy type names:
0: None, 1: Socks4, 2: Socks5, 3: Socks5 w Auth, 4: HTTP, 5: HTTP w Auth, 6: I2P
"""
settings = self.session.get_settings()
proxy_type = settings['proxy_type']
proxy_hostname = settings['i2p_hostname'] if proxy_type == 6 else settings['proxy_hostname']
proxy_port = settings['i2p_port'] if proxy_type == 6 else settings['proxy_port']
proxy_dict = { proxy_dict = {
'type': int(proxy_settings.type), 'type': proxy_type,
'hostname': proxy_settings.hostname, 'hostname': proxy_hostname,
'username': proxy_settings.username, 'username': settings['proxy_username'],
'password': proxy_settings.password, 'password': settings['proxy_password'],
'port': proxy_settings.port, 'port': proxy_port,
'proxy_hostnames': proxy_settings.proxy_hostnames, 'proxy_hostnames': settings['proxy_hostnames'],
'proxy_peer_connections': proxy_settings.proxy_peer_connections 'proxy_peer_connections': settings['proxy_peer_connections'],
'proxy_tracker_connections': settings['proxy_tracker_connections']
} }
return proxy_dict return proxy_dict
@export @export

View File

@ -101,14 +101,12 @@ DEFAULT_PREFS = {
'port': 8080, 'port': 8080,
'proxy_hostnames': True, 'proxy_hostnames': True,
'proxy_peer_connections': True, 'proxy_peer_connections': True,
}, 'proxy_tracker_connections': True,
'i2p_proxy': { 'force_proxy': False,
'hostname': '', 'anonymous_mode': False,
'port': 0
}, },
'peer_tos': '0x00', 'peer_tos': '0x00',
'rate_limit_ip_overhead': True, 'rate_limit_ip_overhead': True,
'anonymous_mode': False,
'geoip_db_location': '/usr/share/GeoIP/GeoIP.dat', 'geoip_db_location': '/usr/share/GeoIP/GeoIP.dat',
'cache_size': 512, 'cache_size': 512,
'cache_expiry': 60, 'cache_expiry': 60,
@ -127,6 +125,17 @@ class PreferencesManager(component.Component):
self.config['proxy'].update(self.config['proxies']['peer']) self.config['proxy'].update(self.config['proxies']['peer'])
log.warning('New proxy config is: %s', self.config['proxy']) log.warning('New proxy config is: %s', self.config['proxy'])
del self.config['proxies'] del self.config['proxies']
if 'i2p_proxy' in self.config and self.config['i2p_proxy']['hostname']:
self.config['proxy'].update(self.config['i2p_proxy'])
self.config['proxy']['type'] = 6
del self.config['i2p_proxy']
if 'anonymous_mode' in self.config:
self.config['proxy']['anonymous_mode'] = self.config['anonymous_mode']
del self.config['anonymous_mode']
if 'proxy' in self.config:
for key in DEFAULT_PREFS['proxy']:
if key not in self.config['proxy']:
self.config['proxy'][key] = DEFAULT_PREFS['proxy'][key]
self.core = component.get('Core') self.core = component.get('Core')
self.new_release_timer = None self.new_release_timer = None
@ -343,33 +352,39 @@ class PreferencesManager(component.Component):
self.new_release_timer.stop() self.new_release_timer.stop()
def _on_set_proxy(self, key, value): def _on_set_proxy(self, key, value):
if key == 'i2p_proxy' or value['type'] == 6: # Initialise with type none and blank hostnames.
proxy_settings = { proxy_settings = {
'proxy_type': lt.proxy_type.none,
'i2p_hostname': '',
'proxy_hostname': '',
'proxy_hostnames': value['proxy_hostnames'],
'proxy_peer_connections': value['proxy_peer_connections'],
'proxy_tracker_connections': value['proxy_tracker_connections'],
'force_proxy': value['force_proxy'],
'anonymous_mode': value['anonymous_mode']
}
if value['type'] == lt.proxy_type.i2p_proxy:
proxy_settings.update({
'proxy_type': lt.proxy_type.i2p_proxy, 'proxy_type': lt.proxy_type.i2p_proxy,
'i2p_hostname': value['hostname'], 'i2p_hostname': value['hostname'],
'i2p_port': value['port'] 'i2p_port': value['port'],
} })
else: elif value['type'] != lt.proxy_type.none:
proxy_settings = { proxy_settings.update({
'proxy_type': value['type'], 'proxy_type': value['type'],
'proxy_hostname': value['hostname'], 'proxy_hostname': value['hostname'],
'proxy_port': value['port'], 'proxy_port': value['port'],
'proxy_username': value['username'], 'proxy_username': value['username'],
'proxy_password': value['password'], 'proxy_password': value['password'],
'proxy_hostnames': value['proxy_hostnames'],
'proxy_peer_connections': value['proxy_peer_connections'],
}
self.core.apply_session_settings(proxy_settings)
def _on_set_i2p_proxy(self, key, value): })
self._on_set_proxy(key, value)
self.core.apply_session_settings(proxy_settings)
def _on_set_rate_limit_ip_overhead(self, key, value): def _on_set_rate_limit_ip_overhead(self, key, value):
self.core.apply_session_setting('rate_limit_ip_overhead', value) self.core.apply_session_setting('rate_limit_ip_overhead', value)
def _on_set_anonymous_mode(self, key, value):
self.core.apply_session_setting('anonymous_mode', value)
def _on_set_geoip_db_location(self, key, geoipdb_path): def _on_set_geoip_db_location(self, key, geoipdb_path):
# Load the GeoIP DB for country look-ups if available # Load the GeoIP DB for country look-ups if available
if os.path.exists(geoipdb_path): if os.path.exists(geoipdb_path):

View File

@ -72,24 +72,17 @@ class BasePreferencePane(BaseInputPane, BaseWindow, PopupsHandler):
def add_config_values(self, conf_dict): def add_config_values(self, conf_dict):
for ipt in self.inputs: for ipt in self.inputs:
if ipt.has_input(): if ipt.has_input():
# gross, have to special case in/out ports since they are tuples # Need special cases for in/out ports or proxy since they are tuples or dicts.
if ipt.name in ('listen_ports_to', 'listen_ports_from', 'out_ports_from', 'out_ports_to', if ipt.name == 'listen_ports_to' or ipt.name == 'listen_ports_from':
'i2p_port', 'i2p_hostname', 'proxy_type', 'proxy_username', 'proxy_hostnames',
'proxy_password', 'proxy_hostname', 'proxy_port', 'proxy_peer_connections',
'listen_interface'):
if ipt.name == 'listen_ports_to':
conf_dict['listen_ports'] = (self.infrom.get_value(), self.into.get_value()) conf_dict['listen_ports'] = (self.infrom.get_value(), self.into.get_value())
elif ipt.name == 'out_ports_to': elif ipt.name == 'out_ports_to' or ipt.name == 'out_ports_from':
conf_dict['outgoing_ports'] = (self.outfrom.get_value(), self.outto.get_value()) conf_dict['outgoing_ports'] = (self.outfrom.get_value(), self.outto.get_value())
elif ipt.name == 'listen_interface': elif ipt.name == 'listen_interface':
interface = ipt.get_value().strip() interface = ipt.get_value().strip()
if is_ip(interface) or not interface: if is_ip(interface) or not interface:
conf_dict['listen_interface'] = interface conf_dict['listen_interface'] = interface
elif ipt.name == 'i2p_port': elif ipt.name.startswith('proxy_'):
conf_dict.setdefault('i2p_proxy', {})['port'] = ipt.get_value() if ipt.name == 'proxy_type':
elif ipt.name == 'i2p_hostname':
conf_dict.setdefault('i2p_proxy', {})['hostname'] = ipt.get_value()
elif ipt.name == 'proxy_type':
conf_dict.setdefault('proxy', {})['type'] = ipt.get_value() conf_dict.setdefault('proxy', {})['type'] = ipt.get_value()
elif ipt.name == 'proxy_username': elif ipt.name == 'proxy_username':
conf_dict.setdefault('proxy', {})['username'] = ipt.get_value() conf_dict.setdefault('proxy', {})['username'] = ipt.get_value()
@ -103,8 +96,15 @@ class BasePreferencePane(BaseInputPane, BaseWindow, PopupsHandler):
conf_dict.setdefault('proxy', {})['proxy_hostnames'] = ipt.get_value() conf_dict.setdefault('proxy', {})['proxy_hostnames'] = ipt.get_value()
elif ipt.name == 'proxy_peer_connections': elif ipt.name == 'proxy_peer_connections':
conf_dict.setdefault('proxy', {})['proxy_peer_connections'] = ipt.get_value() conf_dict.setdefault('proxy', {})['proxy_peer_connections'] = ipt.get_value()
elif ipt.name == 'proxy_tracker_connections':
conf_dict.setdefault('proxy', {})['proxy_tracker_connections'] = ipt.get_value()
elif ipt.name == 'force_proxy':
conf_dict.setdefault('proxy', {})['force_proxy'] = ipt.get_value()
elif ipt.name == 'anonymous_mode':
conf_dict.setdefault('proxy', {})['anonymous_mode'] = ipt.get_value()
else: else:
conf_dict[ipt.name] = ipt.get_value() conf_dict[ipt.name] = ipt.get_value()
if hasattr(ipt, 'get_child'): if hasattr(ipt, 'get_child'):
c = ipt.get_child() c = ipt.get_child()
conf_dict[c.name] = c.get_value() conf_dict[c.name] = c.get_value()
@ -372,25 +372,29 @@ class ProxyPane(BasePreferencePane):
@overrides(BasePreferencePane) @overrides(BasePreferencePane)
def create_pane(self, core_conf, console_config): def create_pane(self, core_conf, console_config):
proxy = core_conf['proxy']
self.add_header(_('Proxy Settings')) self.add_header(_('Proxy Settings'))
self.add_header(_('Proxy'), space_above=True) self.add_header(_('Proxy'), space_above=True)
proxy = core_conf['proxy']
self.add_int_spin_input('proxy_type', '%s:' % _('Type'), proxy['type'], min_val=0, max_val=5) self.add_int_spin_input('proxy_type', '%s:' % _('Type'), proxy['type'], min_val=0, max_val=5)
self.add_info_field('proxy_info_1', ' 0: None 1: Socks4 2: Socks5', '')
self.add_info_field('proxy_info_2', ' 3: Socks5 Auth 4: HTTP 5: HTTP Auth', '')
self.add_text_input('proxy_username', '%s:' % _('Username'), proxy['username']) self.add_text_input('proxy_username', '%s:' % _('Username'), proxy['username'])
self.add_text_input('proxy_password', '%s:' % _('Password'), proxy['password']) self.add_text_input('proxy_password', '%s:' % _('Password'), proxy['password'])
self.add_text_input('proxy_hostname', '%s:' % _('Hostname'), proxy['hostname']) self.add_text_input('proxy_hostname', '%s:' % _('Hostname'), proxy['hostname'])
self.add_int_spin_input('proxy_port', '%s:' % _('Port'), proxy['port'], min_val=0, max_val=65535) self.add_int_spin_input('proxy_port', '%s:' % _('Port'), proxy['port'], min_val=0, max_val=65535)
self.add_checked_input('proxy_hostnames', _('Proxy hostnames'), proxy['proxy_hostnames']) self.add_checked_input('proxy_hostnames', _('Proxy Hostnames'), proxy['proxy_hostnames'])
self.add_checked_input('proxy_peer_connections', _('Proxy peer connections'), proxy['proxy_peer_connections']) self.add_checked_input('proxy_peer_connections', _('Proxy Peers'), proxy['proxy_peer_connections'])
self.add_checked_input('proxy_tracker_connections', _('Proxy Trackers'), proxy['proxy_tracker_connections'])
self.add_header(_('I2P Proxy'), space_above=True) self.add_header('%s' % _('Force Proxy'), space_above=True)
self.add_text_input('i2p_hostname', '%s:' % _('Hostname'), self.add_checked_input('force_proxy', _('Force Proxy'), proxy['force_proxy'])
core_conf['i2p_proxy']['hostname']) self.add_checked_input('anonymous_mode', _('Hide Client Identity'), proxy['anonymous_mode'])
self.add_int_spin_input('i2p_port', self.add_header('%s' % _('Proxy Type Help'), space_above=True)
'%s:' % _('Port'), core_conf['i2p_proxy']['port'], min_val=0, max_val=65535) self.add_text_area(
self.add_checked_input('anonymous_mode', _('Anonymous Mode'), core_conf['anonymous_mode']) 'proxy_text_area',
' 0: None 1: Socks4\n'
' 2: Socks5 3: Socks5 Auth\n'
' 4: HTTP 5: HTTP Auth\n'
' 6: I2P'
)
class CachePane(BasePreferencePane): class CachePane(BasePreferencePane):

View File

@ -2,6 +2,67 @@
<interface> <interface>
<requires lib="gtk+" version="2.24"/> <requires lib="gtk+" version="2.24"/>
<!-- interface-naming-policy toplevel-contextual --> <!-- interface-naming-policy toplevel-contextual -->
<object class="GtkAdjustment" id="adjustment_cache_expiry">
<property name="lower">1</property>
<property name="upper">32000</property>
<property name="value">60</property>
<property name="step_increment">1</property>
<property name="page_increment">10</property>
</object>
<object class="GtkAdjustment" id="adjustment_cache_size">
<property name="upper">999999</property>
<property name="value">100</property>
<property name="step_increment">1</property>
<property name="page_increment">10</property>
</object>
<object class="GtkAdjustment" id="adjustment_share_ratio">
<property name="lower">0.5</property>
<property name="upper">100</property>
<property name="value">2</property>
<property name="step_increment">0.10000000000000001</property>
<property name="page_increment">1</property>
</object>
<object class="GtkAdjustment" id="adjustment_share_ratio_limit">
<property name="lower">-1</property>
<property name="upper">100</property>
<property name="value">1.5</property>
<property name="step_increment">0.10000000000000001</property>
<property name="page_increment">10</property>
</object>
<object class="GtkAdjustment" id="adjustment_spin_active">
<property name="lower">-1</property>
<property name="upper">9999</property>
<property name="step_increment">1</property>
<property name="page_increment">10</property>
</object>
<object class="GtkAdjustment" id="adjustment_spin_daemon_port">
<property name="upper">65535</property>
<property name="step_increment">1</property>
<property name="page_increment">10</property>
</object>
<object class="GtkAdjustment" id="adjustment_spin_downloading">
<property name="lower">-1</property>
<property name="upper">9999</property>
<property name="step_increment">1</property>
<property name="page_increment">10</property>
</object>
<object class="GtkAdjustment" id="adjustment_spin_incoming_port">
<property name="upper">65535</property>
<property name="step_increment">1</property>
<property name="page_increment">10</property>
</object>
<object class="GtkAdjustment" id="adjustment_spin_max_conn_global">
<property name="lower">-1</property>
<property name="upper">9999</property>
<property name="step_increment">1</property>
<property name="page_increment">10</property>
</object>
<object class="GtkAdjustment" id="adjustment_spin_max_conn_per_sec">
<property name="lower">-1</property>
<property name="upper">9999</property>
<property name="step_increment">1</property>
<property name="page_increment">10</property>
</object>
<object class="GtkAdjustment" id="adjustment_spin_max_conn_per_torrent"> <object class="GtkAdjustment" id="adjustment_spin_max_conn_per_torrent">
<property name="lower">-1</property> <property name="lower">-1</property>
<property name="upper">9999</property> <property name="upper">9999</property>
@ -84,72 +145,6 @@
<property name="step_increment">0.10000000000000001</property> <property name="step_increment">0.10000000000000001</property>
<property name="page_increment">10</property> <property name="page_increment">10</property>
</object> </object>
<object class="GtkAdjustment" id="adjustment_cache_expiry">
<property name="lower">1</property>
<property name="upper">32000</property>
<property name="value">60</property>
<property name="step_increment">1</property>
<property name="page_increment">10</property>
</object>
<object class="GtkAdjustment" id="adjustment_cache_size">
<property name="upper">999999</property>
<property name="value">100</property>
<property name="step_increment">1</property>
<property name="page_increment">10</property>
</object>
<object class="GtkAdjustment" id="adjustment_share_ratio">
<property name="lower">0.5</property>
<property name="upper">100</property>
<property name="value">2</property>
<property name="step_increment">0.10000000000000001</property>
<property name="page_increment">1</property>
</object>
<object class="GtkAdjustment" id="adjustment_share_ratio_limit">
<property name="lower">-1</property>
<property name="upper">100</property>
<property name="value">1.5</property>
<property name="step_increment">0.10000000000000001</property>
<property name="page_increment">10</property>
</object>
<object class="GtkAdjustment" id="adjustment_spin_active">
<property name="lower">-1</property>
<property name="upper">9999</property>
<property name="step_increment">1</property>
<property name="page_increment">10</property>
</object>
<object class="GtkAdjustment" id="adjustment_spin_daemon_port">
<property name="upper">65535</property>
<property name="step_increment">1</property>
<property name="page_increment">10</property>
</object>
<object class="GtkAdjustment" id="adjustment_spin_downloading">
<property name="lower">-1</property>
<property name="upper">9999</property>
<property name="step_increment">1</property>
<property name="page_increment">10</property>
</object>
<object class="GtkAdjustment" id="adjustment_spin_i2p_port">
<property name="upper">65535</property>
<property name="step_increment">1</property>
<property name="page_increment">10</property>
</object>
<object class="GtkAdjustment" id="adjustment_spin_incoming_port">
<property name="upper">65535</property>
<property name="step_increment">1</property>
<property name="page_increment">10</property>
</object>
<object class="GtkAdjustment" id="adjustment_spin_max_conn_global">
<property name="lower">-1</property>
<property name="upper">9999</property>
<property name="step_increment">1</property>
<property name="page_increment">10</property>
</object>
<object class="GtkAdjustment" id="adjustment_spin_max_conn_per_sec">
<property name="lower">-1</property>
<property name="upper">9999</property>
<property name="step_increment">1</property>
<property name="page_increment">10</property>
</object>
<object class="GtkListStore" id="liststore1"> <object class="GtkListStore" id="liststore1">
<columns> <columns>
<!-- column-name item --> <!-- column-name item -->
@ -233,6 +228,9 @@
<row> <row>
<col id="0" translatable="yes">HTTP Auth</col> <col id="0" translatable="yes">HTTP Auth</col>
</row> </row>
<row>
<col id="0" translatable="yes">I2P</col>
</row>
</data> </data>
</object> </object>
<object class="GtkDialog" id="pref_dialog"> <object class="GtkDialog" id="pref_dialog">
@ -3469,7 +3467,7 @@ used sparingly.</property>
<object class="GtkTable" id="table11"> <object class="GtkTable" id="table11">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">False</property> <property name="can_focus">False</property>
<property name="n_rows">7</property> <property name="n_rows">8</property>
<property name="n_columns">2</property> <property name="n_columns">2</property>
<property name="column_spacing">5</property> <property name="column_spacing">5</property>
<child> <child>
@ -3645,7 +3643,7 @@ the proxy instead of using the local DNS service</property>
</child> </child>
<child> <child>
<object class="GtkCheckButton" id="chk_proxy_peer_conn"> <object class="GtkCheckButton" id="chk_proxy_peer_conn">
<property name="label" translatable="yes">Proxy Peer Connections</property> <property name="label" translatable="yes">Proxy Peers</property>
<property name="use_action_appearance">False</property> <property name="use_action_appearance">False</property>
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">True</property> <property name="can_focus">True</property>
@ -3662,6 +3660,24 @@ the proxy instead of using the local DNS service</property>
<property name="x_options">GTK_FILL</property> <property name="x_options">GTK_FILL</property>
</packing> </packing>
</child> </child>
<child>
<object class="GtkCheckButton" id="chk_proxy_tracker_conn">
<property name="label" translatable="yes">Proxy Trackers</property>
<property name="use_action_appearance">False</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">False</property>
<property name="xalign">0.49000000953674316</property>
<property name="active">True</property>
<property name="draw_indicator">True</property>
</object>
<packing>
<property name="right_attach">2</property>
<property name="top_attach">7</property>
<property name="bottom_attach">8</property>
<property name="x_options">GTK_FILL</property>
</packing>
</child>
</object> </object>
</child> </child>
</object> </object>
@ -3685,120 +3701,39 @@ the proxy instead of using the local DNS service</property>
</packing> </packing>
</child> </child>
<child> <child>
<object class="GtkFrame" id="frame_i2p"> <object class="GtkFrame" id="frame_anon_mode">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">False</property> <property name="can_focus">False</property>
<property name="label_xalign">0</property> <property name="label_xalign">0</property>
<property name="shadow_type">none</property> <property name="shadow_type">none</property>
<child> <child>
<object class="GtkAlignment" id="alignment41"> <object class="GtkVBox" id="vbox9">
<property name="visible">True</property>
<property name="can_focus">False</property>
<child>
<object class="GtkAlignment" id="alignment_force_proxy">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">False</property> <property name="can_focus">False</property>
<property name="top_padding">5</property> <property name="top_padding">5</property>
<property name="left_padding">12</property> <property name="left_padding">12</property>
<property name="right_padding">12</property> <property name="right_padding">12</property>
<child> <child>
<object class="GtkTable" id="table5"> <object class="GtkCheckButton" id="chk_force_proxy">
<property name="visible">True</property> <property name="label" translatable="yes">Force Proxy Use</property>
<property name="can_focus">False</property> <property name="use_action_appearance">False</property>
<property name="n_rows">2</property>
<property name="n_columns">2</property>
<property name="column_spacing">5</property>
<property name="row_spacing">2</property>
<child>
<object class="GtkLabel" id="label_i2p_host">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="xalign">0</property>
<property name="label" translatable="yes">Hostname:</property>
</object>
<packing>
<property name="x_options">GTK_FILL</property>
</packing>
</child>
<child>
<object class="GtkEntry" id="entry_i2p_host">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">True</property> <property name="can_focus">True</property>
<property name="truncate_multiline">True</property> <property name="receives_default">False</property>
<property name="primary_icon_activatable">False</property> <property name="draw_indicator">True</property>
<property name="secondary_icon_activatable">False</property>
<property name="primary_icon_sensitive">True</property>
<property name="secondary_icon_sensitive">True</property>
</object>
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="label_i2p_port">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="xalign">1</property>
<property name="label" translatable="yes">Port:</property>
</object>
<packing>
<property name="top_attach">1</property>
<property name="bottom_attach">2</property>
<property name="x_options">GTK_FILL</property>
</packing>
</child>
<child>
<object class="GtkAlignment" id="alignment_i2p_port">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="xalign">0</property>
<property name="xscale">0</property>
<child>
<object class="GtkSpinButton" id="spin_i2p_port">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="primary_icon_activatable">False</property>
<property name="secondary_icon_activatable">False</property>
<property name="primary_icon_sensitive">True</property>
<property name="secondary_icon_sensitive">True</property>
<property name="adjustment">adjustment_spin_i2p_port</property>
<property name="numeric">True</property>
</object> </object>
</child> </child>
</object> </object>
<packing> <packing>
<property name="left_attach">1</property> <property name="expand">True</property>
<property name="right_attach">2</property> <property name="fill">True</property>
<property name="top_attach">1</property> <property name="position">0</property>
<property name="bottom_attach">2</property>
<property name="x_options">GTK_FILL</property>
</packing> </packing>
</child> </child>
</object>
</child>
</object>
</child>
<child type="label">
<object class="GtkLabel" id="label_i2p">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">I2P Proxy</property>
<attributes>
<attribute name="weight" value="bold"/>
</attributes>
</object>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="padding">5</property>
<property name="position">1</property>
</packing>
</child>
<child>
<object class="GtkFrame" id="frame_anon_mode">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label_xalign">0</property>
<property name="shadow_type">none</property>
<child> <child>
<object class="GtkAlignment" id="alignment_anon_mode"> <object class="GtkAlignment" id="alignment_anon_mode">
<property name="visible">True</property> <property name="visible">True</property>
@ -3818,12 +3753,19 @@ the proxy instead of using the local DNS service</property>
</object> </object>
</child> </child>
</object> </object>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
</object>
</child> </child>
<child type="label"> <child type="label">
<object class="GtkLabel" id="label_anon_mode"> <object class="GtkLabel" id="label_force_proxy">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">False</property> <property name="can_focus">False</property>
<property name="label" translatable="yes">Anonymous Mode</property> <property name="label" translatable="yes">Force Proxy</property>
<attributes> <attributes>
<attribute name="weight" value="bold"/> <attribute name="weight" value="bold"/>
</attributes> </attributes>
@ -3834,7 +3776,7 @@ the proxy instead of using the local DNS service</property>
<property name="expand">False</property> <property name="expand">False</property>
<property name="fill">False</property> <property name="fill">False</property>
<property name="padding">5</property> <property name="padding">5</property>
<property name="position">2</property> <property name="position">1</property>
</packing> </packing>
</child> </child>
</object> </object>

View File

@ -350,7 +350,7 @@ class Preferences(component.Component):
'spin_max_connections_per_second': ('value', 'max_connections_per_second'), 'spin_max_connections_per_second': ('value', 'max_connections_per_second'),
'chk_ignore_limits_on_local_network': ('active', 'ignore_limits_on_local_network'), 'chk_ignore_limits_on_local_network': ('active', 'ignore_limits_on_local_network'),
'chk_rate_limit_ip_overhead': ('active', 'rate_limit_ip_overhead'), 'chk_rate_limit_ip_overhead': ('active', 'rate_limit_ip_overhead'),
'chk_anonymous_mode': ('active', 'anonymous_mode'),
'spin_max_connections_per_torrent': ('value', 'max_connections_per_torrent'), 'spin_max_connections_per_torrent': ('value', 'max_connections_per_torrent'),
'spin_max_upload_slots_per_torrent': ('value', 'max_upload_slots_per_torrent'), 'spin_max_upload_slots_per_torrent': ('value', 'max_upload_slots_per_torrent'),
'spin_max_download_per_torrent': ('value', 'max_download_speed_per_torrent'), 'spin_max_download_per_torrent': ('value', 'max_download_speed_per_torrent'),
@ -379,8 +379,9 @@ class Preferences(component.Component):
'spin_proxy_port': ('value', lambda: self.core_config['proxy']['port']), 'spin_proxy_port': ('value', lambda: self.core_config['proxy']['port']),
'chk_proxy_host_resolve': ('active', lambda: self.core_config['proxy']['proxy_hostnames']), 'chk_proxy_host_resolve': ('active', lambda: self.core_config['proxy']['proxy_hostnames']),
'chk_proxy_peer_conn': ('active', lambda: self.core_config['proxy']['proxy_peer_connections']), 'chk_proxy_peer_conn': ('active', lambda: self.core_config['proxy']['proxy_peer_connections']),
'entry_i2p_host': ('text', lambda: self.core_config['i2p_proxy']['hostname']), 'chk_proxy_tracker_conn': ('active', lambda: self.core_config['proxy']['proxy_tracker_connections']),
'spin_i2p_port': ('value', lambda: self.core_config['i2p_proxy']['port']), 'chk_force_proxy': ('active', lambda: self.core_config['proxy']['force_proxy']),
'chk_anonymous_mode': ('active', lambda: self.core_config['proxy']['anonymous_mode']),
'accounts_add': (None, None), 'accounts_add': (None, None),
'accounts_listview': (None, None), 'accounts_listview': (None, None),
'button_cache_refresh': (None, None), 'button_cache_refresh': (None, None),
@ -599,20 +600,18 @@ class Preferences(component.Component):
new_core_config['new_release_check'] = self.builder.get_object('chk_new_releases').get_active() new_core_config['new_release_check'] = self.builder.get_object('chk_new_releases').get_active()
# Proxy tab # # Proxy tab #
new_core_config['proxy'] = {} new_core_config['proxy'] = {
new_core_config['proxy']['type'] = self.builder.get_object('combo_proxy_type').get_active() 'type': self.builder.get_object('combo_proxy_type').get_active(),
new_core_config['proxy']['username'] = self.builder.get_object('entry_proxy_user').get_text() 'username': self.builder.get_object('entry_proxy_user').get_text(),
new_core_config['proxy']['password'] = self.builder.get_object('entry_proxy_pass').get_text() 'password': self.builder.get_object('entry_proxy_pass').get_text(),
new_core_config['proxy']['hostname'] = self.builder.get_object('entry_proxy_host').get_text() 'hostname': self.builder.get_object('entry_proxy_host').get_text(),
new_core_config['proxy']['port'] = self.builder.get_object('spin_proxy_port').get_value_as_int() 'port': self.builder.get_object('spin_proxy_port').get_value_as_int(),
new_core_config['proxy']['proxy_hostnames'] = self.builder.get_object( 'proxy_hostnames': self.builder.get_object('chk_proxy_host_resolve').get_active(),
'chk_proxy_host_resolve').get_active() 'proxy_peer_connections': self.builder.get_object('chk_proxy_peer_conn').get_active(),
new_core_config['proxy']['proxy_peer_connections'] = self.builder.get_object( 'proxy_tracker_connections': self.builder.get_object('chk_proxy_tracker_conn').get_active(),
'chk_proxy_peer_conn').get_active() 'force_proxy': self.builder.get_object('chk_force_proxy').get_active(),
new_core_config['i2p_proxy'] = {} 'anonymous_mode': self.builder.get_object('chk_anonymous_mode').get_active()
new_core_config['i2p_proxy']['hostname'] = self.builder.get_object('entry_i2p_host').get_text() }
new_core_config['i2p_proxy']['port'] = self.builder.get_object('spin_i2p_port').get_value_as_int()
new_core_config['anonymous_mode'] = self.builder.get_object('chk_anonymous_mode').get_active()
# Queue tab # # Queue tab #
new_core_config['queue_new_to_top'] = self.builder.get_object('chk_queue_new_top').get_active() new_core_config['queue_new_to_top'] = self.builder.get_object('chk_queue_new_top').get_active()
@ -642,7 +641,7 @@ class Preferences(component.Component):
# Run plugin hook to apply preferences # Run plugin hook to apply preferences
component.get('PluginManager').run_on_apply_prefs() component.get('PluginManager').run_on_apply_prefs()
# Lanuage # Language
if self.language_checkbox.get_active(): if self.language_checkbox.get_active():
new_gtkui_config['language'] = None new_gtkui_config['language'] = None
else: else:
@ -954,31 +953,28 @@ class Preferences(component.Component):
def _on_combo_proxy_type_changed(self, widget): def _on_combo_proxy_type_changed(self, widget):
proxy_type = self.builder.get_object('combo_proxy_type').get_active() proxy_type = self.builder.get_object('combo_proxy_type').get_active()
proxy_entries = [
'label_proxy_host', 'entry_proxy_host', 'label_proxy_port', 'spin_proxy_port',
'label_proxy_pass', 'entry_proxy_pass', 'label_proxy_user', 'entry_proxy_user',
'chk_proxy_host_resolve', 'chk_proxy_peer_conn', 'chk_proxy_tracker_conn']
hides = [] # 0: None, 1: Socks4, 2: Socks5, 3: Socks5 Auth, 4: HTTP, 5: HTTP Auth, 6: I2P
shows = [] show_entries = []
# 0:"None" if proxy_type > 0:
if proxy_type == 0: show_entries.extend([
hides.extend(['entry_proxy_pass', 'entry_proxy_user', 'entry_proxy_host', 'spin_proxy_port', 'label_proxy_host', 'entry_proxy_host', 'label_proxy_port', 'spin_proxy_port',
'label_proxy_pass', 'label_proxy_user', 'label_proxy_host', 'label_proxy_port', 'chk_proxy_peer_conn', 'chk_proxy_tracker_conn'])
'chk_proxy_host_resolve', 'chk_proxy_peer_conn']) if proxy_type in (3, 5):
# 1:"Socks4", 2:"Socks5", 4:"HTTP" show_entries.extend([
elif proxy_type in (1, 2, 4): 'label_proxy_pass', 'entry_proxy_pass', 'label_proxy_user', 'entry_proxy_user'])
if proxy_type in (2, 4): if proxy_type in (2, 3, 4, 5):
shows.extend(['chk_proxy_host_resolve']) show_entries.extend(['chk_proxy_host_resolve'])
hides.extend(['entry_proxy_pass', 'entry_proxy_user', 'label_proxy_pass', 'label_proxy_user'])
shows.extend(['entry_proxy_host', 'spin_proxy_port', 'label_proxy_host',
'label_proxy_port', 'chk_proxy_peer_conn'])
# 3:"Socks5 Auth", 5:"HTTP Auth"
elif proxy_type in (3, 5):
shows.extend(['entry_proxy_pass', 'entry_proxy_user', 'entry_proxy_host', 'spin_proxy_port',
'label_proxy_pass', 'label_proxy_user', 'label_proxy_host', 'label_proxy_port',
'chk_proxy_host_resolve', 'chk_proxy_peer_conn'])
for hide_entry in hides: for entry in proxy_entries:
self.builder.get_object(hide_entry).hide() if entry in show_entries:
for show_entry in shows: self.builder.get_object(entry).show()
self.builder.get_object(show_entry).show() else:
self.builder.get_object(entry).hide()
def _on_button_associate_magnet_clicked(self, widget): def _on_button_associate_magnet_clicked(self, widget):
associate_magnet_links(True) associate_magnet_links(True)

View File

@ -36,7 +36,8 @@ Deluge.preferences.ProxyField = Ext.extend(Ext.form.FieldSet, {
[2, _('Socks5')], [2, _('Socks5')],
[3, _('Socks5 Auth')], [3, _('Socks5 Auth')],
[4, _('HTTP')], [4, _('HTTP')],
[5, _('HTTP Auth')] [5, _('HTTP Auth')],
[6, _('I2P')]
] ]
}), }),
editable: false, editable: false,
@ -100,11 +101,49 @@ Deluge.preferences.ProxyField = Ext.extend(Ext.form.FieldSet, {
xtype: 'checkbox', xtype: 'checkbox',
name: 'proxy_peer_conn', name: 'proxy_peer_conn',
fieldLabel: '', fieldLabel: '',
boxLabel: _('Proxy Peer Connections'), boxLabel: _('Proxy Peers'),
width: 220 width: 220
}); });
this.proxy_peer_conn.on('change', this.onFieldChange, this); this.proxy_peer_conn.on('change', this.onFieldChange, this);
this.proxy_tracker_conn = this.add({
xtype: 'checkbox',
name: 'proxy_tracker_conn',
fieldLabel: '',
boxLabel: _('Proxy Trackers'),
width: 220
});
this.proxy_tracker_conn.on('change', this.onFieldChange, this);
var fieldset = this.add({
xtype: 'fieldset',
border: false,
title: _('Force Proxy'),
autoHeight: true,
labelWidth: 1,
defaultType: 'checkbox',
style: 'padding-left: 0px; margin-top: 10px'
});
this.force_proxy = fieldset.add({
fieldLabel: '',
labelSeparator: '',
height: 20,
name: 'force_proxy',
boxLabel: _('Force Use of Proxy'),
});
this.force_proxy.on('change', this.onFieldChange, this);
this.anonymous_mode = fieldset.add({
fieldLabel: '',
labelSeparator: '',
height: 20,
name: 'anonymous_mode',
boxLabel: _('Hide Client Identity')
});
this.anonymous_mode.on('change', this.onFieldChange, this);
this.setting = false; this.setting = false;
}, },
@ -120,7 +159,10 @@ Deluge.preferences.ProxyField = Ext.extend(Ext.form.FieldSet, {
'username': this.username.getValue(), 'username': this.username.getValue(),
'password': this.password.getValue(), 'password': this.password.getValue(),
'proxy_hostnames': this.proxy_host_resolve.getValue(), 'proxy_hostnames': this.proxy_host_resolve.getValue(),
'proxy_peer_connections': this.proxy_peer_conn.getValue() 'proxy_peer_connections': this.proxy_peer_conn.getValue(),
'proxy_tracker_connections': this.proxy_tracker_conn.getValue(),
'force_proxy': this.force_proxy.getValue(),
'anonymous_mode': this.anonymous_mode.getValue()
} }
}, },
@ -137,6 +179,9 @@ Deluge.preferences.ProxyField = Ext.extend(Ext.form.FieldSet, {
this.password.setValue(value['password']); this.password.setValue(value['password']);
this.proxy_host_resolve.setValue(value['proxy_hostnames']); this.proxy_host_resolve.setValue(value['proxy_hostnames']);
this.proxy_peer_conn.setValue(value['proxy_peer_connections']); this.proxy_peer_conn.setValue(value['proxy_peer_connections']);
this.proxy_tracker_conn.setValue(value['proxy_tracker_connections']);
this.force_proxy.setValue(value['force_proxy']);
this.anonymous_mode.setValue(value['anonymous_mode']);
this.onTypeSelect(this.type, record, index); this.onTypeSelect(this.type, record, index);
this.setting = false; this.setting = false;
@ -157,14 +202,18 @@ Deluge.preferences.ProxyField = Ext.extend(Ext.form.FieldSet, {
this.hostname.show(); this.hostname.show();
this.port.show(); this.port.show();
this.proxy_peer_conn.show(); this.proxy_peer_conn.show();
if (typeId != 1) { this.proxy_tracker_conn.show();
if (typeId > 1 && typeId < 6) {
this.proxy_host_resolve.show(); this.proxy_host_resolve.show();
} else {
this.proxy_host_resolve.hide();
} }
} else { } else {
this.hostname.hide(); this.hostname.hide();
this.port.hide(); this.port.hide();
this.proxy_host_resolve.hide(); this.proxy_host_resolve.hide();
this.proxy_peer_conn.hide(); this.proxy_peer_conn.hide();
this.proxy_tracker_conn.hide();
} }
if (typeId == 3 || typeId == 5) { if (typeId == 3 || typeId == 5) {

View File

@ -1,75 +0,0 @@
/*!
* Deluge.preferences.ProxyI2PField.js
*
* Copyright (c) Damien Churchill 2009-2010 <damoxc@gmail.com>
*
* This file is part of Deluge and is licensed under GNU General Public License 3.0, or later, with
* the additional special exception to link portions of this program with the OpenSSL library.
* See LICENSE for more details.
*/
Ext.ns('Deluge.preferences');
/**
* @class Deluge.preferences.ProxyI2PField
* @extends Ext.form.FieldSet
*/
Deluge.preferences.ProxyI2PField = Ext.extend(Ext.form.FieldSet, {
border: false,
autoHeight: true,
labelWidth: 70,
initComponent: function() {
Deluge.preferences.ProxyI2PField.superclass.initComponent.call(this);
this.hostname = this.add({
xtype: 'textfield',
name: 'hostname',
fieldLabel: _('Host:'),
labelSeparator: '',
width: 220
});
this.hostname.on('change', this.onFieldChange, this);
this.port = this.add({
xtype: 'spinnerfield',
name: 'port',
fieldLabel: _('Port:'),
labelSeparator: '',
width: 80,
decimalPrecision: 0,
minValue: 0,
maxValue: 65535
});
this.port.on('change', this.onFieldChange, this);
this.setting = false;
},
getName: function() {
return this.initialConfig.name;
},
getValue: function() {
return {
'hostname': this.hostname.getValue(),
'port': Number(this.port.getValue())
}
},
// Set the values of the proxies
setValue: function(value) {
this.setting = true;
this.hostname.setValue(value['hostname']);
this.port.setValue(value['port']);
this.setting = false;
},
onFieldChange: function(field, newValue, oldValue) {
if (this.setting) return;
var newValues = this.getValue();
var oldValues = Ext.apply({}, newValues);
oldValues[field.getName()] = oldValue;
this.fireEvent('change', this, newValues, oldValues);
}
});

View File

@ -33,29 +33,6 @@ Deluge.preferences.Proxy = Ext.extend(Ext.form.FormPanel, {
})); }));
this.proxy.on('change', this.onProxyChange, this); this.proxy.on('change', this.onProxyChange, this);
deluge.preferences.getOptionsManager().bind('proxy', this.proxy); deluge.preferences.getOptionsManager().bind('proxy', this.proxy);
this.i2p_proxy = this.add(new Deluge.preferences.ProxyI2PField({
title: _('I2P Proxy'),
name: 'i2p_proxy'
}));
deluge.preferences.getOptionsManager().bind('i2p_proxy', this.i2p_proxy);
var fieldset = this.add({
xtype: 'fieldset',
border: false,
title: _('Anonymous Mode'),
autoHeight: true,
labelWidth: 1,
defaultType: 'checkbox'
});
deluge.preferences.getOptionsManager().bind('anonymous_mode', fieldset.add({
fieldLabel: '',
labelSeparator: '',
height: 20,
name: 'anonymous_mode',
boxLabel: _('Hide Client Identity')
}));
}, },
getValue: function() { getValue: function() {