Skip to content

Commit

Permalink
logic cleanup, fixed missing create_socket
Browse files Browse the repository at this point in the history
  • Loading branch information
JohnDoee committed Feb 17, 2024
1 parent 513bb46 commit 88f6215
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions deluge_client/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,20 +68,21 @@ def __init__(self, host, port, username, password, decode_utf8=False, automatic_
self.request_id = 1
self.connected = False

self._create_socket()

def _create_socket(self, ssl_version=None, ciphers=None):
# Insecure context without remote certificate verification
# This logic is a bit messy to try and support various configurations
ssl_context = ssl.SSLContext(protocol=ssl_version or ssl.PROTOCOL_TLS_CLIENT)
if ssl_version is not None:
ssl_context = ssl.SSLContext(protocol=ssl_version)
else:
ssl_context = ssl.SSLContext(protocol=ssl.PROTOCOL_TLS_CLIENT)
ssl_context.check_hostname = False
ssl_context.verify_mode = ssl.CERT_NONE
if ciphers:
ssl_context.set_ciphers("AES256-SHA")

if ssl_version is not None:
self._socket = ssl_context.wrap_socket(socket.socket(socket.AF_INET, socket.SOCK_STREAM))
else:
self._socket = ssl_context.wrap_socket(socket.socket(socket.AF_INET, socket.SOCK_STREAM))
self._socket = ssl_context.wrap_socket(socket.socket(socket.AF_INET, socket.SOCK_STREAM))
self._socket.settimeout(self.timeout)

def connect(self):
Expand Down

0 comments on commit 88f6215

Please sign in to comment.