ftw 0.0.42 → 0.0.43

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 33fab2173e9d5a55d01c5be096be99b4a6e4c9b6
4
- data.tar.gz: 2d5d057c20fc4bec7705143ba4010d9162623d1f
3
+ metadata.gz: e554187a6f1f99f8aff5f44525e78e22e8d26650
4
+ data.tar.gz: 3470b1876552ed207ee28f063ed88ff5baea514e
5
5
  SHA512:
6
- metadata.gz: 1cd81a35b4289d5c5f3c7aa566d4de5e4192ad2ac8343d7c74d3a13fc695ad6c719254395375448262da6ee13697ce2a066f63eaab32c069e185a4b7d8ee2c9c
7
- data.tar.gz: 437f27db19fd9616dcec6db39d97f02e336ab0d5edeaebff14e785a70d85988a41a8a72bbd2075ccbbd2f4ce9532321277b49730a49894bd1e87681ca5c6eedd
6
+ metadata.gz: 368bd3157428d274bde3ba04c1ca670002ff1993cbd03292f71b2706433a24c63ce8d9fd7a95d45c67e282a1864526608d7237f79125171da78560f2953a0b8c
7
+ data.tar.gz: 8ab90dfa46381cd5a6cf4d107d4892dc179ff2c27c8281508f6181bed91688c1d4234d149c596a1dae16400a60efaa4da2b790ad72f0916640f3a3ff93ce56b7
@@ -2,6 +2,7 @@ require "cabin" # rubygem "cabin"
2
2
  require "ftw/dns"
3
3
  require "ftw/poolable"
4
4
  require "ftw/namespace"
5
+ require "ftw/agent"
5
6
  require "socket"
6
7
  require "timeout" # ruby stdlib, just for the Timeout exception.
7
8
 
@@ -267,20 +268,21 @@ class FTW::Connection
267
268
 
268
269
  # End this connection, specifying why.
269
270
  def disconnect(reason)
271
+ io = @socket
270
272
  if @socket.is_a?(OpenSSL::SSL::SSLSocket)
271
273
  @socket.sysclose()
272
- else
273
- begin
274
- @socket.close_read
275
- rescue IOError => e
276
- # Ignore, perhaps we shouldn't ignore.
277
- end
274
+ io = @socket.io
275
+ end
276
+ begin
277
+ io.close_read
278
+ rescue IOError => e
279
+ # Ignore, perhaps we shouldn't ignore.
280
+ end
278
281
 
279
- begin
280
- @socket.close_write
281
- rescue IOError => e
282
- # Ignore, perhaps we shouldn't ignore.
283
- end
282
+ begin
283
+ io.close_write
284
+ rescue IOError => e
285
+ # Ignore, perhaps we shouldn't ignore.
284
286
  end
285
287
  end # def disconnect
286
288
 
@@ -319,11 +321,18 @@ class FTW::Connection
319
321
  # * :certificate_store, an OpenSSL::X509::Store
320
322
  # * :timeout, a timeout threshold in seconds.
321
323
  # * :ciphers, an OpenSSL ciphers string, see `openssl ciphers` manual for details.
322
- # * :version, any of: SSLv2, SSLv3, TLSv1, TLSv1.1, TLSv1.2
324
+ # * :ssl_version, any of: SSLv2, SSLv3, TLSv1, TLSv1.1, TLSv1.2
325
+ # * :certificate, an OpenSSL::X509::Certificate
326
+ # * :key, an OpenSSL::PKey (like OpenSSL::PKey::RSA)
327
+ #
328
+ # Both `certificate` and `key` are highly recommended if the connection
329
+ # belongs to a server (not a client connection).
323
330
  #
324
331
  # Notes:
325
332
  # * Version may depend on your platform (openssl compilation settings, JVM
326
333
  # version, export restrictions, etc)
334
+ # * Available ciphers will depend on your version of Ruby (or JRuby and JVM),
335
+ # OpenSSL, etc.
327
336
  def secure(options=nil)
328
337
  # Skip this if we're already secure.
329
338
  return if secured?
@@ -331,7 +340,7 @@ class FTW::Connection
331
340
  defaults = {
332
341
  :timeout => nil,
333
342
  :ciphers => FTW::Agent::Configuration::SSL_CIPHER_MAP["MOZILLA_MODERN"],
334
- :version => "TLSv1.1"
343
+ :ssl_version => "TLSv1.1"
335
344
  }
336
345
  settings = defaults.merge(options) unless options.nil?
337
346
 
@@ -353,8 +362,8 @@ class FTW::Connection
353
362
  ssloptions |= OpenSSL::SSL::OP_NO_COMPRESSION
354
363
  end
355
364
  # https://github.com/jruby/jruby/issues/1874
356
- version = OpenSSL::SSL::SSLContext::METHODS.find { |x| x.to_s.gsub("_",".") == settings[:version] }
357
- raise InvalidConfiguration, "Invalid SSL/TLS version '#{settings[:version]}'" if version.nil?
365
+ version = OpenSSL::SSL::SSLContext::METHODS.find { |x| x.to_s.gsub("_",".") == settings[:ssl_version] }
366
+ raise InvalidConfiguration, "Invalid SSL/TLS version '#{settings[:ssl_version]}'" if version.nil?
358
367
  sslcontext.ssl_version = version
359
368
 
360
369
  # We have to set ciphers *after* setting ssl_version because setting
@@ -370,6 +379,11 @@ class FTW::Connection
370
379
  end
371
380
  sslcontext.cert_store = settings[:certificate_store]
372
381
 
382
+ if settings.include?(:certificate) && settings.include?(:key)
383
+ sslcontext.cert = settings[:certificate]
384
+ sslcontext.key = settings[:key]
385
+ end
386
+
373
387
  @socket = OpenSSL::SSL::SSLSocket.new(@socket, sslcontext)
374
388
 
375
389
  # TODO(sissel): Set up local certificat/key stuff. This is required for
data/lib/ftw/server.rb CHANGED
@@ -1,4 +1,6 @@
1
1
  require "ftw/namespace"
2
+ require "ftw/dns"
3
+ require "ftw/connection"
2
4
 
3
5
  # A web server.
4
6
  class FTW::Server
data/lib/ftw/version.rb CHANGED
@@ -3,5 +3,5 @@ require "ftw/namespace"
3
3
  # :nodoc:
4
4
  module FTW
5
5
  # The version of this library
6
- VERSION = "0.0.42"
6
+ VERSION = "0.0.43"
7
7
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ftw
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.42
4
+ version: 0.0.43
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jordan Sissel
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-11-19 00:00:00.000000000 Z
11
+ date: 2015-06-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: cabin
@@ -146,9 +146,10 @@ required_rubygems_version: !ruby/object:Gem::Requirement
146
146
  version: '0'
147
147
  requirements: []
148
148
  rubyforge_project:
149
- rubygems_version: 2.2.2
149
+ rubygems_version: 2.4.6
150
150
  signing_key:
151
151
  specification_version: 4
152
152
  summary: For The Web. Trying to build a solid and sane API for client and server web
153
153
  stuff. Client and Server operations for HTTP, WebSockets, SPDY, etc.
154
154
  test_files: []
155
+ has_rdoc: