skylight 0.0.5 → 0.0.6
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.
- data/lib/skylight.rb +1 -4
- data/lib/skylight/json_proto.rb +3 -1
- data/lib/skylight/middleware.rb +28 -6
- data/lib/skylight/railtie.rb +2 -4
- data/lib/skylight/version.rb +1 -1
- data/lib/skylight/worker.rb +28 -25
- metadata +3 -16
- data/lib/skylight/vendor/excon.rb +0 -160
- data/lib/skylight/vendor/excon/cacert.pem +0 -3367
- data/lib/skylight/vendor/excon/connection.rb +0 -438
- data/lib/skylight/vendor/excon/constants.rb +0 -50
- data/lib/skylight/vendor/excon/errors.rb +0 -140
- data/lib/skylight/vendor/excon/middlewares/base.rb +0 -23
- data/lib/skylight/vendor/excon/middlewares/expects.rb +0 -22
- data/lib/skylight/vendor/excon/middlewares/instrumentor.rb +0 -31
- data/lib/skylight/vendor/excon/middlewares/mock.rb +0 -88
- data/lib/skylight/vendor/excon/response.rb +0 -68
- data/lib/skylight/vendor/excon/socket.rb +0 -206
- data/lib/skylight/vendor/excon/ssl_socket.rb +0 -100
- data/lib/skylight/vendor/excon/standard_instrumentor.rb +0 -19
@@ -1,100 +0,0 @@
|
|
1
|
-
module Skylight
|
2
|
-
module Vendor
|
3
|
-
module Excon
|
4
|
-
class SSLSocket < Socket
|
5
|
-
|
6
|
-
def initialize(data = {})
|
7
|
-
@data = data
|
8
|
-
check_nonblock_support
|
9
|
-
|
10
|
-
super
|
11
|
-
|
12
|
-
# create ssl context
|
13
|
-
ssl_context = OpenSSL::SSL::SSLContext.new
|
14
|
-
|
15
|
-
if @data[:ssl_verify_peer]
|
16
|
-
# turn verification on
|
17
|
-
ssl_context.verify_mode = OpenSSL::SSL::VERIFY_PEER
|
18
|
-
|
19
|
-
if @data[:ssl_ca_path]
|
20
|
-
ssl_context.ca_path = @data[:ssl_ca_path]
|
21
|
-
elsif @data[:ssl_ca_file]
|
22
|
-
ssl_context.ca_file = @data[:ssl_ca_file]
|
23
|
-
end
|
24
|
-
else
|
25
|
-
# turn verification off
|
26
|
-
ssl_context.verify_mode = OpenSSL::SSL::VERIFY_NONE
|
27
|
-
end
|
28
|
-
|
29
|
-
if @data.has_key?(:client_cert) && @data.has_key?(:client_key)
|
30
|
-
ssl_context.cert = OpenSSL::X509::Certificate.new(File.read(@data[:client_cert]))
|
31
|
-
ssl_context.key = OpenSSL::PKey::RSA.new(File.read(@data[:client_key]))
|
32
|
-
end
|
33
|
-
|
34
|
-
if @data[:proxy]
|
35
|
-
request = 'CONNECT ' << @data[:host] << ':' << @data[:port] << Excon::HTTP_1_1
|
36
|
-
request << 'Host: ' << @data[:host] << ':' << @data[:port] << Excon::CR_NL
|
37
|
-
|
38
|
-
if @data[:proxy][:password] || @data[:proxy][:user]
|
39
|
-
auth = ['' << @data[:proxy][:user].to_s << ':' << @data[:proxy][:password].to_s].pack('m').delete(Excon::CR_NL)
|
40
|
-
request << "Proxy-Authorization: Basic " << auth << Excon::CR_NL
|
41
|
-
end
|
42
|
-
|
43
|
-
request << 'Proxy-Connection: Keep-Alive' << Excon::CR_NL
|
44
|
-
|
45
|
-
request << Excon::CR_NL
|
46
|
-
|
47
|
-
# write out the proxy setup request
|
48
|
-
@socket.write(request)
|
49
|
-
|
50
|
-
# eat the proxy's connection response
|
51
|
-
Excon::Response.parse(@socket, { :expects => 200, :method => "CONNECT" })
|
52
|
-
end
|
53
|
-
|
54
|
-
# convert Socket to OpenSSL::SSL::SSLSocket
|
55
|
-
@socket = OpenSSL::SSL::SSLSocket.new(@socket, ssl_context)
|
56
|
-
@socket.sync_close = true
|
57
|
-
@socket.connect
|
58
|
-
|
59
|
-
# Server Name Indication (SNI) RFC 3546
|
60
|
-
if @socket.respond_to?(:hostname=)
|
61
|
-
@socket.hostname = @data[:host]
|
62
|
-
end
|
63
|
-
|
64
|
-
# verify connection
|
65
|
-
if @data[:ssl_verify_peer]
|
66
|
-
@socket.post_connection_check(@data[:host])
|
67
|
-
end
|
68
|
-
|
69
|
-
@socket
|
70
|
-
end
|
71
|
-
|
72
|
-
def connect
|
73
|
-
check_nonblock_support
|
74
|
-
super
|
75
|
-
end
|
76
|
-
|
77
|
-
def read(max_length=nil)
|
78
|
-
check_nonblock_support
|
79
|
-
super
|
80
|
-
end
|
81
|
-
|
82
|
-
def write(data)
|
83
|
-
check_nonblock_support
|
84
|
-
super
|
85
|
-
end
|
86
|
-
|
87
|
-
private
|
88
|
-
|
89
|
-
def check_nonblock_support
|
90
|
-
# backwards compatability for things lacking nonblock
|
91
|
-
if !DEFAULT_NONBLOCK && @data[:nonblock]
|
92
|
-
$stderr.puts("Excon nonblock is not supported by your OpenSSL::SSL::SSLSocket")
|
93
|
-
@data[:nonblock] = false
|
94
|
-
end
|
95
|
-
end
|
96
|
-
|
97
|
-
end
|
98
|
-
end
|
99
|
-
end
|
100
|
-
end
|
@@ -1,19 +0,0 @@
|
|
1
|
-
module Skylight
|
2
|
-
module Vendor
|
3
|
-
module Excon
|
4
|
-
class StandardInstrumentor
|
5
|
-
def self.instrument(name, params = {}, &block)
|
6
|
-
if params.has_key?(:headers) && params[:headers].has_key?('Authorization')
|
7
|
-
params = params.dup
|
8
|
-
params[:headers] = params[:headers].dup
|
9
|
-
params[:headers]['Authorization'] = REDACTED
|
10
|
-
end
|
11
|
-
$stderr.puts("#{name} #{params.inspect}")
|
12
|
-
if block_given?
|
13
|
-
yield
|
14
|
-
end
|
15
|
-
end
|
16
|
-
end
|
17
|
-
end
|
18
|
-
end
|
19
|
-
end
|