parameters: (self, expected_list=None, blocking_call=True)
return_statement: return True, u''
docstring: NB : Strings coming from the ReDemPtion proxy are UTF-8 encoded
          * Packet format:
          uint16                   request_count
          request[request_count]   requests
  
          * request format:
          request := request_update | request_ask
  
          * request_update format:
          uint8                    "!"
          uint8                    key_size
          byte[key_size]           key
          uint32                   value_size
          byte[value_size]         value
  
          * request_ask format:
          uint8                    "?"
          uint8                    key_size
          byte[key_size]           key
  
          key and value are utf8 encoded
          uint are big-endian byte ordered
docstring_summary: NB : Strings coming from the ReDemPtion proxy are UTF-8 encoded
          * Packet format:
          uint16                   request_count
          request[request_count]   requests
docstring_tokens: NB : Strings coming from the ReDemPtion proxy are UTF - 8 encoded * Packet format : uint16 request_count request [ request_count ] requests
function: def receive_data(self, expected_list=None, blocking_call=True):
          """ NB : Strings coming from the ReDemPtion proxy are UTF-8 encoded
          * Packet format:
          uint16                   request_count
          request[request_count]   requests
  
          * request format:
          request := request_update | request_ask
  
          * request_update format:
          uint8                    "!"
          uint8                    key_size
          byte[key_size]           key
          uint32                   value_size
          byte[value_size]         value
  
          * request_ask format:
          uint8                    "?"
          uint8                    key_size
          byte[key_size]           key
  
          key and value are utf8 encoded
          uint are big-endian byte ordered
          """
  
          if blocking_call:
              _ = self.wait_read_proxy_conx()
  
          self._changed_keys = []
  
          def read_sck():
              try:
                  d = self.proxy_conx.recv(65536)
                  if len(d):
                      if DEBUG:
                          Logger().debug(d)
                      return d
  
              except Exception:
                  # Logger().info("%s <<<%s>>>" % (
                  #     u"Failed to read data from rdpproxy authentifier socket",
                  #     traceback.format_exc(e))
                  # )
                  raise AuthentifierSocketClosed()
  
              if DEBUG:
                  Logger().info("received_buffer (empty packet)")
              raise AuthentifierSocketClosed()
  
          class Buffer:
              def __init__(self):
                  self._data = read_sck()
                  self._offset = 0
  
              def reserve_data(self, n):
                  while len(self._data) - self._offset < n:
                      if DEBUG:
                          Logger().info("received_buffer (big packet) "
                                        "old = %d / %d ; required = %d"
                                        % (self._offset, len(self._data), n))
                      self._data = self._data[self._offset:] + read_sck()
                      self._offset = 0
  
              def extract_string(self, n):
                  self.reserve_data(n)
                  _name = self._data[self._offset:self._offset + n]
                  _name = _name.decode('utf8')
                  self._offset += n
                  return _name
  
              def unpack(self, fmt, n):
                  self.reserve_data(n)
                  r = unpack_from(fmt, self._data, self._offset)
                  self._offset += n
                  return r
  
              def is_empty(self):
                  return len(self._data) == self._offset
  
          _buffer = Buffer()
          _data = {}
  
          while True:
              _nfield, = _buffer.unpack('>H', 2)
  
              if DEBUG:
                  Logger().info("received_buffer (nfield) = %d" % (_nfield,))
  
              for _ in range(0, _nfield):
                  _type, _n = _buffer.unpack("BB", 2)
                  _key = _buffer.extract_string(_n)
  
                  if DEBUG:
                      Logger().info("received_buffer (key)   = %s%s"
                                    % ('?' if _type == 0x3f else '!', _key,))
  
                  if _type == 0x3f:  # b'?'
                      _data[_key] = MAGICASK
                  else:
                      _n, = _buffer.unpack('>L', 4)
                      _data[_key] = _buffer.extract_string(_n)
  
                      if DEBUG:
                          if "password" in _key.lower():
                              Logger().info("received_buffer (value) = *****")
                          else:
                              Logger().info(
                                  f"received_buffer (value) = {_data[_key]}"
                              )
  
              if _buffer.is_empty():
                  break
  
              if DEBUG:
                  Logger().info("received_buffer (several packet)")
  
          if not (expected_list and isinstance(expected_list, list)):
              expected_list = []
          for key in expected_list:
              if (key in _data and _data[key] != self.shared.get(key)):
                  self._changed_keys.append(key)
          self.shared.update(_data)
  
          return True, u''
function_tokens: def receive_data ( self , expected_list = None , blocking_call = True ) : if blocking_call : _ = self . wait_read_proxy_conx ( ) self . _changed_keys = [ ] def read_sck ( ) : try : d = self . proxy_conx . recv ( 65536 ) if len ( d ) : if DEBUG : Logger ( ) . debug ( d ) return d except Exception : # Logger().info("%s <<<%s>>>" % ( #     u"Failed to read data from rdpproxy authentifier socket", #     traceback.format_exc(e)) # ) raise AuthentifierSocketClosed ( ) if DEBUG : Logger ( ) . info ( "received_buffer (empty packet)" ) raise AuthentifierSocketClosed ( ) class Buffer : def __init__ ( self ) : self . _data = read_sck ( ) self . _offset = 0 def reserve_data ( self , n ) : while len ( self . _data ) - self . _offset < n : if DEBUG : Logger ( ) . info ( "received_buffer (big packet) " "old = %d / %d ; required = %d" % ( self . _offset , len ( self . _data ) , n ) ) self . _data = self . _data [ self . _offset : ] + read_sck ( ) self . _offset = 0 def extract_string ( self , n ) : self . reserve_data ( n ) _name = self . _data [ self . _offset : self . _offset + n ] _name = _name . decode ( 'utf8' ) self . _offset += n return _name def unpack ( self , fmt , n ) : self . reserve_data ( n ) r = unpack_from ( fmt , self . _data , self . _offset ) self . _offset += n return r def is_empty ( self ) : return len ( self . _data ) == self . _offset _buffer = Buffer ( ) _data = { } while True : _nfield , = _buffer . unpack ( '>H' , 2 ) if DEBUG : Logger ( ) . info ( "received_buffer (nfield) = %d" % ( _nfield , ) ) for _ in range ( 0 , _nfield ) : _type , _n = _buffer . unpack ( "BB" , 2 ) _key = _buffer . extract_string ( _n ) if DEBUG : Logger ( ) . info ( "received_buffer (key)   = %s%s" % ( '?' if _type == 0x3f else '!' , _key , ) ) if _type == 0x3f : # b'?' _data [ _key ] = MAGICASK else : _n , = _buffer . unpack ( '>L' , 4 ) _data [ _key ] = _buffer . extract_string ( _n ) if DEBUG : if "password" in _key . lower ( ) : Logger ( ) . info ( "received_buffer (value) = *****" ) else : Logger ( ) . info ( f"received_buffer (value) = {_data[_key]}" ) if _buffer . is_empty ( ) : break if DEBUG : Logger ( ) . info ( "received_buffer (several packet)" ) if not ( expected_list and isinstance ( expected_list , list ) ) : expected_list = [ ] for key in expected_list : if ( key in _data and _data [ key ] != self . shared . get ( key ) ) : self . _changed_keys . append ( key ) self . shared . update ( _data ) return True , u''