anycable 0.6.3 → 0.6.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 982192dbe84e0576b13033aadf3ead0238e28bf4c30b6dec2d08228cd2093f3c
4
- data.tar.gz: 9af924544238340e0c5b171a738b9bec99ebe25c13cc398d279318f6c9cbef12
3
+ metadata.gz: 6b624b0695335efdb861cfdb90b16caa0b2ddd67698a0ac813a81e9ae98a52eb
4
+ data.tar.gz: b70e2b622120da3ae2df10049e6145d958d84d78ab8a080943a8e50aab4cf983
5
5
  SHA512:
6
- metadata.gz: ba03a684ddce90df929c469deb4b219a494578ab9c203321e9c9f900810f98132eb74d8fc16aa1b79c6042c28bd5b3da2ac83d39bd4e25944127191dc4b2f8b7
7
- data.tar.gz: 77a874ad448dff0cca9d8ada4259c8c48ab4fdb87d1df1f3c6bee1dab50f23335f1fc390ee60fb96483a89cc0071700945bdffa73f908745987de2c2e7877c91
6
+ metadata.gz: 97619fd72a53a84608f47b9a99504b080731a0b8915667007d9cf3240feda2a880b0cdcb67acddefec14c34fbbd169c812a4dc310ef4d0b3757c818471ae019c
7
+ data.tar.gz: efb598ebbd08e0de7574f0de3690b0c7caf11812f3b2afcde26aee5c8bff8a4607cd3a9b791cc978df458d00c37155d23d520118ffc38af98f1e7c9e66760d88
@@ -2,6 +2,22 @@
2
2
 
3
3
  ## master
4
4
 
