def on_request(self, request):
        if not self.ssl or self.bridge:
            return request
        try:
            record, remaining = tls.parse_tls(request)
            message = record.messages[0]
            if not self.clienthello_handled:
                self.clienthello_handled = True
                hello = message.obj
                # Force a full handshake by preventing session resumption by emptying
                # session ID and SessionTicket extension. Otherwise a CCS will follow
                # a ServerHello normally.
                hello.session_id = []
                for ext in hello.extension_list:
                    if ext.type == Extension.TYPE.SESSIONTICKET:
                        ext.raw_data = []
                return record.to_bytes()
            if self.injected_server:
                # OpenSSL after the EarlyCCS fix should send a fatal alert
                # unexpected_message (10). Some other libraries send a close_notify (0)
                # so we accept that as well. Morever, if the client doesn't like the TLS
                # protocol version chosen by the server (regardless of whether early
                # CCS is injected), the client will send a fatal alert
                # protocol_version (70).
                if not (
                    isinstance(message, tls.types.Alert) and
                       ((message.description == Alert.DESCRIPTION.UNEXPECTED_MESSAGE and
                           message.level == Alert.LEVEL.FATAL) or
                       (message.description == Alert.DESCRIPTION.PROTOCOL_VERSION and
                           message.level == Alert.LEVEL.FATAL) or
                       message.description == Alert.DESCRIPTION.CLOSE_NOTIFY)):
                    self.log(
                        logging.CRITICAL,
                        "Client is vulnerable to Early CCS attack!")
                    self.connection.vuln_notify(util.vuln.VULN_EARLY_CCS)
                    self.log_attack_event()

                    self.connection.close()
                else:
                    self.log(
                        logging.DEBUG,
                        "Client not vulnerable to early CCS")
                    self.log_attack_event(success=False)

        except __HOLE__:
            # Failed to parse TLS, this is probably due to a short read of a TLS
            # record.
            pass
        return request
dataset/ETHPy150Open google/nogotofail/nogotofail/mitm/connection/handlers/connection/ccs.py/EarlyCCS.on_request