redcar 0.3.7.1 → 0.3.8

Sign up to get free protection for your applications and to get access to all the features.
Files changed (246) hide show
  1. data/CHANGES +16 -0
  2. data/README.md +5 -0
  3. data/ROADMAP.md +7 -9
  4. data/Rakefile +55 -22
  5. data/lib/redcar.rb +12 -6
  6. data/lib/redcar/installer.rb +119 -44
  7. data/plugins/application/features/step_definitions/speedbar_steps.rb +62 -0
  8. data/plugins/application/features/step_definitions/tree_steps.rb +3 -3
  9. data/plugins/application/features/support/env.rb +2 -1
  10. data/plugins/application/lib/application/notebook.rb +53 -7
  11. data/plugins/application/lib/application/speedbar.rb +12 -0
  12. data/plugins/application/lib/application/tab.rb +16 -5
  13. data/plugins/application/lib/application/treebook.rb +21 -1
  14. data/plugins/application_swt/lib/application_swt.rb +12 -2
  15. data/plugins/application_swt/lib/application_swt/html_tab.rb +4 -0
  16. data/plugins/application_swt/lib/application_swt/notebook.rb +5 -3
  17. data/plugins/application_swt/lib/application_swt/speedbar.rb +15 -27
  18. data/plugins/application_swt/lib/application_swt/swt_wrapper.rb +1 -0
  19. data/plugins/application_swt/lib/application_swt/tab.rb +1 -0
  20. data/plugins/application_swt/lib/application_swt/treebook.rb +36 -8
  21. data/plugins/application_swt/lib/application_swt/window.rb +24 -18
  22. data/plugins/auto_completer/lib/auto_completer.rb +5 -20
  23. data/plugins/core/lib/core.rb +7 -4
  24. data/plugins/core/lib/core/observable_struct.rb +2 -2
  25. data/plugins/declarations/lib/declarations.rb +3 -17
  26. data/plugins/document_search/features/search.feature +163 -0
  27. data/plugins/document_search/features/support/env.rb +4 -0
  28. data/plugins/document_search/lib/document_search.rb +121 -0
  29. data/plugins/document_search/plugin.rb +8 -0
  30. data/plugins/edit_view/features/line_delimiter.feature +7 -0
  31. data/plugins/edit_view/features/step_definitions/editing_steps.rb +49 -1
  32. data/plugins/edit_view/features/step_definitions/tab_steps.rb +10 -11
  33. data/plugins/edit_view/features/switch_tabs.feature +61 -10
  34. data/plugins/edit_view/lib/edit_view.rb +4 -0
  35. data/plugins/edit_view/lib/edit_view/document.rb +56 -0
  36. data/plugins/edit_view/lib/edit_view/document/command.rb +1 -1
  37. data/plugins/edit_view/lib/edit_view/edit_tab.rb +0 -8
  38. data/plugins/edit_view_swt/lib/edit_view_swt.rb +4 -0
  39. data/plugins/html_view/lib/html_controller.rb +19 -1
  40. data/plugins/html_view/lib/html_view.rb +28 -1
  41. data/plugins/html_view/lib/html_view/html_tab.rb +10 -1
  42. data/plugins/plugin_manager_ui/lib/plugin_manager_ui.rb +3 -1
  43. data/plugins/project/features/open_directory_tree.feature +3 -3
  44. data/plugins/project/lib/project.rb +4 -6
  45. data/plugins/project/lib/project/commands.rb +17 -0
  46. data/plugins/project/lib/project/dir_controller.rb +2 -1
  47. data/plugins/project/lib/project/dir_mirror.rb +8 -0
  48. data/plugins/project/lib/project/manager.rb +2 -0
  49. data/plugins/project/plugin.rb +2 -1
  50. data/plugins/project/vendor/net-sftp/Manifest +55 -0
  51. data/plugins/project/vendor/net-sftp/Rakefile +30 -0
  52. data/plugins/project/vendor/net-sftp/lib/net/sftp.rb +70 -0
  53. data/plugins/project/vendor/net-sftp/lib/net/sftp/constants.rb +187 -0
  54. data/plugins/project/vendor/net-sftp/lib/net/sftp/errors.rb +39 -0
  55. data/plugins/project/vendor/net-sftp/lib/net/sftp/operations/dir.rb +93 -0
  56. data/plugins/project/vendor/net-sftp/lib/net/sftp/operations/download.rb +364 -0
  57. data/plugins/project/vendor/net-sftp/lib/net/sftp/operations/file.rb +176 -0
  58. data/plugins/project/vendor/net-sftp/lib/net/sftp/operations/file_factory.rb +60 -0
  59. data/plugins/project/vendor/net-sftp/lib/net/sftp/operations/upload.rb +387 -0
  60. data/plugins/project/vendor/net-sftp/lib/net/sftp/packet.rb +21 -0
  61. data/plugins/project/vendor/net-sftp/lib/net/sftp/protocol.rb +32 -0
  62. data/plugins/project/vendor/net-sftp/lib/net/sftp/protocol/01/attributes.rb +315 -0
  63. data/plugins/project/vendor/net-sftp/lib/net/sftp/protocol/01/base.rb +268 -0
  64. data/plugins/project/vendor/net-sftp/lib/net/sftp/protocol/01/name.rb +43 -0
  65. data/plugins/project/vendor/net-sftp/lib/net/sftp/protocol/02/base.rb +31 -0
  66. data/plugins/project/vendor/net-sftp/lib/net/sftp/protocol/03/base.rb +35 -0
  67. data/plugins/project/vendor/net-sftp/lib/net/sftp/protocol/04/attributes.rb +152 -0
  68. data/plugins/project/vendor/net-sftp/lib/net/sftp/protocol/04/base.rb +94 -0
  69. data/plugins/project/vendor/net-sftp/lib/net/sftp/protocol/04/name.rb +67 -0
  70. data/plugins/project/vendor/net-sftp/lib/net/sftp/protocol/05/base.rb +66 -0
  71. data/plugins/project/vendor/net-sftp/lib/net/sftp/protocol/06/attributes.rb +107 -0
  72. data/plugins/project/vendor/net-sftp/lib/net/sftp/protocol/06/base.rb +63 -0
  73. data/plugins/project/vendor/net-sftp/lib/net/sftp/protocol/base.rb +50 -0
  74. data/plugins/project/vendor/net-sftp/lib/net/sftp/request.rb +91 -0
  75. data/plugins/project/vendor/net-sftp/lib/net/sftp/response.rb +76 -0
  76. data/plugins/project/vendor/net-sftp/lib/net/sftp/session.rb +951 -0
  77. data/plugins/project/vendor/net-sftp/lib/net/sftp/version.rb +18 -0
  78. data/plugins/project/vendor/net-sftp/setup.rb +1331 -0
  79. data/plugins/project/vendor/net-sftp/test/common.rb +171 -0
  80. data/plugins/project/vendor/net-sftp/test/protocol/01/test_attributes.rb +97 -0
  81. data/plugins/project/vendor/net-sftp/test/protocol/01/test_base.rb +210 -0
  82. data/plugins/project/vendor/net-sftp/test/protocol/01/test_name.rb +27 -0
  83. data/plugins/project/vendor/net-sftp/test/protocol/02/test_base.rb +26 -0
  84. data/plugins/project/vendor/net-sftp/test/protocol/03/test_base.rb +27 -0
  85. data/plugins/project/vendor/net-sftp/test/protocol/04/test_attributes.rb +148 -0
  86. data/plugins/project/vendor/net-sftp/test/protocol/04/test_base.rb +74 -0
  87. data/plugins/project/vendor/net-sftp/test/protocol/04/test_name.rb +53 -0
  88. data/plugins/project/vendor/net-sftp/test/protocol/05/test_base.rb +62 -0
  89. data/plugins/project/vendor/net-sftp/test/protocol/06/test_attributes.rb +124 -0
  90. data/plugins/project/vendor/net-sftp/test/protocol/06/test_base.rb +51 -0
  91. data/plugins/project/vendor/net-sftp/test/protocol/test_base.rb +42 -0
  92. data/plugins/project/vendor/net-sftp/test/test_all.rb +7 -0
  93. data/plugins/project/vendor/net-sftp/test/test_dir.rb +47 -0
  94. data/plugins/project/vendor/net-sftp/test/test_download.rb +252 -0
  95. data/plugins/project/vendor/net-sftp/test/test_file.rb +159 -0
  96. data/plugins/project/vendor/net-sftp/test/test_file_factory.rb +48 -0
  97. data/plugins/project/vendor/net-sftp/test/test_packet.rb +9 -0
  98. data/plugins/project/vendor/net-sftp/test/test_protocol.rb +17 -0
  99. data/plugins/project/vendor/net-sftp/test/test_request.rb +71 -0
  100. data/plugins/project/vendor/net-sftp/test/test_response.rb +53 -0
  101. data/plugins/project/vendor/net-sftp/test/test_session.rb +741 -0
  102. data/plugins/project/vendor/net-sftp/test/test_upload.rb +219 -0
  103. data/plugins/project/vendor/net-ssh/Manifest +110 -0
  104. data/plugins/project/vendor/net-ssh/Rakefile +85 -0
  105. data/plugins/project/vendor/net-ssh/Rudyfile +96 -0
  106. data/plugins/project/vendor/net-ssh/lib/net/ssh.rb +215 -0
  107. data/plugins/project/vendor/net-ssh/lib/net/ssh/authentication/agent.rb +179 -0
  108. data/plugins/project/vendor/net-ssh/lib/net/ssh/authentication/constants.rb +18 -0
  109. data/plugins/project/vendor/net-ssh/lib/net/ssh/authentication/key_manager.rb +193 -0
  110. data/plugins/project/vendor/net-ssh/lib/net/ssh/authentication/methods/abstract.rb +60 -0
  111. data/plugins/project/vendor/net-ssh/lib/net/ssh/authentication/methods/hostbased.rb +71 -0
  112. data/plugins/project/vendor/net-ssh/lib/net/ssh/authentication/methods/keyboard_interactive.rb +66 -0
  113. data/plugins/project/vendor/net-ssh/lib/net/ssh/authentication/methods/password.rb +39 -0
  114. data/plugins/project/vendor/net-ssh/lib/net/ssh/authentication/methods/publickey.rb +92 -0
  115. data/plugins/project/vendor/net-ssh/lib/net/ssh/authentication/pageant.rb +183 -0
  116. data/plugins/project/vendor/net-ssh/lib/net/ssh/authentication/session.rb +134 -0
  117. data/plugins/project/vendor/net-ssh/lib/net/ssh/buffer.rb +340 -0
  118. data/plugins/project/vendor/net-ssh/lib/net/ssh/buffered_io.rb +198 -0
  119. data/plugins/project/vendor/net-ssh/lib/net/ssh/config.rb +202 -0
  120. data/plugins/project/vendor/net-ssh/lib/net/ssh/connection/channel.rb +630 -0
  121. data/plugins/project/vendor/net-ssh/lib/net/ssh/connection/constants.rb +33 -0
  122. data/plugins/project/vendor/net-ssh/lib/net/ssh/connection/session.rb +597 -0
  123. data/plugins/project/vendor/net-ssh/lib/net/ssh/connection/term.rb +178 -0
  124. data/plugins/project/vendor/net-ssh/lib/net/ssh/errors.rb +85 -0
  125. data/plugins/project/vendor/net-ssh/lib/net/ssh/key_factory.rb +102 -0
  126. data/plugins/project/vendor/net-ssh/lib/net/ssh/known_hosts.rb +129 -0
  127. data/plugins/project/vendor/net-ssh/lib/net/ssh/loggable.rb +61 -0
  128. data/plugins/project/vendor/net-ssh/lib/net/ssh/packet.rb +102 -0
  129. data/plugins/project/vendor/net-ssh/lib/net/ssh/prompt.rb +93 -0
  130. data/plugins/project/vendor/net-ssh/lib/net/ssh/proxy/command.rb +75 -0
  131. data/plugins/project/vendor/net-ssh/lib/net/ssh/proxy/errors.rb +14 -0
  132. data/plugins/project/vendor/net-ssh/lib/net/ssh/proxy/http.rb +94 -0
  133. data/plugins/project/vendor/net-ssh/lib/net/ssh/proxy/socks4.rb +70 -0
  134. data/plugins/project/vendor/net-ssh/lib/net/ssh/proxy/socks5.rb +142 -0
  135. data/plugins/project/vendor/net-ssh/lib/net/ssh/ruby_compat.rb +43 -0
  136. data/plugins/project/vendor/net-ssh/lib/net/ssh/service/forward.rb +288 -0
  137. data/plugins/project/vendor/net-ssh/lib/net/ssh/test.rb +89 -0
  138. data/plugins/project/vendor/net-ssh/lib/net/ssh/test/channel.rb +129 -0
  139. data/plugins/project/vendor/net-ssh/lib/net/ssh/test/extensions.rb +152 -0
  140. data/plugins/project/vendor/net-ssh/lib/net/ssh/test/kex.rb +44 -0
  141. data/plugins/project/vendor/net-ssh/lib/net/ssh/test/local_packet.rb +51 -0
  142. data/plugins/project/vendor/net-ssh/lib/net/ssh/test/packet.rb +81 -0
  143. data/plugins/project/vendor/net-ssh/lib/net/ssh/test/remote_packet.rb +38 -0
  144. data/plugins/project/vendor/net-ssh/lib/net/ssh/test/script.rb +157 -0
  145. data/plugins/project/vendor/net-ssh/lib/net/ssh/test/socket.rb +64 -0
  146. data/plugins/project/vendor/net-ssh/lib/net/ssh/transport/algorithms.rb +384 -0
  147. data/plugins/project/vendor/net-ssh/lib/net/ssh/transport/cipher_factory.rb +97 -0
  148. data/plugins/project/vendor/net-ssh/lib/net/ssh/transport/constants.rb +30 -0
  149. data/plugins/project/vendor/net-ssh/lib/net/ssh/transport/hmac.rb +31 -0
  150. data/plugins/project/vendor/net-ssh/lib/net/ssh/transport/hmac/abstract.rb +79 -0
  151. data/plugins/project/vendor/net-ssh/lib/net/ssh/transport/hmac/md5.rb +12 -0
  152. data/plugins/project/vendor/net-ssh/lib/net/ssh/transport/hmac/md5_96.rb +11 -0
  153. data/plugins/project/vendor/net-ssh/lib/net/ssh/transport/hmac/none.rb +15 -0
  154. data/plugins/project/vendor/net-ssh/lib/net/ssh/transport/hmac/sha1.rb +13 -0
  155. data/plugins/project/vendor/net-ssh/lib/net/ssh/transport/hmac/sha1_96.rb +11 -0
  156. data/plugins/project/vendor/net-ssh/lib/net/ssh/transport/identity_cipher.rb +55 -0
  157. data/plugins/project/vendor/net-ssh/lib/net/ssh/transport/kex.rb +13 -0
  158. data/plugins/project/vendor/net-ssh/lib/net/ssh/transport/kex/diffie_hellman_group1_sha1.rb +208 -0
  159. data/plugins/project/vendor/net-ssh/lib/net/ssh/transport/kex/diffie_hellman_group_exchange_sha1.rb +77 -0
  160. data/plugins/project/vendor/net-ssh/lib/net/ssh/transport/openssl.rb +128 -0
  161. data/plugins/project/vendor/net-ssh/lib/net/ssh/transport/packet_stream.rb +235 -0
  162. data/plugins/project/vendor/net-ssh/lib/net/ssh/transport/server_version.rb +71 -0
  163. data/plugins/project/vendor/net-ssh/lib/net/ssh/transport/session.rb +276 -0
  164. data/plugins/project/vendor/net-ssh/lib/net/ssh/transport/state.rb +206 -0
  165. data/plugins/project/vendor/net-ssh/lib/net/ssh/verifiers/lenient.rb +30 -0
  166. data/plugins/project/vendor/net-ssh/lib/net/ssh/verifiers/null.rb +12 -0
  167. data/plugins/project/vendor/net-ssh/lib/net/ssh/verifiers/strict.rb +53 -0
  168. data/plugins/project/vendor/net-ssh/lib/net/ssh/version.rb +62 -0
  169. data/plugins/project/vendor/net-ssh/net-ssh.gemspec +138 -0
  170. data/plugins/project/vendor/net-ssh/setup.rb +1585 -0
  171. data/plugins/project/vendor/net-ssh/support/arcfour_check.rb +20 -0
  172. data/plugins/project/vendor/net-ssh/support/ssh_tunnel_bug.rb +65 -0
  173. data/plugins/project/vendor/net-ssh/test/README.txt +42 -0
  174. data/plugins/project/vendor/net-ssh/test/authentication/methods/common.rb +28 -0
  175. data/plugins/project/vendor/net-ssh/test/authentication/methods/test_abstract.rb +51 -0
  176. data/plugins/project/vendor/net-ssh/test/authentication/methods/test_hostbased.rb +114 -0
  177. data/plugins/project/vendor/net-ssh/test/authentication/methods/test_keyboard_interactive.rb +98 -0
  178. data/plugins/project/vendor/net-ssh/test/authentication/methods/test_password.rb +50 -0
  179. data/plugins/project/vendor/net-ssh/test/authentication/methods/test_publickey.rb +127 -0
  180. data/plugins/project/vendor/net-ssh/test/authentication/test_agent.rb +205 -0
  181. data/plugins/project/vendor/net-ssh/test/authentication/test_key_manager.rb +105 -0
  182. data/plugins/project/vendor/net-ssh/test/authentication/test_session.rb +93 -0
  183. data/plugins/project/vendor/net-ssh/test/common.rb +107 -0
  184. data/plugins/project/vendor/net-ssh/test/configs/eqsign +3 -0
  185. data/plugins/project/vendor/net-ssh/test/configs/exact_match +8 -0
  186. data/plugins/project/vendor/net-ssh/test/configs/host_plus +10 -0
  187. data/plugins/project/vendor/net-ssh/test/configs/multihost +4 -0
  188. data/plugins/project/vendor/net-ssh/test/configs/nohost +19 -0
  189. data/plugins/project/vendor/net-ssh/test/configs/numeric_host +4 -0
  190. data/plugins/project/vendor/net-ssh/test/configs/wild_cards +14 -0
  191. data/plugins/project/vendor/net-ssh/test/connection/test_channel.rb +467 -0
  192. data/plugins/project/vendor/net-ssh/test/connection/test_session.rb +488 -0
  193. data/plugins/project/vendor/net-ssh/test/manual/test_forward.rb +185 -0
  194. data/plugins/project/vendor/net-ssh/test/test_all.rb +9 -0
  195. data/plugins/project/vendor/net-ssh/test/test_buffer.rb +336 -0
  196. data/plugins/project/vendor/net-ssh/test/test_buffered_io.rb +63 -0
  197. data/plugins/project/vendor/net-ssh/test/test_config.rb +117 -0
  198. data/plugins/project/vendor/net-ssh/test/test_key_factory.rb +67 -0
  199. data/plugins/project/vendor/net-ssh/test/transport/hmac/test_md5.rb +39 -0
  200. data/plugins/project/vendor/net-ssh/test/transport/hmac/test_md5_96.rb +25 -0
  201. data/plugins/project/vendor/net-ssh/test/transport/hmac/test_none.rb +34 -0
  202. data/plugins/project/vendor/net-ssh/test/transport/hmac/test_sha1.rb +34 -0
  203. data/plugins/project/vendor/net-ssh/test/transport/hmac/test_sha1_96.rb +25 -0
  204. data/plugins/project/vendor/net-ssh/test/transport/kex/test_diffie_hellman_group1_sha1.rb +146 -0
  205. data/plugins/project/vendor/net-ssh/test/transport/kex/test_diffie_hellman_group_exchange_sha1.rb +92 -0
  206. data/plugins/project/vendor/net-ssh/test/transport/test_algorithms.rb +302 -0
  207. data/plugins/project/vendor/net-ssh/test/transport/test_cipher_factory.rb +213 -0
  208. data/plugins/project/vendor/net-ssh/test/transport/test_hmac.rb +34 -0
  209. data/plugins/project/vendor/net-ssh/test/transport/test_identity_cipher.rb +40 -0
  210. data/plugins/project/vendor/net-ssh/test/transport/test_packet_stream.rb +441 -0
  211. data/plugins/project/vendor/net-ssh/test/transport/test_server_version.rb +78 -0
  212. data/plugins/project/vendor/net-ssh/test/transport/test_session.rb +315 -0
  213. data/plugins/project/vendor/net-ssh/test/transport/test_state.rb +173 -0
  214. data/plugins/redcar/plugin.rb +3 -1
  215. data/plugins/redcar/redcar.rb +108 -121
  216. data/plugins/redcar_debug/lib/redcar_debug.rb +2 -0
  217. data/plugins/runnables/lib/runnables.rb +80 -23
  218. data/plugins/runnables/lib/runnables/command_output_controller.rb +102 -0
  219. data/plugins/runnables/lib/runnables/running_process_checker.rb +34 -0
  220. data/plugins/runnables/{plugin_no_load.rb → plugin.rb} +2 -1
  221. data/plugins/runnables/vendor/session-2.4.0/HISTORY +73 -0
  222. data/plugins/runnables/vendor/session-2.4.0/README +89 -0
  223. data/plugins/runnables/vendor/session-2.4.0/TODO +3 -0
  224. data/plugins/runnables/vendor/session-2.4.0/VERSION +1 -0
  225. data/plugins/runnables/vendor/session-2.4.0/gemspec.rb +22 -0
  226. data/plugins/runnables/vendor/session-2.4.0/install.rb +143 -0
  227. data/plugins/runnables/vendor/session-2.4.0/lib/session.rb +757 -0
  228. data/plugins/runnables/vendor/session-2.4.0/sample/bash.rb +60 -0
  229. data/plugins/runnables/vendor/session-2.4.0/sample/driver.rb +47 -0
  230. data/plugins/runnables/vendor/session-2.4.0/sample/session_idl.rb +25 -0
  231. data/plugins/runnables/vendor/session-2.4.0/sample/session_sh.rb +29 -0
  232. data/plugins/runnables/vendor/session-2.4.0/sample/sh0.rb +23 -0
  233. data/plugins/runnables/vendor/session-2.4.0/sample/stdin.rb +17 -0
  234. data/plugins/runnables/vendor/session-2.4.0/sample/threadtest.rb +42 -0
  235. data/plugins/runnables/vendor/session-2.4.0/session-2.4.0.gem +0 -0
  236. data/plugins/runnables/vendor/session-2.4.0/test/session.rb +227 -0
  237. data/plugins/runnables/views/command_output.html.erb +32 -0
  238. data/plugins/task_manager/lib/task_manager.rb +2 -0
  239. data/plugins/textmate/lib/textmate/plist.rb +1 -1
  240. data/plugins/textmate/lib/textmate/snippet.rb +1 -0
  241. data/plugins/tree/lib/tree/mirror.rb +8 -1
  242. data/plugins/tree_view_swt/lib/tree_view_swt.rb +29 -2
  243. metadata +191 -6
  244. data/plugins/declarations/TODO +0 -3
  245. data/plugins/redcar/spec/redcar/redcar_spec.rb +0 -70
  246. data/plugins/redcar/spec/spec_helper.rb +0 -4
