Class Jabber::Bytestreams::SOCKS5BytestreamsTarget
In: lib/xmpp4r/bytestreams/helper/socks5bytestreams/target.rb
Parent: SOCKS5Bytestreams

SOCKS5 Bytestreams implementation of the target site

Methods

accept  

Public Instance methods

Wait until the stream has been established

May raise various exceptions

[Source]

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

[Validate]