### Home Classes Methods

### In Files

- lib/xmpp4r/bytestreams/helper/socks5bytestreams/initiator.rb

### Parent

Jabber::Bytestreams::SOCKS5Bytestreams

### Methods

- ::new
- #add_streamhost
- #open

### Files

- CHANGELOG
- COPYING
- LICENSE
- README.rdoc
- README_ruby19.txt

### Class/Module Index

Quicksearch

- Jabber
- Jabber::ArgumentError
- Jabber::Bytestreams
- Jabber::Bytestreams::IBB
- Jabber::Bytestreams::IBBInitiator
- Jabber::Bytestreams::IBBQueueItem
- Jabber::Bytestreams::IBBTarget
- Jabber::Bytestreams::IqQueryBytestreams
- Jabber::Bytestreams::IqSi
- Jabber::Bytestreams::IqSiFile
- Jabber::Bytestreams::IqSiFileRange
- Jabber::Bytestreams::SOCKS5Bytestreams
- Jabber::Bytestreams::SOCKS5BytestreamsInitiator
- Jabber::Bytestreams::SOCKS5BytestreamsPeer
- Jabber::Bytestreams::SOCKS5BytestreamsServer
- Jabber::Bytestreams::SOCKS5BytestreamsServerStreamHost
- Jabber::Bytestreams::SOCKS5BytestreamsTarget
- Jabber::Bytestreams::SOCKS5Socket
- Jabber::Bytestreams::StreamHost
- Jabber::Bytestreams::StreamHostUsed
- Jabber::Callback
- Jabber::CallbackList
- Jabber::Caps
- Jabber::Caps::C
- Jabber::Caps::Helper
- Jabber::Client
- Jabber::ClientAuthenticationFailure
- Jabber::Command
- Jabber::Command::IqCommand
- Jabber::Command::Responder
- Jabber::Component
- Jabber::ComponentAuthenticationFailure
- Jabber::Connection
- Jabber::Connection::SSLSocketUTF8
- Jabber::Dataforms
- Jabber::Dataforms::XData
- Jabber::Dataforms::XDataField
- Jabber::Dataforms::XDataInstructions
- Jabber::Dataforms::XDataReported
- Jabber::Dataforms::XDataTitle
- Jabber::Delay
- Jabber::Delay::XDelay
- Jabber::Discovery
- Jabber::Discovery::Feature
- Jabber::Discovery::Helper
- Jabber::Discovery::Identity
- Jabber::Discovery::IqQueryDiscoInfo
- Jabber::Discovery::IqQueryDiscoItems
- Jabber::Discovery::Item
- Jabber::Discovery::Responder
- Jabber::EntityTime
- Jabber::EntityTime::IqTime
- Jabber::EntityTime::Responder
- Jabber::ErrorResponse
- Jabber::FeatureNegotiation
- Jabber::FeatureNegotiation::IqFeature
- Jabber::FileTransfer
- Jabber::FileTransfer::FileSource
- Jabber::FileTransfer::Helper
- Jabber::FileTransfer::TransferSource
- Jabber::Framework
- Jabber::Framework::Base
- Jabber::Framework::Bot
- Jabber::HTTPBinding
- Jabber::HTTPBinding::Client
- Jabber::IdGenerator
- Jabber::InvalidChatState
- Jabber::Iq
- Jabber::IqQuery
- Jabber::JID
- Jabber::JabberError
- Jabber::LastActivity
- Jabber::LastActivity::Helper
- Jabber::LastActivity::IqQueryLastActivity
- Jabber::MUC
- Jabber::MUC::IqQueryMUCAdmin
- Jabber::MUC::IqQueryMUCAdminItem
- Jabber::MUC::IqQueryMUCOwner
- Jabber::MUC::MUCBrowser
- Jabber::MUC::MUCClient
- Jabber::MUC::SimpleMUCClient
- Jabber::MUC::UserItem
- Jabber::MUC::XMUC
- Jabber::MUC::XMUCUser
- Jabber::MUC::XMUCUserInvite
- Jabber::MUC::XMUCUserItem
- Jabber::Message
- Jabber::NoNameXmlnsRegistered
- Jabber::NotConnected
- Jabber::Observable
- Jabber::Observable::Contact
- Jabber::Observable::PubSub
- Jabber::Observable::PubSub::AlreadySet
- Jabber::Observable::PubSub::NoService
- Jabber::Observable::Subscriptions
- Jabber::Presence
- Jabber::PubSub
- Jabber::PubSub::Configuration
- Jabber::PubSub::Event
- Jabber::PubSub::EventItem
- Jabber::PubSub::EventItems
- Jabber::PubSub::IqPubSub
- Jabber::PubSub::IqPubSubOwner
- Jabber::PubSub::Item
- Jabber::PubSub::Items
- Jabber::PubSub::NodeBrowser
- Jabber::PubSub::NodeConfig
- Jabber::PubSub::NodeHelper
- Jabber::PubSub::OAuthPubSubStreamHelper
- Jabber::PubSub::OAuthServiceHelper
- Jabber::PubSub::OwnerNodeConfig
- Jabber::PubSub::Publish
- Jabber::PubSub::Retract
- Jabber::PubSub::ServiceHelper
- Jabber::PubSub::Subscription
- Jabber::PubSub::SubscriptionConfig
- Jabber::PubSub::Unsubscribe
- Jabber::RPC
- Jabber::RPC::Client
- Jabber::RPC::IqQueryRPC
- Jabber::RPC::Server
- Jabber::Reliable
- Jabber::Reliable::Connection
- Jabber::Reliable::Listener
- Jabber::Roster
- Jabber::Roster::Helper
- Jabber::Roster::Helper::RosterItem
- Jabber::Roster::IqQueryRoster
- Jabber::Roster::RosterItem
- Jabber::Roster::RosterX
- Jabber::Roster::RosterXItem
- Jabber::Roster::XRoster
- Jabber::Roster::XRosterItem
- Jabber::SASL
- Jabber::SASL::Anonymous
- Jabber::SASL::Base
- Jabber::SASL::DigestMD5
- Jabber::SASL::Plain
- Jabber::SOCKS5Error
- Jabber::Semaphore
- Jabber::ServerDisconnected
- Jabber::Stream
- Jabber::Stream::ThreadBlock
- Jabber::StreamParser
- Jabber::Test
- Jabber::Test::ListenerMocker
- Jabber::UserLocation
- Jabber::UserLocation::Helper
- Jabber::UserLocation::Location
- Jabber::UserTune
- Jabber::UserTune::Helper
- Jabber::UserTune::Tune
- Jabber::Vcard
- Jabber::Vcard::Helper
- Jabber::Vcard::IqVcard
- Jabber::Version
- Jabber::Version::IqQueryVersion
- Jabber::Version::Responder
- Jabber::Version::SimpleResponder
- Jabber::X
- Jabber::XHTML
- Jabber::XHTML::Body
- Jabber::XHTML::HTML
- Jabber::XMPPElement
- Jabber::XMPPStanza
- Jabber::XParent
- REXML
- REXML::Element
- REXML::IOSource
- XMLRPC
- XMLRPC::Create
- Base64
- ObservableThing
- QObserver
- ThreadStore

