Commit Graph

348 Commits

Author SHA1 Message Date
Vipul A M
7e7d6ccf34
Changelog edits 2016-11-12 13:14:49 -05:00
Rafael Mendonça França
fe1f4b2ad5
Add more rubocop rules about whitespaces 2016-10-29 01:17:49 -02:00
Charles Oliver Nutter
51de32b2ec Lazy-load blade for actioncable tests; no blade on JRuby. 2016-10-21 17:19:44 -05:00
Matthew Draper
dae4044734 Permit same-origin connections by default
WebSocket always defers the decision to the server, because it didn't
have to deal with legacy compatibility... but the same-origin policy is
still a reasonable default.

Origin checks do not protect against a directly connecting attacker --
they can lie about their host, but can also lie about their origin.
Origin checks protect against a connection from 3rd-party controlled
script in a context where a victim browser's cookies will be passed
along. And if an attacker has breached that protection, they've already
compromised the HTTP session, so treating the WebSocket connection in
the same way seems reasonable.

In case this logic proves incorrect (or anyone just wants to be more
paranoid), we retain a config option to disable it.
2016-10-11 12:51:10 +10:30
Matthew Draper
f8c53eff7b Merge pull request #26568 from skateman/cable-sameorigin-as-host
Optionally allow ActionCable requests from the same host as origin
2016-10-11 12:28:38 +10:30
Matthew Draper
3a11c5b626 Merge pull request #26714 from matthewd/close-race
Work around read/close race (x2)
2016-10-07 04:30:08 +10:30
Matthew Draper
1fe967d0c9 Wait for the socket to be closed asynchronously 2016-10-06 13:12:35 +10:30
Matthew Draper
acd7ba795e Use a branch of websocket-client-simple, to work around read/close race 2016-10-06 12:51:26 +10:30
Matthew Draper
4a7c5685c8 Close the IO from the read loop thread
IO#close and IO#read across threads don't get along so well:

After T1 enters #read and releases the GVL, T2 can call #close on the
IO, thereby both closing the fd and freeing the buffer while T1 is using
them.
2016-10-06 10:31:14 +10:30
kenta-s
a0f871f95a Change page:change to turbolinks:load in README.md [ci skip] 2016-10-05 19:41:27 +09:00
Matthew Draper
39fb3069f8 Don't shut down adapters that haven't been set
We hit when we skip the PostgreSQL adapter.
2016-10-04 06:40:38 +10:30
Matthew Draper
a92fa72600 Shut down the worker pool - don't kill it
Different parts of concurrent-ruby's documentation make inconsistent
claims about how kill will behave. It doesn't do the thing we want.
2016-10-03 05:38:25 +10:30
Jon Moss
d1cc11a360 Add tests for Server::Base#restart 2016-10-02 09:02:01 -04:00
Jon Moss
35a497dc29 Move behavior to Server::Base, and flush pubsub 2016-10-02 08:45:38 -04:00
Jon Moss
a5dfba4135 Shutdown pubsub connection before classes are reloaded
Before this patch, if you were to make a file edit in your Rails
application and you tried to load up the page, it would hang
indefinitely. The issue is that Active Record is trying to cleanup after
itself and clear all active connection, but Action Cable is still
holding onto a connection from the pool. To resolve this, we are now
shutting down the pubsub adapter before classes are reloaded, to avoid
this altogether (connection is being returned to the pool).

