websocket 1.2.9 → 1.2.10
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/.github/workflows/test.yml +61 -0
- data/CHANGELOG.md +7 -0
- data/Gemfile +1 -0
- data/README.md +8 -1
- data/lib/websocket/frame/outgoing.rb +1 -1
- data/lib/websocket/handshake/base.rb +16 -2
- data/lib/websocket/handshake/client.rb +1 -1
- data/lib/websocket/handshake/handler/client04.rb +3 -3
- data/lib/websocket/handshake/handler/client75.rb +1 -1
- data/lib/websocket/handshake/handler/server04.rb +1 -1
- data/lib/websocket/handshake/server.rb +3 -3
- data/lib/websocket/version.rb +1 -1
- data/spec/support/all_client_drafts.rb +4 -0
- data/spec/support/all_server_drafts.rb +7 -1
- metadata +8 -36
- data/.travis.yml +0 -19
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4463e6e6f36b66267381b20c6dbab2fc1fd417319fcc9d2fb1a760c87a7d26e6
|
4
|
+
data.tar.gz: 71187172f0f75a938c50573cf0b2b378f092ec93f42b57cacea5c73f559ba085
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9875cb5996d580b1564e4a6cf2ef897ccf99d37577d2a22dd1e7750323dfc5aad181641411596b96667ebf614604d0ff581e3b39ae75d49c2bc1290c1ec4a82d
|
7
|
+
data.tar.gz: fd772c288aee75ca9c7328fd8096bc30bde61a69247633a4b9a2a7e61dff260d48bd4abbf957a02ead55ac83c365d945f3753b053c9e6f5cf237925b2c510a06
|
@@ -0,0 +1,61 @@
|
|
1
|
+
name: Test
|
2
|
+
|
3
|
+
on:
|
4
|
+
push:
|
5
|
+
branches:
|
6
|
+
- 'master'
|
7
|
+
pull_request:
|
8
|
+
branches:
|
9
|
+
- '*'
|
10
|
+
|
11
|
+
jobs:
|
12
|
+
rubocop:
|
13
|
+
runs-on: ubuntu-latest
|
14
|
+
name: Rubocop
|
15
|
+
steps:
|
16
|
+
- uses: actions/checkout@v2
|
17
|
+
|
18
|
+
- name: Set up Ruby
|
19
|
+
uses: ruby/setup-ruby@v1
|
20
|
+
with:
|
21
|
+
ruby-version: '3.0'
|
22
|
+
|
23
|
+
- name: Install gems
|
24
|
+
run: bundle install
|
25
|
+
|
26
|
+
- name: Run Rubocop
|
27
|
+
run: bundle exec rubocop
|
28
|
+
|
29
|
+
test:
|
30
|
+
strategy:
|
31
|
+
fail-fast: false
|
32
|
+
matrix:
|
33
|
+
ruby:
|
34
|
+
- 2.1
|
35
|
+
- 2.3
|
36
|
+
- 2.4
|
37
|
+
- 2.5
|
38
|
+
- 2.6
|
39
|
+
- 2.7
|
40
|
+
- "3.0"
|
41
|
+
- 3.1
|
42
|
+
- 3.2
|
43
|
+
- 3.3
|
44
|
+
- jruby
|
45
|
+
|
46
|
+
runs-on: ubuntu-latest
|
47
|
+
name: Ruby ${{ matrix.ruby }}
|
48
|
+
|
49
|
+
steps:
|
50
|
+
- uses: actions/checkout@v2
|
51
|
+
|
52
|
+
- name: Set up Ruby
|
53
|
+
uses: ruby/setup-ruby@v1
|
54
|
+
with:
|
55
|
+
ruby-version: ${{ matrix.ruby }}
|
56
|
+
|
57
|
+
- name: Install gems
|
58
|
+
run: bundle install
|
59
|
+
|
60
|
+
- name: Run tests
|
61
|
+
run: bundle exec rspec
|
data/CHANGELOG.md
CHANGED
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -4,7 +4,6 @@ Universal Ruby library to handle WebSocket protocol. It focuses on providing abs
|
|
4
4
|
|
5
5
|
[](http://badge.fury.io/rb/websocket)
|
6
6
|
[](https://rubygems.org/gems/websocket)
|
7
|
-
[](http://travis-ci.org/imanel/websocket-ruby)
|
8
7
|
[](https://codeclimate.com/github/imanel/websocket-ruby)
|
9
8
|
|
10
9
|
**Autobahn tests:** [server](http://imanel.github.com/websocket-ruby/autobahn/server/), [client](http://imanel.github.com/websocket-ruby/autobahn/client/)
|
@@ -118,6 +117,14 @@ WebSocket gem is written in pure Ruby, without any dependencies or native extens
|
|
118
117
|
|
119
118
|
In order to use native extension just install [websocket-native](http://github.com/imanel/websocket-ruby-native) gem or add it to Gemfile - WebSocket will automatically detect and load it.
|
120
119
|
|
120
|
+
## Support
|
121
|
+
|
122
|
+
If you like my work then consider supporting me:
|
123
|
+
|
124
|
+
[](https://en.cryptobadges.io/donate/bc1qmxfc703ezscvd4qv0dvp7hwy7vc4kl6currs5e)
|
125
|
+
|
126
|
+
[](https://en.cryptobadges.io/donate/0xA7048d5F866e2c3206DC95ebFa988fF987c0BccB)
|
127
|
+
|
121
128
|
## License
|
122
129
|
|
123
130
|
(The MIT License)
|
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
module WebSocket
|
4
4
|
module Frame
|
5
|
-
# Construct or parse
|
5
|
+
# Construct or parse outgoing WebSocket Frame.
|
6
6
|
# @note You should NEVER use this class directly - use Client or Server subclasses instead, as they contain additional frame options(i.e. Client-side masking in draft 04)
|
7
7
|
#
|
8
8
|
# @example
|
@@ -7,7 +7,7 @@ module WebSocket
|
|
7
7
|
include ExceptionHandler
|
8
8
|
include NiceInspect
|
9
9
|
|
10
|
-
attr_reader :host, :
|
10
|
+
attr_reader :host, :path, :query,
|
11
11
|
:state, :version, :secure,
|
12
12
|
:headers, :protocols
|
13
13
|
|
@@ -66,6 +66,20 @@ module WebSocket
|
|
66
66
|
(@leftovers.to_s.split("\n", reserved_leftover_lines + 1)[reserved_leftover_lines] || '').strip
|
67
67
|
end
|
68
68
|
|
69
|
+
# Return default port for protocol (80 for ws, 443 for wss)
|
70
|
+
def default_port
|
71
|
+
secure ? 443 : 80
|
72
|
+
end
|
73
|
+
|
74
|
+
# Check if provided port is a default one
|
75
|
+
def default_port?
|
76
|
+
port == default_port
|
77
|
+
end
|
78
|
+
|
79
|
+
def port
|
80
|
+
@port || default_port
|
81
|
+
end
|
82
|
+
|
69
83
|
# URI of request.
|
70
84
|
# @return [String] Full URI with protocol
|
71
85
|
# @example
|
@@ -73,7 +87,7 @@ module WebSocket
|
|
73
87
|
def uri
|
74
88
|
uri = String.new(secure ? 'wss://' : 'ws://')
|
75
89
|
uri << host
|
76
|
-
uri << ":#{port}"
|
90
|
+
uri << ":#{port}" unless default_port?
|
77
91
|
uri << path
|
78
92
|
uri << "?#{query}" if query
|
79
93
|
uri
|
@@ -21,7 +21,7 @@ module WebSocket
|
|
21
21
|
%w[Connection Upgrade]
|
22
22
|
]
|
23
23
|
host = @handshake.host
|
24
|
-
host += ":#{@handshake.port}"
|
24
|
+
host += ":#{@handshake.port}" unless @handshake.default_port?
|
25
25
|
keys << ['Host', host]
|
26
26
|
keys += super
|
27
27
|
keys << ['Sec-WebSocket-Origin', @handshake.origin] if @handshake.origin
|
@@ -34,13 +34,13 @@ module WebSocket
|
|
34
34
|
# Sec-WebSocket-Key value
|
35
35
|
# @return [String] key
|
36
36
|
def key
|
37
|
-
@key ||=
|
37
|
+
@key ||= [(1..16).map { rand(255).chr } * ''].pack('m').strip
|
38
38
|
end
|
39
39
|
|
40
40
|
# Value of Sec-WebSocket-Accept that should be delivered back by server
|
41
41
|
# @return [Sering] accept
|
42
42
|
def accept
|
43
|
-
@accept ||=
|
43
|
+
@accept ||= [Digest::SHA1.digest(key + '258EAFA5-E914-47DA-95CA-C5AB0DC85B11')].pack('m').strip
|
44
44
|
end
|
45
45
|
|
46
46
|
# Verify if received header Sec-WebSocket-Accept matches generated one.
|
@@ -18,7 +18,7 @@ module WebSocket
|
|
18
18
|
%w[Connection Upgrade]
|
19
19
|
]
|
20
20
|
host = @handshake.host
|
21
|
-
host += ":#{@handshake.port}"
|
21
|
+
host += ":#{@handshake.port}" unless @handshake.default_port?
|
22
22
|
keys << ['Host', host]
|
23
23
|
keys << ['Origin', @handshake.origin] if @handshake.origin
|
24
24
|
keys << ['WebSocket-Protocol', @handshake.protocols.first] if @handshake.protocols.any?
|
@@ -33,7 +33,7 @@ module WebSocket
|
|
33
33
|
def signature
|
34
34
|
return unless key
|
35
35
|
string_to_sign = "#{key}258EAFA5-E914-47DA-95CA-C5AB0DC85B11"
|
36
|
-
|
36
|
+
[Digest::SHA1.digest(string_to_sign)].pack('m').chomp
|
37
37
|
end
|
38
38
|
|
39
39
|
def verify_key
|
@@ -129,13 +129,13 @@ module WebSocket
|
|
129
129
|
# Host of server according to client header
|
130
130
|
# @return [String] host
|
131
131
|
def host
|
132
|
-
@headers['host'].to_s.split(':')[0].to_s
|
132
|
+
@host || @headers['host'].to_s.split(':')[0].to_s
|
133
133
|
end
|
134
134
|
|
135
135
|
# Port of server according to client header
|
136
|
-
# @return [
|
136
|
+
# @return [Integer] port
|
137
137
|
def port
|
138
|
-
@headers['host'].to_s.split(':')[1]
|
138
|
+
(@port || @headers['host'].to_s.split(':')[1] || default_port).to_i
|
139
139
|
end
|
140
140
|
|
141
141
|
private
|
data/lib/websocket/version.rb
CHANGED
@@ -38,6 +38,10 @@ RSpec.shared_examples_for 'all client drafts' do
|
|
38
38
|
expect(handshake.query).to eql('aaa=bbb')
|
39
39
|
end
|
40
40
|
|
41
|
+
it 'returns default port' do
|
42
|
+
expect(handshake.port).to be(80)
|
43
|
+
end
|
44
|
+
|
41
45
|
it 'returns valid port' do
|
42
46
|
@request_params = { port: 123 }
|
43
47
|
expect(handshake.port).to be(123)
|
@@ -47,11 +47,17 @@ RSpec.shared_examples_for 'all server drafts' do
|
|
47
47
|
expect(handshake.query).to eql('aaa=bbb')
|
48
48
|
end
|
49
49
|
|
50
|
+
it 'returns default port' do
|
51
|
+
handshake << client_request
|
52
|
+
|
53
|
+
expect(handshake.port).to be(80)
|
54
|
+
end
|
55
|
+
|
50
56
|
it 'returns valid port' do
|
51
57
|
@request_params = { port: 123 }
|
52
58
|
handshake << client_request
|
53
59
|
|
54
|
-
expect(handshake.port).to
|
60
|
+
expect(handshake.port).to be(123)
|
55
61
|
end
|
56
62
|
|
57
63
|
it 'returns valid response' do
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: websocket
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.2.
|
4
|
+
version: 1.2.10
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Bernard Potocki
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2023-09-19 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: Universal Ruby library to handle WebSocket protocol
|
14
14
|
email:
|
@@ -19,9 +19,9 @@ extra_rdoc_files: []
|
|
19
19
|
files:
|
20
20
|
- ".codeclimate.yml"
|
21
21
|
- ".github/workflows/publish.yml"
|
22
|
+
- ".github/workflows/test.yml"
|
22
23
|
- ".gitignore"
|
23
24
|
- ".rubocop.yml"
|
24
|
-
- ".travis.yml"
|
25
25
|
- CHANGELOG.md
|
26
26
|
- Gemfile
|
27
27
|
- README.md
|
@@ -96,7 +96,7 @@ homepage: http://github.com/imanel/websocket-ruby
|
|
96
96
|
licenses:
|
97
97
|
- MIT
|
98
98
|
metadata: {}
|
99
|
-
post_install_message:
|
99
|
+
post_install_message:
|
100
100
|
rdoc_options: []
|
101
101
|
require_paths:
|
102
102
|
- lib
|
@@ -111,36 +111,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
111
111
|
- !ruby/object:Gem::Version
|
112
112
|
version: '0'
|
113
113
|
requirements: []
|
114
|
-
rubygems_version: 3.
|
115
|
-
signing_key:
|
114
|
+
rubygems_version: 3.4.10
|
115
|
+
signing_key:
|
116
116
|
specification_version: 4
|
117
117
|
summary: Universal Ruby library to handle WebSocket protocol
|
118
|
-
test_files:
|
119
|
-
- spec/frame/incoming_03_spec.rb
|
120
|
-
- spec/frame/incoming_04_spec.rb
|
121
|
-
- spec/frame/incoming_05_spec.rb
|
122
|
-
- spec/frame/incoming_07_spec.rb
|
123
|
-
- spec/frame/incoming_75_spec.rb
|
124
|
-
- spec/frame/incoming_common_spec.rb
|
125
|
-
- spec/frame/masking_spec.rb
|
126
|
-
- spec/frame/outgoing_03_spec.rb
|
127
|
-
- spec/frame/outgoing_04_spec.rb
|
128
|
-
- spec/frame/outgoing_05_spec.rb
|
129
|
-
- spec/frame/outgoing_07_spec.rb
|
130
|
-
- spec/frame/outgoing_75_spec.rb
|
131
|
-
- spec/frame/outgoing_common_spec.rb
|
132
|
-
- spec/handshake/client_04_spec.rb
|
133
|
-
- spec/handshake/client_11_spec.rb
|
134
|
-
- spec/handshake/client_75_spec.rb
|
135
|
-
- spec/handshake/client_76_spec.rb
|
136
|
-
- spec/handshake/server_04_spec.rb
|
137
|
-
- spec/handshake/server_75_spec.rb
|
138
|
-
- spec/handshake/server_76_spec.rb
|
139
|
-
- spec/spec_helper.rb
|
140
|
-
- spec/support/all_client_drafts.rb
|
141
|
-
- spec/support/all_server_drafts.rb
|
142
|
-
- spec/support/frames_base.rb
|
143
|
-
- spec/support/handshake_requests.rb
|
144
|
-
- spec/support/incoming_frames.rb
|
145
|
-
- spec/support/outgoing_frames.rb
|
146
|
-
- spec/support/overwrites.rb
|
118
|
+
test_files: []
|
data/.travis.yml
DELETED
@@ -1,19 +0,0 @@
|
|
1
|
-
dist: trusty
|
2
|
-
language: ruby
|
3
|
-
script: "bundle exec rake"
|
4
|
-
rvm:
|
5
|
-
- 2.1
|
6
|
-
- 2.2
|
7
|
-
- 2.3
|
8
|
-
- 2.4
|
9
|
-
- 2.5
|
10
|
-
- ruby-head
|
11
|
-
- jruby-9.1.9.0 # https://github.com/travis-ci/travis-ci/issues/8446
|
12
|
-
- jruby-head
|
13
|
-
- rbx-3
|
14
|
-
|
15
|
-
matrix:
|
16
|
-
allow_failures:
|
17
|
-
- rvm: ruby-head
|
18
|
-
- rvm: jruby-head
|
19
|
-
- rvm: rbx-3
|