5
+ ## 0.6.4 (2020-01-24)
6
+
7
+ - Fix Ruby 2.7 warnings. ([@palkan])
8
+
9
+ – Add `REMOTE_ADDR` socket env variable using a synthetic header passed from a websocket
10
+ server. ([@sponomarev][])
11
+
12
+ Recreating a request object in your custom connection factory using `Rack::Request` or
13
+ `ActionDispatch::Request` (already implemented in [anycable-rails](https://github.com/anycable/anycable-rails))
14
+ gives you an access to `request.ip` with the properly set IP address.
15
+
16
+ - Align socket env to be more compatibile with Rack Spec ([@sponomarev][])
17
+
18
+ Provide as much env details as possible to be able to reconstruct the full
19
+ request object in a custom connection factory.
20
+
5
21
  ## 0.6.3 (2019-03-26)
6
22
 
7
23
  - Relax `redis` gem version requirement. ([@palkan][])
@@ -244,3 +260,4 @@ Implement `Disconnect` handler, which invokes `Connection#disconnect` (along wit
244
260
  [@sadovnik]: https://github.com/sadovnik
245
261
  [@accessd]: https://github.com/accessd
246
262
  [@DarthSim]: https://github.com/DarthSim
263
+ [@sponomarev]: https://github.com/sponomarev
data/README.md CHANGED
@@ -9,7 +9,7 @@
9
9
 
10
10
  AnyCable allows you to use any WebSocket server (written in any language) as a replacement for your Ruby server (such as Faye, ActionCable, etc).
11
11
 
12
- AnyCable uses ActionCable protocol, so you can use ActionCable [JavaScript client](https://www.npmjs.com/package/actioncable) without any monkey-patching.
12
+ AnyCable uses the same protocol as ActionCable, so you can use its [JavaScript client](https://www.npmjs.com/package/actioncable) without any monkey-patching.
13
13
 
14
14
  <a href="https://evilmartians.com/">
15
15
  <img src="https://evilmartians.com/badges/sponsored-by-evil-martians.svg" alt="Sponsored by Evil Martians" width="236" height="54"></a>
@@ -17,7 +17,7 @@ AnyCable uses ActionCable protocol, so you can use ActionCable [JavaScript clien
17
17
  ## Requirements
18
18
 
19
19
  - Ruby >= 2.4
20
- - Redis (for brodcasting, [discuss other options](https://github.com/anycable/anycable/issues/2) with us!)
20
+ - Redis (for broadcasting, [discuss other options](https://github.com/anycable/anycable/issues/2) with us!)
21
21
 
22
22
  ## Usage
23
23
 
@@ -71,3 +71,8 @@ Please, provide reproduction script (using [this template](https://github.com/an
71
71
 
72
72
  ## License
73
73
  The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
74
+
75
+ ## Security Contact
76
+
77
+ To report a security vulnerability, please use the [Tidelift security contact](https://tidelift.com/security). Tidelift will coordinate the fix and disclosure.
78
+
@@ -26,7 +26,7 @@ module AnyCable
26
26
  end
27
27
  end
28
28
 
29
- BroadcastAdapters.const_get(adapter_class_name, false).new(options || {})
29
+ BroadcastAdapters.const_get(adapter_class_name, false).new(**(options || {}))
30
30
  end
31
31
  # rubocop: enable Metrics/AbcSize, Metrics/MethodLength
32
32
  end
@@ -1,7 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require "webrick"
4
-
5
3
  module AnyCable
6
4
  # Server for HTTP healthchecks.
7
5
  #
@@ -53,6 +51,8 @@ module AnyCable
53
51
  attr_reader :logger
54
52
 
55
53
  def build_server
54
+ require "webrick"
55
+
56
56
  WEBrick::HTTPServer.new(
57
57
  Port: port,
58
58
  Logger: logger,
@@ -66,7 +66,9 @@ module AnyCable
66
66
  def command(message, _unused_call)
67
67
  logger.debug("RPC Command: #{message.inspect}")
68
68
 
69
- socket = build_socket
69
+ # We don't have path/headers information here,
70
+ # but we still want `connection.env` to work
71
+ socket = build_socket(env: base_rack_env)
70
72
 
71
73
  connection = factory.call(
72
74
  socket,
@@ -97,24 +99,42 @@ module AnyCable
97
99
 
98
100
  private
99
101
 
100
- # Build env from path
102
+ # Build Rack env from request
101
103
  def rack_env(request)
102
104
  uri = URI.parse(request.path)
103
- {
104
- "QUERY_STRING" => uri.query,
105
- "SCRIPT_NAME" => "",
105
+
106
+ env = base_rack_env
107
+ env.merge!(
106
108
  "PATH_INFO" => uri.path,
109
+ "QUERY_STRING" => uri.query,
110
+ "SERVER_NAME" => uri.host,
107
111
  "SERVER_PORT" => uri.port.to_s,
108
112
  "HTTP_HOST" => uri.host,
109
- # Hack to avoid Missing rack.input error
110
- "rack.request.form_input" => "",
111
- "rack.input" => "",
112
- "rack.request.form_hash" => {}
113
- }.merge(build_headers(request.headers))
113
+ "REMOTE_ADDR" => request.headers.delete("REMOTE_ADDR"),
114
+ "rack.url_scheme" => uri.scheme
115
+ )
116
+
117
+ env.merge!(build_headers(request.headers))
118
+ end
119
+
120
+ def base_rack_env
121
+ # Minimum required variables according to Rack Spec
122
+ # (not all of them though, just those enough for Action Cable to work)
123
+ # See https://rubydoc.info/github/rack/rack/master/file/SPEC
124
+ {
125
+ "REQUEST_METHOD" => "GET",
126
+ "SCRIPT_NAME" => "",
127
+ "PATH_INFO" => "/",
128
+ "QUERY_STRING" => "",
129
+ "SERVER_NAME" => "",
130
+ "SERVER_PORT" => "80",
131
+ "rack.url_scheme" => "http",
132
+ "rack.input" => ""
133
+ }
114
134
  end
115
135
 
116
136
  def build_socket(**options)
117
- AnyCable::Socket.new(options)
137
+ AnyCable::Socket.new(**options)
118
138
  end
119
139
 
120
140
  def build_headers(headers)
@@ -117,7 +117,7 @@ module AnyCable
117
117
  attr_reader :logger, :start_thread
118
118
 
119
119
  def build_server(options)
120
- GRPC::RpcServer.new(options).tap do |server|
120
+ GRPC::RpcServer.new(**options).tap do |server|
121
121
  server.add_http2_port(host, :this_port_is_insecure)
122
122
  server.handle(AnyCable::RPCHandler)
123
123
  server.handle(build_health_checker)
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module AnyCable
4
- VERSION = "0.6.3"
4
+ VERSION = "0.6.4"
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: anycable
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.3
4
+ version: 0.6.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - palkan
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-03-26 00:00:00.000000000 Z
11
+ date: 2020-01-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: anyway_config
@@ -114,14 +114,14 @@ dependencies:
114
114
  requirements:
115
115
  - - "~>"
116
116
  - !ruby/object:Gem::Version
117
- version: 0.65.0
117
+ version: 0.68.0
118
118
  type: :development
119
119
  prerelease: false
120
120
  version_requirements: !ruby/object:Gem::Requirement
121
121
  requirements:
122
122
  - - "~>"
123
123
  - !ruby/object:Gem::Version
124
- version: 0.65.0
124
+ version: 0.68.0
125
125
  - !ruby/object:Gem::Dependency
126
126
  name: simplecov
127
127
  requirement: !ruby/object:Gem::Requirement
@@ -184,7 +184,12 @@ files:
184
184
  homepage: http://github.com/anycable/anycable
185
185
  licenses:
186
186
  - MIT
187
- metadata: {}
187
+ metadata:
188
+ bug_tracker_uri: http://github.com/anycable/anycable/issues
189
+ changelog_uri: https://github.com/anycable/anycable/blob/master/CHANGELOG.md
190
+ documentation_uri: https://docs.anycable.io/
191
+ homepage_uri: https://anycable.io/
192
+ source_code_uri: http://github.com/anycable/anycable
188
193
  post_install_message:
189
194
  rdoc_options: []
190
195
  require_paths:
@@ -200,7 +205,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
200
205
  - !ruby/object:Gem::Version
201
206
  version: '0'
202
207
  requirements: []
203
- rubygems_version: 3.0.2
208
+ rubygems_version: 3.0.3
204
209
  signing_key:
205
210
  specification_version: 4
206
211
  summary: AnyCable is a polyglot replacement for ActionCable-compatible servers