bosh port must now be included in bosh URI

This commit is contained in:
Yann Leboulanger 2009-07-17 11:20:28 +02:00
parent 235c4d9ab8
commit 19e302b918
6 changed files with 73 additions and 90 deletions

View File

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE glade-interface SYSTEM "glade-2.0.dtd">
<!--*- mode: xml -*-->
<?xml version="1.0"?>
<glade-interface>
<!-- interface-requires gtk+ 2.12 -->
<!-- interface-naming-policy toplevel-contextual -->
<widget class="GtkWindow" id="manage_proxies_window">
<property name="border_width">12</property>
<property name="title" translatable="yes">Manage Proxy Profiles</property>
@ -22,9 +22,9 @@
<widget class="GtkScrolledWindow" id="scrolledwindow38">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="hscrollbar_policy">GTK_POLICY_AUTOMATIC</property>
<property name="vscrollbar_policy">GTK_POLICY_AUTOMATIC</property>
<property name="shadow_type">GTK_SHADOW_IN</property>
<property name="hscrollbar_policy">automatic</property>
<property name="vscrollbar_policy">automatic</property>
<property name="shadow_type">in</property>
<child>
<widget class="GtkTreeView" id="proxies_treeview">
<property name="visible">True</property>
@ -35,34 +35,44 @@
</widget>
</child>
</widget>
<packing>
<property name="position">0</property>
</packing>
</child>
<child>
<widget class="GtkHButtonBox" id="hbuttonbox21">
<property name="visible">True</property>
<property name="spacing">6</property>
<property name="layout_style">GTK_BUTTONBOX_END</property>
<property name="layout_style">end</property>
<child>
<widget class="GtkButton" id="add_proxy_button">
<property name="label">gtk-add</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="can_default">True</property>
<property name="label">gtk-add</property>
<property name="receives_default">False</property>
<property name="use_stock">True</property>
<property name="response_id">0</property>
<signal name="clicked" handler="on_add_proxy_button_clicked"/>
</widget>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">0</property>
</packing>
</child>
<child>
<widget class="GtkButton" id="remove_proxy_button">
<property name="label">gtk-remove</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="can_default">True</property>
<property name="label">gtk-remove</property>
<property name="receives_default">False</property>
<property name="use_stock">True</property>
<property name="response_id">0</property>
<signal name="clicked" handler="on_remove_proxy_button_clicked"/>
</widget>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">1</property>
</packing>
</child>
@ -73,6 +83,9 @@
</packing>
</child>
</widget>
<packing>
<property name="position">0</property>
</packing>
</child>
<child>
<widget class="GtkVBox" id="vbox90">
@ -81,7 +94,7 @@
<widget class="GtkFrame" id="frame34">
<property name="visible">True</property>
<property name="label_xalign">0</property>
<property name="shadow_type">GTK_SHADOW_NONE</property>
<property name="shadow_type">none</property>
<child>
<widget class="GtkAlignment" id="alignment72">
<property name="visible">True</property>
@ -165,13 +178,16 @@ BOSH</property>
</packing>
</child>
</widget>
<packing>
<property name="position">0</property>
</packing>
</child>
<child>
<widget class="GtkFrame" id="frame23">
<property name="visible">True</property>
<property name="border_width">6</property>
<property name="label_xalign">0</property>
<property name="shadow_type">GTK_SHADOW_NONE</property>
<property name="shadow_type">none</property>
<child>
<widget class="GtkAlignment" id="alignment51">
<property name="visible">True</property>
@ -180,53 +196,24 @@ BOSH</property>
<widget class="GtkTable" id="proxy_table">
<property name="visible">True</property>
<property name="sensitive">False</property>
<property name="n_rows">8</property>
<property name="n_rows">7</property>
<property name="n_columns">2</property>
<property name="column_spacing">12</property>
<property name="row_spacing">6</property>
<child>
<widget class="GtkEntry" id="boshport_entry">
<property name="visible">True</property>
<property name="can_focus">True</property>
<signal name="changed" handler="on_boshport_entry_changed"/>
</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>
<property name="y_options"></property>
</packing>
</child>
<child>
<widget class="GtkLabel" id="boshport_label">
<property name="visible">True</property>
<property name="xalign">0</property>
<property name="label" translatable="yes">B_OSH Port:</property>
<property name="use_underline">True</property>
<property name="mnemonic_widget">boshport_entry</property>
</widget>
<packing>
<property name="top_attach">1</property>
<property name="bottom_attach">2</property>
<property name="x_options">GTK_FILL</property>
<property name="y_options"></property>
</packing>
</child>
<child>
<widget class="GtkCheckButton" id="boshuseproxy_checkbutton">
<property name="label" translatable="yes">Use HTTP prox_y</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="label" translatable="yes">Use HTTP prox_y</property>
<property name="receives_default">False</property>
<property name="use_underline">True</property>
<property name="response_id">0</property>
<property name="draw_indicator">True</property>
<signal name="toggled" handler="on_boshuseproxy_checkbutton_toggled"/>
</widget>
<packing>
<property name="right_attach">2</property>
<property name="top_attach">2</property>
<property name="bottom_attach">3</property>
<property name="top_attach">1</property>
<property name="bottom_attach">2</property>
<property name="x_options">GTK_FILL</property>
<property name="y_options"></property>
</packing>
@ -258,18 +245,18 @@ BOSH</property>
</child>
<child>
<widget class="GtkCheckButton" id="useauth_checkbutton">
<property name="label" translatable="yes">Use proxy auth_entication</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="label" translatable="yes">Use proxy auth_entication</property>
<property name="receives_default">False</property>
<property name="use_underline">True</property>
<property name="response_id">0</property>
<property name="draw_indicator">True</property>
<signal name="toggled" handler="on_useauth_checkbutton_toggled"/>
</widget>
<packing>
<property name="right_attach">2</property>
<property name="top_attach">5</property>
<property name="bottom_attach">6</property>
<property name="top_attach">4</property>
<property name="bottom_attach">5</property>
<property name="x_options">GTK_FILL</property>
<property name="y_options"></property>
</packing>
@ -283,8 +270,8 @@ BOSH</property>
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
<property name="top_attach">6</property>
<property name="bottom_attach">7</property>
<property name="top_attach">5</property>
<property name="bottom_attach">6</property>
<property name="y_options"></property>
</packing>
</child>
@ -298,8 +285,8 @@ BOSH</property>
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
<property name="top_attach">7</property>
<property name="bottom_attach">8</property>
<property name="top_attach">6</property>
<property name="bottom_attach">7</property>
<property name="y_options"></property>
</packing>
</child>
@ -312,8 +299,8 @@ BOSH</property>
<property name="mnemonic_widget">proxyuser_entry</property>
</widget>
<packing>
<property name="top_attach">6</property>
<property name="bottom_attach">7</property>
<property name="top_attach">5</property>
<property name="bottom_attach">6</property>
<property name="x_options">GTK_FILL</property>
<property name="y_options"></property>
</packing>
@ -327,8 +314,8 @@ BOSH</property>
<property name="mnemonic_widget">proxypass_entry</property>
</widget>
<packing>
<property name="top_attach">7</property>
<property name="bottom_attach">8</property>
<property name="top_attach">6</property>
<property name="bottom_attach">7</property>
<property name="x_options">GTK_FILL</property>
<property name="y_options"></property>
</packing>
@ -342,8 +329,8 @@ BOSH</property>
<property name="mnemonic_widget">proxyhost_entry</property>
</widget>
<packing>
<property name="top_attach">3</property>
<property name="bottom_attach">4</property>
<property name="top_attach">2</property>
<property name="bottom_attach">3</property>
<property name="x_options">GTK_FILL</property>
<property name="y_options"></property>
</packing>
@ -357,8 +344,8 @@ BOSH</property>
<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>
<property name="top_attach">3</property>
<property name="bottom_attach">4</property>
<property name="y_options"></property>
</packing>
</child>
@ -371,8 +358,8 @@ BOSH</property>
<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>
<property name="top_attach">2</property>
<property name="bottom_attach">3</property>
<property name="y_options"></property>
</packing>
</child>
@ -385,8 +372,8 @@ BOSH</property>
<property name="mnemonic_widget">proxyport_entry</property>
</widget>
<packing>
<property name="top_attach">4</property>
<property name="bottom_attach">5</property>
<property name="top_attach">3</property>
<property name="bottom_attach">4</property>
<property name="x_options">GTK_FILL</property>
<property name="y_options"></property>
</packing>
@ -416,23 +403,31 @@ BOSH</property>
</packing>
</child>
</widget>
<packing>
<property name="position">0</property>
</packing>
</child>
<child>
<widget class="GtkHButtonBox" id="hbuttonbox22">
<property name="visible">True</property>
<property name="border_width">7</property>
<property name="spacing">12</property>
<property name="layout_style">GTK_BUTTONBOX_END</property>
<property name="layout_style">end</property>
<child>
<widget class="GtkButton" id="close_button">
<property name="label">gtk-close</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="can_default">True</property>
<property name="label">gtk-close</property>
<property name="receives_default">False</property>
<property name="use_stock">True</property>
<property name="response_id">0</property>
<signal name="clicked" handler="on_close_button_clicked"/>
</widget>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">0</property>
</packing>
</child>
</widget>
<packing>

