From 79042070b33eac28ea13a3724e6761aeb28e7ecd Mon Sep 17 00:00:00 2001 From: Marcel Nijenhof Date: Tue, 12 Feb 2019 22:00:49 +0100 Subject: [PATCH] Ssl optioneel gemaakt --- lmwsip.py | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/lmwsip.py b/lmwsip.py index 104d24d..b8247a5 100644 --- a/lmwsip.py +++ b/lmwsip.py @@ -82,25 +82,29 @@ Opens the connection and logs in connects to lmw with tcp using the values of the object creation. """ - self._context = ssl.create_default_context() - self._context.check_hostname = self.check_ssl self._tcp = socket.create_connection((self.host, self.port)) - self._ssl = self._context.wrap_socket(self._tcp, + if (self.ssl): + self._context = ssl.create_default_context() + self._context.check_hostname = self.check_ssl + self._ssl = self._context.wrap_socket(self._tcp, server_hostname=self.host) + self._socket = self._ssl + else: + self._socket = self._tcp def send(self, sipcmd): """send(sipcmd) send a sip command to the server """ - self._ssl.sendall(sipcmd.encode('ascii')) + self._socket.sendall(sipcmd.encode('ascii')) def recv(self): """recv() recieve a answer from the sip server """ - return(self._ssl.recv()) + return(self._socket.recv()) def login(self): """login()