vagrant-unbundled 2.2.18.0 → 2.2.19.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (176) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +15 -0
  3. data/Gemfile.lock +6 -6
  4. data/contrib/zsh/generate_zsh_completion.rb +2 -2
  5. data/lib/vagrant/errors.rb +8 -0
  6. data/plugins/commands/upload/command.rb +1 -1
  7. data/plugins/guests/atomic/guest.rb +1 -1
  8. data/plugins/guests/coreos/cap/configure_networks.rb +65 -0
  9. data/plugins/guests/darwin/cap/mount_smb_shared_folder.rb +6 -3
  10. data/plugins/guests/suse/cap/halt.rb +5 -1
  11. data/plugins/guests/windows/cap/rsync.rb +5 -1
  12. data/plugins/hosts/darwin/cap/path.rb +4 -0
  13. data/plugins/hosts/darwin/cap/version.rb +23 -0
  14. data/plugins/hosts/darwin/plugin.rb +5 -0
  15. data/plugins/hosts/windows/cap/ssh.rb +1 -1
  16. data/plugins/providers/virtualbox/action/network.rb +39 -2
  17. data/plugins/provisioners/chef/cap/freebsd/chef_installed.rb +5 -3
  18. data/plugins/provisioners/chef/cap/linux/chef_installed.rb +5 -3
  19. data/plugins/provisioners/chef/cap/omnios/chef_installed.rb +7 -5
  20. data/plugins/provisioners/chef/cap/windows/chef_installed.rb +3 -2
  21. data/templates/locales/en.yml +25 -0
  22. data/vagrant.gemspec +1 -1
  23. data/vendor/bundle/ruby/3.0.0/gems/excon-0.89.0/CONTRIBUTING.md +23 -0
  24. data/vendor/bundle/ruby/3.0.0/gems/excon-0.89.0/CONTRIBUTORS.md +140 -0
  25. data/vendor/bundle/ruby/3.0.0/gems/excon-0.89.0/LICENSE.md +20 -0
  26. data/vendor/bundle/ruby/3.0.0/gems/excon-0.89.0/README.md +492 -0
  27. data/vendor/bundle/ruby/3.0.0/gems/excon-0.89.0/data/cacert.pem +3232 -0
  28. data/vendor/bundle/ruby/3.0.0/gems/excon-0.89.0/excon.gemspec +45 -0
  29. data/vendor/bundle/ruby/3.0.0/gems/excon-0.89.0/lib/excon/connection.rb +599 -0
  30. data/vendor/bundle/ruby/3.0.0/gems/excon-0.89.0/lib/excon/constants.rb +172 -0
  31. data/vendor/bundle/ruby/3.0.0/gems/excon-0.89.0/lib/excon/error.rb +229 -0
  32. data/vendor/bundle/ruby/3.0.0/gems/excon-0.89.0/lib/excon/extensions/uri.rb +34 -0
  33. data/vendor/bundle/ruby/3.0.0/gems/excon-0.89.0/lib/excon/headers.rb +85 -0
  34. data/vendor/bundle/ruby/3.0.0/gems/excon-0.89.0/lib/excon/instrumentors/logging_instrumentor.rb +48 -0
  35. data/vendor/bundle/ruby/3.0.0/gems/excon-0.89.0/lib/excon/instrumentors/standard_instrumentor.rb +21 -0
  36. data/vendor/bundle/ruby/3.0.0/gems/excon-0.89.0/lib/excon/middlewares/base.rb +31 -0
  37. data/vendor/bundle/ruby/3.0.0/gems/excon-0.89.0/lib/excon/middlewares/capture_cookies.rb +32 -0
  38. data/vendor/bundle/ruby/3.0.0/gems/excon-0.89.0/lib/excon/middlewares/decompress.rb +44 -0
  39. data/vendor/bundle/ruby/3.0.0/gems/excon-0.89.0/lib/excon/middlewares/escape_path.rb +12 -0
  40. data/vendor/bundle/ruby/3.0.0/gems/excon-0.89.0/lib/excon/middlewares/expects.rb +25 -0
  41. data/vendor/bundle/ruby/3.0.0/gems/excon-0.89.0/lib/excon/middlewares/idempotent.rb +57 -0
  42. data/vendor/bundle/ruby/3.0.0/gems/excon-0.89.0/lib/excon/middlewares/instrumentor.rb +49 -0
  43. data/vendor/bundle/ruby/3.0.0/gems/excon-0.89.0/lib/excon/middlewares/mock.rb +61 -0
  44. data/vendor/bundle/ruby/3.0.0/gems/excon-0.89.0/lib/excon/middlewares/redirect_follower.rb +87 -0
  45. data/vendor/bundle/ruby/3.0.0/gems/excon-0.89.0/lib/excon/middlewares/response_parser.rb +16 -0
  46. data/vendor/bundle/ruby/3.0.0/gems/excon-0.89.0/lib/excon/pretty_printer.rb +39 -0
  47. data/vendor/bundle/ruby/3.0.0/gems/excon-0.89.0/lib/excon/response.rb +234 -0
  48. data/vendor/bundle/ruby/3.0.0/gems/excon-0.89.0/lib/excon/socket.rb +297 -0
  49. data/vendor/bundle/ruby/3.0.0/gems/excon-0.89.0/lib/excon/ssl_socket.rb +194 -0
  50. data/vendor/bundle/ruby/3.0.0/gems/excon-0.89.0/lib/excon/test/plugin/server/exec.rb +26 -0
  51. data/vendor/bundle/ruby/3.0.0/gems/excon-0.89.0/lib/excon/test/plugin/server/puma.rb +23 -0
  52. data/vendor/bundle/ruby/3.0.0/gems/excon-0.89.0/lib/excon/test/plugin/server/unicorn.rb +40 -0
  53. data/vendor/bundle/ruby/3.0.0/gems/excon-0.89.0/lib/excon/test/plugin/server/webrick.rb +26 -0
  54. data/vendor/bundle/ruby/3.0.0/gems/excon-0.89.0/lib/excon/test/server.rb +106 -0
  55. data/vendor/bundle/ruby/3.0.0/gems/excon-0.89.0/lib/excon/unix_socket.rb +42 -0
  56. data/vendor/bundle/ruby/3.0.0/gems/excon-0.89.0/lib/excon/utils.rb +143 -0
  57. data/vendor/bundle/ruby/3.0.0/gems/excon-0.89.0/lib/excon/version.rb +4 -0
  58. data/vendor/bundle/ruby/3.0.0/gems/excon-0.89.0/lib/excon.rb +255 -0
  59. data/vendor/bundle/ruby/3.0.0/gems/i18n-1.8.11/MIT-LICENSE +20 -0
  60. data/vendor/bundle/ruby/3.0.0/gems/i18n-1.8.11/README.md +122 -0
  61. data/vendor/bundle/ruby/3.0.0/gems/i18n-1.8.11/lib/i18n/backend/base.rb +289 -0
  62. data/vendor/bundle/ruby/3.0.0/gems/i18n-1.8.11/lib/i18n/backend/cache.rb +113 -0
  63. data/vendor/bundle/ruby/3.0.0/gems/i18n-1.8.11/lib/i18n/backend/cache_file.rb +36 -0
  64. data/vendor/bundle/ruby/3.0.0/gems/i18n-1.8.11/lib/i18n/backend/cascade.rb +56 -0
  65. data/vendor/bundle/ruby/3.0.0/gems/i18n-1.8.11/lib/i18n/backend/chain.rb +130 -0
  66. data/vendor/bundle/ruby/3.0.0/gems/i18n-1.8.11/lib/i18n/backend/fallbacks.rb +97 -0
  67. data/vendor/bundle/ruby/3.0.0/gems/i18n-1.8.11/lib/i18n/backend/flatten.rb +118 -0
  68. data/vendor/bundle/ruby/3.0.0/gems/i18n-1.8.11/lib/i18n/backend/gettext.rb +85 -0
  69. data/vendor/bundle/ruby/3.0.0/gems/i18n-1.8.11/lib/i18n/backend/interpolation_compiler.rb +123 -0
  70. data/vendor/bundle/ruby/3.0.0/gems/i18n-1.8.11/lib/i18n/backend/key_value.rb +206 -0
  71. data/vendor/bundle/ruby/3.0.0/gems/i18n-1.8.11/lib/i18n/backend/memoize.rb +54 -0
  72. data/vendor/bundle/ruby/3.0.0/gems/i18n-1.8.11/lib/i18n/backend/metadata.rb +71 -0
  73. data/vendor/bundle/ruby/3.0.0/gems/i18n-1.8.11/lib/i18n/backend/pluralization.rb +55 -0
  74. data/vendor/bundle/ruby/3.0.0/gems/i18n-1.8.11/lib/i18n/backend/simple.rb +108 -0
  75. data/vendor/bundle/ruby/3.0.0/gems/i18n-1.8.11/lib/i18n/backend/transliterator.rb +108 -0
  76. data/vendor/bundle/ruby/3.0.0/gems/i18n-1.8.11/lib/i18n/backend.rb +21 -0
  77. data/vendor/bundle/ruby/3.0.0/gems/i18n-1.8.11/lib/i18n/config.rb +165 -0
  78. data/vendor/bundle/ruby/3.0.0/gems/i18n-1.8.11/lib/i18n/core_ext/hash.rb +59 -0
  79. data/vendor/bundle/ruby/3.0.0/gems/i18n-1.8.11/lib/i18n/exceptions.rb +111 -0
  80. data/vendor/bundle/ruby/3.0.0/gems/i18n-1.8.11/lib/i18n/gettext/helpers.rb +75 -0
  81. data/vendor/bundle/ruby/3.0.0/gems/i18n-1.8.11/lib/i18n/gettext/po_parser.rb +329 -0
  82. data/vendor/bundle/ruby/3.0.0/gems/i18n-1.8.11/lib/i18n/gettext.rb +28 -0
  83. data/vendor/bundle/ruby/3.0.0/gems/i18n-1.8.11/lib/i18n/interpolate/ruby.rb +39 -0
  84. data/vendor/bundle/ruby/3.0.0/gems/i18n-1.8.11/lib/i18n/locale/fallbacks.rb +99 -0
  85. data/vendor/bundle/ruby/3.0.0/gems/i18n-1.8.11/lib/i18n/locale/tag/parents.rb +24 -0
  86. data/vendor/bundle/ruby/3.0.0/gems/i18n-1.8.11/lib/i18n/locale/tag/rfc4646.rb +74 -0
  87. data/vendor/bundle/ruby/3.0.0/gems/i18n-1.8.11/lib/i18n/locale/tag/simple.rb +39 -0
  88. data/vendor/bundle/ruby/3.0.0/gems/i18n-1.8.11/lib/i18n/locale/tag.rb +28 -0
  89. data/vendor/bundle/ruby/3.0.0/gems/i18n-1.8.11/lib/i18n/locale.rb +8 -0
  90. data/vendor/bundle/ruby/3.0.0/gems/i18n-1.8.11/lib/i18n/middleware.rb +17 -0
  91. data/vendor/bundle/ruby/3.0.0/gems/i18n-1.8.11/lib/i18n/tests/basics.rb +60 -0
  92. data/vendor/bundle/ruby/3.0.0/gems/i18n-1.8.11/lib/i18n/tests/defaults.rb +52 -0
  93. data/vendor/bundle/ruby/3.0.0/gems/i18n-1.8.11/lib/i18n/tests/interpolation.rb +163 -0
  94. data/vendor/bundle/ruby/3.0.0/gems/i18n-1.8.11/lib/i18n/tests/link.rb +66 -0
  95. data/vendor/bundle/ruby/3.0.0/gems/i18n-1.8.11/lib/i18n/tests/localization/date.rb +117 -0
  96. data/vendor/bundle/ruby/3.0.0/gems/i18n-1.8.11/lib/i18n/tests/localization/date_time.rb +103 -0
  97. data/vendor/bundle/ruby/3.0.0/gems/i18n-1.8.11/lib/i18n/tests/localization/procs.rb +117 -0
  98. data/vendor/bundle/ruby/3.0.0/gems/i18n-1.8.11/lib/i18n/tests/localization/time.rb +103 -0
  99. data/vendor/bundle/ruby/3.0.0/gems/i18n-1.8.11/lib/i18n/tests/localization.rb +19 -0
  100. data/vendor/bundle/ruby/3.0.0/gems/i18n-1.8.11/lib/i18n/tests/lookup.rb +81 -0
  101. data/vendor/bundle/ruby/3.0.0/gems/i18n-1.8.11/lib/i18n/tests/pluralization.rb +35 -0
  102. data/vendor/bundle/ruby/3.0.0/gems/i18n-1.8.11/lib/i18n/tests/procs.rb +60 -0
  103. data/vendor/bundle/ruby/3.0.0/gems/i18n-1.8.11/lib/i18n/tests.rb +14 -0
  104. data/vendor/bundle/ruby/3.0.0/gems/i18n-1.8.11/lib/i18n/version.rb +5 -0
  105. data/vendor/bundle/ruby/3.0.0/gems/i18n-1.8.11/lib/i18n.rb +415 -0
  106. data/vendor/bundle/ruby/3.0.0/gems/mime-types-3.4.1/Code-of-Conduct.md +73 -0
  107. data/vendor/bundle/ruby/3.0.0/gems/mime-types-3.4.1/Contributing.md +132 -0
  108. data/vendor/bundle/ruby/3.0.0/gems/mime-types-3.4.1/History.md +269 -0
  109. data/vendor/bundle/ruby/3.0.0/gems/mime-types-3.4.1/Licence.md +25 -0
  110. data/vendor/bundle/ruby/3.0.0/gems/mime-types-3.4.1/Manifest.txt +31 -0
  111. data/vendor/bundle/ruby/3.0.0/gems/mime-types-3.4.1/README.rdoc +194 -0
  112. data/vendor/bundle/ruby/3.0.0/gems/mime-types-3.4.1/Rakefile +270 -0
  113. data/vendor/bundle/ruby/3.0.0/gems/mime-types-3.4.1/lib/mime/type/columnar.rb +57 -0
  114. data/vendor/bundle/ruby/3.0.0/gems/mime-types-3.4.1/lib/mime/type.rb +634 -0
  115. data/vendor/bundle/ruby/3.0.0/gems/mime-types-3.4.1/lib/mime/types/_columnar.rb +137 -0
  116. data/vendor/bundle/ruby/3.0.0/gems/mime-types-3.4.1/lib/mime/types/cache.rb +58 -0
  117. data/vendor/bundle/ruby/3.0.0/gems/mime-types-3.4.1/lib/mime/types/columnar.rb +3 -0
  118. data/vendor/bundle/ruby/3.0.0/gems/mime-types-3.4.1/lib/mime/types/container.rb +96 -0
  119. data/vendor/bundle/ruby/3.0.0/gems/mime-types-3.4.1/lib/mime/types/deprecations.rb +36 -0
  120. data/vendor/bundle/ruby/3.0.0/gems/mime-types-3.4.1/lib/mime/types/full.rb +19 -0
  121. data/vendor/bundle/ruby/3.0.0/gems/mime-types-3.4.1/lib/mime/types/loader.rb +159 -0
  122. data/vendor/bundle/ruby/3.0.0/gems/mime-types-3.4.1/lib/mime/types/logger.rb +37 -0
  123. data/vendor/bundle/ruby/3.0.0/gems/mime-types-3.4.1/lib/mime/types/registry.rb +90 -0
  124. data/vendor/bundle/ruby/3.0.0/gems/mime-types-3.4.1/lib/mime/types.rb +233 -0
  125. data/vendor/bundle/ruby/3.0.0/gems/mime-types-3.4.1/lib/mime-types.rb +3 -0
  126. data/vendor/bundle/ruby/3.0.0/gems/mime-types-3.4.1/test/bad-fixtures/malformed +9 -0
  127. data/vendor/bundle/ruby/3.0.0/gems/mime-types-3.4.1/test/fixture/json.json +1 -0
  128. data/vendor/bundle/ruby/3.0.0/gems/mime-types-3.4.1/test/fixture/old-data +9 -0
  129. data/vendor/bundle/ruby/3.0.0/gems/mime-types-3.4.1/test/fixture/yaml.yaml +55 -0
  130. data/vendor/bundle/ruby/3.0.0/gems/mime-types-3.4.1/test/minitest_helper.rb +11 -0
  131. data/vendor/bundle/ruby/3.0.0/gems/mime-types-3.4.1/test/test_mime_type.rb +621 -0
  132. data/vendor/bundle/ruby/3.0.0/gems/mime-types-3.4.1/test/test_mime_types.rb +169 -0
  133. data/vendor/bundle/ruby/3.0.0/gems/mime-types-3.4.1/test/test_mime_types_cache.rb +118 -0
  134. data/vendor/bundle/ruby/3.0.0/gems/mime-types-3.4.1/test/test_mime_types_class.rb +159 -0
  135. data/vendor/bundle/ruby/3.0.0/gems/mime-types-3.4.1/test/test_mime_types_lazy.rb +49 -0
  136. data/vendor/bundle/ruby/3.0.0/gems/mime-types-3.4.1/test/test_mime_types_loader.rb +32 -0
  137. data/vendor/bundle/ruby/3.0.0/gems/mime-types-data-3.2021.1115/Code-of-Conduct.md +75 -0
  138. data/vendor/bundle/ruby/3.0.0/gems/mime-types-data-3.2021.1115/Contributing.md +241 -0
  139. data/vendor/bundle/ruby/3.0.0/gems/mime-types-data-3.2021.1115/History.md +494 -0
  140. data/vendor/bundle/ruby/3.0.0/gems/mime-types-data-3.2021.1115/Licence.md +24 -0
  141. data/vendor/bundle/ruby/3.0.0/gems/mime-types-data-3.2021.1115/Manifest.txt +34 -0
  142. data/vendor/bundle/ruby/3.0.0/gems/mime-types-data-3.2021.1115/README.md +73 -0
  143. data/vendor/bundle/ruby/3.0.0/gems/mime-types-data-3.2021.1115/Rakefile +155 -0
  144. data/vendor/bundle/ruby/3.0.0/gems/mime-types-data-3.2021.1115/data/content_type_mime.db +878 -0
  145. data/vendor/bundle/ruby/3.0.0/gems/mime-types-data-3.2021.1115/data/ext_mime.db +1198 -0
  146. data/vendor/bundle/ruby/3.0.0/gems/mime-types-data-3.2021.1115/data/mime-types.json +1 -0
  147. data/vendor/bundle/ruby/3.0.0/gems/mime-types-data-3.2021.1115/data/mime.content_type.column +2376 -0
  148. data/vendor/bundle/ruby/3.0.0/gems/mime-types-data-3.2021.1115/data/mime.docs.column +2376 -0
  149. data/vendor/bundle/ruby/3.0.0/gems/mime-types-data-3.2021.1115/data/mime.encoding.column +2376 -0
  150. data/vendor/bundle/ruby/3.0.0/gems/mime-types-data-3.2021.1115/data/mime.flags.column +2376 -0
  151. data/vendor/bundle/ruby/3.0.0/gems/mime-types-data-3.2021.1115/data/mime.friendly.column +2376 -0
  152. data/vendor/bundle/ruby/3.0.0/gems/mime-types-data-3.2021.1115/data/mime.pext.column +2376 -0
  153. data/vendor/bundle/ruby/3.0.0/gems/mime-types-data-3.2021.1115/data/mime.use_instead.column +2376 -0
  154. data/vendor/bundle/ruby/3.0.0/gems/mime-types-data-3.2021.1115/data/mime.xrefs.column +2376 -0
  155. data/vendor/bundle/ruby/3.0.0/gems/mime-types-data-3.2021.1115/lib/mime/types/data.rb +21 -0
  156. data/vendor/bundle/ruby/3.0.0/gems/mime-types-data-3.2021.1115/lib/mime-types-data.rb +3 -0
  157. data/vendor/bundle/ruby/3.0.0/gems/mime-types-data-3.2021.1115/types/application.yaml +17254 -0
  158. data/vendor/bundle/ruby/3.0.0/gems/mime-types-data-3.2021.1115/types/audio.yaml +1716 -0
  159. data/vendor/bundle/ruby/3.0.0/gems/mime-types-data-3.2021.1115/types/chemical.yaml +71 -0
  160. data/vendor/bundle/ruby/3.0.0/gems/mime-types-data-3.2021.1115/types/conference.yaml +9 -0
  161. data/vendor/bundle/ruby/3.0.0/gems/mime-types-data-3.2021.1115/types/drawing.yaml +15 -0
  162. data/vendor/bundle/ruby/3.0.0/gems/mime-types-data-3.2021.1115/types/font.yaml +65 -0
  163. data/vendor/bundle/ruby/3.0.0/gems/mime-types-data-3.2021.1115/types/image.yaml +1251 -0
  164. data/vendor/bundle/ruby/3.0.0/gems/mime-types-data-3.2021.1115/types/message.yaml +200 -0
  165. data/vendor/bundle/ruby/3.0.0/gems/mime-types-data-3.2021.1115/types/model.yaml +390 -0
  166. data/vendor/bundle/ruby/3.0.0/gems/mime-types-data-3.2021.1115/types/multipart.yaml +179 -0
  167. data/vendor/bundle/ruby/3.0.0/gems/mime-types-data-3.2021.1115/types/provisional-standard-types.yaml +129 -0
  168. data/vendor/bundle/ruby/3.0.0/gems/mime-types-data-3.2021.1115/types/text.yaml +1166 -0
  169. data/vendor/bundle/ruby/3.0.0/gems/mime-types-data-3.2021.1115/types/video.yaml +1121 -0
  170. data/vendor/bundle/ruby/3.0.0/gems/mime-types-data-3.2021.1115/types/world.yaml +8 -0
  171. data/vendor/bundle/ruby/3.0.0/specifications/excon-0.89.0.gemspec +58 -0
  172. data/vendor/bundle/ruby/3.0.0/specifications/i18n-1.8.11.gemspec +32 -0
  173. data/vendor/bundle/ruby/3.0.0/specifications/mime-types-3.4.1.gemspec +63 -0
  174. data/vendor/bundle/ruby/3.0.0/specifications/mime-types-data-3.2021.1115.gemspec +54 -0
  175. data/version.txt +1 -1
  176. metadata +157 -4
