net-ssh 1.0.1 → 1.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -14,8 +14,8 @@
14
14
  </div>
15
15
  </td><td valign='middle' align='right'>
16
16
  <div class="info">
17
- Net::SSH Version: <strong>1.0.1</strong><br />
18
- Manual Last Updated: <strong>2005-06-17 20:55 UTC</strong>
17
+ Net::SSH Version: <strong>1.0.2</strong><br />
18
+ Manual Last Updated: <strong>2005-07-27 05:13 UTC</strong>
19
19
  </div>
20
20
  </td></tr>
21
21
  </table>
@@ -14,8 +14,8 @@
14
14
  </div>
15
15
  </td><td valign='middle' align='right'>
16
16
  <div class="info">
17
- Net::SSH Version: <strong>1.0.1</strong><br />
18
- Manual Last Updated: <strong>2005-06-17 20:55 UTC</strong>
17
+ Net::SSH Version: <strong>1.0.2</strong><br />
18
+ Manual Last Updated: <strong>2005-07-27 05:13 UTC</strong>
19
19
  </div>
20
20
  </td></tr>
21
21
  </table>
@@ -259,9 +259,9 @@
259
259
  <div class='figure'>
260
260
  <span class='caption'>Using keyword arguments [ruby]</span>
261
261
  <div class='body'><table border='0' cellpadding='0' cellspacing='0'><tr><td class='lineno'>1<br />2<br />3<br />4<br />5<br />6<br />7<br /></td><td width='100%'><link rel='stylesheet' type='text/css' href='stylesheets/ruby.css' /><div class='ruby'><pre><span class="constant">Net</span><span class="punct">::</span><span class="constant">SSH</span><span class="punct">.</span><span class="ident">start</span><span class="punct">(</span> <span class="punct">'</span><span class="string">host</span><span class="punct">',</span>
262
- <span class="symbol">:password</span><span class="punct">=&gt;'</span><span class="string">passwd</span><span class="punct">',</span>
263
- <span class="symbol">:port</span><span class="punct">=&gt;</span><span class="number">1234</span><span class="punct">,</span>
264
- <span class="symbol">:username</span><span class="punct">=&gt;'</span><span class="string">user</span><span class="punct">',</span>
262
+ <span class="symbol">:password=</span><span class="punct">&gt;'</span><span class="string">passwd</span><span class="punct">',</span>
263
+ <span class="symbol">:port=</span><span class="punct">&gt;</span><span class="number">1234</span><span class="punct">,</span>
264
+ <span class="symbol">:username=</span><span class="punct">&gt;'</span><span class="string">user</span><span class="punct">',</span>
265
265
  <span class="punct">...</span> <span class="punct">)</span> <span class="keyword">do</span> <span class="punct">|</span><span class="ident">session</span><span class="punct">|</span>
266
266
  <span class="punct">...</span>
267
267
  <span class="keyword">end</span></pre></div></td></tr></table></div></div>
@@ -14,8 +14,8 @@
14
14
  </div>
15
15
  </td><td valign='middle' align='right'>
16
16
  <div class="info">
17
- Net::SSH Version: <strong>1.0.1</strong><br />
18
- Manual Last Updated: <strong>2005-06-17 20:55 UTC</strong>
17
+ Net::SSH Version: <strong>1.0.2</strong><br />
18
+ Manual Last Updated: <strong>2005-07-27 05:13 UTC</strong>
19
19
  </div>
20
20
  </td></tr>
21
21
  </table>
@@ -355,7 +355,7 @@
355
355
  </tr>
356
356
  <tr>
357
357
  <td style="vertical-align:top;text-align:center;"><code>on_request</code> </td>
358
- <td> When the server sends a &#8220;channel request&#8221; to the client, this callback will be invoked. Channel requests from the server typically indicate things like the exit status of a process. This callback should take three parameters: the channel, a boolean (indicating whether or not the server wants an explicit reply to this request), and the data from the request.</td>
358
+ <td> When the server sends a &#8220;channel request&#8221; to the client, this callback will be invoked. Channel requests from the server typically indicate things like the exit status of a process. This callback should take four parameters: the channel, the type of request (as a string, like &#8220;exit-status&#8221;), a boolean (indicating whether or not the server wants an explicit reply to this request), and the data from the request, which will be a buffer object (see the <span class="caps">API</span> documentation for <code>Net::SSH::Util::ReaderBufferImpl</code>).</td>
359
359
  </tr>
360
360
  <tr>
361
361
  <td style="vertical-align:top;text-align:center;"><code>on_success</code> </td>
@@ -14,8 +14,8 @@
14
14
  </div>
15
15
  </td><td valign='middle' align='right'>
16
16
  <div class="info">
17
- Net::SSH Version: <strong>1.0.1</strong><br />
18
- Manual Last Updated: <strong>2005-06-17 20:55 UTC</strong>
17
+ Net::SSH Version: <strong>1.0.2</strong><br />
18
+ Manual Last Updated: <strong>2005-07-27 05:13 UTC</strong>
19
19
  </div>
