Ejemplo n.º 1
0
    def setup(self):
        StreamRequestHandler.setup(self)
        self.is_websocket = self.rfile.peek().find(b'Upgrade: websocket') != -1

        if self.is_websocket:
            self.keep_alive = True
            self.finished = False
            self.handshake_done = False
            self.valid_client = False
            self.bytes_buffer = bytearray()
Ejemplo n.º 2
0
	def setup(self):
		if self.server.use_ssl:
			self.connection = self.request
			self.rfile = socket.SocketIO(self.request, "rb")
			self.wfile = socket.SocketIO(self.request, "wb")
		else:
			StreamRequestHandler.setup(self)
		self.keep_alive = True
		self.handshake_done = False
		self.valid_client = False
Ejemplo n.º 3
0
 def setup(self):
     StreamRequestHandler.setup(self)
     self.keep_alive = True
     self.handshake_done = False
     self.valid_client = False
Ejemplo n.º 4
0
 def setup(self):
     StreamRequestHandler.setup(self)
     self.conn_keep_alive = True  # decides if the connection should be kept alive
     self.handshake_success = False  # WebSocket handshake
     self.read_key = ""  # the key read from WebSocket handshake
     self.read_upgr_param = False  # whether the WebSocket handshake contained the upgrade parameter
Ejemplo n.º 5
0
 def setup(self):
     StreamRequestHandler.setup(self)
     threading.current_thread().setName(f"handler-{self.server.display_name}")
Ejemplo n.º 6
0
    def setup(self):
        # Do a DNS lookup on the client.
        try:
            info = socket.gethostbyaddr(self.client_address[0])
            self._client_domain = info[0]
        except socket.herror:
            self._client_domain = self.client_address[0]

        LOG.info("Remote probe client connected (%s from port %i)",
                 self._client_domain, self.client_address[1])

        # Get the session and probe we're serving from the server.
        self._session = self.server.session
        self._probe = self.server.probe

        # Give the probe a session if it doesn't have one, in case it needs to access settings.
        # TODO: create a session proxy so client-side options can be accessed
        if self._probe.session is None:
            self._probe.session = self._session

        # Dict to store handles for AP memory interfaces.
        self._next_ap_memif_handle = 0
        self._ap_memif_handles = {}

        # Create the request handlers dict here so we can reference bound probe methods.
        self._REQUEST_HANDLERS = {
            # Command                Handler                            Arg count
            'hello': (self._request__hello, 1),
            'readprop': (self._request__read_property, 1),
            'open': (self._probe.open, 0),  # 'open'
            'close': (self._probe.close, 0),  # 'close'
            'lock': (self._probe.lock, 0),  # 'lock'
            'unlock': (self._probe.unlock, 0),  # 'unlock'
            'connect': (self._request__connect, 1),  # 'connect', protocol:str
            'disconnect': (self._probe.disconnect, 0),  # 'disconnect'
            'swj_sequence': (self._probe.swj_sequence,
                             2),  # 'swj_sequence', length:int, bits:int
            'swd_sequence': (
                self._probe.swd_sequence, 1
            ),  # 'swd_sequence', sequences:List[Union[Tuple[int], Tuple[int, int]]] -> Tuple[int, List[bytes]]
            'jtag_sequence': (
                self._probe.jtag_sequence, 4
            ),  # 'jtag_sequence', cycles:int, tms:int, read_tdo:bool, tdi:int -> Union[None, int]
            'set_clock': (self._probe.set_clock, 1),  # 'set_clock', freq:int
            'reset': (self._probe.reset, 0),  # 'reset'
            'assert_reset':
            (self._probe.assert_reset, 1),  # 'assert_reset', asserted:bool
            'is_reset_asserted':
            (self._probe.is_reset_asserted, 0),  # 'is_reset_asserted'
            'flush': (self._probe.flush, 0),  # 'flush'
            'read_dp': (self._probe.read_dp, 1),  # 'read_dp', addr:int -> int
            'write_dp':
            (self._probe.write_dp, 2),  # 'write_dp', addr:int, data:int
            'read_ap': (self._probe.read_ap, 1),  # 'read_ap', addr:int -> int
            'write_ap':
            (self._probe.write_ap, 2),  # 'write_ap', addr:int, data:int
            'read_ap_multiple':
            (self._probe.read_ap_multiple,
             2),  # 'read_ap_multiple', addr:int, count:int -> List[int]
            'write_ap_multiple':
            (self._probe.write_ap_multiple,
             2),  # 'write_ap_multiple', addr:int, data:List[int]
            'get_memory_interface_for_ap': (
                self._request__get_memory_interface_for_ap, 2
            ),  # 'get_memory_interface_for_ap', ap_address_version:int, ap_nominal_address:int -> handle:int|null
            'swo_start': (self._probe.swo_start,
                          1),  # 'swo_start', baudrate:int
            'swo_stop': (self._probe.swo_stop, 0),  # 'swo_stop'
            'swo_read': (self._request__swo_read,
                         0),  # 'swo_read' -> List[int]
            'read_mem':
            (self._request__read_mem,
             3),  # 'read_mem', handle:int, addr:int, xfer_size:int -> int
            'write_mem':
            (self._request__write_mem,
             4),  # 'write_mem', handle:int, addr:int, value:int, xfer_size:int
            'read_block32': (
                self._request__read_block32, 3
            ),  # 'read_block32', handle:int, addr:int, word_count:int -> List[int]
            'write_block32':
            (self._request__write_block32,
             3),  # 'write_block32', handle:int, addr:int, data:List[int]
            'read_block8': (
                self._request__read_block8, 3
            ),  # 'read_block8', handle:int, addr:int, word_count:int -> List[int]
            'write_block8':
            (self._request__write_block8,
             3),  # 'write_block8', handle:int, addr:int, data:List[int]
        }

        # Let superclass do its thing. (Can't use super() here because the superclass isn't derived
        # from object in Py2.)
        StreamRequestHandler.setup(self)
Ejemplo n.º 7
0
 def setup(self):
   StreamRequestHandler.setup(self)
   self.is_connected = True
   self.handshaked = False
   self.is_websocket = True
Ejemplo n.º 8
0
 def setup(self):
     StreamRequestHandler.setup(self)
     self.connectionAlive = True
     self.doHandshake = False
     self.approvedClient = False