@@ -0,0 +1,297 @@
1
+ # frozen_string_literal: true
2
+ require 'resolv'
3
+
4
+ module Excon
5
+ class Socket
6
+ include Utils
7
+
8
+ extend Forwardable
9
+
10
+ attr_accessor :data
11
+
12
+ # read/write drawn from https://github.com/ruby-amqp/bunny/commit/75d9dd79551b31a5dd3d1254c537bad471f108cf
13
+ CONNECT_RETRY_EXCEPTION_CLASSES = if defined?(IO::EINPROGRESSWaitWritable) # Ruby >= 2.1
14
+ [Errno::EINPROGRESS, IO::EINPROGRESSWaitWritable]
15
+ else # Ruby <= 2.0
16
+ [Errno::EINPROGRESS]
17
+ end
18
+ READ_RETRY_EXCEPTION_CLASSES = if defined?(IO::EAGAINWaitReadable) # Ruby >= 2.1
19
+ [Errno::EAGAIN, Errno::EWOULDBLOCK, IO::WaitReadable, IO::EAGAINWaitReadable, IO::EWOULDBLOCKWaitReadable]
20
+ else # Ruby <= 2.0
21
+ [Errno::EAGAIN, Errno::EWOULDBLOCK, IO::WaitReadable]
22
+ end
23
+ WRITE_RETRY_EXCEPTION_CLASSES = if defined?(IO::EAGAINWaitWritable) # Ruby >= 2.1
24
+ [Errno::EAGAIN, Errno::EWOULDBLOCK, IO::WaitWritable, IO::EAGAINWaitWritable, IO::EWOULDBLOCKWaitWritable]
25
+ else # Ruby <= 2.0
26
+ [Errno::EAGAIN, Errno::EWOULDBLOCK, IO::WaitWritable]
27
+ end
28
+
29
+ def params
30
+ Excon.display_warning('Excon::Socket#params is deprecated use Excon::Socket#data instead.')
31
+ @data
32
+ end
33
+
34
+ def params=(new_params)
35
+ Excon.display_warning('Excon::Socket#params= is deprecated use Excon::Socket#data= instead.')
36
+ @data = new_params
37
+ end
38
+
39
+ attr_reader :remote_ip
40
+
41
+ def_delegators(:@socket, :close)
42
+
43
+ def initialize(data = {})
44
+ @data = data
45
+ @nonblock = data[:nonblock]
46
+ @port ||= @data[:port] || 80
47
+ @read_buffer = String.new
48
+ @eof = false
49
+ connect
50
+ end
51
+
52
+ def read(max_length = nil)
53
+ if @eof
54
+ return max_length ? nil : ''
55
+ elsif @nonblock
56
+ read_nonblock(max_length)
57
+ else
58
+ read_block(max_length)
59
+ end
60
+ end
61
+
62
+ def readline
63
+ return legacy_readline if RUBY_VERSION.to_f <= 1.8_7
64
+ buffer = String.new
65
+ buffer << (read_nonblock(1) || raise(EOFError)) while buffer[-1] != "\n"
66
+ buffer
67
+ end
68
+
69
+ def legacy_readline
70
+ begin
71
+ Timeout.timeout(@data[:read_timeout]) do
72
+ @socket.readline
73
+ end
74
+ rescue Timeout::Error
75
+ raise Excon::Errors::Timeout.new('read timeout reached')
76
+ end
77
+ end
78
+
79
+ def write(data)
80
+ if @nonblock
81
+ write_nonblock(data)
82
+ else
83
+ write_block(data)
84
+ end
85
+ end
86
+
87
+ def local_address
88
+ unpacked_sockaddr[1]
89
+ end
90
+
91
+ def local_port
92
+ unpacked_sockaddr[0]
93
+ end
94
+
95
+ private
96
+
97
+ def connect
98
+ @socket = nil
99
+ exception = nil
100
+ hostname = @data[:hostname]
101
+ port = @port
102
+ family = @data[:family]
103
+
104
+ if @data[:proxy]
105
+ hostname = @data[:proxy][:hostname]
106
+ port = @data[:proxy][:port]
107
+ family = @data[:proxy][:family]
108
+ end
109
+
110
+ Resolv.each_address(hostname) do |ip|
111
+ # already succeeded on previous addrinfo
112
+ if @socket
113
+ break
114
+ end
115
+
116
+ @remote_ip = ip
117
+ @data[:remote_ip] = ip
118
+
119
+ # nonblocking connect
120
+ begin
121
+ sockaddr = ::Socket.sockaddr_in(port, ip)
122
+ addrinfo = Addrinfo.getaddrinfo(ip, port, family, :STREAM).first
123
+ socket = ::Socket.new(addrinfo.pfamily, addrinfo.socktype, addrinfo.protocol)
124
+
125
+ if @data[:reuseaddr]
126
+ socket.setsockopt(::Socket::Constants::SOL_SOCKET, ::Socket::Constants::SO_REUSEADDR, true)
127
+ if defined?(::Socket::Constants::SO_REUSEPORT)
128
+ socket.setsockopt(::Socket::Constants::SOL_SOCKET, ::Socket::Constants::SO_REUSEPORT, true)
129
+ end
130
+ end
131
+
132
+ if @nonblock
133
+ socket.connect_nonblock(sockaddr)
134
+ else
135
+ socket.connect(sockaddr)
136
+ end
137
+ @socket = socket
138
+ rescue *CONNECT_RETRY_EXCEPTION_CLASSES
139
+ select_with_timeout(socket, :connect_write)
140
+ begin
141
+ socket.connect_nonblock(sockaddr)
142
+ @socket = socket
143
+ rescue Errno::EISCONN
144
+ @socket = socket
145
+ rescue SystemCallError => exception
146
+ socket.close rescue nil
147
+ end
148
+ rescue SystemCallError => exception
149
+ socket.close rescue nil if socket
150
+ end
151
+ end
152
+
153
+ exception ||= Resolv::ResolvError.new("no address for #{hostname}")
154
+
155
+ # this will be our last encountered exception
156
+ fail exception unless @socket
157
+
158
+ if @data[:tcp_nodelay]
159
+ @socket.setsockopt(::Socket::IPPROTO_TCP,
160
+ ::Socket::TCP_NODELAY,
161
+ true)
162
+ end
163
+
164
+ if @data[:keepalive]
165
+ if [:SOL_SOCKET, :SO_KEEPALIVE, :SOL_TCP, :TCP_KEEPIDLE, :TCP_KEEPINTVL, :TCP_KEEPCNT].all?{|c| ::Socket.const_defined? c}
166
+ @socket.setsockopt(::Socket::SOL_SOCKET, ::Socket::SO_KEEPALIVE, true)
167
+ @socket.setsockopt(::Socket::SOL_TCP, ::Socket::TCP_KEEPIDLE, @data[:keepalive][:time])
168
+ @socket.setsockopt(::Socket::SOL_TCP, ::Socket::TCP_KEEPINTVL, @data[:keepalive][:intvl])
169
+ @socket.setsockopt(::Socket::SOL_TCP, ::Socket::TCP_KEEPCNT, @data[:keepalive][:probes])
170
+ else
171
+ Excon.display_warning('Excon::Socket keepalive was set, but is not supported by Ruby version.')
172
+ end
173
+ end
174
+ end
175
+
176
+ def read_nonblock(max_length)
177
+ begin
178
+ if max_length
179
+ until @read_buffer.length >= max_length
180
+ @read_buffer << @socket.read_nonblock(max_length - @read_buffer.length)
181
+ end
182
+ else
183
+ loop do
184
+ @read_buffer << @socket.read_nonblock(@data[:chunk_size])
185
+ end
186
+ end
187
+ rescue OpenSSL::SSL::SSLError => error
188
+ if error.message == 'read would block'
189
+ select_with_timeout(@socket, :read) && retry
190
+ else
191
+ raise(error)
192
+ end
193
+ rescue *READ_RETRY_EXCEPTION_CLASSES
194
+ if @read_buffer.empty?
195
+ # if we didn't read anything, try again...
196
+ select_with_timeout(@socket, :read) && retry
197
+ end
198
+ rescue EOFError
199
+ @eof = true
200
+ end
201
+
202
+ if max_length
203
+ if @read_buffer.empty?
204
+ nil # EOF met at beginning
205
+ else
206
+ @read_buffer.slice!(0, max_length)
207
+ end
208
+ else
209
+ # read until EOFError, so return everything
210
+ @read_buffer.slice!(0, @read_buffer.length)
211
+ end
212
+ end
213
+
214
+ def read_block(max_length)
215
+ @socket.read(max_length)
216
+ rescue OpenSSL::SSL::SSLError => error
217
+ if error.message == 'read would block'
218
+ select_with_timeout(@socket, :read) && retry
219
+ else
220
+ raise(error)
221
+ end
222
+ rescue *READ_RETRY_EXCEPTION_CLASSES
223
+ if @read_buffer.empty?
224
+ select_with_timeout(@socket, :read) && retry
225
+ end
226
+ rescue EOFError
227
+ @eof = true
228
+ end
229
+
230
+ def write_nonblock(data)
231
+ data = binary_encode(data)
232
+ loop do
233
+ written = nil
234
+ begin
235
+ # I wish that this API accepted a start position, then we wouldn't
236
+ # have to slice data when there is a short write.
237
+ written = @socket.write_nonblock(data)
238
+ rescue Errno::EFAULT => error
239
+ if OpenSSL.const_defined?(:OPENSSL_LIBRARY_VERSION) && OpenSSL::OPENSSL_LIBRARY_VERSION.split(' ')[1] == '1.0.2'
240
+ msg = "The version of OpenSSL this ruby is built against (1.0.2) has a vulnerability
241
+ which causes a fault. For more, see https://github.com/excon/excon/issues/467"
242
+ raise SecurityError.new(msg)
243
+ else
244
+ raise error
245
+ end
246
+ rescue OpenSSL::SSL::SSLError, *WRITE_RETRY_EXCEPTION_CLASSES => error
247
+ if error.is_a?(OpenSSL::SSL::SSLError) && error.message != 'write would block'
248
+ raise error
249
+ else
250
+ select_with_timeout(@socket, :write) && retry
251
+ end
252
+ end
253
+
254
+ # Fast, common case.
255
+ break if written == data.size
256
+
257
+ # This takes advantage of the fact that most ruby implementations
258
+ # have Copy-On-Write strings. Thusly why requesting a subrange
259
+ # of data, we actually don't copy data because the new string
260
+ # simply references a subrange of the original.
261
+ data = data[written, data.size]
262
+ end
263
+ end
264
+
265
+ def write_block(data)
266
+ @socket.write(data)
267
+ rescue OpenSSL::SSL::SSLError, *WRITE_RETRY_EXCEPTION_CLASSES => error
268
+ if error.is_a?(OpenSSL::SSL::SSLError) && error.message != 'write would block'
269
+ raise error
270
+ else
271
+ select_with_timeout(@socket, :write) && retry
272
+ end
273
+ end
274
+
275
+ def select_with_timeout(socket, type)
276
+ select = case type
277
+ when :connect_read
278
+ IO.select([socket], nil, nil, @data[:connect_timeout])
279
+ when :connect_write
280
+ IO.select(nil, [socket], nil, @data[:connect_timeout])
281
+ when :read
282
+ IO.select([socket], nil, nil, @data[:read_timeout])
283
+ when :write
284
+ IO.select(nil, [socket], nil, @data[:write_timeout])
285
+ end
286
+ select || raise(Excon::Errors::Timeout.new("#{type} timeout reached"))
287
+ end
288
+
289
+ def unpacked_sockaddr
290
+ @unpacked_sockaddr ||= ::Socket.unpack_sockaddr_in(@socket.to_io.getsockname)
291
+ rescue ArgumentError => e
292
+ unless e.message == 'not an AF_INET/AF_INET6 sockaddr'
293
+ raise
294
+ end
295
+ end
296
+ end
297
+ end
@@ -0,0 +1,194 @@
1
+ # frozen_string_literal: true
2
+ module Excon
3
+ class SSLSocket < Socket
4
+ HAVE_NONBLOCK = [:connect_nonblock, :read_nonblock, :write_nonblock].all? do |m|
5
+ OpenSSL::SSL::SSLSocket.public_method_defined?(m)
6
+ end
7
+
8
+ def initialize(data = {})
9
+ @port = data[:port] || 443
10
+ super
11
+
12
+ # create ssl context
13
+ ssl_context = OpenSSL::SSL::SSLContext.new
14
+
15
+ # set the security level before setting other parameters affected by it
16
+ if @data[:ssl_security_level]
17
+ ssl_context.security_level = @data[:ssl_security_level]
18
+ end
19
+
20
+ # disable less secure options, when supported
21
+ ssl_context_options = OpenSSL::SSL::SSLContext::DEFAULT_PARAMS[:options]
22
+ if defined?(OpenSSL::SSL::OP_DONT_INSERT_EMPTY_FRAGMENTS)
23
+ ssl_context_options &= ~OpenSSL::SSL::OP_DONT_INSERT_EMPTY_FRAGMENTS
24
+ end
25
+
26
+ if defined?(OpenSSL::SSL::OP_NO_COMPRESSION)
27
+ ssl_context_options |= OpenSSL::SSL::OP_NO_COMPRESSION
28
+ end
29
+ ssl_context.options = ssl_context_options
30
+
31
+ ssl_context.ciphers = @data[:ciphers]
32
+ if @data[:ssl_version]
33
+ ssl_context.ssl_version = @data[:ssl_version]
34
+ end
35
+ if @data[:ssl_min_version]
36
+ ssl_context.min_version = @data[:ssl_min_version]
37
+ end
38
+ if @data[:ssl_max_version]
39
+ ssl_context.max_version = @data[:ssl_max_version]
40
+ end
41
+
42
+
43
+ if @data[:ssl_verify_peer]
44
+ # turn verification on
45
+ ssl_context.verify_mode = OpenSSL::SSL::VERIFY_PEER
46
+
47
+ if (ca_file = @data[:ssl_ca_file] || ENV['SSL_CERT_FILE'])
48
+ ssl_context.ca_file = ca_file
49
+ end
50
+ if (ca_path = @data[:ssl_ca_path] || ENV['SSL_CERT_DIR'])
51
+ ssl_context.ca_path = ca_path
52
+ end
53
+ if (cert_store = @data[:ssl_cert_store])
54
+ ssl_context.cert_store = cert_store
55
+ end
56
+
57
+ # no defaults, fallback to bundled
58
+ unless ca_file || ca_path || cert_store
59
+ ssl_context.cert_store = OpenSSL::X509::Store.new
60
+ ssl_context.cert_store.set_default_paths
61
+
62
+ # workaround issue #257 (JRUBY-6970)
63
+ ca_file = DEFAULT_CA_FILE
64
+ ca_file = ca_file.gsub(/^jar:/, '') if ca_file =~ /^jar:file:\//
65
+
66
+ begin
67
+ ssl_context.cert_store.add_file(ca_file)
68
+ rescue
69
+ Excon.display_warning("Excon unable to add file to cert store, ignoring: #{ca_file}\n[#{$!.class}] #{$!.message}")
70
+ end
71
+ end
72
+
73
+ if (verify_callback = @data[:ssl_verify_callback])
74
+ ssl_context.verify_callback = verify_callback
75
+ end
76
+ else
77
+ # turn verification off
78
+ ssl_context.verify_mode = OpenSSL::SSL::VERIFY_NONE
79
+ end
80
+
81
+ # Verify certificate hostname if supported (ruby >= 2.4.0)
82
+ ssl_context.verify_hostname = @data[:ssl_verify_hostname] if ssl_context.respond_to?(:verify_hostname=)
83
+
84
+ if client_cert_data && client_key_data
85
+ ssl_context.cert = OpenSSL::X509::Certificate.new client_cert_data
86
+ if OpenSSL::PKey.respond_to? :read
87
+ ssl_context.key = OpenSSL::PKey.read(client_key_data, client_key_pass)
88
+ else
89
+ ssl_context.key = OpenSSL::PKey::RSA.new(client_key_data, client_key_pass)
90
+ end
91
+ elsif @data.key?(:certificate) && @data.key?(:private_key)
92
+ ssl_context.cert = OpenSSL::X509::Certificate.new(@data[:certificate])
93
+ if OpenSSL::PKey.respond_to? :read
94
+ ssl_context.key = OpenSSL::PKey.read(@data[:private_key], client_key_pass)
95
+ else
96
+ ssl_context.key = OpenSSL::PKey::RSA.new(@data[:private_key], client_key_pass)
97
+ end
98
+ end
99
+
100
+ if @data[:proxy]
101
+ request = "CONNECT #{@data[:host]}#{port_string(@data.merge(:omit_default_port => false))}#{Excon::HTTP_1_1}" +
102
+ "Host: #{@data[:host]}#{port_string(@data)}#{Excon::CR_NL}"
103
+
104
+ if @data[:proxy].has_key?(:user) || @data[:proxy].has_key?(:password)
105
+ user, pass = Utils.unescape_form(@data[:proxy][:user].to_s), Utils.unescape_form(@data[:proxy][:password].to_s)
106
+ auth = ["#{user}:#{pass}"].pack('m').delete(Excon::CR_NL)
107
+ request += "Proxy-Authorization: Basic #{auth}#{Excon::CR_NL}"
108
+ end
109
+
110
+ request += "Proxy-Connection: Keep-Alive#{Excon::CR_NL}"
111
+
112
+ if @data[:ssl_proxy_headers]
113
+ request << Utils.headers_hash_to_s(@data[:ssl_proxy_headers])
114
+ end
115
+
116
+ request += Excon::CR_NL
117
+
118
+ # write out the proxy setup request
119
+ @socket.write(request)
120
+
121
+ # eat the proxy's connection response
122
+ response = Excon::Response.parse(self, :expects => 200, :method => 'CONNECT')
123
+ if response[:response][:status] != 200
124
+ raise(Excon::Errors::ProxyConnectionError.new("proxy connection could not be established", request, response))
125
+ end
126
+ end
127
+
128
+ # convert Socket to OpenSSL::SSL::SSLSocket
129
+ @socket = OpenSSL::SSL::SSLSocket.new(@socket, ssl_context)
130
+ @socket.sync_close = true
131
+
132
+ # Server Name Indication (SNI) RFC 3546
133
+ if @socket.respond_to?(:hostname=)
134
+ @socket.hostname = @data[:host]
135
+ end
136
+
137
+ begin
138
+ if @nonblock
139
+ begin
140
+ @socket.connect_nonblock
141
+ rescue Errno::EAGAIN, Errno::EWOULDBLOCK, IO::WaitReadable
142
+ select_with_timeout(@socket, :connect_read) && retry
143
+ rescue IO::WaitWritable
144
+ select_with_timeout(@socket, :connect_write) && retry
145
+ end
146
+ else
147
+ @socket.connect
148
+ end
149
+ rescue Errno::ETIMEDOUT, Timeout::Error
150
+ raise Excon::Errors::Timeout.new('connect timeout reached')
151
+ end
152
+
153
+ # verify connection
154
+ if @data[:ssl_verify_peer]
155
+ @socket.post_connection_check(@data[:ssl_verify_peer_host] || @data[:host])
156
+ end
157
+ end
158
+
159
+ private
160
+
161
+ def client_cert_data
162
+ @client_cert_data ||= if (ccd = @data[:client_cert_data])
163
+ ccd
164
+ elsif (path = @data[:client_cert])
165
+ File.read path
166
+ elsif (path = @data[:certificate_path])
167
+ warn ":certificate_path is no longer supported and will be deprecated. Please use :client_cert or :client_cert_data"
168
+ File.read path
169
+ end
170
+ end
171
+
172
+ def connect
173
+ # backwards compatability for things lacking nonblock
174
+ @nonblock = HAVE_NONBLOCK && @nonblock
175
+ super
176
+ end
177
+
178
+ def client_key_data
179
+ @client_key_data ||= if (ckd = @data[:client_key_data])
180
+ ckd
181
+ elsif (path = @data[:client_key])
182
+ File.read path
183
+ elsif (path = @data[:private_key_path])
184
+ warn ":private_key_path is no longer supported and will be deprecated. Please use :client_key or :client_key_data"
185
+ File.read path
186
+ end
187
+ end
188
+
189
+ def client_key_pass
190
+ @data[:client_key_pass] || @data[:private_key_pass]
191
+ end
192
+
193
+ end
194
+ end
@@ -0,0 +1,26 @@
1
+ module Excon
2
+ module Test
3
+ module Plugin
4
+ module Server
5
+ module Exec
6
+ def start(app_str = app)
7
+ open_process(app_str)
8
+ process_stderr = ""
9
+ line = ''
10
+ until line =~ /\Aready\Z/
11
+ line = error.gets
12
+ raise process_stderr if line.nil?
13
+ process_stderr << line
14
+ fatal_time = elapsed_time > timeout
15
+ if fatal_time
16
+ msg = "executable #{app_str} has taken too long to start"
17
+ raise msg
18
+ end
19
+ end
20
+ true
21
+ end
22
+ end
23
+ end
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,23 @@
1
+ module Excon
2
+ module Test
3
+ module Plugin
4
+ module Server
5
+ module Puma
6
+ def start(app_str = app, bind_uri = bind)
7
+ open_process(RbConfig.ruby, '-S', 'puma', '-b', bind_uri.to_s, app_str)
8
+ process_stderr = ""
9
+ line = ''
10
+ until line =~ /Use Ctrl-C to stop/
11
+ line = read.gets
12
+ raise process_stderr if line.nil?
13
+ process_stderr << line
14
+ fatal_time = elapsed_time > timeout
15
+ raise 'puma server has taken too long to start' if fatal_time
16
+ end
17
+ true
18
+ end
19
+ end
20
+ end
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,40 @@
1
+ module Excon
2
+ module Test
3
+ module Plugin
4
+ module Server
5
+ module Unicorn
6
+ def start(app_str = app, bind_uri = bind)
7
+ bind_uri = URI.parse(bind_uri) unless bind_uri.is_a? URI::Generic
8
+ is_unix_socket = (bind_uri.scheme == "unix")
9
+ if is_unix_socket
10
+ bind_str = bind_uri.to_s
11
+ else
12
+ host = bind_uri.host.gsub(/[\[\]]/, '')
13
+ bind_str = "#{host}:#{bind_uri.port}"
14
+ end
15
+ args = [
16
+ RbConfig.ruby,
17
+ '-S',
18
+ 'unicorn',
19
+ '--no-default-middleware',
20
+ '-l',
21
+ bind_str,
22
+ app_str
23
+ ]
24
+ open_process(*args)
25
+ process_stderr = ''
26
+ line = ''
27
+ until line =~ /worker\=0 ready/
28
+ line = error.gets
29
+ raise process_stderr if line.nil?
30
+ process_stderr << line
31
+ fatal_time = elapsed_time > timeout
32
+ raise 'unicorn server has taken too long to start' if fatal_time
33
+ end
34
+ true
35
+ end
36
+ end
37
+ end
38
+ end
39
+ end
40
+ end
@@ -0,0 +1,26 @@
1
+ module Excon
2
+ module Test
3
+ module Plugin
4
+ module Server
5
+ module Webrick
6
+ def start(app_str = app, bind_uri = bind)
7
+ bind_uri = URI.parse(bind_uri) unless bind_uri.is_a? URI::Generic
8
+ host = bind_uri.host.gsub(/[\[\]]/, '')
9
+ port = bind_uri.port.to_s
10
+ open_process(RbConfig.ruby, '-S', 'rackup', '-s', 'webrick', '--host', host, '--port', port, app_str)
11
+ process_stderr = ""
12
+ line = ''
13
+ until line =~ /HTTPServer#start/
14
+ line = error.gets
15
+ raise process_stderr if line.nil?
16
+ process_stderr << line
17
+ fatal_time = elapsed_time > timeout
18
+ raise 'webrick server has taken too long to start' if fatal_time
19
+ end
20
+ true
21
+ end
22
+ end
23
+ end
24
+ end
25
+ end
26
+ end