def process_error_setup(self, message, conn): if len(message) != 10: print 'Malformed error!' return print "Received error at server:", util.get_error_message(message[7]) conn.close() return
def send_error_setup(self, conn, error_code): error_message = bytearray(10 * '\x00', 'hex') error_message[0] = '\x06' error_message[1:5] = util.int_to_binary(5, 4) if self.session_id: error_message[5:7] = self.session_id else: error_message[5:7] = '\x00\x00' # session ID not yet generated, can't send it error_message[7] = error_code error_message[8:10] = '\xF0\xF0' print 'Sending error from client:', util.get_error_message(error_message[7]) conn.send(error_message) conn.close() return
def send_error_secure(self, conn, error_code): error_message = bytearray(10 * '\x00', 'hex') error_message[0] = '\x06' error_message[1:5] = util.int_to_binary(5, 4) if self.session_ids.get(conn): error_message[5:7] = self.session_ids[conn] else: error_message[ 5: 7] = '\x00\x00' # session ID not yet generated, can't send it error_message[7] = error_code error_message[8:10] = '\xF0\xF0' print 'Sending error from server:', util.get_error_message( error_message[7]), self.secure_error_count[conn] conn.send(error_message) self.secure_error_count[conn] += 1 if self.secure_error_count[conn] >= 10: conn.close() self.is_connected[conn] = False return
def process_error(self, message, conn): if len(message) != 10: print 'Malformed error!' return print "Received error at client:", util.get_error_message(message[7])