20
20
  </td></tr>
21
21
  </table>
@@ -14,8 +14,8 @@
14
14
  </div>
15
15
  </td><td valign='middle' align='right'>
16
16
  <div class="info">
17
- Net::SSH Version: <strong>1.0.1</strong><br />
18
- Manual Last Updated: <strong>2005-06-17 20:55 UTC</strong>
17
+ Net::SSH Version: <strong>1.0.2</strong><br />
18
+ Manual Last Updated: <strong>2005-07-27 05:13 UTC</strong>
19
19
  </div>
20
20
  </td></tr>
21
21
  </table>
@@ -14,8 +14,8 @@
14
14
  </div>
15
15
  </td><td valign='middle' align='right'>
16
16
  <div class="info">
17
- Net::SSH Version: <strong>1.0.1</strong><br />
18
- Manual Last Updated: <strong>2005-06-17 20:55 UTC</strong>
17
+ Net::SSH Version: <strong>1.0.2</strong><br />
18
+ Manual Last Updated: <strong>2005-07-27 05:13 UTC</strong>
19
19
  </div>
20
20
  </td></tr>
21
21
  </table>
@@ -14,8 +14,8 @@
14
14
  </div>
15
15
  </td><td valign='middle' align='right'>
16
16
  <div class="info">
17
- Net::SSH Version: <strong>1.0.1</strong><br />
18
- Manual Last Updated: <strong>2005-06-17 20:55 UTC</strong>
17
+ Net::SSH Version: <strong>1.0.2</strong><br />
18
+ Manual Last Updated: <strong>2005-07-27 05:13 UTC</strong>
19
19
  </div>
20
20
  </td></tr>
21
21
  </table>
@@ -14,8 +14,8 @@
14
14
  </div>
15
15
  </td><td valign='middle' align='right'>
16
16
  <div class="info">
17
- Net::SSH Version: <strong>1.0.1</strong><br />
18
- Manual Last Updated: <strong>2005-06-17 20:55 UTC</strong>
17
+ Net::SSH Version: <strong>1.0.2</strong><br />
18
+ Manual Last Updated: <strong>2005-07-27 05:13 UTC</strong>
19
19
  </div>
20
20
  </td></tr>
21
21
  </table>
@@ -216,7 +216,7 @@
216
216
  <table border='0' cellpadding='0' cellspacing='0' align='center'><tr><td>
217
217
  <ul>
218
218
 
219
- <li>Updated from the (now-defunct) Hieraki version of the documentation</li>
219
+ <li>Corrected documentation for channel on_request callback.</li>
220
220
 
221
221
  </ul>
222
222
  </table>
@@ -23,7 +23,7 @@ product: !^product
23
23
  - Net::SSH Wiki: http://net-ssh.rubyforge.org/wiki/wiki.pl
24
24
 
25
25
  recent_updates:
26
- - "Updated from the (now-defunct) Hieraki version of the documentation"
26
+ - "Corrected documentation for channel on_request callback."
27
27
 
28
28
  chapters:
29
29
 
@@ -9,7 +9,7 @@ table(list).
9
9
  |=^. @on_eof@ | This callback is called when the server indicates that no more data will be sent _from the server_ over this channel. Your program is still welcome to send data to the server, but you are guaranteed at this point that your @on_data@ and @on_extended_data@ callbacks will no longer be called for this channel. The callback should accept a single parameter, the channel itself.|
10
10
  |=^. @on_extended_data@ | This callback is called when _extended data_ is received from the server. There are (potentially) many _types_ of extended data. The callback should accept three parameters: the channel, an integer indicating the type of the data, and the data itself. Right now, you can pretty much count on the data type being a "1", which corresponds to the remote process's @stderr@ stream. Other data types are not defined in the SSH specification, but that does not mean some SSH servers won't try to invent their own.|
11
11
  |=^. @on_failure@ | When a request is sent over a channel (via the @send_request@ or @send_request_string@ methods), it may either succeed or fail. If it fails, this callback will be invoked. It should take a single parameter: the channel itself.|
12
- |=^. @on_request@ | When the server sends a "channel request" to the client, this callback will be invoked. Channel requests from the server typically indicate things like the exit status of a process. This callback should take three parameters: the channel, a boolean (indicating whether or not the server wants an explicit reply to this request), and the data from the request.|
12
+ |=^. @on_request@ | When the server sends a "channel request" to the client, this callback will be invoked. Channel requests from the server typically indicate things like the exit status of a process. This callback should take four parameters: the channel, the type of request (as a string, like "exit-status"), a boolean (indicating whether or not the server wants an explicit reply to this request), and the data from the request, which will be a buffer object (see the API documentation for @Net::SSH::Util::ReaderBufferImpl@).|
13
13
  |=^. @on_success@ | When a request is sent over a channel (via the @send_request@ or @send_request_string@ methods), it may either succeed or fail. If it succeeds, this callback will be invoked. It should take a single parameter: the channel itself.|
