mqtt 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 +5 -5
- data/NEWS.md +1 -1
- data/README.md +1 -1
- data/lib/mqtt/client.rb +495 -479
- data/lib/mqtt/openssl_fix.rb +29 -0
- data/lib/mqtt/packet.rb +181 -234
- data/lib/mqtt/patches/string_encoding.rb +5 -7
- data/lib/mqtt/proxy.rb +81 -85
- data/lib/mqtt/sn/packet.rb +469 -512
- data/lib/mqtt/version.rb +1 -1
- data/lib/mqtt.rb +1 -3
- data/spec/mqtt_client_spec.rb +78 -7
- data/spec/mqtt_packet_spec.rb +8 -0
- metadata +24 -10
@@ -0,0 +1,29 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# This is a monkey patch to work around a missing method in OpenSSL. Older
|
4
|
+
# versions of OpenSSL were missing the `getbyte` method (regular sockets have
|
5
|
+
# a getbyte method but OpenSSL sockets didn't). We added `getbyte` to OpenSSL
|
6
|
+
# here: https://github.com/ruby/openssl/pull/438
|
7
|
+
#
|
8
|
+
# This patch is just to backport the `getbyte` method until folks are able to
|
9
|
+
# upgrade OpenSSL packages
|
10
|
+
unless OpenSSL::SSL::SSLSocket.method_defined?(:getbyte)
|
11
|
+
class OpenSSL::SSL::SSLSocket
|
12
|
+
def getbyte
|
13
|
+
byte = read(1)
|
14
|
+
byte && unpack_byte(byte)
|
15
|
+
end
|
16
|
+
|
17
|
+
private
|
18
|
+
|
19
|
+
if ''.respond_to?(:unpack1)
|
20
|
+
def unpack_byte(str)
|
21
|
+
str.unpack1('C')
|
22
|
+
end
|
23
|
+
else
|
24
|
+
def unpack_byte(str)
|
25
|
+
str.unpack('C').first
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|