Merge branch 'incoming'
commit
41a71fccd9
|
@ -1,3 +1,11 @@
|
||||||
|
2017-04-27 Ray Brown <code@liquibits.com>
|
||||||
|
|
||||||
|
Release 1.2.3
|
||||||
|
|
||||||
|
* dtls/wrapper.py: Add optional parameter to DtlsSocket: client_timeout (seconds). If client_timeout is specified, clients that have not communicated within the time frame will be dropped.
|
||||||
|
* setup.py: Version incremented to 1.2.3
|
||||||
|
* dtls/__init__.py: Increment version
|
||||||
|
|
||||||
2017-04-10 Ray Brown <code@liquibits.com>
|
2017-04-10 Ray Brown <code@liquibits.com>
|
||||||
|
|
||||||
Release 1.2.2
|
Release 1.2.2
|
||||||
|
|
|
@ -32,7 +32,7 @@ sockets.
|
||||||
wrap_socket's parameters and their semantics have been maintained.
|
wrap_socket's parameters and their semantics have been maintained.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
VERSION = 1, 2, 2
|
VERSION = 1, 2, 3
|
||||||
|
|
||||||
def _prep_bins():
|
def _prep_bins():
|
||||||
"""
|
"""
|
||||||
|
|
|
@ -72,14 +72,27 @@ class DtlsSocket(object):
|
||||||
|
|
||||||
class _ClientSession(object):
|
class _ClientSession(object):
|
||||||
|
|
||||||
def __init__(self, host, port, handshake_done=False):
|
def __init__(self, host, port, handshake_done=False, timeout=None):
|
||||||
self.host = host
|
self.host = host
|
||||||
self.port = int(port)
|
self.port = int(port)
|
||||||
self.handshake_done = handshake_done
|
self.handshake_done = handshake_done
|
||||||
|
self.timeout = timeout
|
||||||
|
self.updateTimestamp()
|
||||||
|
|
||||||
def getAddr(self):
|
def getAddr(self):
|
||||||
return self.host, self.port
|
return self.host, self.port
|
||||||
|
|
||||||
|
def updateTimestamp(self):
|
||||||
|
if self.timeout != None:
|
||||||
|
self.last_update = time.time()
|
||||||
|
|
||||||
|
def expired(self):
|
||||||
|
if self.timeout == None:
|
||||||
|
return False
|
||||||
|
else:
|
||||||
|
return (time.time() - self.last_update) > self.timeout
|
||||||
|
|
||||||
|
|
||||||
def __init__(self,
|
def __init__(self,
|
||||||
sock=None,
|
sock=None,
|
||||||
keyfile=None,
|
keyfile=None,
|
||||||
|
@ -95,7 +108,8 @@ class DtlsSocket(object):
|
||||||
sigalgs=None,
|
sigalgs=None,
|
||||||
user_mtu=None,
|
user_mtu=None,
|
||||||
server_key_exchange_curve=None,
|
server_key_exchange_curve=None,
|
||||||
server_cert_options=ssl.SSL_BUILD_CHAIN_FLAG_NONE):
|
server_cert_options=ssl.SSL_BUILD_CHAIN_FLAG_NONE,
|
||||||
|
client_timeout=None):
|
||||||
|
|
||||||
if server_cert_options is None:
|
if server_cert_options is None:
|
||||||
server_cert_options = ssl.SSL_BUILD_CHAIN_FLAG_NONE
|
server_cert_options = ssl.SSL_BUILD_CHAIN_FLAG_NONE
|
||||||
|
@ -108,6 +122,7 @@ class DtlsSocket(object):
|
||||||
self._user_mtu = user_mtu
|
self._user_mtu = user_mtu
|
||||||
self._server_key_exchange_curve = server_key_exchange_curve
|
self._server_key_exchange_curve = server_key_exchange_curve
|
||||||
self._server_cert_options = server_cert_options
|
self._server_cert_options = server_cert_options
|
||||||
|
self._client_timeout = client_timeout
|
||||||
|
|
||||||
# Default socket creation
|
# Default socket creation
|
||||||
_sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
|
_sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
|
||||||
|
@ -205,6 +220,7 @@ class DtlsSocket(object):
|
||||||
else:
|
else:
|
||||||
buf = self._clientRead(conn, bufsize)
|
buf = self._clientRead(conn, bufsize)
|
||||||
if buf:
|
if buf:
|
||||||
|
self._clients[conn].updateTimestamp()
|
||||||
if conn in self._clients:
|
if conn in self._clients:
|
||||||
return buf, self._clients[conn].getAddr()
|
return buf, self._clients[conn].getAddr()
|
||||||
else:
|
else:
|
||||||
|
@ -220,6 +236,10 @@ class DtlsSocket(object):
|
||||||
ret = conn.handle_timeout()
|
ret = conn.handle_timeout()
|
||||||
_logger.debug('Retransmission triggered for %s: %d' % (str(self._clients[conn].getAddr()), ret))
|
_logger.debug('Retransmission triggered for %s: %d' % (str(self._clients[conn].getAddr()), ret))
|
||||||
|
|
||||||
|
if self._clients[conn].expired() == True:
|
||||||
|
_logger.debug('Found expired session')
|
||||||
|
self._clientDrop(conn)
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
raise e
|
raise e
|
||||||
|
|
||||||
|
|
2
setup.py
2
setup.py
|
@ -29,7 +29,7 @@ from pickle import dump, load
|
||||||
from setuptools import setup
|
from setuptools import setup
|
||||||
|
|
||||||
NAME = "Dtls"
|
NAME = "Dtls"
|
||||||
VERSION = "1.2.2"
|
VERSION = "1.2.3"
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
# Full upload sequence for new version:
|
# Full upload sequence for new version:
|
||||||
|
|
Loading…
Reference in New Issue