Class | Jabber::Bytestreams::SOCKS5BytestreamsTarget |
In: |
lib/xmpp4r/bytestreams/helper/socks5bytestreams/target.rb
|
Parent: | SOCKS5Bytestreams |
SOCKS5 Bytestreams implementation of the target site
Wait until the stream has been established
May raise various exceptions
# File lib/xmpp4r/bytestreams/helper/socks5bytestreams/target.rb, line 14 14: def accept 15: error = nil 16: connect_lock = Mutex.new 17: connect_lock.lock 18: 19: @stream.add_iq_callback(200, self) { |iq| 20: if iq.type == :set and iq.from == @initiator_jid and iq.to == @target_jid and iq.query.kind_of?(IqQueryBytestreams) 21: begin 22: @stream.delete_iq_callback(self) 23: 24: iq.query.each_element('streamhost') { |streamhost| 25: if streamhost.host and streamhost.port and not @socks 26: begin 27: @socks = connect_socks(streamhost) 28: @streamhost_used = streamhost 29: rescue Exception => e 30: Jabber::debuglog("SOCKS5 Bytestreams: #{e.class}: #{e}\n#{e.backtrace.join("\n")}") 31: @streamhost_cbs.process(streamhost, :failure, e) 32: end 33: end 34: } 35: 36: reply = iq.answer(false) 37: if @streamhost_used 38: reply.type = :result 39: reply.add(IqQueryBytestreams.new) 40: reply.query.add(StreamHostUsed.new(@streamhost_used.jid)) 41: else 42: reply.type = :error 43: reply.add(Error.new('item-not-found')) 44: end 45: @stream.send(reply) 46: rescue Exception => e 47: error = e 48: end 49: 50: connect_lock.unlock 51: true 52: else 53: false 54: end 55: } 56: 57: connect_lock.lock 58: connect_lock.unlock 59: raise error if error 60: (@socks != nil) 61: end