protocol-websocket 0.17.0 → 0.19.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data/lib/protocol/websocket/binary_frame.rb +2 -2
- data/lib/protocol/websocket/close_frame.rb +1 -1
- data/lib/protocol/websocket/coder/json.rb +1 -1
- data/lib/protocol/websocket/coder.rb +1 -1
- data/lib/protocol/websocket/connection.rb +2 -3
- data/lib/protocol/websocket/continuation_frame.rb +1 -1
- data/lib/protocol/websocket/error.rb +1 -1
- data/lib/protocol/websocket/extension/compression/constants.rb +3 -3
- data/lib/protocol/websocket/extension/compression/deflate.rb +2 -2
- data/lib/protocol/websocket/extension/compression/inflate.rb +3 -3
- data/lib/protocol/websocket/extension/compression.rb +6 -6
- data/lib/protocol/websocket/extensions.rb +3 -3
- data/lib/protocol/websocket/frame.rb +6 -6
- data/lib/protocol/websocket/framer.rb +7 -7
- data/lib/protocol/websocket/headers.rb +9 -9
- data/lib/protocol/websocket/message.rb +10 -3
- data/lib/protocol/websocket/ping_frame.rb +2 -2
- data/lib/protocol/websocket/pong_frame.rb +1 -1
- data/lib/protocol/websocket/text_frame.rb +2 -2
- data/lib/protocol/websocket/version.rb +1 -1
- data/lib/protocol/websocket.rb +4 -4
- data.tar.gz.sig +0 -0
- metadata +2 -3
- metadata.gz.sig +0 -0
- data/lib/protocol/websocket/json_message.rb +0 -23
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a0ce7a7a66a43bf2fd5ec0af4a6050feb443adb076b75b2d3037cccbd9012fa4
|
4
|
+
data.tar.gz: c672fa5bca423ca23f0b9d608d6a6e89058eaca979d939ad4e01c606b51175ed
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 598365c3df8b46fb6e79668a8d8bb452eb1e973f04f31c16346a391884448bda2d2869a6affcb2a3513a5b2dc6fab66e110f7eaebfe2593f9a50eb0bc624eb46
|
7
|
+
data.tar.gz: 4fadd3a84c98f07fbbae57a766178f85d1042500c8403e944992a3f118180c8d9952e5997c963cd26c5e843bf0e45802f2da1372a94288989ce5e1578eca0aba
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
@@ -5,8 +5,7 @@
|
|
5
5
|
# Copyright, 2019, by William T. Nelson.
|
6
6
|
# Copyright, 2021, by Aurora Nockert.
|
7
7
|
|
8
|
-
require_relative
|
9
|
-
require 'securerandom'
|
8
|
+
require_relative "framer"
|
10
9
|
|
11
10
|
module Protocol
|
12
11
|
module WebSocket
|
@@ -267,7 +266,7 @@ module Protocol
|
|
267
266
|
def write(message, **options)
|
268
267
|
case message
|
269
268
|
when String
|
270
|
-
|
269
|
+
# This is a compatibility shim for the previous implementation. We may want to eventually deprecate this use case... or maybe it's convenient enough to leave it around.
|
271
270
|
if message.encoding == Encoding::UTF_8
|
272
271
|
return send_text(message, **options)
|
273
272
|
else
|
@@ -1,15 +1,15 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
# Released under the MIT License.
|
4
|
-
# Copyright, 2022-
|
4
|
+
# Copyright, 2022-2024, by Samuel Williams.
|
5
5
|
|
6
|
-
require
|
6
|
+
require "zlib"
|
7
7
|
|
8
8
|
module Protocol
|
9
9
|
module WebSocket
|
10
10
|
module Extension
|
11
11
|
module Compression
|
12
|
-
NAME =
|
12
|
+
NAME = "permessage-deflate"
|
13
13
|
|
14
14
|
# Zlib is not capable of handling < 9 window bits.
|
15
15
|
MINIMUM_WINDOW_BITS = 9
|
@@ -1,9 +1,9 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
# Released under the MIT License.
|
4
|
-
# Copyright, 2022-
|
4
|
+
# Copyright, 2022-2024, by Samuel Williams.
|
5
5
|
|
6
|
-
require_relative
|
6
|
+
require_relative "constants"
|
7
7
|
|
8
8
|
module Protocol
|
9
9
|
module WebSocket
|
@@ -1,9 +1,9 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
# Released under the MIT License.
|
4
|
-
# Copyright, 2022-
|
4
|
+
# Copyright, 2022-2024, by Samuel Williams.
|
5
5
|
|
6
|
-
require_relative
|
6
|
+
require_relative "constants"
|
7
7
|
|
8
8
|
module Protocol
|
9
9
|
module WebSocket
|
@@ -26,7 +26,7 @@ module Protocol
|
|
26
26
|
)
|
27
27
|
end
|
28
28
|
|
29
|
-
TRAILER = [0x00, 0x00, 0xff, 0xff].pack(
|
29
|
+
TRAILER = [0x00, 0x00, 0xff, 0xff].pack("C*")
|
30
30
|
|
31
31
|
def initialize(parent, context_takeover: true, window_bits: 15)
|
32
32
|
@parent = parent
|
@@ -3,9 +3,9 @@
|
|
3
3
|
# Released under the MIT License.
|
4
4
|
# Copyright, 2022-2024, by Samuel Williams.
|
5
5
|
|
6
|
-
require_relative
|
7
|
-
require_relative
|
8
|
-
require_relative
|
6
|
+
require_relative "compression/constants"
|
7
|
+
require_relative "compression/inflate"
|
8
|
+
require_relative "compression/deflate"
|
9
9
|
|
10
10
|
module Protocol
|
11
11
|
module WebSocket
|
@@ -22,13 +22,13 @@ module Protocol
|
|
22
22
|
when 8..15
|
23
23
|
header << "client_max_window_bits=#{client_max_window_bits}"
|
24
24
|
when true
|
25
|
-
header <<
|
25
|
+
header << "client_max_window_bits"
|
26
26
|
else
|
27
27
|
raise ArgumentError, "Invalid local maximum window bits!"
|
28
28
|
end
|
29
29
|
|
30
30
|
if client_no_context_takeover
|
31
|
-
header <<
|
31
|
+
header << "client_no_context_takeover"
|
32
32
|
end
|
33
33
|
|
34
34
|
case server_max_window_bits
|
@@ -41,7 +41,7 @@ module Protocol
|
|
41
41
|
end
|
42
42
|
|
43
43
|
if server_no_context_takeover
|
44
|
-
header <<
|
44
|
+
header << "server_no_context_takeover"
|
45
45
|
end
|
46
46
|
|
47
47
|
return header
|
@@ -3,8 +3,8 @@
|
|
3
3
|
# Released under the MIT License.
|
4
4
|
# Copyright, 2022-2024, by Samuel Williams.
|
5
5
|
|
6
|
-
require_relative
|
7
|
-
require_relative
|
6
|
+
require_relative "extension/compression"
|
7
|
+
require_relative "headers"
|
8
8
|
|
9
9
|
module Protocol
|
10
10
|
module WebSocket
|
@@ -16,7 +16,7 @@ module Protocol
|
|
16
16
|
name, *arguments = header.split(/\s*;\s*/)
|
17
17
|
|
18
18
|
arguments = arguments.map do |argument|
|
19
|
-
argument.split(
|
19
|
+
argument.split("=", 2)
|
20
20
|
end
|
21
21
|
|
22
22
|
yield name, arguments
|
@@ -5,7 +5,7 @@
|
|
5
5
|
# Copyright, 2019, by Soumya.
|
6
6
|
# Copyright, 2021, by Aurora Nockert.
|
7
7
|
|
8
|
-
require_relative
|
8
|
+
require_relative "error"
|
9
9
|
|
10
10
|
module Protocol
|
11
11
|
module WebSocket
|
@@ -178,10 +178,10 @@ module Protocol
|
|
178
178
|
|
179
179
|
if length == 126
|
180
180
|
buffer = stream.read(2) or raise EOFError, "Could not read length!"
|
181
|
-
length = buffer.unpack(
|
181
|
+
length = buffer.unpack("n").first
|
182
182
|
elsif length == 127
|
183
183
|
buffer = stream.read(8) or raise EOFError, "Could not read length!"
|
184
|
-
length = buffer.unpack(
|
184
|
+
length = buffer.unpack("Q>").first
|
185
185
|
end
|
186
186
|
|
187
187
|
if length > maximum_frame_size
|
@@ -223,12 +223,12 @@ module Protocol
|
|
223
223
|
buffer << [
|
224
224
|
(@finished ? 0b1000_0000 : 0) | (@flags << 4) | @opcode,
|
225
225
|
(@mask ? 0b1000_0000 : 0) | short_length,
|
226
|
-
].pack(
|
226
|
+
].pack("CC")
|
227
227
|
|
228
228
|
if short_length == 126
|
229
|
-
buffer << [@length].pack(
|
229
|
+
buffer << [@length].pack("n")
|
230
230
|
elsif short_length == 127
|
231
|
-
buffer << [@length].pack(
|
231
|
+
buffer << [@length].pack("Q>")
|
232
232
|
end
|
233
233
|
|
234
234
|
buffer << @mask if @mask
|
@@ -3,14 +3,14 @@
|
|
3
3
|
# Released under the MIT License.
|
4
4
|
# Copyright, 2019-2024, by Samuel Williams.
|
5
5
|
|
6
|
-
require_relative
|
6
|
+
require_relative "frame"
|
7
7
|
|
8
|
-
require_relative
|
9
|
-
require_relative
|
10
|
-
require_relative
|
11
|
-
require_relative
|
12
|
-
require_relative
|
13
|
-
require_relative
|
8
|
+
require_relative "continuation_frame"
|
9
|
+
require_relative "text_frame"
|
10
|
+
require_relative "binary_frame"
|
11
|
+
require_relative "close_frame"
|
12
|
+
require_relative "ping_frame"
|
13
|
+
require_relative "pong_frame"
|
14
14
|
|
15
15
|
module Protocol
|
16
16
|
module WebSocket
|
@@ -1,27 +1,27 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
# Released under the MIT License.
|
4
|
-
# Copyright, 2019-
|
4
|
+
# Copyright, 2019-2024, by Samuel Williams.
|
5
5
|
|
6
|
-
require
|
7
|
-
require
|
6
|
+
require "digest/sha1"
|
7
|
+
require "securerandom"
|
8
8
|
|
9
9
|
module Protocol
|
10
10
|
module WebSocket
|
11
11
|
module Headers
|
12
12
|
# The protocol string used for the `upgrade:` header (HTTP/1) and `:protocol` pseudo-header (HTTP/2).
|
13
|
-
PROTOCOL = "websocket"
|
13
|
+
PROTOCOL = "websocket"
|
14
14
|
|
15
15
|
# The WebSocket protocol header, used for application level protocol negotiation.
|
16
|
-
SEC_WEBSOCKET_PROTOCOL =
|
16
|
+
SEC_WEBSOCKET_PROTOCOL = "sec-websocket-protocol"
|
17
17
|
|
18
18
|
# The WebSocket version header. Used for negotiating binary protocol version.
|
19
|
-
SEC_WEBSOCKET_VERSION =
|
19
|
+
SEC_WEBSOCKET_VERSION = "sec-websocket-version"
|
20
20
|
|
21
|
-
SEC_WEBSOCKET_KEY =
|
22
|
-
SEC_WEBSOCKET_ACCEPT =
|
21
|
+
SEC_WEBSOCKET_KEY = "sec-websocket-key"
|
22
|
+
SEC_WEBSOCKET_ACCEPT = "sec-websocket-accept"
|
23
23
|
|
24
|
-
SEC_WEBSOCKET_EXTENSIONS =
|
24
|
+
SEC_WEBSOCKET_EXTENSIONS = "sec-websocket-extensions"
|
25
25
|
|
26
26
|
module Nounce
|
27
27
|
GUID = "258EAFA5-E914-47DA-95CA-C5AB0DC85B11"
|
@@ -3,8 +3,8 @@
|
|
3
3
|
# Released under the MIT License.
|
4
4
|
# Copyright, 2022-2024, by Samuel Williams.
|
5
5
|
|
6
|
-
require_relative
|
7
|
-
require_relative
|
6
|
+
require_relative "frame"
|
7
|
+
require_relative "coder"
|
8
8
|
|
9
9
|
module Protocol
|
10
10
|
module WebSocket
|
@@ -12,7 +12,7 @@ module Protocol
|
|
12
12
|
class Message
|
13
13
|
# Create a new message from a buffer.
|
14
14
|
# @attribute buffer [String] The message buffer.
|
15
|
-
def initialize(buffer)
|
15
|
+
def initialize(buffer = "")
|
16
16
|
@buffer = buffer
|
17
17
|
end
|
18
18
|
|
@@ -72,5 +72,12 @@ module Protocol
|
|
72
72
|
connection.send_binary(@buffer, **options)
|
73
73
|
end
|
74
74
|
end
|
75
|
+
|
76
|
+
# Represents a ping message that can be sent over a WebSocket connection.
|
77
|
+
class PingMessage < Message
|
78
|
+
def send(connection)
|
79
|
+
connection.send_ping(@buffer)
|
80
|
+
end
|
81
|
+
end
|
75
82
|
end
|
76
83
|
end
|
data/lib/protocol/websocket.rb
CHANGED
@@ -3,7 +3,7 @@
|
|
3
3
|
# Released under the MIT License.
|
4
4
|
# Copyright, 2019-2024, by Samuel Williams.
|
5
5
|
|
6
|
-
require_relative
|
7
|
-
require_relative
|
8
|
-
require_relative
|
9
|
-
require_relative
|
6
|
+
require_relative "websocket/version"
|
7
|
+
require_relative "websocket/framer"
|
8
|
+
require_relative "websocket/connection"
|
9
|
+
require_relative "websocket/message"
|
data.tar.gz.sig
CHANGED
Binary file
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: protocol-websocket
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.19.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Samuel Williams
|
@@ -41,7 +41,7 @@ cert_chain:
|
|
41
41
|
Q2K9NVun/S785AP05vKkXZEFYxqG6EW012U4oLcFl5MySFajYXRYbuUpH6AY+HP8
|
42
42
|
voD0MPg1DssDLKwXyt1eKD/+Fq0bFWhwVM/1XiAXL7lyYUyOq24KHgQ2Csg=
|
43
43
|
-----END CERTIFICATE-----
|
44
|
-
date: 2024-09-
|
44
|
+
date: 2024-09-25 00:00:00.000000000 Z
|
45
45
|
dependencies:
|
46
46
|
- !ruby/object:Gem::Dependency
|
47
47
|
name: protocol-http
|
@@ -79,7 +79,6 @@ files:
|
|
79
79
|
- lib/protocol/websocket/frame.rb
|
80
80
|
- lib/protocol/websocket/framer.rb
|
81
81
|
- lib/protocol/websocket/headers.rb
|
82
|
-
- lib/protocol/websocket/json_message.rb
|
83
82
|
- lib/protocol/websocket/message.rb
|
84
83
|
- lib/protocol/websocket/ping_frame.rb
|
85
84
|
- lib/protocol/websocket/pong_frame.rb
|
metadata.gz.sig
CHANGED
Binary file
|
@@ -1,23 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
# Released under the MIT License.
|
4
|
-
# Copyright, 2022-2024, by Samuel Williams.
|
5
|
-
|
6
|
-
require_relative 'message'
|
7
|
-
|
8
|
-
warn "Protocol::WebSocket::JSONMessage is deprecated. Use Protocol::WebSocket::TextMessage instead."
|
9
|
-
|
10
|
-
module Protocol
|
11
|
-
module WebSocket
|
12
|
-
# @deprecated Use {TextMessage} instead.
|
13
|
-
class JSONMessage < TextMessage
|
14
|
-
def self.wrap(message)
|
15
|
-
message
|
16
|
-
end
|
17
|
-
|
18
|
-
def self.generate(object)
|
19
|
-
self.new(JSON.generate(object))
|
20
|
-
end
|
21
|
-
end
|
22
|
-
end
|
23
|
-
end
|