View File

@ -363,7 +363,6 @@ class Config:
'user': [ opt_str, '' ],
'pass': [ opt_str, '' ],
'bosh_uri': [ opt_str, '' ],
'bosh_port': [ opt_int, 80 ],
'bosh_useproxy': [ opt_bool, False ],
'bosh_wait': [ opt_int, 30 ],
'bosh_hold': [ opt_int, 2 ],

View File

@ -622,7 +622,7 @@ class Connection(ConnectionHandlers):
if self._proxy:
msg = '>>>>>> '
if self._proxy['type']=='bosh':
msg = '%s over BOSH %s:%s' % (msg, self._proxy['bosh_uri'], self._proxy['bosh_port'])
msg = '%s over BOSH %s' % (msg, self._proxy['bosh_uri'])
if self._proxy['type'] in ['http','socks5'] or self._proxy['bosh_useproxy']:
msg = '%s over proxy %s:%s' % (msg, self._proxy['host'], self._proxy['port'])
log.info(msg)

View File

@ -62,7 +62,6 @@ class NonBlockingBOSH(NonBlockingTransport):
self.bosh_hold = bosh_dict['bosh_hold']
self.bosh_requests = self.bosh_hold
self.bosh_uri = bosh_dict['bosh_uri']
self.bosh_port = bosh_dict['bosh_port']
self.bosh_content = bosh_dict['bosh_content']
self.over_proxy = bosh_dict['bosh_useproxy']
if estabilish_tls:
@ -85,7 +84,8 @@ class NonBlockingBOSH(NonBlockingTransport):
self.proxy_dict['type'] = 'http'
# with SSL over proxy, we do HTTP CONNECT to proxy to open a channel to
# BOSH Connection Manager
self.proxy_dict['xmpp_server'] = (urisplit(self.bosh_uri)[1], self.bosh_port)
host, port = urisplit(self.bosh_uri)[1].split(':', 1)
self.proxy_dict['xmpp_server'] = (host, int(port))
self.proxy_dict['credentials'] = self.proxy_creds
@ -416,7 +416,6 @@ class NonBlockingBOSH(NonBlockingTransport):
def get_new_http_socket(self):
http_dict = {'http_uri': self.bosh_uri,
'http_port': self.bosh_port,
'http_version': self.http_version,
'http_persistent': self.http_persistent,
'add_proxy_headers': self.over_proxy and not self.estabilish_tls}

