Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 13 additions & 3 deletions at_client/connections/atconnection.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,19 +15,29 @@ class AtConnection(ABC):
Abstract base class for connecting to and communicating with an atprotocol server.
"""

def __init__(self, host:str, port:int, context:ssl.SSLContext, verbose:bool=False):
def __init__(self, host:str, port:int, context:ssl.SSLContext=None, verbose:bool=False):
"""
Initialize the AtConnection object.

Parameters:
- host (str): The host name or IP address of the server.
- port (int): The port number of the server.
- context (ssl.SSLContext): The SSL context for secure connections.
- context (ssl.SSLContext, optional): The SSL context for secure connections.
- verbose (bool, optional): Indicates if verbose output is enabled (default is False).
"""
if isinstance(context, ssl.SSLContext):
context.minimum_version = ssl.TLSVersion.TLSv1_2
self._context = context
elif isinstance(context, bool):
verbose = context
self._context = ssl.create_default_context()
self._context.minimum_version = ssl.TLSVersion.TLSv1_2
else:
self._context = ssl.create_default_context()
self._context.minimum_version = ssl.TLSVersion.TLSv1_2

self._host = host
self._port = port
self._context = context
self._addr_info = socket.getaddrinfo(host, port)[0][-1]
self._socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
self._secure_root_socket = None
Expand Down
2 changes: 1 addition & 1 deletion at_client/connections/atmonitorconnection.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class AtMonitorConnection(AtSecondaryConnection):
should_be_running: bool = False

def __init__(self, queue: queue.Queue, atsign: AtSign, address: Address,
context: ssl.SSLContext = ssl.create_default_context(),
context: ssl.SSLContext = None,
verbose: bool = True, regex=".*", last_received_time: int = 0):
self.atsign = atsign
self.queue = queue
Expand Down
4 changes: 2 additions & 2 deletions at_client/connections/atrootconnection.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class AtRootConnection(AtConnection):
__instance = None

@staticmethod
def get_instance(host:str='root.atsign.org', port:int=64, context:ssl.SSLContext=ssl.create_default_context(), verbose:bool=False):
def get_instance(host:str='root.atsign.org', port:int=64, context:ssl.SSLContext=None, verbose:bool=False):
"""
Get an instance of AtRootConnection using the singleton pattern.

Expand All @@ -25,7 +25,7 @@ def get_instance(host:str='root.atsign.org', port:int=64, context:ssl.SSLContext
port : int, optional
The port number of the root server (default is 64).
context : ssl.SSLContext, optional
The SSL context for secure connections (default is ssl.create_default_context()).
The SSL context for secure connections (default is None).
verbose : bool, optional
Indicates if verbose output is enabled (default is False).

Expand Down
4 changes: 2 additions & 2 deletions at_client/connections/atsecondaryconnection.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ class AtSecondaryConnection(AtConnection):
Subclass of AtConnection representing a connection to the secondary server in the atprotocol.
"""

def __init__(self, address: Address, context:ssl.SSLContext=ssl.create_default_context(), verbose:bool=False):
def __init__(self, address: Address, context:ssl.SSLContext=None, verbose:bool=False):
"""
Initialize the AtSecondaryConnection object.

Expand All @@ -20,7 +20,7 @@ def __init__(self, address: Address, context:ssl.SSLContext=ssl.create_default_c
port : int
The port number of the secondary server.
context : ssl.SSLContext, optional
The SSL context for secure connections (default is ssl.create_default_context()).
The SSL context for secure connections (default is None).
verbose : bool, optional
Indicates if verbose output is enabled (default is False).
"""
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "atsdk"
version = "0.2.73"
version = "0.2.74"
description = "Python SDK for atPlatform"
authors = ["Umang Shah <shahumang19@gmail.com>","Chris Swan <chris@atsign.com>"]
maintainers = ["Chris Swan <chris@atsign.com>"]
Expand Down