protocol-websocket 0.5.0 → 0.6.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/lib/protocol/websocket/connection.rb +3 -2
- data/lib/protocol/websocket/{digest.rb → headers.rb} +25 -4
- data/lib/protocol/websocket/version.rb +1 -1
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c86a30474a3cc59d80067cff2ffd5ca70ad3e6a1790cb733ec3c3e50a470d8ee
|
4
|
+
data.tar.gz: 0dd99e817ecb007230fd72a5d6192377407c342335957fb7684e36e7e5ce0eee
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: af32770dae2bd359017808d16534872fa59aeb1de7323c1ceaba940d8b553ec59c23c73fe5fe83c352e8a08a4afca976ca06b0cc253d30c3ebf0d6ddf4ffde81
|
7
|
+
data.tar.gz: e4ff5515d2ff8312058161e08b5e42996282aa78d24f03a12dcf47de9541654c8d8de4b27b50cac65498bbd79de62f681c2f9894ff60b5925886db480c53973b
|
data/.gitignore
CHANGED
@@ -50,7 +50,7 @@ module Protocol
|
|
50
50
|
end
|
51
51
|
|
52
52
|
def close
|
53
|
-
send_close
|
53
|
+
send_close unless closed?
|
54
54
|
|
55
55
|
@framer.close
|
56
56
|
end
|
@@ -121,7 +121,8 @@ module Protocol
|
|
121
121
|
frame = CloseFrame.new(mask: @mask)
|
122
122
|
frame.pack(code, message)
|
123
123
|
|
124
|
-
write_frame(frame)
|
124
|
+
self.write_frame(frame)
|
125
|
+
self.flush
|
125
126
|
|
126
127
|
@state = :closed
|
127
128
|
end
|
@@ -19,13 +19,34 @@
|
|
19
19
|
# THE SOFTWARE.
|
20
20
|
|
21
21
|
require 'digest/sha1'
|
22
|
+
require 'securerandom'
|
22
23
|
|
23
24
|
module Protocol
|
24
25
|
module WebSocket
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
26
|
+
module Headers
|
27
|
+
# The protocol string used for the `upgrade:` header (HTTP/1) and `:protocol` pseudo-header (HTTP/2).
|
28
|
+
PROTOCOL = "websocket".freeze
|
29
|
+
|
30
|
+
# These general headers are used to negotiate the connection.
|
31
|
+
SEC_WEBSOCKET_PROTOCOL = 'sec-websocket-protocol'.freeze
|
32
|
+
SEC_WEBSOCKET_VERSION = 'sec-websocket-version'.freeze
|
33
|
+
|
34
|
+
SEC_WEBSOCKET_KEY = 'sec-websocket-key'.freeze
|
35
|
+
SEC_WEBSOCKET_ACCEPT = 'sec-websocket-accept'.freeze
|
36
|
+
|
37
|
+
module Nounce
|
38
|
+
GUID = "258EAFA5-E914-47DA-95CA-C5AB0DC85B11"
|
39
|
+
|
40
|
+
# Valid for the `SEC_WEBSOCKET_KEY` header.
|
41
|
+
def self.generate_key
|
42
|
+
SecureRandom.base64(16)
|
43
|
+
end
|
44
|
+
|
45
|
+
# Valid for the `SEC_WEBSOCKET_ACCEPT` header.
|
46
|
+
def self.accept_digest(key)
|
47
|
+
Digest::SHA1.base64digest(key + GUID)
|
48
|
+
end
|
49
|
+
end
|
29
50
|
end
|
30
51
|
end
|
31
52
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: protocol-websocket
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.6.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Samuel Williams
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-05-
|
11
|
+
date: 2019-05-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: protocol-http
|
@@ -112,10 +112,10 @@ files:
|
|
112
112
|
- lib/protocol/websocket/close_frame.rb
|
113
113
|
- lib/protocol/websocket/connection.rb
|
114
114
|
- lib/protocol/websocket/continuation_frame.rb
|
115
|
-
- lib/protocol/websocket/digest.rb
|
116
115
|
- lib/protocol/websocket/error.rb
|
117
116
|
- lib/protocol/websocket/frame.rb
|
118
117
|
- lib/protocol/websocket/framer.rb
|
118
|
+
- lib/protocol/websocket/headers.rb
|
119
119
|
- lib/protocol/websocket/ping_frame.rb
|
120
120
|
- lib/protocol/websocket/pong_frame.rb
|
121
121
|
- lib/protocol/websocket/text_frame.rb
|
@@ -140,7 +140,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
140
140
|
- !ruby/object:Gem::Version
|
141
141
|
version: '0'
|
142
142
|
requirements: []
|
143
|
-
rubygems_version: 3.0.
|
143
|
+
rubygems_version: 3.0.2
|
144
144
|
signing_key:
|
145
145
|
specification_version: 4
|
146
146
|
summary: A low level implementation of the WebSocket protocol.
|