rookout 0.1.15 → 0.1.16
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 +4 -4
- data/lib/rookout/com_ws/websocket_client.rb +43 -16
- data/lib/rookout/commit.rb +1 -1
- data/lib/rookout/exceptions.rb +6 -0
- data/lib/rookout/interface.rb +7 -1
- data/lib/rookout/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e08815efb5a89029e091fe5cd252dce182407411e6025de9db8e5ae2659d77d7
|
4
|
+
data.tar.gz: 60bba85497d1f9253e3447283fa1adb97096cb21213b5911ba90371323f1de26
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3d4744c8a0eda6615c1c9b503503d67a1ee647ac7dbf4607fe75b1d9aeff90f8ad98dd497df23eab4488f692f26266d5fd048db566a88a8713272ad072843200
|
7
|
+
data.tar.gz: 7aec7fcff6e9637319f5867b19f2a5eb15d1a0c560a7e1ed212f21b730ed67253db853eff0d3aeacb89a66a6b558f06fbb9049c68d2a8d052cc6787630859247
|
@@ -2,6 +2,7 @@ module Rookout
|
|
2
2
|
module ComWs
|
3
3
|
require "openssl"
|
4
4
|
require "websocket/driver"
|
5
|
+
require "uri"
|
5
6
|
|
6
7
|
require_relative "../config"
|
7
8
|
require_relative "../logger"
|
@@ -11,14 +12,13 @@ module Rookout
|
|
11
12
|
def initialize url, proxy, token
|
12
13
|
@token = token
|
13
14
|
@connection = WebsocketConnection.new url, proxy
|
15
|
+
@proxy = proxy
|
14
16
|
@driver = nil
|
15
|
-
@error = nil
|
16
17
|
@last_ping = nil
|
17
18
|
end
|
18
19
|
|
19
20
|
def connect
|
20
|
-
|
21
|
-
@connection.connect
|
21
|
+
connection_error = nil
|
22
22
|
@driver = WebSocket::Driver.client @connection
|
23
23
|
|
24
24
|
headers.each do |key, value|
|
@@ -26,18 +26,20 @@ module Rookout
|
|
26
26
|
end
|
27
27
|
|
28
28
|
@driver.on :error do |error|
|
29
|
-
|
29
|
+
connection_error = error
|
30
30
|
end
|
31
31
|
|
32
32
|
# Connect to the remote server
|
33
|
-
@driver.start
|
34
33
|
# TODO: ADD CONNECT TIMEOUT
|
34
|
+
@connection.connect @driver
|
35
|
+
@driver.start
|
36
|
+
|
35
37
|
while @driver.state == :connecting
|
36
38
|
recv_data = @connection.read_char
|
37
39
|
@driver.parse recv_data
|
38
40
|
end
|
39
41
|
|
40
|
-
raise Exceptions::RookWebsocketException,
|
42
|
+
raise Exceptions::RookWebsocketException, connection_error if @driver.state != :open
|
41
43
|
end
|
42
44
|
|
43
45
|
def connection_pump message_handler
|
@@ -88,14 +90,36 @@ module Rookout
|
|
88
90
|
@secure = %w[https wss].include? @uri.scheme
|
89
91
|
|
90
92
|
@socket = nil
|
93
|
+
|
94
|
+
@proxy_connected = false
|
91
95
|
end
|
92
96
|
|
93
|
-
def connect
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
97
|
+
def connect driver
|
98
|
+
@socket = tcp_connect
|
99
|
+
|
100
|
+
proxy_connect driver if @proxy
|
101
|
+
|
102
|
+
@socket = ssl_connect @socket if @secure
|
103
|
+
end
|
104
|
+
|
105
|
+
def proxy_connect driver
|
106
|
+
connection_error = nil
|
107
|
+
@proxy_connected = false
|
108
|
+
proxy = driver.proxy @proxy
|
109
|
+
|
110
|
+
proxy.on :connect do
|
111
|
+
@proxy_connected = true
|
98
112
|
end
|
113
|
+
|
114
|
+
proxy.on :error do |error|
|
115
|
+
connection_error = error
|
116
|
+
end
|
117
|
+
|
118
|
+
proxy.start
|
119
|
+
|
120
|
+
proxy.parse read_char until @proxy_connected == true || !connection_error.nil?
|
121
|
+
|
122
|
+
raise Exceptions::RookProxyException, connection_error unless connection_error.nil?
|
99
123
|
end
|
100
124
|
|
101
125
|
attr_reader :url
|
@@ -118,13 +142,16 @@ module Rookout
|
|
118
142
|
private
|
119
143
|
|
120
144
|
def tcp_connect
|
121
|
-
|
122
|
-
|
145
|
+
if @proxy
|
146
|
+
uri = URI(@proxy)
|
147
|
+
TCPSocket.new uri.host, uri.port
|
148
|
+
else
|
149
|
+
TCPSocket.new @uri.host,
|
150
|
+
@uri.port || (@secure ? 443 : 80)
|
151
|
+
end
|
123
152
|
end
|
124
153
|
|
125
|
-
def ssl_connect
|
126
|
-
tcp_socket = tcp_connect
|
127
|
-
|
154
|
+
def ssl_connect tcp_socket
|
128
155
|
ctx = ::OpenSSL::SSL::SSLContext.new
|
129
156
|
ctx.min_version = ::OpenSSL::SSL::TLS1_2_VERSION
|
130
157
|
cert_store = ::OpenSSL::X509::Store.new
|
data/lib/rookout/commit.rb
CHANGED
data/lib/rookout/exceptions.rb
CHANGED
@@ -178,6 +178,12 @@ module Rookout
|
|
178
178
|
end
|
179
179
|
end
|
180
180
|
|
181
|
+
class RookProxyException < ToolException
|
182
|
+
def initialize error
|
183
|
+
super "Error from proxy #{error}", { "error" => error }
|
184
|
+
end
|
185
|
+
end
|
186
|
+
|
181
187
|
class RookBadProtobuf < ToolException
|
182
188
|
def initialize
|
183
189
|
super 'Bad protobuf version. Please execute "bundle config force_ruby_platform true" before "bundler install".'
|
data/lib/rookout/interface.rb
CHANGED
@@ -17,6 +17,8 @@ module Rookout
|
|
17
17
|
throw_errors = options[:throw_errors] == true
|
18
18
|
Config.debug = evaluate_flag options[:debug], "ROOKOUT_DEBUG"
|
19
19
|
|
20
|
+
puts "[Rookout] Running in debug mode" if Config.debug
|
21
|
+
|
20
22
|
begin
|
21
23
|
verify_env
|
22
24
|
|
@@ -103,7 +105,7 @@ module Rookout
|
|
103
105
|
proxy = evaluate_config options[:proxy], "ROOKOUT_PROXY"
|
104
106
|
token = evaluate_config options[:token], "ROOKOUT_TOKEN"
|
105
107
|
|
106
|
-
raise RookMissingToken if token.nil? &&
|
108
|
+
raise RookMissingToken if token.nil? && !(host_specified options)
|
107
109
|
verify_token token if token
|
108
110
|
|
109
111
|
labels = stringify_labels(options[:labels]) || parse_labels(ENV["ROOKOUT_LABELS"])
|
@@ -115,6 +117,10 @@ module Rookout
|
|
115
117
|
{ host: host, port: port, proxy: proxy, token: token, labels: labels, async_start: async_start, fork: fork }
|
116
118
|
end
|
117
119
|
|
120
|
+
def host_specified options
|
121
|
+
!options[:host].nil? || !ENV["ROOKOUT_CONTROLLER_HOST"].nil? || !ENV["ROOKOUT_AGENT_HOST"].nil?
|
122
|
+
end
|
123
|
+
|
118
124
|
def evaluate_flag argument, env_var_name
|
119
125
|
return true? argument unless argument.nil?
|
120
126
|
true? ENV[env_var_name]
|
data/lib/rookout/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rookout
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.16
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Liran Haimovitch
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-01-
|
11
|
+
date: 2021-01-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: binding_of_caller
|