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
Instance Attribute Summary (collapse)
-
- (Object) allow_ibb_fallback
Set this to false if you don't want to fallback to In-Band Bytestreams.
-
- (Object) allow_private_ips
Set this to true if the buddies of your bot will be in the same local network.
Instance Method Summary (collapse)
-
- (Object) accept(handler, *params)
Accept an incoming file-transfer.
-
- (Object) decline
Decline an incoming file-transfer.
-
- (S5b) initialize(stream, iq)
constructor
A new instance of S5b.
-
- (Object) offer
Offer a file to somebody, not implemented yet.
Constructor Details
- (S5b) initialize(stream, iq)
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
- (Object) allow_ibb_fallback
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 |
- (Object) allow_private_ips
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
- (Object) accept(handler, *params)
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 |
- (Object) decline
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 |
- (Object) offer
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 |