예제 #1
0
    def onConnectionRequest(self, pdu: X224ConnectionRequestPDU):
        """
        Log the connection cookie and handle connection protocols.
        :param pdu: the connection request
        """

        parser = NegotiationRequestParser()
        self.originalRequest = parser.parse(pdu.payload)
        self.state.requestedProtocols = self.originalRequest.requestedProtocols

        if self.originalRequest.cookie:
            self.log.info("%(cookie)s",
                          {"cookie": self.originalRequest.cookie.decode()})
        else:
            self.log.info("No cookie for this connection")

        chosenProtocols = self.originalRequest.requestedProtocols

        if chosenProtocols is not None:
            # Only SSL is implemented, so remove other protocol flags
            chosenProtocols &= NegotiationProtocols.SSL

        modifiedRequest = NegotiationRequestPDU(
            self.originalRequest.cookie,
            self.originalRequest.flags,
            chosenProtocols,
            self.originalRequest.correlationFlags,
            self.originalRequest.correlationID,
        )

        payload = parser.write(modifiedRequest)
        defer(self.connectToServer(payload))
예제 #2
0
    def onConnectionRequest(self, pdu: X224ConnectionRequestPDU):
        """
        Log the connection cookie and handle connection protocols.
        :param pdu: the connection request
        """

        parser = NegotiationRequestParser()
        self.originalRequest = parser.parse(pdu.payload)
        self.state.requestedProtocols = self.originalRequest.requestedProtocols

        if self.originalRequest.flags & NegotiationRequestFlags.RESTRICTED_ADMIN_MODE_REQUIRED:
            self.log.warning("Client has enabled Restricted Admin Mode, which forces Network-Level Authentication (NLA)."
                             " Connection will fail.", {"restrictedAdminActivated": True})

        if self.originalRequest.cookie:
            self.log.info("%(cookie)s", {"cookie": self.originalRequest.cookie.decode()})
        else:
            self.log.info("No cookie for this connection")

        chosenProtocols = self.originalRequest.requestedProtocols

        if chosenProtocols is not None:
            # Tell the server we only support the allowed authentication methods.
            chosenProtocols &= self.state.config.authMethods

        modifiedRequest = NegotiationRequestPDU(
            self.originalRequest.cookie,
            self.originalRequest.flags,
            chosenProtocols,
            self.originalRequest.correlationFlags,
            self.originalRequest.correlationID,
        )

        payload = parser.write(modifiedRequest)
        defer(self.connectToServer(payload))