Credits to @skateman for discovering this bug. :)
2016-10-02 08:45:38 -04:00
Matthew Draper
7c812c2401 Use websocket-client-simple instead of Faye as a websockets client
Mostly, this is just to avoid EventMachine. But there's also an argument
to be made that we're better off using a different protocol library for
our test suite than the one we use to implement the server.
2016-10-02 12:25:33 +10:30
Matthew Draper
a5abc310cd Shut down EventMachine before re-enabling warnings 2016-10-02 12:25:33 +10:30
Matthew Draper
3e779d3c67 In-line the configuration points that only existed for Faye support 2016-10-01 15:36:26 +09:30
Matthew Draper
d44177d45e Remove Faye mode
No deprecation, because it was never documented.
2016-10-01 15:35:59 +09:30
Matthew Draper
9588a3d66d Merge pull request #26547 from palkan/fix/actioncable-confirmation-race-condition
Avoid race condition on subscription confirmation
2016-10-01 15:18:39 +09:30
Matthew Draper
5d92089bca Buffer writes to the cable sockets
Otherwise, they can sometimes block, leading to reduced system
throughput.
2016-09-28 06:44:23 +09:30
palkan
3e68d8b872 Add Channel#ensure_confirmation_sent; call #subscribe_to_channel after initializing 2016-09-22 20:25:09 +03:00
Dávid Halász
268c340b09 Optionally allow ActionCable requests from the same host as origin
When the `allow_same_origin_as_host` is set to `true`, the request
forgery protection permits `HTTP_ORIGIN` values starting with the
corresponding `proto://` prefix followed by `HTTP_HOST`. This way
it is not required to specify the list of allowed URLs.
2016-09-21 16:10:46 +02:00
palkan
03a209e92a [Fix #25381] Avoid race condition on subscription confirmation 2016-09-20 19:42:24 +03:00
Prathamesh Sonpatki
f838c213be
[ci skip] Fix formatting of documentation of worker_pool method from AC::Server::Base 2016-09-07 12:05:36 +05:30
Prathamesh Sonpatki
0c9ef8d943
[ci skip] Fix formatting in Action Cable Connection::Base module docs 2016-09-07 08:04:52 +05:30
Prathamesh Sonpatki
c683ac4fe0
[ci fix] Fix API documentation for Streams module from Action Cable 2016-09-06 23:10:15 +05:30
Xavier Noria
bb1ecdcc67 fixes remaining RuboCop issues [Vipul A M, Xavier Noria] 2016-09-01 23:41:49 +02:00
Jon Moss
831e2c8d1b Prevent invocation of channel action if rejected connection
Fixes #23757.

Before this commit, even if `reject` was called in the `subscribe`
method for an Action Cable channel, all actions on that channel could
still be invoked. This calls a `return` if a rejected connection tries
to invoke any actions on the channel.
2016-08-19 13:00:39 -04:00
Rafael Mendonça França
55f9b8129a
Add three new rubocop rules
Style/SpaceBeforeBlockBraces
Style/SpaceInsideBlockBraces
Style/SpaceInsideHashLiteralBraces

Fix all violations in the repository.
2016-08-16 04:30:11 -03:00
Vipul A M
8b984161d6
Pass over changelogs [ci skip] 2016-08-10 09:33:13 +05:30
Xavier Noria
46f511685c revises more Lint/EndAlignment offenses 2016-08-08 18:25:11 +02:00
Xavier Noria
cf082927ef copy-edits an exception message
Inserted spaces in the name of Rails components.

Since I was on it, also used PostgreSQL instead of Postgres
because albeit Postgres is an accepted alias, PostgreSQL is
the official name and the actual name of the adapter.

See

    https://wiki.postgresql.org/wiki/ProjectName

with regard to PostgreSQL vs Postgres.
2016-08-07 22:58:20 +02:00
Ryuta Kamizono
762e3f05f3 Add Style/EmptyLines in .rubocop.yml and remove extra empty lines 2016-08-07 17:50:59 +09:00
Xavier Noria
b326e82dc0 applies remaining conventions across the project 2016-08-06 20:20:22 +02:00
Xavier Noria
80e66cc4d9 normalizes indentation and whitespace across the project 2016-08-06 20:16:27 +02:00
Xavier Noria
411ccbdab2 remove redundant curlies from hash arguments 2016-08-06 19:44:11 +02:00
Xavier Noria
12a70404cd modernizes hash syntax in actioncable 2016-08-06 19:32:32 +02:00
Xavier Noria
e6ab70c439 applies new string literal convention to the rest of the project
The current code base is not uniform. After some discussion,
we have chosen to go with double quotes by default.
2016-08-06 19:28:46 +02:00
Xavier Noria
adca8154c6 applies new string literal convention in the gemspecs
The current code base is not uniform. After some discussion,
we have chosen to go with double quotes by default.
2016-08-06 19:27:12 +02:00
Xavier Noria
f8477f13bf applies new string literal convention in actioncable/test
The current code base is not uniform. After some discussion,
we have chosen to go with double quotes by default.
2016-08-06 19:15:15 +02:00
Xavier Noria
b678eb57e9 applies new string literal convention in actioncable/lib
The current code base is not uniform. After some discussion,
we have chosen to go with double quotes by default.
2016-08-06 19:13:46 +02:00
Santosh Wadghule
e73b5cf51b Give importance to rails command in the comment section. 2016-07-13 19:13:05 +05:30
Matthew Draper
48e8056d4f Correct changelog layout
[ci skip]
2016-07-09 03:17:51 +09:30
Matthew Draper
e995611155 Insert changelog entry for #25615 2016-07-09 02:56:03 +09:30
Matthew Draper
92421ee2d2 Merge pull request #25624 from tinco/actioncable_write_race
Fix race condition in websocket stream write
2016-07-09 02:44:15 +09:30
Matthew Draper
08a9074613 Merge pull request #24988 from mwear/action_cable_broadcast_notifications
Add ActiveSupport::Notifications hook to ActionCable::Server.broadcast
2016-07-04 08:44:14 +09:30
Matthew Draper
550303c05c Merge pull request #25030 from mmmpa/pull_request
ActionCable, sometimes add_channel is not called.
2016-07-04 08:39:02 +09:30
Matthew Draper
a468774cc1 Merge pull request #25293 from y-yagi/remove_needless_comments
remove needless comments
2016-07-03 04:08:30 +09:30
Tinco Andringa
3120b51de7 close hijacked i/o socket after use (fixes #25613) 2016-07-01 23:03:30 +02:00