ability to discover STUN server with SRV records of jabber server
This commit is contained in:
parent
e8b88db629
commit
c1d0013cb0
|
@ -2128,7 +2128,7 @@ $T will be replaced by auto-not-available timeout</property>
|
||||||
<child>
|
<child>
|
||||||
<widget class="GtkTable" id="table9">
|
<widget class="GtkTable" id="table9">
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
<property name="n_columns">3</property>
|
<property name="n_columns">4</property>
|
||||||
<property name="column_spacing">6</property>
|
<property name="column_spacing">6</property>
|
||||||
<property name="row_spacing">6</property>
|
<property name="row_spacing">6</property>
|
||||||
<child>
|
<child>
|
||||||
|
@ -2148,8 +2148,8 @@ $T will be replaced by auto-not-available timeout</property>
|
||||||
<property name="use_markup">True</property>
|
<property name="use_markup">True</property>
|
||||||
</widget>
|
</widget>
|
||||||
<packing>
|
<packing>
|
||||||
<property name="left_attach">2</property>
|
<property name="left_attach">3</property>
|
||||||
<property name="right_attach">3</property>
|
<property name="right_attach">4</property>
|
||||||
<property name="x_options">GTK_FILL</property>
|
<property name="x_options">GTK_FILL</property>
|
||||||
</packing>
|
</packing>
|
||||||
</child>
|
</child>
|
||||||
|
@ -2157,12 +2157,28 @@ $T will be replaced by auto-not-available timeout</property>
|
||||||
<widget class="GtkEntry" id="stun_server_entry">
|
<widget class="GtkEntry" id="stun_server_entry">
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
<property name="can_focus">True</property>
|
<property name="can_focus">True</property>
|
||||||
|
<property name="tooltip" translatable="yes">STUN server hostname. If none given, Gajim will try
|
||||||
|
to discover one from server.</property>
|
||||||
<property name="invisible_char">●</property>
|
<property name="invisible_char">●</property>
|
||||||
<signal name="changed" handler="stun_server_entry_changed"/>
|
<signal name="changed" handler="stun_server_entry_changed"/>
|
||||||
</widget>
|
</widget>
|
||||||
|
<packing>
|
||||||
|
<property name="left_attach">2</property>
|
||||||
|
<property name="right_attach">3</property>
|
||||||
|
</packing>
|
||||||
|
</child>
|
||||||
|
<child>
|
||||||
|
<widget class="GtkCheckButton" id="stun_checkbutton">
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<property name="can_focus">True</property>
|
||||||
|
<property name="receives_default">False</property>
|
||||||
|
<property name="draw_indicator">True</property>
|
||||||
|
<signal name="toggled" handler="on_stun_checkbutton_toggled"/>
|
||||||
|
</widget>
|
||||||
<packing>
|
<packing>
|
||||||
<property name="left_attach">1</property>
|
<property name="left_attach">1</property>
|
||||||
<property name="right_attach">2</property>
|
<property name="right_attach">2</property>
|
||||||
|
<property name="x_options">GTK_FILL</property>
|
||||||
</packing>
|
</packing>
|
||||||
</child>
|
</child>
|
||||||
</widget>
|
</widget>
|
||||||
|
|
|
@ -277,6 +277,7 @@ class Config:
|
||||||
'audio_output_device': [opt_str, 'autoaudiosink'],
|
'audio_output_device': [opt_str, 'autoaudiosink'],
|
||||||
'video_input_device': [opt_str, 'autovideosrc ! videoscale ! ffmpegcolorspace'],
|
'video_input_device': [opt_str, 'autovideosrc ! videoscale ! ffmpegcolorspace'],
|
||||||
'video_output_device': [opt_str, 'autovideosink'],
|
'video_output_device': [opt_str, 'autovideosink'],
|
||||||
|
'use_stun_server': [opt_bool, True, _('If True, Gajim will try to use a STUN server when using jingle. The one in "stun_server" option, or the one given by the jabber server.')],
|
||||||
'stun_server': [opt_str, '', _('STUN server to use when using jingle')],
|
'stun_server': [opt_str, '', _('STUN server to use when using jingle')],
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -150,6 +150,7 @@ class CommonConnection:
|
||||||
self.private_storage_supported = False
|
self.private_storage_supported = False
|
||||||
|
|
||||||
self.muc_jid = {} # jid of muc server for each transport type
|
self.muc_jid = {} # jid of muc server for each transport type
|
||||||
|
self._stun_servers = [] # STUN servers of our jabber server
|
||||||
|
|
||||||
self.get_config_values_or_default()
|
self.get_config_values_or_default()
|
||||||
|
|
||||||
|
@ -1508,6 +1509,13 @@ class Connection(CommonConnection, ConnectionHandlers):
|
||||||
self.discoverInfo(gajim.config.get_per('accounts', self.name, 'hostname'),
|
self.discoverInfo(gajim.config.get_per('accounts', self.name, 'hostname'),
|
||||||
id_prefix='Gajim_')
|
id_prefix='Gajim_')
|
||||||
self.privacy_rules_requested = False
|
self.privacy_rules_requested = False
|
||||||
|
# Discover Stun server(s)
|
||||||
|
gajim.resolver.resolve('_stun._udp.' + helpers.idn_to_ascii(
|
||||||
|
self.connected_hostname), self._on_stun_resolved)
|
||||||
|
|
||||||
|
def _on_stun_resolved(self, host, result_array):
|
||||||
|
if len(result_array) != 0:
|
||||||
|
self._stun_servers = self._hosts = [i for i in result_array]
|
||||||
|
|
||||||
def _request_privacy(self):
|
def _request_privacy(self):
|
||||||
iq = common.xmpp.Iq('get', common.xmpp.NS_PRIVACY, xmlns = '')
|
iq = common.xmpp.Iq('get', common.xmpp.NS_PRIVACY, xmlns = '')
|
||||||
|
|
|
@ -213,8 +213,7 @@ class ConnectionDisco:
|
||||||
continue
|
continue
|
||||||
items.append(attr)
|
items.append(attr)
|
||||||
jid = helpers.get_full_jid_from_iq(iq_obj)
|
jid = helpers.get_full_jid_from_iq(iq_obj)
|
||||||
hostname = gajim.config.get_per('accounts', self.name,
|
hostname = gajim.config.get_per('accounts', self.name, 'hostname')
|
||||||
'hostname')
|
|
||||||
id_ = iq_obj.getID()
|
id_ = iq_obj.getID()
|
||||||
if jid == hostname and id_[:6] == 'Gajim_':
|
if jid == hostname and id_[:6] == 'Gajim_':
|
||||||
for item in items:
|
for item in items:
|
||||||
|
|
|
@ -72,15 +72,18 @@ class JingleRTPContent(JingleContent):
|
||||||
# pidgin and telepathy-gabble don't follow the XEP, and it won't work
|
# pidgin and telepathy-gabble don't follow the XEP, and it won't work
|
||||||
# due to bad controlling-mode
|
# due to bad controlling-mode
|
||||||
params = {'controlling-mode': self.session.weinitiate, 'debug': False}
|
params = {'controlling-mode': self.session.weinitiate, 'debug': False}
|
||||||
stun_server = gajim.config.get('stun_server')
|
if gajim.config.get('use_stun_server'):
|
||||||
if stun_server:
|
stun_server = gajim.config.get('stun_server')
|
||||||
try:
|
if not stun_server and self._stun_servers:
|
||||||
ip = socket.getaddrinfo(stun_server, 0, socket.AF_UNSPEC,
|
stun_server = self._stun_servers[0]['host']
|
||||||
socket.SOCK_STREAM)[0][4][0]
|
if stun_server:
|
||||||
except socket.gaierror, (errnum, errstr):
|
try:
|
||||||
log.warn('Lookup of stun ip failed: %s' % errstr)
|
ip = socket.getaddrinfo(stun_server, 0, socket.AF_UNSPEC,
|
||||||
else:
|
socket.SOCK_STREAM)[0][4][0]
|
||||||
params['stun-ip'] = ip
|
except socket.gaierror, (errnum, errstr):
|
||||||
|
log.warn('Lookup of stun ip failed: %s' % errstr)
|
||||||
|
else:
|
||||||
|
params['stun-ip'] = ip
|
||||||
|
|
||||||
self.p2pstream = self.p2psession.new_stream(participant,
|
self.p2pstream = self.p2psession.new_stream(participant,
|
||||||
farsight.DIRECTION_RECV, 'nice', params)
|
farsight.DIRECTION_RECV, 'nice', params)
|
||||||
|
|
|
@ -452,9 +452,15 @@ class PreferencesWindow:
|
||||||
combobox = self.xml.get_widget(opt_name + '_combobox')
|
combobox = self.xml.get_widget(opt_name + '_combobox')
|
||||||
combobox.set_sensitive(False)
|
combobox.set_sensitive(False)
|
||||||
|
|
||||||
# Connection
|
# STUN
|
||||||
|
cb = self.xml.get_widget('stun_checkbutton')
|
||||||
|
st = gajim.config.get('use_stun_server')
|
||||||
|
cb.set_active(st)
|
||||||
|
|
||||||
entry = self.xml.get_widget('stun_server_entry')
|
entry = self.xml.get_widget('stun_server_entry')
|
||||||
entry.set_text(gajim.config.get('stun_server'))
|
entry.set_text(gajim.config.get('stun_server'))
|
||||||
|
if not st:
|
||||||
|
entry.set_sensitive(False)
|
||||||
|
|
||||||
### Advanced tab ###
|
### Advanced tab ###
|
||||||
# open links with
|
# open links with
|
||||||
|
@ -1085,6 +1091,10 @@ class PreferencesWindow:
|
||||||
def on_video_output_combobox_changed(self, widget):
|
def on_video_output_combobox_changed(self, widget):
|
||||||
self.on_av_combobox_changed(widget, 'video_output')
|
self.on_av_combobox_changed(widget, 'video_output')
|
||||||
|
|
||||||
|
def on_stun_checkbutton_toggled(self, widget):
|
||||||
|
self.on_checkbutton_toggled(widget, 'use_stun_server',
|
||||||
|
[self.xml.get_widget('stun_server_entry')])
|
||||||
|
|
||||||
def stun_server_entry_changed(self, widget):
|
def stun_server_entry_changed(self, widget):
|
||||||
gajim.config.set('stun_server', widget.get_text().decode('utf-8'))
|
gajim.config.set('stun_server', widget.get_text().decode('utf-8'))
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue