Class: Blather::FileTransfer::S5b
- Inherits:
-
Object
- Object
- Blather::FileTransfer::S5b
- Defined in:
- lib/blather/file_transfer/s5b.rb
Overview
SOCKS5 Bytestreams Transfer helper Takes care of accepting, declining and offering file transfers through the stream
Defined Under Namespace
Classes: SocketConnection
Instance Attribute Summary collapse
-
#allow_ibb_fallback ⇒ Object
Set this to false if you don’t want to fallback to In-Band Bytestreams.
-
#allow_private_ips ⇒ Object
Set this to true if the buddies of your bot will be in the same local network.
Instance Method Summary collapse
-
#accept(handler, *params) ⇒ Object
Accept an incoming file-transfer.
-
#decline ⇒ Object
Decline an incoming file-transfer.
-
#initialize(stream, iq) ⇒ S5b
constructor
A new instance of S5b.
-
#offer ⇒ Object
Offer a file to somebody, not implemented yet.
Constructor Details
#initialize(stream, iq) ⇒ S5b
Returns a new instance of S5b.
16 17 18 19 20 21 |
# File 'lib/blather/file_transfer/s5b.rb', line 16 def initialize(stream, iq) @stream = stream @iq = iq @allow_ibb_fallback = true @allow_private_ips = false end |
Instance Attribute Details
#allow_ibb_fallback ⇒ Object
Set this to false if you don’t want to fallback to In-Band Bytestreams
8 9 10 |
# File 'lib/blather/file_transfer/s5b.rb', line 8 def allow_ibb_fallback @allow_ibb_fallback end |
#allow_private_ips ⇒ Object
Set this to true if the buddies of your bot will be in the same local network
Usually IM clients advertise all network addresses which they can determine. Skipping the local ones can save time if your bot is not in the same local network as it’s buddies
14 15 16 |
# File 'lib/blather/file_transfer/s5b.rb', line 14 def allow_private_ips @allow_private_ips end |
Instance Method Details
#accept(handler, *params) ⇒ Object
Accept an incoming file-transfer
27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/blather/file_transfer/s5b.rb', line 27 def accept(handler, *params) @streamhosts = @iq.streamhosts @streamhosts.delete_if {|s| begin IPAddr.new(s.host).private? rescue false end } unless @allow_private_ips @socket_address = Digest::SHA1.hexdigest("#{@iq.sid}#{@iq.from}#{@iq.to}") @handler = handler @params = params connect_next_streamhost @stream.clear_handlers :s5b_open, :from => @iq.from end |
#decline ⇒ Object
Decline an incoming file-transfer
40 41 42 43 |
# File 'lib/blather/file_transfer/s5b.rb', line 40 def decline @stream.clear_handlers :s5b_open, :from => @iq.from @stream.write StanzaError.new(@iq, 'not-acceptable', :auth).to_node end |
#offer ⇒ Object
Offer a file to somebody, not implemented yet
46 47 48 |
# File 'lib/blather/file_transfer/s5b.rb', line 46 def offer # TODO: implement end |