|
|
|
|
88
|
def add(self, service_id, data_id, callback, *args, **kwargs):
|
88
|
def add(self, service_id, data_id, callback, *args, **kwargs):
|
89
|
cb_data = self.get(service_id, data_id)
|
89
|
cb_data = self.get(service_id, data_id)
|
90
|
if cb_data != (None, None, None):
|
90
|
if cb_data != (None, None, None):
|
|
|
91
|
+<<<<<<< HEAD
|
91
|
self.logger.warning("Overwriting existing callback %s for service_id (%s) and data_id (%s) to %s!", repr(cb_data[0].__name__), repr(service_id), repr(data_id), repr(callback.__name__))
|
92
|
self.logger.warning("Overwriting existing callback %s for service_id (%s) and data_id (%s) to %s!", repr(cb_data[0].__name__), repr(service_id), repr(data_id), repr(callback.__name__))
|
|
|
93
|
+=======
|
|
|
94
|
+ logger.warning("Overwriting existing callback %s for service_id (%s) and data_id (%s) to %s!" , repr(cb_data[0].__name__), repr(service_id), repr(data_id), repr(callback.__name__))
|
|
|
95
|
+>>>>>>> 8beacaef2257e82852e1c0b5442ec4d09b891b7c
|
92
|
if service_id not in self:
|
96
|
if service_id not in self:
|
93
|
self[service_id] = {}
|
97
|
self[service_id] = {}
|
94
|
self[service_id][data_id] = (callback, args, kwargs)
|
98
|
self[service_id][data_id] = (callback, args, kwargs)
|
|
|
|
|
143
|
|
147
|
|
144
|
.. literalinclude:: ../../socket_protocol/_examples_/socket_protocol__struct_json_protocol_client.log
|
148
|
.. literalinclude:: ../../socket_protocol/_examples_/socket_protocol__struct_json_protocol_client.log
|
145
|
"""
|
149
|
"""
|
|
|
150
|
+<<<<<<< HEAD
|
146
|
DEFAULT_CHANNEL_NAME = 'all_others'
|
151
|
DEFAULT_CHANNEL_NAME = 'all_others'
|
147
|
|
152
|
|
|
|
153
|
+=======
|
|
|
154
|
+>>>>>>> 8beacaef2257e82852e1c0b5442ec4d09b891b7c
|
148
|
SID_AUTH_SEED_REQUEST = 1
|
155
|
SID_AUTH_SEED_REQUEST = 1
|
149
|
SID_AUTH_KEY_REQUEST = 2
|
156
|
SID_AUTH_KEY_REQUEST = 2
|
150
|
SID_AUTH_KEY_CHECK_REQUEST = 3
|
157
|
SID_AUTH_KEY_CHECK_REQUEST = 3
|
|
|
|
|
196
|
self.__comm_inst__ = comm_instance
|
203
|
self.__comm_inst__ = comm_instance
|
197
|
self.__secret__ = secret
|
204
|
self.__secret__ = secret
|
198
|
self.__auto_auth__ = auto_auth
|
205
|
self.__auto_auth__ = auto_auth
|
|
|
206
|
+<<<<<<< HEAD
|
199
|
#
|
207
|
#
|
200
|
self.__callbacks__ = callback_storage(channel_name)
|
208
|
self.__callbacks__ = callback_storage(channel_name)
|
201
|
self.__init_channel_name__(channel_name)
|
209
|
self.__init_channel_name__(channel_name)
|
|
|
210
|
+=======
|
|
|
211
|
+ self.__channel_name__ = channel_name
|
|
|
212
|
+>>>>>>> 8beacaef2257e82852e1c0b5442ec4d09b891b7c
|
202
|
#
|
213
|
#
|
203
|
self.__clean_receive_buffer__()
|
214
|
self.__clean_receive_buffer__()
|
204
|
self.__callbacks__.add(self.SID_AUTH_SEED_REQUEST, 0, self.__authentificate_create_seed__)
|
215
|
self.__callbacks__.add(self.SID_AUTH_SEED_REQUEST, 0, self.__authentificate_create_seed__)
|
|
|
|
|
213
|
self.__comm_inst__.register_connect_callback(self.__connection_established__)
|
224
|
self.__comm_inst__.register_connect_callback(self.__connection_established__)
|
214
|
self.__comm_inst__.register_disconnect_callback(self.__authentification_state_reset__)
|
225
|
self.__comm_inst__.register_disconnect_callback(self.__authentification_state_reset__)
|
215
|
|
226
|
|
|
|
227
|
+<<<<<<< HEAD
|
216
|
def __init_channel_name__(self, channel_name):
|
228
|
def __init_channel_name__(self, channel_name):
|
217
|
self.__comm_inst__.init_channel_name(channel_name)
|
229
|
self.__comm_inst__.init_channel_name(channel_name)
|
218
|
self.__callbacks__.init_channel_name(channel_name)
|
230
|
self.__callbacks__.init_channel_name(channel_name)
|
|
|
|
|
229
|
|
241
|
|
230
|
def __log_prefix__(self):
|
242
|
def __log_prefix__(self):
|
231
|
return ' SP client:' if self.__comm_inst__.IS_CLIENT else ' SP server:'
|
243
|
return ' SP client:' if self.__comm_inst__.IS_CLIENT else ' SP server:'
|
|
|
244
|
+=======
|
|
|
245
|
+ def __log_prefix__(self):
|
|
|
246
|
+ postfix = ' (client)' if self.__comm_inst__.IS_CLIENT else ' (server)'
|
|
|
247
|
+ if self.__channel_name__ is None:
|
|
|
248
|
+ return __name__ + postfix + ':'
|
|
|
249
|
+ else:
|
|
|
250
|
+ return self.__channel_name__ + postfix + ':'
|
|
|
251
|
+>>>>>>> 8beacaef2257e82852e1c0b5442ec4d09b891b7c
|
232
|
|
252
|
|
233
|
def connected(self):
|
253
|
def connected(self):
|
234
|
return self.__comm_inst__.is_connected()
|
254
|
return self.__comm_inst__.is_connected()
|
|
|
|
|
252
|
return self.STATUS_OKAY, self.__channel_name__
|
272
|
return self.STATUS_OKAY, self.__channel_name__
|
253
|
else:
|
273
|
else:
|
254
|
prev_channel_name = self.__channel_name__
|
274
|
prev_channel_name = self.__channel_name__
|
|
|
275
|
+<<<<<<< HEAD
|
255
|
self.__init_channel_name__(data)
|
276
|
self.__init_channel_name__(data)
|
256
|
if prev_channel_name is not None and prev_channel_name != data:
|
277
|
if prev_channel_name is not None and prev_channel_name != data:
|
257
|
self.logger.warning('%s overwriting user defined channel name from %s to %s', self.__log_prefix__(), repr(prev_channel_name), repr(data))
|
278
|
self.logger.warning('%s overwriting user defined channel name from %s to %s', self.__log_prefix__(), repr(prev_channel_name), repr(data))
|
258
|
elif prev_channel_name is None:
|
279
|
elif prev_channel_name is None:
|
259
|
self.logger.info('%s channel name is now %s', self.__log_prefix__(), repr(self.__channel_name__))
|
280
|
self.logger.info('%s channel name is now %s', self.__log_prefix__(), repr(self.__channel_name__))
|
|
|
281
|
+=======
|
|
|
282
|
+ self.__channel_name__ = data
|
|
|
283
|
+ if prev_channel_name is not None and prev_channel_name != data:
|
|
|
284
|
+ logger.warning('%s overwriting user defined channel name from %s to %s', self.__log_prefix__(), repr(prev_channel_name), repr(data))
|
|
|
285
|
+ elif prev_channel_name is None:
|
|
|
286
|
+ logger.info('%s channel name is now %s', self.__log_prefix__(), repr(self.__channel_name__))
|
|
|
287
|
+>>>>>>> 8beacaef2257e82852e1c0b5442ec4d09b891b7c
|
260
|
return self.STATUS_OKAY, None
|
288
|
return self.STATUS_OKAY, None
|
261
|
|
289
|
|
262
|
def __channel_name_response__(self, msg):
|
290
|
def __channel_name_response__(self, msg):
|
263
|
data = msg.get_data()
|
291
|
data = msg.get_data()
|
264
|
if self.__channel_name__ is None and data is not None:
|
292
|
if self.__channel_name__ is None and data is not None:
|
|
|
293
|
+<<<<<<< HEAD
|
265
|
self.__init_channel_name__(data)
|
294
|
self.__init_channel_name__(data)
|
266
|
self.logger.info('%s channel name is now %s', self.__log_prefix__(), repr(self.__channel_name__))
|
295
|
self.logger.info('%s channel name is now %s', self.__log_prefix__(), repr(self.__channel_name__))
|
267
|
return self.STATUS_OKAY, None
|
296
|
return self.STATUS_OKAY, None
|
268
|
|
297
|
|
269
|
def __authentification_state_reset__(self):
|
298
|
def __authentification_state_reset__(self):
|
270
|
self.logger.info("%s Resetting authentification state to AUTH_STATE_UNKNOWN_CLIENT", self.__log_prefix__())
|
299
|
self.logger.info("%s Resetting authentification state to AUTH_STATE_UNKNOWN_CLIENT", self.__log_prefix__())
|
|
|
300
|
+=======
|
|
|
301
|
+ self.__channel_name__ = data
|
|
|
302
|
+ logger.info('%s channel name is now %s', self.__log_prefix__(), repr(self.__channel_name__))
|
|
|
303
|
+ return self.STATUS_OKAY, None
|
|
|
304
|
+
|
|
|
305
|
+ def __authentification_state_reset__(self):
|
|
|
306
|
+ logger.info("%s Resetting authentification state to AUTH_STATE_UNKNOWN_CLIENT", self.__log_prefix__())
|
|
|
307
|
+>>>>>>> 8beacaef2257e82852e1c0b5442ec4d09b891b7c
|
271
|
self.__authentification_state__ = self.AUTH_STATE_UNKNOWN_CLIENT
|
308
|
self.__authentification_state__ = self.AUTH_STATE_UNKNOWN_CLIENT
|
272
|
|
309
|
|
273
|
def __analyse_frame__(self, frame):
|
310
|
def __analyse_frame__(self, frame):
|
|
|
|
|
306
|
def __data_available_callback__(self, comm_inst):
|
343
|
def __data_available_callback__(self, comm_inst):
|
307
|
frame = comm_inst.receive()
|
344
|
frame = comm_inst.receive()
|
308
|
if not self.__check_frame_checksum__(frame):
|
345
|
if not self.__check_frame_checksum__(frame):
|
|
|
346
|
+<<<<<<< HEAD
|
309
|
self.logger.warning("%s Received message has a wrong checksum and will be ignored: %s.", self.__log_prefix__(), stringtools.hexlify(frame))
|
347
|
self.logger.warning("%s Received message has a wrong checksum and will be ignored: %s.", self.__log_prefix__(), stringtools.hexlify(frame))
|
|
|
348
|
+=======
|
|
|
349
|
+ logger.warning("%s Received message has a wrong checksum and will be ignored: %s.", self.__log_prefix__(), stringtools.hexlify(frame))
|
|
|
350
|
+>>>>>>> 8beacaef2257e82852e1c0b5442ec4d09b891b7c
|
310
|
else:
|
351
|
else:
|
311
|
msg = self.__analyse_frame__(frame)
|
352
|
msg = self.__analyse_frame__(frame)
|
312
|
self.logger.info(
|
353
|
self.logger.info(
|
|
|
|
|
325
|
if self.__secret__ is not None and not self.check_authentification_state() and msg.get_service_id() not in self.SID_AUTH_LIST:
|
366
|
if self.__secret__ is not None and not self.check_authentification_state() and msg.get_service_id() not in self.SID_AUTH_LIST:
|
326
|
status = self.STATUS_AUTH_REQUIRED
|
367
|
status = self.STATUS_AUTH_REQUIRED
|
327
|
data = None
|
368
|
data = None
|
|
|
369
|
+<<<<<<< HEAD
|
328
|
self.logger.warning("%s Received message needs authentification: %s. Sending negative response.", self.__log_prefix__(), self.AUTH_STATUS_NAMES.get(self.__authentification_state__, 'Unknown authentification status!'))
|
370
|
self.logger.warning("%s Received message needs authentification: %s. Sending negative response.", self.__log_prefix__(), self.AUTH_STATUS_NAMES.get(self.__authentification_state__, 'Unknown authentification status!'))
|
329
|
elif callback is None:
|
371
|
elif callback is None:
|
330
|
self.logger.warning("%s Received message with no registered callback. Sending negative response.", self.__log_prefix__())
|
372
|
self.logger.warning("%s Received message with no registered callback. Sending negative response.", self.__log_prefix__())
|
|
|
373
|
+=======
|
|
|
374
|
+ logger.warning("%s Received message needs authentification: %s. Sending negative response.", self.__log_prefix__(), self.AUTH_STATUS_NAMES.get(self.__authentification_state__, 'Unknown authentification status!'))
|
|
|
375
|
+ elif callback is None:
|
|
|
376
|
+ logger.warning("%s Received message with no registered callback. Sending negative response.", self.__log_prefix__())
|
|
|
377
|
+>>>>>>> 8beacaef2257e82852e1c0b5442ec4d09b891b7c
|
331
|
status = self.STATUS_BUFFERING_UNHANDLED_REQUEST
|
378
|
status = self.STATUS_BUFFERING_UNHANDLED_REQUEST
|
332
|
data = None
|
379
|
data = None
|
333
|
else:
|
380
|
else:
|
334
|
try:
|
381
|
try:
|
|
|
382
|
+<<<<<<< HEAD
|
335
|
self.logger.debug("%s Executing callback %s to process received data", self.__log_prefix__(), callback.__name__)
|
383
|
self.logger.debug("%s Executing callback %s to process received data", self.__log_prefix__(), callback.__name__)
|
|
|
384
|
+=======
|
|
|
385
|
+ logger.debug("%s Executing callback %s to process received data", self.__log_prefix__(), callback.__name__)
|
|
|
386
|
+>>>>>>> 8beacaef2257e82852e1c0b5442ec4d09b891b7c
|
336
|
status, data = callback(msg, *args, **kwargs)
|
387
|
status, data = callback(msg, *args, **kwargs)
|
337
|
except TypeError:
|
388
|
except TypeError:
|
338
|
raise TypeError('Check return value of callback function {callback_name} for service_id {service_id} and data_id {data_id}'.format(callback_name=callback.__name__, service_id=repr(msg.get_service_id()), data_id=repr(msg.get_data_id())))
|
389
|
raise TypeError('Check return value of callback function {callback_name} for service_id {service_id} and data_id {data_id}'.format(callback_name=callback.__name__, service_id=repr(msg.get_service_id()), data_id=repr(msg.get_data_id())))
|
|
|
|
|
342
|
# RESPONSE RECEIVED
|
393
|
# RESPONSE RECEIVED
|
343
|
#
|
394
|
#
|
344
|
if msg.get_status() not in [self.STATUS_OKAY]:
|
395
|
if msg.get_status() not in [self.STATUS_OKAY]:
|
|
|
396
|
+<<<<<<< HEAD
|
345
|
self.logger.warning("%s Received message has a peculiar status: %s", self.__log_prefix__(), self.STATUS_NAMES.get(msg.get_status(), 'Unknown status response!'))
|
397
|
self.logger.warning("%s Received message has a peculiar status: %s", self.__log_prefix__(), self.STATUS_NAMES.get(msg.get_status(), 'Unknown status response!'))
|
|
|
398
|
+=======
|
|
|
399
|
+ logger.warning("%s Received message has a peculiar status: %s", self.__log_prefix__(), self.STATUS_NAMES.get(msg.get_status(), 'Unknown status response!'))
|
|
|
400
|
+>>>>>>> 8beacaef2257e82852e1c0b5442ec4d09b891b7c
|
346
|
if callback is None:
|
401
|
if callback is None:
|
347
|
status = self.STATUS_OKAY
|
402
|
status = self.STATUS_OKAY
|
348
|
data = None
|
403
|
data = None
|
349
|
self.__buffer_received_data__(msg)
|
404
|
self.__buffer_received_data__(msg)
|
350
|
else:
|
405
|
else:
|
351
|
try:
|
406
|
try:
|
|
|
407
|
+<<<<<<< HEAD
|
352
|
self.logger.debug("%s Executing callback %s to process received data", self.__log_prefix__(), callback.__name__)
|
408
|
self.logger.debug("%s Executing callback %s to process received data", self.__log_prefix__(), callback.__name__)
|
|
|
409
|
+=======
|
|
|
410
|
+ logger.debug("%s Executing callback %s to process received data", self.__log_prefix__(), callback.__name__)
|
|
|
411
|
+>>>>>>> 8beacaef2257e82852e1c0b5442ec4d09b891b7c
|
353
|
status, data = callback(msg, *args, **kwargs)
|
412
|
status, data = callback(msg, *args, **kwargs)
|
354
|
except TypeError:
|
413
|
except TypeError:
|
355
|
raise TypeError('Check return value of callback function {callback_name} for service_id {service_id} and data_id {data_id}'.format(callback_name=callback.__name__, service_id=repr(msg.get_service_id()), data_id=repr(msg.get_data_id())))
|
414
|
raise TypeError('Check return value of callback function {callback_name} for service_id {service_id} and data_id {data_id}'.format(callback_name=callback.__name__, service_id=repr(msg.get_service_id()), data_id=repr(msg.get_data_id())))
|
|
|
|
|
360
|
if not msg.get_data_id() in self.__msg_buffer__[msg.get_service_id()]:
|
419
|
if not msg.get_data_id() in self.__msg_buffer__[msg.get_service_id()]:
|
361
|
self.__msg_buffer__[msg.get_service_id()][msg.get_data_id()] = []
|
420
|
self.__msg_buffer__[msg.get_service_id()][msg.get_data_id()] = []
|
362
|
self.__msg_buffer__[msg.get_service_id()][msg.get_data_id()].append(msg)
|
421
|
self.__msg_buffer__[msg.get_service_id()][msg.get_data_id()].append(msg)
|
|
|
422
|
+<<<<<<< HEAD
|
363
|
self.logger.debug("%s Message data is stored in buffer and is now ready to be retrieved by receive method", self.__log_prefix__())
|
423
|
self.logger.debug("%s Message data is stored in buffer and is now ready to be retrieved by receive method", self.__log_prefix__())
|
364
|
|
424
|
|
365
|
def __clean_receive_buffer__(self):
|
425
|
def __clean_receive_buffer__(self):
|
366
|
self.logger.debug("%s Cleaning up receive-buffer", self.__log_prefix__())
|
426
|
self.logger.debug("%s Cleaning up receive-buffer", self.__log_prefix__())
|
|
|
427
|
+=======
|
|
|
428
|
+ logger.debug("%s Message data is stored in buffer and is now ready to be retrieved by receive method", self.__log_prefix__())
|
|
|
429
|
+
|
|
|
430
|
+ def __clean_receive_buffer__(self):
|
|
|
431
|
+ logger.debug("%s Cleaning up receive-buffer", self.__log_prefix__())
|
|
|
432
|
+>>>>>>> 8beacaef2257e82852e1c0b5442ec4d09b891b7c
|
367
|
self.__msg_buffer__ = {}
|
433
|
self.__msg_buffer__ = {}
|
368
|
|
434
|
|
369
|
def receive(self, service_id, data_id, timeout=1):
|
435
|
def receive(self, service_id, data_id, timeout=1):
|
|
|
|
|
377
|
cnt += 1
|
443
|
cnt += 1
|
378
|
time.sleep(0.1)
|
444
|
time.sleep(0.1)
|
379
|
if data is None and cnt >= timeout * 10:
|
445
|
if data is None and cnt >= timeout * 10:
|
|
|
446
|
+<<<<<<< HEAD
|
380
|
self.logger.warning('%s TIMEOUT (%ss): Requested data (service_id: %s; data_id: %s) not in buffer.', self.__log_prefix__(), repr(timeout), repr(service_id), repr(data_id))
|
447
|
self.logger.warning('%s TIMEOUT (%ss): Requested data (service_id: %s; data_id: %s) not in buffer.', self.__log_prefix__(), repr(timeout), repr(service_id), repr(data_id))
|
|
|
448
|
+=======
|
|
|
449
|
+ logger.warning('%s TIMEOUT (%ss): Requested data (service_id: %s; data_id: %s) not in buffer.', self.__log_prefix__(), repr(timeout), repr(service_id), repr(data_id))
|
|
|
450
|
+>>>>>>> 8beacaef2257e82852e1c0b5442ec4d09b891b7c
|
381
|
return data
|
451
|
return data
|
382
|
|
452
|
|
383
|
def __mk_msg__(self, status, service_id, data_id, data):
|
453
|
def __mk_msg__(self, status, service_id, data_id, data):
|
|
|
|
|
402
|
|
472
|
|
403
|
This methods sends out a message with the given content.
|
473
|
This methods sends out a message with the given content.
|
404
|
"""
|
474
|
"""
|
|
|
475
|
+<<<<<<< HEAD
|
405
|
self.logger.log(log_lvl, '%s TX -> status: %d, service_id: %d, data_id: %d, data: "%s"', self.__log_prefix__(), status, service_id, data_id, repr(data))
|
476
|
self.logger.log(log_lvl, '%s TX -> status: %d, service_id: %d, data_id: %d, data: "%s"', self.__log_prefix__(), status, service_id, data_id, repr(data))
|
|
|
477
|
+=======
|
|
|
478
|
+ logger.log(log_lvl, '%s TX -> status: %d, service_id: %d, data_id: %d, data: "%s"', self.__log_prefix__(), status, service_id, data_id, repr(data))
|
|
|
479
|
+>>>>>>> 8beacaef2257e82852e1c0b5442ec4d09b891b7c
|
406
|
return self.__comm_inst__.send(self.__build_frame__(service_id, data_id, data, status), timeout=timeout, log_lvl=logging.DEBUG)
|
480
|
return self.__comm_inst__.send(self.__build_frame__(service_id, data_id, data, status), timeout=timeout, log_lvl=logging.DEBUG)
|
407
|
|
481
|
|
408
|
def register_callback(self, service_id, data_id, callback, *args, **kwargs):
|
482
|
def register_callback(self, service_id, data_id, callback, *args, **kwargs):
|
|
|
|
|
446
|
"""
|
520
|
"""
|
447
|
if self.__secret__ is not None:
|
521
|
if self.__secret__ is not None:
|
448
|
self.__authentification_state__ = self.AUTH_STATE_SEED_REQUESTED
|
522
|
self.__authentification_state__ = self.AUTH_STATE_SEED_REQUESTED
|
|
|
523
|
+<<<<<<< HEAD
|
449
|
self.logger.info("%s Requesting seed for authentification", self.__log_prefix__())
|
524
|
self.logger.info("%s Requesting seed for authentification", self.__log_prefix__())
|
|
|
525
|
+=======
|
|
|
526
|
+ logger.info("%s Requesting seed for authentification", self.__log_prefix__())
|
|
|
527
|
+>>>>>>> 8beacaef2257e82852e1c0b5442ec4d09b891b7c
|
450
|
self.send(self.SID_AUTH_SEED_REQUEST, 0, None)
|
528
|
self.send(self.SID_AUTH_SEED_REQUEST, 0, None)
|
451
|
cnt = 0
|
529
|
cnt = 0
|
452
|
while cnt < timeout * 10:
|
530
|
while cnt < timeout * 10:
|
|
|
|
|
472
|
return hashlib.sha512(seed.encode('utf-8') + self.__secret__.encode('utf-8')).hexdigest()
|
550
|
return hashlib.sha512(seed.encode('utf-8') + self.__secret__.encode('utf-8')).hexdigest()
|
473
|
|
551
|
|
474
|
def __authentificate_create_seed__(self, msg):
|
552
|
def __authentificate_create_seed__(self, msg):
|
|
|
553
|
+<<<<<<< HEAD
|
475
|
self.logger.info("%s Got seed request, sending seed for authentification", self.__log_prefix__())
|
554
|
self.logger.info("%s Got seed request, sending seed for authentification", self.__log_prefix__())
|
|
|
555
|
+=======
|
|
|
556
|
+ logger.info("%s Got seed request, sending seed for authentification", self.__log_prefix__())
|
|
|
557
|
+>>>>>>> 8beacaef2257e82852e1c0b5442ec4d09b891b7c
|
476
|
self.__authentification_state__ = self.AUTH_STATE_SEED_TRANSFERRED
|
558
|
self.__authentification_state__ = self.AUTH_STATE_SEED_TRANSFERRED
|
477
|
if sys.version_info >= (3, 0):
|
559
|
if sys.version_info >= (3, 0):
|
478
|
self.__seed__ = binascii.hexlify(os.urandom(32)).decode('utf-8')
|
560
|
self.__seed__ = binascii.hexlify(os.urandom(32)).decode('utf-8')
|
|
|
|
|
481
|
return self.STATUS_OKAY, self.__seed__
|
563
|
return self.STATUS_OKAY, self.__seed__
|
482
|
|
564
|
|
483
|
def __authentificate_create_key__(self, msg):
|
565
|
def __authentificate_create_key__(self, msg):
|
|
|
566
|
+<<<<<<< HEAD
|
484
|
self.logger.info("%s Got seed, sending key for authentification", self.__log_prefix__())
|
567
|
self.logger.info("%s Got seed, sending key for authentification", self.__log_prefix__())
|
|
|
568
|
+=======
|
|
|
569
|
+ logger.info("%s Got seed, sending key for authentification", self.__log_prefix__())
|
|
|
570
|
+>>>>>>> 8beacaef2257e82852e1c0b5442ec4d09b891b7c
|
485
|
self.__authentification_state__ = self.AUTH_STATE_KEY_TRANSFERRED
|
571
|
self.__authentification_state__ = self.AUTH_STATE_KEY_TRANSFERRED
|
486
|
seed = msg.get_data()
|
572
|
seed = msg.get_data()
|
487
|
key = self.__authentificate_salt_and_hash__(seed)
|
573
|
key = self.__authentificate_salt_and_hash__(seed)
|
|
|
|
|
491
|
key = msg.get_data()
|
577
|
key = msg.get_data()
|
492
|
if key == self.__authentificate_salt_and_hash__(self.__seed__):
|
578
|
if key == self.__authentificate_salt_and_hash__(self.__seed__):
|
493
|
self.__authentification_state__ = self.AUTH_STATE_TRUSTED_CLIENT
|
579
|
self.__authentification_state__ = self.AUTH_STATE_TRUSTED_CLIENT
|
|
|
580
|
+<<<<<<< HEAD
|
494
|
self.logger.info("%s Got correct key, sending positive authentification feedback", self.__log_prefix__())
|
581
|
self.logger.info("%s Got correct key, sending positive authentification feedback", self.__log_prefix__())
|
495
|
return self.STATUS_OKAY, True
|
582
|
return self.STATUS_OKAY, True
|
496
|
else:
|
583
|
else:
|
497
|
self.__authentification_state__ = self.AUTH_STATE_UNKNOWN_CLIENT
|
584
|
self.__authentification_state__ = self.AUTH_STATE_UNKNOWN_CLIENT
|
498
|
self.logger.info("%s Got incorrect key, sending negative authentification feedback", self.__log_prefix__())
|
585
|
self.logger.info("%s Got incorrect key, sending negative authentification feedback", self.__log_prefix__())
|
|
|
586
|
+=======
|
|
|
587
|
+ logger.info("%s Got correct key, sending positive authentification feedback", self.__log_prefix__())
|
|
|
588
|
+ return self.STATUS_OKAY, True
|
|
|
589
|
+ else:
|
|
|
590
|
+ self.__authentification_state__ = self.AUTH_STATE_UNKNOWN_CLIENT
|
|
|
591
|
+ logger.info("%s Got incorrect key, sending negative authentification feedback", self.__log_prefix__())
|
|
|
592
|
+>>>>>>> 8beacaef2257e82852e1c0b5442ec4d09b891b7c
|
499
|
return self.STATUS_OKAY, False
|
593
|
return self.STATUS_OKAY, False
|
500
|
|
594
|
|
501
|
def __authentificate_process_feedback__(self, msg):
|
595
|
def __authentificate_process_feedback__(self, msg):
|
502
|
feedback = msg.get_data()
|
596
|
feedback = msg.get_data()
|
503
|
if feedback:
|
597
|
if feedback:
|
504
|
self.__authentification_state__ = self.AUTH_STATE_TRUSTED_CLIENT
|
598
|
self.__authentification_state__ = self.AUTH_STATE_TRUSTED_CLIENT
|
|
|
599
|
+<<<<<<< HEAD
|
505
|
self.logger.info("%s Got positive authentification feedback", self.__log_prefix__())
|
600
|
self.logger.info("%s Got positive authentification feedback", self.__log_prefix__())
|
506
|
else:
|
601
|
else:
|
507
|
self.__authentification_state__ = self.AUTH_STATE_UNKNOWN_CLIENT
|
602
|
self.__authentification_state__ = self.AUTH_STATE_UNKNOWN_CLIENT
|
508
|
self.logger.warning("%s Got negative authentification feedback", self.__log_prefix__())
|
603
|
self.logger.warning("%s Got negative authentification feedback", self.__log_prefix__())
|
|
|
604
|
+=======
|
|
|
605
|
+ logger.info("%s Got positive authentification feedback", self.__log_prefix__())
|
|
|
606
|
+ else:
|
|
|
607
|
+ self.__authentification_state__ = self.AUTH_STATE_UNKNOWN_CLIENT
|
|
|
608
|
+ logger.warning("%s Got negative authentification feedback", self.__log_prefix__())
|
|
|
609
|
+>>>>>>> 8beacaef2257e82852e1c0b5442ec4d09b891b7c
|
509
|
return self.STATUS_OKAY, None
|
610
|
return self.STATUS_OKAY, None
|
510
|
|
611
|
|
511
|
|
612
|
|