14
14
  |=^. @on_window_adjust@ | When the server asks the client to adjust this channel's window size, this callback will be invoked. It should accept two parameters: the channel, and the number of bytes to add the channel's window size.|
15
15
 
@@ -29,4 +29,4 @@ Net::SSH.start( 'host' ) do |session|
29
29
 
30
30
  session.loop
31
31
  end
32
- }}}
32
+ }}}
@@ -460,7 +460,7 @@ module Net
460
460
 
461
461
  # Invoked when the server sends a request packet. This in turn calls
462
462
  # the "on_request" callback.
463
- event :request, :want_reply, :data
463
+ event :request, :type, :want_reply, :data
464
464
 
465
465
  # Invoked when the server sends confirmation of a successful operation.
466
466
  # This in turn invokes the "on_success" callback, if set.
@@ -55,7 +55,9 @@ module Net
55
55
  @channel_map = Hash.new
56
56
  @request_queue = Array.new
57
57
  @channel_open_handlers = Hash.new
58
+
58
59
  @data_requests = Array.new
60
+ @data_requests_mutex = Mutex.new
59
61
  end
60
62
 
61
63
  #--
@@ -112,7 +114,9 @@ module Net
112
114
  # maximum packet size from the client. Clients should not call this
113
115
  # method directly.
114
116
  def register_data_request( channel, data, type=nil )
115
- @data_requests << DataRequest.new( channel, data, type )
117
+ @data_requests_mutex.synchronize do
118
+ @data_requests << DataRequest.new( channel, data, type )
119
+ end
116
120
 
117
121
  # make sure the new data request has a chance to be sent to the
118
122
  # server... Otherwise, it cannot be sent until the next time #process
@@ -350,29 +354,34 @@ module Net
350
354
 
351
355
  # Process all pending data requests.
352
356
  def process_data_requests
353
- # guard against recursive/simultaneous calls
357
+ # guard against recursive calls
354
358
  return if @processing_data_requests
355
359
 
356
- @processing_data_requests = true
357
- @data_requests.map! do |req|
358
- while req && req.channel.window_size > 0
359
- remaining = if req.type
360
- req.channel.send_extended_data_packet( req.type, req.data )
361
- else
362
- req.channel.send_data_packet( req.data )
360
+ # guard against simultaneous calls
361
+ @data_requests_mutex.synchronize do
362
+ begin
363
+ @processing_data_requests = true
364
+ @data_requests.map! do |req|
365
+ while req && req.channel.window_size > 0
366
+ remaining = if req.type
367
+ req.channel.send_extended_data_packet( req.type, req.data )
368
+ else
369
+ req.channel.send_data_packet( req.data )
370
+ end
371
+ if remaining
372
+ req.data = remaining
373
+ else
374
+ req = nil
375
+ end
363
376
  end
364
- if remaining
365
- req.data = remaining
366
- else
367
- req = nil
377
+
378
+ req
368
379
  end
380
+ @data_requests.compact!
381
+ ensure
382
+ @processing_data_requests = false
369
383
  end
370
-
371
- req
372
384
  end
373
- @data_requests.compact!
374
- ensure
375
- @processing_data_requests = false
376
385
  end
377
386
 
378
387
  #--
@@ -248,7 +248,7 @@ module Net
248
248
  forward = @local_forwards[ key ]
249
249
  @local_forwards.delete key
250
250
 
251
- forward[ :socket ].close
251
+ forward[ :socket ].shutdown
252
252
  forward[ :thread ].terminate
253
253
 
254
254
  true
@@ -191,7 +191,7 @@ module Net
191
191
  ( args[0][:username] || args[0][:password] ||
192
192
  args[0][:port] || args[0][:options] )
193
193
  # then
194
- @username = args[0][:username] || username
194
+ @username = args[0][:username] || @username
195
195
  @password = args[0][:password]
196
196
 
197
197
  @options.update args.shift
@@ -20,7 +20,7 @@ module Net
20
20
 
21
21
  MAJOR = 1
22
22
  MINOR = 0
23
- TINY = 1
23
+ TINY = 2
24
24
 
25
25
  STRING = [ MAJOR, MINOR, TINY ].join( "." )
26
26
 
metadata CHANGED
@@ -3,8 +3,8 @@ rubygems_version: 0.8.10
3
3
  specification_version: 1
4
4
  name: net-ssh
5
5
  version: !ruby/object:Gem::Version
6
- version: 1.0.1
7
- date: 2005-06-17
6
+ version: 1.0.2
7
+ date: 2005-07-26
8
8
  summary: Net::SSH is a pure-Ruby implementation of the SSH2 client protocol.
9
9
  require_paths:
10
10
  - lib