Esempio n. 1
0
File: JAP.py Progetto: web883/jap
    def action_JAP_UPDATE(self, request):
        data = request.args["data"][0]

        decoder = JAP_LOCAL.JSONDecoder()
        configuration = decoder.decode(data)

        JAP_LOCAL.setConfiguration("./JAP.json", configuration,
                                   getDefaultConfiguration)

        logger = logging.getLogger("JAP")

        if configuration["LOGGER"]["LEVEL"] == "DEBUG":
            logger.setLevel(logging.DEBUG)
        elif configuration["LOGGER"]["LEVEL"] == "INFO":
            logger.setLevel(logging.INFO)
        elif configuration["LOGGER"]["LEVEL"] == "WARNING":
            logger.setLevel(logging.WARNING)
        elif configuration["LOGGER"]["LEVEL"] == "ERROR":
            logger.setLevel(logging.ERROR)
        elif configuration["LOGGER"]["LEVEL"] == "CRITICAL":
            logger.setLevel(logging.CRITICAL)
        else:
            logger.setLevel(logging.NOTSET)

        resolver = JAP_LOCAL.createResolver(configuration)
        reactor.installResolver(resolver)

        return ""
Esempio n. 2
0
    def processMessageState0(self):
        logger.debug("WSOutputProtocol.processMessageState0")

        decoder = JAP_LOCAL.JSONDecoder()
        response = decoder.decode(self.message)

        self.inputProtocol.outputProtocol_connectionMade()

        self.message = ""
        self.messageState = 1
Esempio n. 3
0
File: JAP.py Progetto: web883/jap
    def action_JAP_REMOTE_WS_UPDATE(self, request):
        data = request.args["data"][0]

        decoder = JAP_LOCAL.JSONDecoder()
        configuration = decoder.decode(data)

        JAP_LOCAL.setConfiguration("./JAP_REMOTE_WS.json", configuration,
                                   JAP_REMOTE_WS.getDefaultConfiguration)

        return ""
Esempio n. 4
0
    def processMessageState0(self):
        logger.debug("WSInputProtocol.processMessageState0")

        decoder = JAP_LOCAL.JSONDecoder()
        request = decoder.decode(self.message)

        authorized = False

        if len(self.configuration["REMOTE_PROXY_SERVER"]
               ["AUTHENTICATION"]) == 0:
            authorized = True

        if authorized == False:
            i = 0
            while i < len(self.configuration["REMOTE_PROXY_SERVER"]
                          ["AUTHENTICATION"]):
                if self.configuration["REMOTE_PROXY_SERVER"]["AUTHENTICATION"][
                        i]["USERNAME"] == request["REMOTE_PROXY_SERVER"][
                            "AUTHENTICATION"][
                                "USERNAME"] and self.configuration[
                                    "REMOTE_PROXY_SERVER"]["AUTHENTICATION"][
                                        i]["PASSWORD"] == request[
                                            "REMOTE_PROXY_SERVER"][
                                                "AUTHENTICATION"]["PASSWORD"]:
                    authorized = True
                    break

                i = i + 1

        if authorized == False:
            self.sendClose()

            return

        self.remoteAddress = request["REMOTE_ADDRESS"]
        self.remotePort = request["REMOTE_PORT"]

        logger.debug("WSInputProtocol.remoteAddress: " + self.remoteAddress)
        logger.debug("WSInputProtocol.remotePort: " + str(self.remotePort))

        outputProtocolFactory = WSOutputProtocolFactory(self)
        outputProtocolFactory.protocol = WSOutputProtocol

        tunnel = JAP_LOCAL.Tunnel(self.configuration)
        tunnel.connect(self.remoteAddress, self.remotePort,
                       outputProtocolFactory)