Ssl optioneel gemaakt
This commit is contained in:
14
lmwsip.py
14
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()
|
||||
|
Reference in New Issue
Block a user