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