Ssl optioneel gemaakt
This commit is contained in:
10
lmwsip.py
10
lmwsip.py
@@ -82,25 +82,29 @@ Opens the connection and logs in
|
|||||||
|
|
||||||
connects to lmw with tcp using the values of the object creation.
|
connects to lmw with tcp using the values of the object creation.
|
||||||
"""
|
"""
|
||||||
|
self._tcp = socket.create_connection((self.host, self.port))
|
||||||
|
if (self.ssl):
|
||||||
self._context = ssl.create_default_context()
|
self._context = ssl.create_default_context()
|
||||||
self._context.check_hostname = self.check_ssl
|
self._context.check_hostname = self.check_ssl
|
||||||
self._tcp = socket.create_connection((self.host, self.port))
|
|
||||||
self._ssl = self._context.wrap_socket(self._tcp,
|
self._ssl = self._context.wrap_socket(self._tcp,
|
||||||
server_hostname=self.host)
|
server_hostname=self.host)
|
||||||
|
self._socket = self._ssl
|
||||||
|
else:
|
||||||
|
self._socket = self._tcp
|
||||||
|
|
||||||
def send(self, sipcmd):
|
def send(self, sipcmd):
|
||||||
"""send(sipcmd)
|
"""send(sipcmd)
|
||||||
|
|
||||||
send a sip command to the server
|
send a sip command to the server
|
||||||
"""
|
"""
|
||||||
self._ssl.sendall(sipcmd.encode('ascii'))
|
self._socket.sendall(sipcmd.encode('ascii'))
|
||||||
|
|
||||||
def recv(self):
|
def recv(self):
|
||||||
"""recv()
|
"""recv()
|
||||||
|
|
||||||
recieve a answer from the sip server
|
recieve a answer from the sip server
|
||||||
"""
|
"""
|
||||||
return(self._ssl.recv())
|
return(self._socket.recv())
|
||||||
|
|
||||||
def login(self):
|
def login(self):
|
||||||
"""login()
|
"""login()
|
||||||
|
Reference in New Issue
Block a user