This commit is contained in:
Stefan Midjich 2017-09-29 19:01:27 +02:00
parent e08ede6631
commit 7bfebdd4ba
1 changed files with 11 additions and 9 deletions

View File

@ -27,21 +27,23 @@ class Client(object):
# found. # found.
if client_data is None: if client_data is None:
raise StorageNotFound('Client not found') raise StorageNotFound('Client not found')
else:
# Next try to get an existing client by IP and protocol
self.ip_address = kw.pop('ip_address')
self.protocol = kw.pop('protocol')
# Next try to get an existing client by IP and protocol if self.ip_address and self.protocol:
self.ip_address = kw.pop('ip_address') client_data = self.storage.get_client(
self.protocol = kw.pop('protocol') self._ip_address,
self.protocol
if self.ip_address and self.protocol: )
client_data = self.storage.get_client(
self._ip_address,
self.protocol
)
if client_data: if client_data:
self.load_client(client_data) self.load_client(client_data)
else: else:
self.client_id = str(uuid4()) self.client_id = str(uuid4())
self.ip_address = kw.pop('ip_address')
self.protocol = kw.pop('protocol')
self.created = datetime.now() self.created = datetime.now()
self.enabled = False self.enabled = False
self.last_packets = 0 self.last_packets = 0