View File

@ -56,8 +56,9 @@ def get_proxy_data_from_dict(proxy):
proxy_type = proxy['type']
if proxy_type == 'bosh' and not proxy['bosh_useproxy']:
# with BOSH not over proxy we have to parse the hostname from BOSH URI
tcp_host, tcp_port = urisplit(proxy['bosh_uri'])[1], proxy['bosh_port']
tcp_host = tcp_host.split(':')[0]
tcp_host = urisplit(proxy['bosh_uri'])[1]
tcp_host, tcp_port = tcp_host.split(':', 1)
tcp_port = int(tcp_port)
else:
# with proxy!=bosh or with bosh over HTTP proxy we're connecting to proxy
# machine
@ -603,9 +604,10 @@ class NonBlockingHTTP(NonBlockingTCP):
self.http_protocol, self.http_host, self.http_path = urisplit(
http_dict['http_uri'])
self.http_host, self.http_port = self.http_host.split(':', 1)
self.http_port = int(self.http_port)
self.http_protocol = self.http_protocol or 'http'
self.http_path = self.http_path or '/'
self.http_port = http_dict['http_port']
self.http_version = http_dict['http_version']
self.http_persistent = http_dict['http_persistent']
self.add_proxy_headers = http_dict['add_proxy_headers']

View File

