protocol-websocket 0.19.0 → 0.20.0

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: a0ce7a7a66a43bf2fd5ec0af4a6050feb443adb076b75b2d3037cccbd9012fa4
4
- data.tar.gz: c672fa5bca423ca23f0b9d608d6a6e89058eaca979d939ad4e01c606b51175ed
3
+ metadata.gz: c0f42ab3d5253103ee0a3bc0b3b6ad1ba09c34cd05aa0ae8abcad14cf41889f5
4
+ data.tar.gz: e543425bcc0219da7de6d8bf25c55cb27e2065ab3848090a0464558d929c1e79
5
5
  SHA512:
6
- metadata.gz: 598365c3df8b46fb6e79668a8d8bb452eb1e973f04f31c16346a391884448bda2d2869a6affcb2a3513a5b2dc6fab66e110f7eaebfe2593f9a50eb0bc624eb46
7
- data.tar.gz: 4fadd3a84c98f07fbbae57a766178f85d1042500c8403e944992a3f118180c8d9952e5997c963cd26c5e843bf0e45802f2da1372a94288989ce5e1578eca0aba
6
+ metadata.gz: c4f5c67e456e61dceab5407edc739e6c14c165f9d9e123459c64d307c4573f8db2d8ac441d13e009bdbfba34a2d5342db314a03d97635816be6a1031b156f401
7
+ data.tar.gz: 268a562e395ae6bfbe2460881af7fe81a549ee43f1a95e2039250a8d50d15b217a2d1a251ca56e59e5b33866f1ecfc16b3b8efb861f4d15a449e07f8df1ddfe9
checksums.yaml.gz.sig CHANGED
Binary file
@@ -23,6 +23,7 @@ module Protocol
23
23
  # @parameter mask [Boolean | String] An optional 4-byte string which is used to mask the payload.
24
24
  def initialize(finished = true, payload = nil, flags: 0, opcode: self.class::OPCODE, mask: false)
25
25
  if mask == true
26
+ # Generate a unique mask for each frame:
26
27
  mask = SecureRandom.bytes(4)
27
28
  end
28
29
 
@@ -29,9 +29,11 @@ module Protocol
29
29
 
30
30
  # Wraps an underlying {Async::IO::Stream} for reading and writing binary data into structured frames.
31
31
  class Framer
32
- def initialize(stream, frames = FRAMES)
32
+ def initialize(stream, frames = FRAMES, requires_masking: false)
33
33
  @stream = stream
34
34
  @frames = frames
35
+
36
+ @requires_masking = requires_masking
35
37
  end
36
38
 
37
39
  # Close the underlying stream.
@@ -54,6 +56,10 @@ module Protocol
54
56
  klass = @frames[opcode] || Frame
55
57
  frame = klass.read(finished, flags, opcode, @stream, maximum_frame_size)
56
58
 
59
+ if @requires_masking and !frame.mask
60
+ raise ProtocolError, "Received unmasked frame but requires masking!"
61
+ end
62
+
57
63
  return frame
58
64
  end
59
65
 
@@ -15,7 +15,7 @@ module Protocol
15
15
  # Generate a suitable reply.
16
16
  # @returns [PongFrame]
17
17
  def reply(**options)
18
- PongFrame.new(true, self.unpack, **options)
18
+ PongFrame.new(true, **options).pack(self.unpack)
19
19
  end
20
20
 
21
21
  # Apply this frame to the specified connection.
@@ -5,6 +5,6 @@
5
5
 
6
6
  module Protocol
7
7
  module WebSocket
8
- VERSION = "0.19.0"
8
+ VERSION = "0.20.0"
9
9
  end
10
10
  end
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.19.0
4
+ version: 0.20.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-25 00:00:00.000000000 Z
44
+ date: 2024-10-09 00:00:00.000000000 Z
45
45
  dependencies:
46
46
  - !ruby/object:Gem::Dependency
47
47
  name: protocol-http
metadata.gz.sig CHANGED
Binary file