protocol-zmtp 0.1.1 → 0.1.2
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/lib/protocol/zmtp/codec/frame.rb +5 -1
- data/lib/protocol/zmtp/connection.rb +6 -6
- data/lib/protocol/zmtp/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: dafca992ff161d0cdb81664bfc85fd7f9194517222dcb5d11426a35c6a5f1c38
|
|
4
|
+
data.tar.gz: 9176b6c3090ef6ccaab8c37bb95d00f781a91c38a57606f08215ccaaf835726c
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 0aeecc4dd2454e4953ca64a5211aae337cc05846a348434f90cecd258495aefcac9489dc264df65dcbe9e7d0c266436ecdca355c80a8e4423a4b6c052d904f91
|
|
7
|
+
data.tar.gz: f725b19d48b976315b64e2c1f44663f0454db080a737de074f84a77122e623e8673afb7d662627972d680b6b9af7c209aab90c4c95a1a2654706b5daefe89dd9
|
|
@@ -73,7 +73,7 @@ module Protocol
|
|
|
73
73
|
# @return [Frame]
|
|
74
74
|
# @raise [Error] on invalid frame
|
|
75
75
|
# @raise [EOFError] if the connection is closed
|
|
76
|
-
def self.read_from(io)
|
|
76
|
+
def self.read_from(io, max_message_size: nil)
|
|
77
77
|
flags = io.read_exactly(1).getbyte(0)
|
|
78
78
|
|
|
79
79
|
more = (flags & FLAGS_MORE) != 0
|
|
@@ -86,6 +86,10 @@ module Protocol
|
|
|
86
86
|
io.read_exactly(1).getbyte(0)
|
|
87
87
|
end
|
|
88
88
|
|
|
89
|
+
if max_message_size && size > max_message_size
|
|
90
|
+
raise Error, "frame size #{size} exceeds max_message_size #{max_message_size}"
|
|
91
|
+
end
|
|
92
|
+
|
|
89
93
|
body = size > 0 ? io.read_exactly(size) : "".b
|
|
90
94
|
|
|
91
95
|
new(body, more: more, command: command)
|
|
@@ -160,18 +160,18 @@ module Protocol
|
|
|
160
160
|
# @raise [EOFError] if connection is closed
|
|
161
161
|
def read_frame
|
|
162
162
|
loop do
|
|
163
|
-
|
|
163
|
+
begin
|
|
164
|
+
frame = Codec::Frame.read_from(@io, max_message_size: @max_message_size)
|
|
165
|
+
rescue Error
|
|
166
|
+
close
|
|
167
|
+
raise
|
|
168
|
+
end
|
|
164
169
|
touch_heartbeat
|
|
165
170
|
|
|
166
171
|
if @mechanism.encrypted? && frame.body.bytesize > 8 && frame.body.byteslice(0, 8) == "\x07MESSAGE".b
|
|
167
172
|
frame = @mechanism.decrypt(frame)
|
|
168
173
|
end
|
|
169
174
|
|
|
170
|
-
if @max_message_size && !frame.command? && frame.body.bytesize > @max_message_size
|
|
171
|
-
close
|
|
172
|
-
raise Error, "frame size #{frame.body.bytesize} exceeds max_message_size #{@max_message_size}"
|
|
173
|
-
end
|
|
174
|
-
|
|
175
175
|
if frame.command?
|
|
176
176
|
cmd = Codec::Command.from_body(frame.body)
|
|
177
177
|
case cmd.name
|