No matching classes.

# Jabber::Bytestreams::SOCKS5BytestreamsInitiator

SOCKS5Bytestreams implementation for the initiator side

### Attributes

streamhosts[R]

### Public Class Methods

new(stream, session_id, initiator_jid, target_jid) click to toggle source

    # File lib/xmpp4r/bytestreams/helper/socks5bytestreams/initiator.rb, line 12
    def initialize(stream, session_id, initiator_jid, target_jid)
      super
      @streamhosts = []
    end

### Public Instance Methods

add_streamhost(streamhost) click to toggle source

Add a streamhost which will be offered to the target

streamhost | can be:

- StreamHost

    if already got all information (host/port)

- SOCKS5BytestreamsServer

    if this is the local streamhost

- String

    or [JID] if information should be automatically resolved by SOCKS5Bytestreams::query_streamhost

    # File lib/xmpp4r/bytestreams/helper/socks5bytestreams/initiator.rb, line 24
    def add_streamhost(streamhost)
      if streamhost.kind_of?(StreamHost)
        @streamhosts << streamhost
      elsif streamhost.kind_of?(SOCKS5BytestreamsServer)
        streamhost.each_streamhost(@initiator_jid) { |sh|
          @streamhosts << sh
        }
      elsif streamhost.kind_of?(String) or streamhost.kind_of?(JID)
        @streamhosts << SOCKS5Bytestreams::query_streamhost(@stream, streamhost, @initiator_jid)
      else
        raise "Unknown streamhost type: #{streamhost.class}"
      end
    end

open() click to toggle source

Send the configured streamhosts to the target, wait for an answer and connect to the host the target chose.

    # File lib/xmpp4r/bytestreams/helper/socks5bytestreams/initiator.rb, line 42
    def open
      iq1 = Iq.new(:set, @target_jid)
      iq1.from = @initiator_jid
      bs = iq1.add IqQueryBytestreams.new(@session_id)
      @streamhosts.each { |se|
        bs.add(se)
      }

      peer_used = nil
      @stream.send_with_id(iq1) { |response|
        if response.query.kind_of?(IqQueryBytestreams)
          peer_used = response.query.streamhost_used
          raise "No streamhost-used" unless peer_used
          raise "Invalid streamhost-used" unless peer_used.jid
        end
      }

      @streamhost_used = nil
      @streamhosts.each { |sh|
        if peer_used.jid == sh.jid
          @streamhost_used = sh
          break
        end
      }
      if @streamhost_used.jid == @initiator_jid
        # This is our own JID, so the target chose SOCKS5BytestreamsServer
        @socks = @streamhost_used.server.peer_sock(stream_address)
        raise "Target didn't connect" unless @socks
        @streamhost_cbs.process(@streamhost_used, :success, nil)
      else
        begin
          @socks = connect_socks(@streamhost_used)
        rescue Exception => e
          Jabber::debuglog("SOCKS5 Bytestreams: #{e.class}: #{e}\n#{e.backtrace.join("\n")}")
          @streamhost_cbs.process(@streamhost_used, :failure, e)
          raise e
        end
        iq2 = Iq.new(:set, @streamhost_used.jid)
        iq2.add(IqQueryBytestreams.new(@session_id)).activate = @target_jid.to_s
        @stream.send_with_id(iq2)
      end
    end

[Validate]

Generated with the Darkfish Rdoc Generator 2.