go-mqtt 0.0.1

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.
@@ -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