Sha256: e05a6ab4d67b4a816407c2759cca032ac2541bc4175dd449ed10c98ecd86f306

Contents?: true

Size: 1.91 KB

Versions: 15

Compression:

Stored size: 1.91 KB

Contents

# =XMPP4R - XMPP Library for Ruby
# License:: Ruby's license (see the LICENSE file) or GNU GPL, at your option.
# Website::http://home.gna.org/xmpp4r/

module Jabber
  module Bytestreams
    ##
    # SOCKS5 Bytestreams implementation of the target site
    class SOCKS5BytestreamsTarget < SOCKS5Bytestreams
      ##
      # Wait until the stream has been established
      #
      # May raise various exceptions
      def accept
        error = nil
        connect_sem = Semaphore.new

        @stream.add_iq_callback(200, self) { |iq|
          if iq.type == :set and iq.from == @initiator_jid and iq.to == @target_jid and iq.query.kind_of?(IqQueryBytestreams)
            begin
              @stream.delete_iq_callback(self)

              iq.query.each_element('streamhost') { |streamhost|
                if streamhost.host and streamhost.port and not @socks
                  begin
                    @socks = connect_socks(streamhost)
                    @streamhost_used = streamhost
                  rescue Exception => e
                    Jabber::debuglog("SOCKS5 Bytestreams: #{e.class}: #{e}\n#{e.backtrace.join("\n")}")
                    @streamhost_cbs.process(streamhost, :failure, e)
                  end
                end
              }

              reply = iq.answer(false)
              if @streamhost_used
                reply.type = :result
                reply.add(IqQueryBytestreams.new)
                reply.query.add(StreamHostUsed.new(@streamhost_used.jid))
              else
                reply.type = :error
                reply.add(ErrorResponse.new('item-not-found'))
              end
              @stream.send(reply)
            rescue Exception => e
              error = e
            end

            connect_sem.run
            true
          else
            false
          end
        }

        connect_sem.wait
        raise error if error
        (@socks != nil)
      end
    end
  end
end

Version data entries

15 entries across 15 versions & 6 rubygems

Version Path
bryanl-xmpp4r-0.3.2 lib/xmpp4r/bytestreams/helper/socks5bytestreams/target.rb
heipei-xmpp4r-0.3.2 lib/xmpp4r/bytestreams/helper/socks5bytestreams/target.rb
cerberus-0.8.0 lib/vendor/xmpp4r/lib/xmpp4r/bytestreams/helper/socks5bytestreams/target.rb.orig
cerberus-0.7.9 lib/vendor/xmpp4r/lib/xmpp4r/bytestreams/helper/socks5bytestreams/target.rb.orig
edavis10-cerberus-0.7.8 lib/vendor/xmpp4r/lib/xmpp4r/bytestreams/helper/socks5bytestreams/target.rb.orig
cerberus-0.7.8 lib/vendor/xmpp4r/lib/xmpp4r/bytestreams/helper/socks5bytestreams/target.rb.orig
cerberus-0.7.7 lib/vendor/xmpp4r/lib/xmpp4r/bytestreams/helper/socks5bytestreams/target.rb.orig
cerberus-0.7.6 lib/vendor/xmpp4r/lib/xmpp4r/bytestreams/helper/socks5bytestreams/target.rb.orig
cerberus-0.7.2 lib/vendor/xmpp4r/lib/xmpp4r/bytestreams/helper/socks5bytestreams/target.rb.orig
cerberus-0.7.5 lib/vendor/xmpp4r/lib/xmpp4r/bytestreams/helper/socks5bytestreams/target.rb.orig
cerberus-0.7 lib/vendor/xmpp4r/lib/xmpp4r/bytestreams/helper/socks5bytestreams/target.rb.orig
mack-notifier-0.8.2 lib/gems/xmpp4r-0.4/lib/xmpp4r/bytestreams/helper/socks5bytestreams/target.rb.orig
mack-notifier-0.8.3.1 lib/gems/xmpp4r-0.4/lib/xmpp4r/bytestreams/helper/socks5bytestreams/target.rb.orig
mack-notifier-0.8.3 lib/gems/xmpp4r-0.4/lib/xmpp4r/bytestreams/helper/socks5bytestreams/target.rb.orig
xmpp4r-0.4 lib/xmpp4r/bytestreams/helper/socks5bytestreams/target.rb.orig