### Home Classes Methods

### In Files

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

### Parent

Object

### Methods

- ::new
- ::query_streamhost
- #add_streamhost_callback
- #close
- #flush
- #read
- #write

### 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::SOCKS5Bytestreams

SOCKS5 Bytestreams (JEP-0065) implementation

Don't use directly, use SOCKS5BytestreamsInitiator and SOCKS5BytestreamsTarget

### Attributes

connect_timeout[RW]

SOCKS connection timeout (for trying multiple streamhosts)

default: nil, use the OS' default timeout

streamhost_used[R]

StreamHost

  the SOCKS connection is using

### Public Class Methods

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

    # File lib/xmpp4r/bytestreams/helper/socks5bytestreams/base.rb, line 31
    def initialize(stream, session_id, initiator_jid, target_jid)
      @stream = stream
      @session_id = session_id
      @initiator_jid = (initiator_jid.kind_of?(String) ? JID.new(initiator_jid) : initiator_jid)
      @target_jid = (target_jid.kind_of?(String) ? JID.new(target_jid) : target_jid)
      @socks = nil
      @connect_timeout = nil
      @streamhost_used = nil
      @streamhost_cbs = CallbackList.new
    end

query_streamhost(stream, streamhost, my_jid=nil) click to toggle source

Query a JID for its stream-host information

SOCKS5BytestreamsInitiator#add_streamhost can do this for you. Use this method if you plan to do multiple transfers, so you can cache the result.

stream

Stream

  to operate on

streamhost

JID

  of the proxy

my_jid

JID

  Optional sender JID for Component operation

    # File lib/xmpp4r/bytestreams/helper/socks5bytestreams/base.rb, line 96
    def self.query_streamhost(stream, streamhost, my_jid=nil)
      res = nil

      iq = Iq.new(:get, streamhost)
      iq.from = my_jid
      iq.add(IqQueryBytestreams.new)
      stream.send_with_id(iq) { |reply|
        reply.query.each_element { |e|
          if e.kind_of?(StreamHost)
            e.jid = reply.from  # Help misconfigured proxys
            res = e
          end
        }
      }

      if res and res.jid and res.host and res.port
        res
      else
        nil
      end
    end

### Public Instance Methods

add_streamhost_callback(priority = 0, ref = nil, &block) click to toggle source

Add a callback that will be called when there is action regarding SOCKS stream-hosts

Usage of this callback is optional and serves informational purposes only.

block takes three arguments:

- The StreamHost instance that is currently being tried

- State information (is either :connecting, :authenticating, :success or :failure)

- The exception value for the state :failure, else nil

    # File lib/xmpp4r/bytestreams/helper/socks5bytestreams/base.rb, line 52
    def add_streamhost_callback(priority = 0, ref = nil, &block)
      @streamhost_cbs.add(priority, ref, block)
    end

close() click to toggle source

Close the stream-host connection

    # File lib/xmpp4r/bytestreams/helper/socks5bytestreams/base.rb, line 83
    def close
      @socks.close
    end

flush() click to toggle source

Flush the SOCKS5 socket

    # File lib/xmpp4r/bytestreams/helper/socks5bytestreams/base.rb, line 66
    def flush
      @socks.flush
    end

read(length=nil) click to toggle source

Receive from the stream-host

length

Fixnum

  Amount of bytes (Will be passed to TCPSocket#read for the underlying SOCKS5 connection)

result

String

  (or [nil] if finished)

    # File lib/xmpp4r/bytestreams/helper/socks5bytestreams/base.rb, line 60
    def read(length=nil)
      @socks.read(length)
    end

write(buf) click to toggle source

Send to the stream-host

buf

String

  Data

result

Fixnum

  Amount of bytes sent

    # File lib/xmpp4r/bytestreams/helper/socks5bytestreams/base.rb, line 74
    def write(buf)
      @socks.write(buf)
      # FIXME: On FreeBSD this throws Errno::EPERM after it has already written a few
      # kilobytes, and when there are multiple sockets. ktrace told, that this originates
      # from the syscall, not ruby.
    end

[Validate]

Generated with the Darkfish Rdoc Generator 2.