def _send_socks5_info(self, file_props): """ Send iq for the present streamhosts and proxies """ if not app.account_is_connected(self._account): return receiver = file_props.receiver sender = file_props.sender sha_str = helpers.get_auth_sha(file_props.sid, sender, receiver) file_props.sha_str = sha_str port = app.config.get('file_transfers_port') listener = app.socks5queue.start_listener(port, sha_str, self._result_socks5_sid, file_props) if not listener: file_props.error = -5 from gajim.common.connection_handlers_events import FileRequestErrorEvent app.nec.push_incoming_event(FileRequestErrorEvent(None, conn=self._con, jid=receiver, file_props=file_props, error_msg='')) self._connect_error(file_props.sid, error='not-acceptable', error_type='modify') else: iq = nbxmpp.Iq(to=receiver, typ='set') file_props.request_id = 'id_' + file_props.sid iq.setID(file_props.request_id) query = iq.setTag('query', namespace=nbxmpp.NS_BYTESTREAM) query.setAttr('sid', file_props.sid) self._add_addiditional_streamhosts_to_query(query, file_props) self._add_local_ips_as_streamhosts_to_query(query, file_props) self._add_proxy_streamhosts_to_query(query, file_props) self._add_upnp_igd_as_streamhost_to_query(query, file_props, iq)
def _listen_host(self): receiver = self.file_props.receiver sender = self.file_props.sender sha_str = helpers.get_auth_sha(self.file_props.sid, sender, receiver) self.file_props.sha_str = sha_str port = app.config.get('file_transfers_port') fingerprint = None if self.use_security: fingerprint = 'server' listener = app.socks5queue.start_listener(port, sha_str, self._store_socks5_sid, self.file_props, fingerprint=fingerprint, typ='sender' if self.weinitiate else 'receiver') if not listener: # send error message, notify the user return
def ok(s, proto, ext_ip, re, ext_port, local_ip, local_port, desc): log.debug('Got GUPnP-IGD answer: external: %s:%s, internal: %s:%s', ext_ip, ext_port, local_ip, local_port) if local_port != app.config.get('file_transfers_port'): sender = file_props.sender receiver = file_props.receiver sha_str = helpers.get_auth_sha(file_props.sid, sender, receiver) listener = app.socks5queue.start_listener(local_port, sha_str, self._result_socks5_sid, file_props.sid) if listener: self._add_streamhosts_to_query(query, sender, ext_port, [ext_ip]) else: self._add_streamhosts_to_query(query, file_props.sender, ext_port, [ext_ip]) self._con.connection.send(iq) cleanup_gupnp()
def _send_socks5_info(self, file_props): """ Send iq for the present streamhosts and proxies """ if not app.account_is_available(self._account): return receiver = file_props.receiver sender = file_props.sender sha_str = helpers.get_auth_sha(file_props.sid, sender, receiver) file_props.sha_str = sha_str port = app.settings.get('file_transfers_port') listener = app.socks5queue.start_listener(port, sha_str, self._result_socks5_sid, file_props) if not listener: file_props.error = -5 app.nec.push_incoming_event( NetworkEvent('file-request-error', conn=self._con, jid=app.get_jid_without_resource(receiver), file_props=file_props, error_msg='')) self._connect_error(file_props.sid, error='not-acceptable', error_type='modify') else: iq = nbxmpp.Iq(to=receiver, typ='set') file_props.request_id = 'id_' + file_props.sid iq.setID(file_props.request_id) query = iq.setTag('query', namespace=Namespace.BYTESTREAM) query.setAttr('sid', file_props.sid) self._add_addiditional_streamhosts_to_query(query, file_props) self._add_local_ips_as_streamhosts_to_query(query, file_props) self._add_proxy_streamhosts_to_query(query, file_props) self._add_upnp_igd_as_streamhost_to_query(query, file_props, iq)