@ -1085,9 +1085,7 @@ class ManageProxiesWindow:
def show_bosh_fields(self, show=True):
if show:
self.xml.get_widget('boshuri_entry').show()
self.xml.get_widget('boshport_entry').show()
self.xml.get_widget('boshuri_label').show()
self.xml.get_widget('boshport_label').show()
self.xml.get_widget('boshuseproxy_checkbutton').show()
else:
cb = self.xml.get_widget('boshuseproxy_checkbutton')
@ -1095,9 +1093,7 @@ class ManageProxiesWindow:
cb.set_active(True)
self.on_boshuseproxy_checkbutton_toggled(cb)
self.xml.get_widget('boshuri_entry').hide()
self.xml.get_widget('boshport_entry').hide()
self.xml.get_widget('boshuri_label').hide()
self.xml.get_widget('boshport_label').hide()
def fill_proxies_treeview(self):
@ -1178,7 +1174,6 @@ class ManageProxiesWindow:
proxyuser_entry = self.xml.get_widget('proxyuser_entry')
proxypass_entry = self.xml.get_widget('proxypass_entry')
boshuri_entry = self.xml.get_widget('boshuri_entry')
boshport_entry = self.xml.get_widget('boshport_entry')
useauth_checkbutton = self.xml.get_widget('useauth_checkbutton')
boshuseproxy_checkbutton = self.xml.get_widget('boshuseproxy_checkbutton')
proxyhost_entry.set_text('')
@ -1218,8 +1213,6 @@ class ManageProxiesWindow:
'pass'))
boshuri_entry.set_text(gajim.config.get_per('proxies', proxy,
'bosh_uri'))
boshport_entry.set_text(unicode(gajim.config.get_per('proxies', proxy,
'bosh_port')))
types = ['http', 'socks5', 'bosh']
self.proxytype_combobox.set_active(types.index(proxytype))
boshuseproxy_checkbutton.set_active(
@ -1276,11 +1269,6 @@ class ManageProxiesWindow:
proxy = self.proxyname_entry.get_text().decode('utf-8')
gajim.config.set_per('proxies', proxy, 'bosh_uri', value)
def on_boshport_entry_changed(self, widget):
value = widget.get_text().decode('utf-8')
proxy = self.proxyname_entry.get_text().decode('utf-8')
gajim.config.set_per('proxies', proxy, 'bosh_port', value)
def on_proxypass_entry_changed(self, widget):
value = widget.get_text().decode('utf-8')
proxy = self.proxyname_entry.get_text().decode('utf-8')