Skip to content

Commit

Permalink
Upgraded websocket-client module to fix Radarr SignalRCore disconnect…
Browse files Browse the repository at this point in the history
…ion issues.
  • Loading branch information
morpheus65535 committed May 18, 2021
1 parent baf25b2 commit 70a0f68
Show file tree
Hide file tree
Showing 21 changed files with 1,363 additions and 645 deletions.
2 changes: 1 addition & 1 deletion libs/version.txt
Expand Up @@ -40,7 +40,7 @@ subliminal=2.1.0dev
tzlocal=2.1b1
twine=3.4.1
urllib3=1.23
websocket-client=0.54.0
websocket-client=0.59.0 <-- Modified to work with SignalRCore: https://github.com/websocket-client/websocket-client/commit/3112b7d75b1e5d65cb8fdfca7801606649044ed1#commitcomment-50947250

## indirect dependencies
auditok=0.1.5 # Required-by: ffsubsync
Expand Down
5 changes: 2 additions & 3 deletions libs/websocket/__init__.py
Expand Up @@ -15,8 +15,7 @@
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1335 USA
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
"""
from ._abnf import *
Expand All @@ -26,4 +25,4 @@
from ._logging import *
from ._socket import *

__version__ = "0.54.0"
__version__ = "0.59.0"
57 changes: 34 additions & 23 deletions libs/websocket/_abnf.py
@@ -1,3 +1,7 @@
"""
"""

"""
websocket - WebSocket client library for Python
Expand All @@ -15,8 +19,7 @@
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1335 USA
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
"""
import array
Expand Down Expand Up @@ -105,7 +108,7 @@ def _mask(_m, _d):
class ABNF(object):
"""
ABNF frame class.
see http://tools.ietf.org/html/rfc5234
See http://tools.ietf.org/html/rfc5234
and http://tools.ietf.org/html/rfc6455#section-5.2
"""

Expand Down Expand Up @@ -139,8 +142,7 @@ class ABNF(object):
def __init__(self, fin=0, rsv1=0, rsv2=0, rsv3=0,
opcode=OPCODE_TEXT, mask=1, data=""):
"""
Constructor for ABNF.
please check RFC for arguments.
Constructor for ABNF. Please check RFC for arguments.
"""
self.fin = fin
self.rsv1 = rsv1
Expand All @@ -155,7 +157,10 @@ def __init__(self, fin=0, rsv1=0, rsv2=0, rsv3=0,

def validate(self, skip_utf8_validation=False):
"""
validate the ABNF frame.
Validate the ABNF frame.
Parameters
----------
skip_utf8_validation: skip utf8 validation.
"""
if self.rsv1 or self.rsv2 or self.rsv3:
Expand Down Expand Up @@ -193,15 +198,18 @@ def __str__(self):
@staticmethod
def create_frame(data, opcode, fin=1):
"""
create frame to send text, binary and other data.
Create frame to send text, binary and other data.
data: data to send. This is string value(byte array).
if opcode is OPCODE_TEXT and this value is unicode,
Parameters
----------
data: <type>
data to send. This is string value(byte array).
If opcode is OPCODE_TEXT and this value is unicode,
data value is converted into unicode string, automatically.
opcode: operation code. please see OPCODE_XXX.
fin: fin flag. if set to 0, create continue fragmentation.
opcode: <type>
operation code. please see OPCODE_XXX.
fin: <type>
fin flag. if set to 0, create continue fragmentation.
"""
if opcode == ABNF.OPCODE_TEXT and isinstance(data, six.text_type):
data = data.encode("utf-8")
Expand All @@ -210,7 +218,7 @@ def create_frame(data, opcode, fin=1):

def format(self):
"""
format this object to string(byte array) to send data to server.
Format this object to string(byte array) to send data to server.
"""
if any(x not in (0, 1) for x in [self.fin, self.rsv1, self.rsv2, self.rsv3]):
raise ValueError("not 0 or 1")
Expand All @@ -220,9 +228,9 @@ def format(self):
if length >= ABNF.LENGTH_63:
raise ValueError("data is too long")

frame_header = chr(self.fin << 7
| self.rsv1 << 6 | self.rsv2 << 5 | self.rsv3 << 4
| self.opcode)
frame_header = chr(self.fin << 7 |
self.rsv1 << 6 | self.rsv2 << 5 | self.rsv3 << 4 |
self.opcode)
if length < ABNF.LENGTH_7:
frame_header += chr(self.mask << 7 | length)
frame_header = six.b(frame_header)
Expand Down Expand Up @@ -252,11 +260,14 @@ def _get_masked(self, mask_key):
@staticmethod
def mask(mask_key, data):
"""
mask or unmask data. Just do xor for each byte
mask_key: 4 byte string(byte).
data: data to mask/unmask.
Mask or unmask data. Just do xor for each byte
Parameters
----------
mask_key: <type>
4 byte string(byte).
data: <type>
data to mask/unmask.
"""
if data is None:
data = ""
Expand All @@ -276,7 +287,7 @@ def mask(mask_key, data):
a = numpy.frombuffer(data, dtype="uint32")
masked = numpy.bitwise_xor(a, [_mask_key]).astype("uint32")
if len(data) > origlen:
return masked.tobytes()[:origlen]
return masked.tobytes()[:origlen]
return masked.tobytes()
else:
_m = array.array("B", mask_key)
Expand Down

0 comments on commit 70a0f68

Please sign in to comment.