@@ -0,0 +1,142 @@
1
+ require 'socket'
2
+ require 'net/ssh/ruby_compat'
3
+ require 'net/ssh/proxy/errors'
4
+
5
+ module Net
6
+ module SSH
7
+ module Proxy
8
+
9
+ # An implementation of a SOCKS5 proxy. To use it, instantiate it, then
10
+ # pass the instantiated object via the :proxy key to Net::SSH.start:
11
+ #
12
+ # require 'net/ssh/proxy/socks5'
13
+ #
14
+ # proxy = Net::SSH::Proxy::SOCKS5.new('proxy.host', proxy_port,
15
+ # :user => 'user', :password => "password")
16
+ # Net::SSH.start('host', 'user', :proxy => proxy) do |ssh|
17
+ # ...
18
+ # end
19
+ class SOCKS5
20
+ # The SOCKS protocol version used by this class
21
+ VERSION = 5
22
+
23
+ # The SOCKS authentication type for requests without authentication
24
+ METHOD_NO_AUTH = 0
25
+
26
+ # The SOCKS authentication type for requests via username/password
27
+ METHOD_PASSWD = 2
28
+
29
+ # The SOCKS authentication type for when there are no supported
30
+ # authentication methods.
31
+ METHOD_NONE = 0xFF
32
+
33
+ # The SOCKS packet type for requesting a proxy connection.
34
+ CMD_CONNECT = 1
35
+
36
+ # The SOCKS address type for connections via IP address.
37
+ ATYP_IPV4 = 1
38
+
39
+ # The SOCKS address type for connections via domain name.
40
+ ATYP_DOMAIN = 3
41
+
42
+ # The SOCKS response code for a successful operation.
43
+ SUCCESS = 0
44
+
45
+ # The proxy's host name or IP address
46
+ attr_reader :proxy_host
47
+
48
+ # The proxy's port number
49
+ attr_reader :proxy_port
50
+
51
+ # The map of options given at initialization
52
+ attr_reader :options
53
+
54
+ # Create a new proxy connection to the given proxy host and port.
55
+ # Optionally, :user and :password options may be given to
56
+ # identify the username and password with which to authenticate.
57
+ def initialize(proxy_host, proxy_port=1080, options={})
58
+ @proxy_host = proxy_host
59
+ @proxy_port = proxy_port
60
+ @options = options
61
+ end
62
+
63
+ # Return a new socket connected to the given host and port via the
64
+ # proxy that was requested when the socket factory was instantiated.
65
+ def open(host, port)
66
+ socket = TCPSocket.new(proxy_host, proxy_port)
67
+
68
+ methods = [METHOD_NO_AUTH]
69
+ methods << METHOD_PASSWD if options[:user]
70
+
71
+ packet = [VERSION, methods.size, *methods].pack("C*")
72
+ socket.send packet, 0
73
+
74
+ version, method = socket.recv(2).unpack("CC")
75
+ if version != VERSION
76
+ socket.close
77
+ raise Net::SSH::Proxy::Error, "invalid SOCKS version (#{version})"
78
+ end
79
+
80
+ if method == METHOD_NONE
81
+ socket.close
82
+ raise Net::SSH::Proxy::Error, "no supported authorization methods"
83
+ end
84
+
85
+ negotiate_password(socket) if method == METHOD_PASSWD
86
+
87
+ packet = [VERSION, CMD_CONNECT, 0].pack("C*")
88
+
89
+ if host =~ /^(\d+)\.(\d+)\.(\d+)\.(\d+)$/
90
+ packet << [ATYP_IPV4, $1.to_i, $2.to_i, $3.to_i, $4.to_i].pack("C*")
91
+ else
92
+ packet << [ATYP_DOMAIN, host.length, host].pack("CCA*")
93
+ end
94
+
95
+ packet << [port].pack("n")
96
+ socket.send packet, 0
97
+
98
+ version, reply, = socket.recv(2).unpack("C*")
99
+ socket.recv(1)
100
+ address_type = socket.recv(1).getbyte(0)
101
+ case address_type
102
+ when 1
103
+ socket.recv(4) # get four bytes for IPv4 address
104
+ when 3
105
+ len = socket.recv(1).getbyte(0)
106
+ hostname = socket.recv(len)
107
+ when 4
108
+ ipv6addr hostname = socket.recv(16)
109
+ else
110
+ socket.close
111
+ raise ConnectionError, "Illegal response type"
112
+ end
113
+ portnum = socket.recv(2)
114
+
115
+ unless reply == SUCCESS
116
+ socket.close
117
+ raise ConnectError, "#{reply}"
118
+ end
119
+
120
+ return socket
121
+ end
122
+
123
+ private
124
+
125
+ # Simple username/password negotiation with the SOCKS5 server.
126
+ def negotiate_password(socket)
127
+ packet = [0x01, options[:user].length, options[:user],
128
+ options[:password].length, options[:password]].pack("CCA*CA*")
129
+ socket.send packet, 0
130
+
131
+ version, status = socket.recv(2).unpack("CC")
132
+
133
+ if status != SUCCESS
134
+ socket.close
135
+ raise UnauthorizedError, "could not authorize user"
136
+ end
137
+ end
138
+ end
139
+
140
+ end
141
+ end
142
+ end
@@ -0,0 +1,43 @@
1
+ require 'thread'
2
+
3
+ class String
4
+ if RUBY_VERSION < "1.9"
5
+ def getbyte(index)
6
+ self[index]
7
+ end
8
+ end
9
+ end
10
+
11
+ module Net; module SSH
12
+
13
+ # This class contains miscellaneous patches and workarounds
14
+ # for different ruby implementations.
15
+ class Compat
16
+
17
+ # A workaround for an IO#select threading bug in certain versions of MRI 1.8.
18
+ # See: http://net-ssh.lighthouseapp.com/projects/36253/tickets/1-ioselect-threading-bug-in-ruby-18
19
+ # The root issue is documented here: http://redmine.ruby-lang.org/issues/show/1993
20
+ if RUBY_VERSION >= '1.9' || RUBY_PLATFORM == 'java'
21
+ def self.io_select(*params)
22
+ IO.select(*params)
23
+ end
24
+ else
25
+ SELECT_MUTEX = Mutex.new
26
+ def self.io_select(*params)
27
+ # It should be safe to wrap calls in a mutex when the timeout is 0
28
+ # (that is, the call is not supposed to block).
29
+ # We leave blocking calls unprotected to avoid causing deadlocks.
30
+ # This should still catch the main case for Capistrano users.
31
+ if params[3] == 0
32
+ SELECT_MUTEX.synchronize do
33
+ IO.select(*params)
34
+ end
35
+ else
36
+ IO.select(*params)
37
+ end
38
+ end
39
+ end
40
+
41
+ end
42
+
43
+ end; end
@@ -0,0 +1,288 @@
1
+ require 'net/ssh/loggable'
2
+
3
+ module Net; module SSH; module Service
4
+
5
+ # This class implements various port forwarding services for use by
6
+ # Net::SSH clients. The Forward class should never need to be instantiated
7
+ # directly; instead, it should be accessed via the singleton instance
8
+ # returned by Connection::Session#forward:
9
+ #
10
+ # ssh.forward.local(1234, "www.capify.org", 80)
11
+ class Forward
12
+ include Loggable
13
+
14
+ # The underlying connection service instance that the port-forwarding
15
+ # services employ.
16
+ attr_reader :session
17
+
18
+ # A simple class for representing a requested remote forwarded port.
19
+ Remote = Struct.new(:host, :port) #:nodoc:
20
+
21
+ # Instantiates a new Forward service instance atop the given connection
22
+ # service session. This will register new channel open handlers to handle
23
+ # the specialized channels that the SSH port forwarding protocols employ.
24
+ def initialize(session)
25
+ @session = session
26
+ self.logger = session.logger
27
+ @remote_forwarded_ports = {}
28
+ @local_forwarded_ports = {}
29
+ @agent_forwarded = false
30
+
31
+ session.on_open_channel('forwarded-tcpip', &method(:forwarded_tcpip))
32
+ session.on_open_channel('auth-agent', &method(:auth_agent_channel))
33
+ session.on_open_channel('auth-agent@openssh.com', &method(:auth_agent_channel))
34
+ end
35
+
36
+ # Starts listening for connections on the local host, and forwards them
37
+ # to the specified remote host/port via the SSH connection. This method
38
+ # accepts either three or four arguments. When four arguments are given,
39
+ # they are:
40
+ #
41
+ # * the local address to bind to
42
+ # * the local port to listen on
43
+ # * the remote host to forward connections to
44
+ # * the port on the remote host to connect to
45
+ #
46
+ # If three arguments are given, it is as if the local bind address is
47
+ # "127.0.0.1", and the rest are applied as above.
48
+ #
49
+ # ssh.forward.local(1234, "www.capify.org", 80)
50
+ # ssh.forward.local("0.0.0.0", 1234, "www.capify.org", 80)
51
+ def local(*args)
52
+ if args.length < 3 || args.length > 4
53
+ raise ArgumentError, "expected 3 or 4 parameters, got #{args.length}"
54
+ end
55
+
56
+ bind_address = "127.0.0.1"
57
+ bind_address = args.shift if args.first.is_a?(String) && args.first =~ /\D/
58
+
59
+ local_port = args.shift.to_i
60
+ remote_host = args.shift
61
+ remote_port = args.shift.to_i
62
+
63
+ socket = TCPServer.new(bind_address, local_port)
64
+
65
+ @local_forwarded_ports[[local_port, bind_address]] = socket
66
+
67
+ session.listen_to(socket) do |server|
68
+ client = server.accept
69
+ debug { "received connection on #{bind_address}:#{local_port}" }
70
+
71
+ channel = session.open_channel("direct-tcpip", :string, remote_host, :long, remote_port, :string, bind_address, :long, local_port) do |achannel|
72
+ achannel.info { "direct channel established" }
73
+ end
74
+
75
+ prepare_client(client, channel, :local)
76
+
77
+ channel.on_open_failed do |ch, code, description|
78
+ channel.error { "could not establish direct channel: #{description} (#{code})" }
79
+ channel[:socket].close
80
+ end
81
+ end
82
+ end
83
+
84
+ # Terminates an active local forwarded port. If no such forwarded port
85
+ # exists, this will raise an exception. Otherwise, the forwarded connection
86
+ # is terminated.
87
+ #
88
+ # ssh.forward.cancel_local(1234)
89
+ # ssh.forward.cancel_local(1234, "0.0.0.0")
90
+ def cancel_local(port, bind_address="127.0.0.1")
91
+ socket = @local_forwarded_ports.delete([port, bind_address])
92
+ socket.shutdown rescue nil
93
+ socket.close rescue nil
94
+ session.stop_listening_to(socket)
95
+ end
96
+
97
+ # Returns a list of all active locally forwarded ports. The returned value
98
+ # is an array of arrays, where each element is a two-element tuple
99
+ # consisting of the local port and bind address corresponding to the
100
+ # forwarding port.
101
+ def active_locals
102
+ @local_forwarded_ports.keys
103
+ end
104
+
105
+ # Requests that all connections on the given remote-port be forwarded via
106
+ # the local host to the given port/host. The last argument describes the
107
+ # bind address on the remote host, and defaults to 127.0.0.1.
108
+ #
109
+ # This method will return immediately, but the port will not actually be
110
+ # forwarded immediately. If the remote server is not able to begin the
111
+ # listener for this request, an exception will be raised asynchronously.
112
+ #
113
+ # If you want to know when the connection is active, it will show up in the
114
+ # #active_remotes list. If you want to block until the port is active, you
115
+ # could do something like this:
116
+ #
117
+ # ssh.forward.remote(80, "www.google.com", 1234, "0.0.0.0")
118
+ # ssh.loop { !ssh.forward.active_remotes.include?([1234, "0.0.0.0"]) }
119
+ def remote(port, host, remote_port, remote_host="127.0.0.1")
120
+ session.send_global_request("tcpip-forward", :string, remote_host, :long, remote_port) do |success, response|
121
+ if success
122
+ debug { "remote forward from remote #{remote_host}:#{remote_port} to #{host}:#{port} established" }
123
+ @remote_forwarded_ports[[remote_port, remote_host]] = Remote.new(host, port)
124
+ else
125
+ error { "remote forwarding request failed" }
126
+ raise Net::SSH::Exception, "remote forwarding request failed"
127
+ end
128
+ end
129
+ end
130
+
131
+ # an alias, for token backwards compatibility with the 1.x API
132
+ alias :remote_to :remote
133
+
134
+ # Requests that a remote forwarded port be cancelled. The remote forwarded
135
+ # port on the remote host, bound to the given address on the remote host,
136
+ # will be terminated, but not immediately. This method returns immediately
137
+ # after queueing the request to be sent to the server. If for some reason
138
+ # the port cannot be cancelled, an exception will be raised (asynchronously).
139
+ #
140
+ # If you want to know when the connection has been cancelled, it will no
141
+ # longer be present in the #active_remotes list. If you want to block until
142
+ # the port is no longer active, you could do something like this:
143
+ #
144
+ # ssh.forward.cancel_remote(1234, "0.0.0.0")
145
+ # ssh.loop { ssh.forward.active_remotes.include?([1234, "0.0.0.0"]) }
146
+ def cancel_remote(port, host="127.0.0.1")
147
+ session.send_global_request("cancel-tcpip-forward", :string, host, :long, port) do |success, response|
148
+ if success
149
+ @remote_forwarded_ports.delete([port, host])
150
+ else
151
+ raise Net::SSH::Exception, "could not cancel remote forward request on #{host}:#{port}"
152
+ end
153
+ end
154
+ end
155
+
156
+ # Returns all active forwarded remote ports. The returned value is an
157
+ # array of two-element tuples, where the first element is the port on the
158
+ # remote host and the second is the bind address.
159
+ def active_remotes
160
+ @remote_forwarded_ports.keys
161
+ end
162
+
163
+ # Enables SSH agent forwarding on the given channel. The forwarded agent
164
+ # will remain active even after the channel closes--the channel is only
165
+ # used as the transport for enabling the forwarded connection. You should
166
+ # never need to call this directly--it is called automatically the first
167
+ # time a session channel is opened, when the connection was created with
168
+ # :forward_agent set to true:
169
+ #
170
+ # Net::SSH.start("remote.host", "me", :forwrd_agent => true) do |ssh|
171
+ # ssh.open_channel do |ch|
172
+ # # agent will be automatically forwarded by this point
173
+ # end
174
+ # ssh.loop
175
+ # end
176
+ def agent(channel)
177
+ return if @agent_forwarded
178
+ @agent_forwarded = true
179
+
180
+ channel.send_channel_request("auth-agent-req@openssh.com") do |achannel, success|
181
+ if success
182
+ debug { "authentication agent forwarding is active" }
183
+ else
184
+ achannel.send_channel_request("auth-agent-req") do |a2channel, success2|
185
+ if success2
186
+ debug { "authentication agent forwarding is active" }
187
+ else
188
+ error { "could not establish forwarding of authentication agent" }
189
+ end
190
+ end
191
+ end
192
+ end
193
+ end
194
+
195
+ private
196
+
197
+ # Perform setup operations that are common to all forwarded channels.
198
+ # +client+ is a socket, +channel+ is the channel that was just created,
199
+ # and +type+ is an arbitrary string describing the type of the channel.
200
+ def prepare_client(client, channel, type)
201
+ client.extend(Net::SSH::BufferedIo)
202
+ client.extend(Net::SSH::ForwardedBufferedIo)
203
+ client.logger = logger
204
+
205
+ session.listen_to(client)
206
+ channel[:socket] = client
207
+
208
+ channel.on_data do |ch, data|
209
+ debug { "data:#{data.length} on #{type} forwarded channel" }
210
+ ch[:socket].enqueue(data)
211
+ end
212
+
213
+ # Handles server close on the sending side by Miklós Fazekas
214
+ channel.on_eof do |ch|
215
+ debug { "eof #{type} on #{type} forwarded channel" }
216
+ begin
217
+ ch[:socket].send_pending
218
+ ch[:socket].shutdown Socket::SHUT_WR
219
+ rescue IOError => e
220
+ if e.message =~ /closed/ then
221
+ debug { "epipe in on_eof => shallowing exception:#{e}" }
222
+ else
223
+ raise
224
+ end
225
+ rescue Errno::EPIPE => e
226
+ debug { "epipe in on_eof => shallowing exception:#{e}" }
227
+ rescue Errno::ENOTCONN => e
228
+ debug { "enotconn in on_eof => shallowing exception:#{e}" }
229
+ end
230
+ end
231
+
232
+ channel.on_close do |ch|
233
+ debug { "closing #{type} forwarded channel" }
234
+ ch[:socket].close if !client.closed?
235
+ session.stop_listening_to(ch[:socket])
236
+ end
237
+
238
+ channel.on_process do |ch|
239
+ if ch[:socket].closed?
240
+ ch.info { "#{type} forwarded connection closed" }
241
+ ch.close
242
+ elsif ch[:socket].available > 0
243
+ data = ch[:socket].read_available(8192)
244
+ ch.debug { "read #{data.length} bytes from client, sending over #{type} forwarded connection" }
245
+ ch.send_data(data)
246
+ end
247
+ end
248
+ end
249
+
250
+ # The callback used when a new "forwarded-tcpip" channel is requested
251
+ # by the server. This will open a new socket to the host/port specified
252
+ # when the forwarded connection was first requested.
253
+ def forwarded_tcpip(session, channel, packet)
254
+ connected_address = packet.read_string
255
+ connected_port = packet.read_long
256
+ originator_address = packet.read_string
257
+ originator_port = packet.read_long
258
+
259
+ remote = @remote_forwarded_ports[[connected_port, connected_address]]
260
+
261
+ if remote.nil?
262
+ raise Net::SSH::ChannelOpenFailed.new(1, "unknown request from remote forwarded connection on #{connected_address}:#{connected_port}")
263
+ end
264
+
265
+ client = TCPSocket.new(remote.host, remote.port)
266
+ info { "connected #{connected_address}:#{connected_port} originator #{originator_address}:#{originator_port}" }
267
+
268
+ prepare_client(client, channel, :remote)
269
+ rescue SocketError => err
270
+ raise Net::SSH::ChannelOpenFailed.new(2, "could not connect to remote host (#{remote.host}:#{remote.port}): #{err.message}")
271
+ end
272
+
273
+ # The callback used when an auth-agent channel is requested by the server.
274
+ def auth_agent_channel(session, channel, packet)
275
+ info { "opening auth-agent channel" }
276
+ channel[:invisible] = true
277
+
278
+ begin
279
+ agent = Authentication::Agent.connect(logger)
280
+ prepare_client(agent.socket, channel, :agent)
281
+ rescue Exception => e
282
+ error { "attempted to connect to agent but failed: #{e.class.name} (#{e.message})" }
283
+ raise Net::SSH::ChannelOpenFailed.new(2, "could not connect to authentication agent")
284
+ end
285
+ end
286
+ end
287
+
288
+ end; end; end