def send_command(self, data, checksum = True): if checksum == True: to_send = data+get_checksum(data, '')+'\r\n' else: to_send = data+'\r\n' logger.debug('PROXY < %s' % to_send.strip()) yield self.stream.write(to_send)
def dispatch_client(self): try: while True: line = yield self.stream.read_until(b'\r\n') if self.authenticated == True: events.put('envisalink', None, line) else: if line.strip() == ('005' + config.ENVISALINKPROXYPASS + get_checksum('005', config.ENVISALINKPROXYPASS)): logger.info('Proxy User Authenticated') self.authenticated = True self.send_command('5051') else: logger.info('Proxy User Authentication failed') self.send_command('5050') self.stream.close() except StreamClosedError: #on_disconnect will catch this pass