Exemplo n.º 1
0
    def req_config_handler(self):
        req = urlparse.urlparse(self.path).query
        reqs = urlparse.parse_qs(req, keep_blank_values=True)
        data = ''

        appid_updated = False

        try:
            if reqs['cmd'] == ['get_config']:
                data = json.dumps(user_config.user_special, default=lambda o: o.__dict__)
            elif reqs['cmd'] == ['set_config']:
                appids = self.postvars['appid'][0]
                if appids != user_config.user_special.appid:
                    if appids:
                        fail_appid_list = test_appid.test_appids(appids)
                        if len(fail_appid_list):
                            fail_appid = "|".join(fail_appid_list)
                            return self.send_response('text/html', '{"res":"fail", "reason":"appid fail:%s"}' % fail_appid)

                    appid_updated = True
                    user_config.user_special.appid = appids
                user_config.user_special.password = self.postvars['password'][0]
                user_config.user_special.proxy_enable = self.postvars['proxy_enable'][0]
                user_config.user_special.proxy_type = self.postvars['proxy_type'][0]
                user_config.user_special.proxy_host = self.postvars['proxy_host'][0]
                user_config.user_special.proxy_port = self.postvars['proxy_port'][0]
                if not user_config.user_special.proxy_port:
                    user_config.user_special.proxy_port = 0
                user_config.user_special.proxy_user = self.postvars['proxy_user'][0]
                user_config.user_special.proxy_passwd = self.postvars['proxy_passwd'][0]
                user_config.user_special.host_appengine_mode = self.postvars['host_appengine_mode'][0]
                use_ipv6 = int(self.postvars['use_ipv6'][0])
                if user_config.user_special.use_ipv6 != use_ipv6:
                    if use_ipv6:
                        if not check_ip.check_ipv6():
                            xlog.warn("Enable Ipv6 but check failed.")
                            return self.send_response('text/html', '{"res":"fail", "reason":"IPv6 fail"}')

                    user_config.user_special.use_ipv6 = use_ipv6
                user_config.save()

                config.load()
                appid_manager.reset_appid()
                import connect_manager
                connect_manager.load_proxy_config()
                connect_manager.https_manager.load_config()
                if appid_updated:
                    connect_manager.https_manager.clean_old_connection()

                google_ip.reset()
                check_ip.load_proxy_config()

                data = '{"res":"success"}'
                self.send_response('text/html', data)
                #http_request("http://127.0.0.1:8085/init_module?module=gae_proxy&cmd=restart")
                return
        except Exception as e:
            xlog.exception("req_config_handler except:%s", e)
            data = '{"res":"fail", "except":"%s"}' % e
        self.send_response('text/html', data)
Exemplo n.º 2
0
    def req_config_handler(self):
        req = urlparse.urlparse(self.path).query
        reqs = urlparse.parse_qs(req, keep_blank_values=True)
        data = ''

        try:
            if reqs['cmd'] == ['get_config']:
                data = json.dumps(user_config.user_special,
                                  default=lambda o: o.__dict__)
            elif reqs['cmd'] == ['set_config']:
                user_config.user_special.appid = self.postvars['appid'][0]
                user_config.user_special.password = self.postvars['password'][
                    0]
                user_config.user_special.proxy_enable = self.postvars[
                    'proxy_enable'][0]
                user_config.user_special.proxy_type = self.postvars[
                    'proxy_type'][0]
                user_config.user_special.proxy_host = self.postvars[
                    'proxy_host'][0]
                user_config.user_special.proxy_port = self.postvars[
                    'proxy_port'][0]
                user_config.user_special.proxy_user = self.postvars[
                    'proxy_user'][0]
                user_config.user_special.proxy_passwd = self.postvars[
                    'proxy_passwd'][0]
                user_config.user_special.host_appengine_mode = self.postvars[
                    'host_appengine_mode'][0]
                user_config.user_special.ip_connect_interval = int(
                    self.postvars['ip_connect_interval'][0])
                user_config.user_special.use_ipv6 = int(
                    self.postvars['use_ipv6'][0])
                user_config.user_special.connect_interval = int(
                    self.postvars['connect_interval'][0])
                user_config.save()

                config.load()
                appid_manager.reset_appid()
                import connect_manager
                connect_manager.load_sock()
                connect_manager.https_manager.load_config()
                connect_manager.forwork_manager.load_config()

                google_ip.load_config()
                check_ip.load_sock()

                data = '{"res":"success"}'
                self.send_response('text/html', data)
                #http_request("http://127.0.0.1:8085/init_module?module=gae_proxy&cmd=restart")
                return
        except Exception as e:
            xlog.exception("req_config_handler except:%s", e)
            data = '{"res":"fail", "except":"%s"}' % e
        self.send_response('text/html', data)
Exemplo n.º 3
0
    def req_config_handler(self):
        req = urlparse.urlparse(self.path).query
        reqs = urlparse.parse_qs(req, keep_blank_values=True)
        data = ''

        appid_updated = False

        try:
            if reqs['cmd'] == ['get_config']:
                data = json.dumps(user_config.user_special,
                                  default=lambda o: o.__dict__)
            elif reqs['cmd'] == ['set_config']:
                appids = self.postvars['appid'][0]
                if appids != user_config.user_special.appid:
                    if appids and (google_ip.good_ipv4_num +
                                   google_ip.good_ipv6_num):
                        fail_appid_list = test_appid.test_appids(appids)
                        if len(fail_appid_list):
                            fail_appid = "|".join(fail_appid_list)
                            return self.send_response_nc(
                                'text/html',
                                '{"res":"fail", "reason":"appid fail:%s"}' %
                                fail_appid)

                    appid_updated = True
                    user_config.user_special.appid = appids

                user_config.save()

                config.load()
                appid_manager.reset_appid()
                import connect_manager
                connect_manager.https_manager.load_config()
                if appid_updated:
                    http_dispatch.close_all_worker()

                google_ip.reset()

                data = '{"res":"success"}'
                self.send_response_nc('text/html', data)
                #http_request("http://127.0.0.1:8085/init_module?module=gae_proxy&cmd=restart")
                return
        except Exception as e:
            xlog.exception("req_config_handler except:%s", e)
            data = '{"res":"fail", "except":"%s"}' % e
        self.send_response_nc('text/html', data)
Exemplo n.º 4
0
    def req_config_handler(self):
        req = urlparse.urlparse(self.path).query
        reqs = urlparse.parse_qs(req, keep_blank_values=True)
        data = ""

        try:
            if reqs["cmd"] == ["get_config"]:
                data = json.dumps(user_config.user_special, default=lambda o: o.__dict__)
            elif reqs["cmd"] == ["set_config"]:
                user_config.user_special.appid = self.postvars["appid"][0]
                user_config.user_special.password = self.postvars["password"][0]
                user_config.user_special.proxy_enable = self.postvars["proxy_enable"][0]
                user_config.user_special.proxy_type = self.postvars["proxy_type"][0]
                user_config.user_special.proxy_host = self.postvars["proxy_host"][0]
                user_config.user_special.proxy_port = self.postvars["proxy_port"][0]
                user_config.user_special.proxy_user = self.postvars["proxy_user"][0]
                user_config.user_special.proxy_passwd = self.postvars["proxy_passwd"][0]
                user_config.user_special.host_appengine_mode = self.postvars["host_appengine_mode"][0]
                user_config.user_special.ip_connect_interval = int(self.postvars["ip_connect_interval"][0])
                user_config.user_special.use_ipv6 = int(self.postvars["use_ipv6"][0])
                user_config.user_special.connect_interval = int(self.postvars["connect_interval"][0])
                user_config.save()

                config.load()
                appid_manager.reset_appid()
                import connect_manager

                connect_manager.load_proxy_config()
                connect_manager.https_manager.load_config()
                connect_manager.forwork_manager.load_config()

                google_ip.reset()
                check_ip.load_proxy_config()

                data = '{"res":"success"}'
                self.send_response("text/html", data)
                # http_request("http://127.0.0.1:8085/init_module?module=gae_proxy&cmd=restart")
                return
        except Exception as e:
            xlog.exception("req_config_handler except:%s", e)
            data = '{"res":"fail", "except":"%s"}' % e
        self.send_response("text/html", data)
Exemplo n.º 5
0
    def req_config_handler(self):
        req = urlparse.urlparse(self.path).query
        reqs = urlparse.parse_qs(req, keep_blank_values=True)
        data = ''

        appid_updated = False

        try:
            if reqs['cmd'] == ['get_config']:
                data = json.dumps(user_config.user_special, default=lambda o: o.__dict__)
            elif reqs['cmd'] == ['set_config']:
                appids = self.postvars['appid'][0]
                if appids != user_config.user_special.appid:
                    if appids and (google_ip.good_ipv4_num + google_ip.good_ipv6_num):
                        fail_appid_list = test_appid.test_appids(appids)
                        if len(fail_appid_list):
                            fail_appid = "|".join(fail_appid_list)
                            return self.send_response_nc('text/html', '{"res":"fail", "reason":"appid fail:%s"}' % fail_appid)

                    appid_updated = True
                    user_config.user_special.appid = appids

                user_config.save()

                config.load()
                appid_manager.reset_appid()
                import connect_manager
                connect_manager.https_manager.load_config()
                if appid_updated:
                    http_dispatch.close_all_worker()

                google_ip.reset()

                data = '{"res":"success"}'
                self.send_response_nc('text/html', data)
                #http_request("http://127.0.0.1:8085/init_module?module=gae_proxy&cmd=restart")
                return
        except Exception as e:
            xlog.exception("req_config_handler except:%s", e)
            data = '{"res":"fail", "except":"%s"}' % e
        self.send_response_nc('text/html', data)
Exemplo n.º 6
0
    def req_config_handler(self):
        req = urlparse.urlparse(self.path).query
        reqs = urlparse.parse_qs(req, keep_blank_values=True)
        data = ''

        appid_updated = False

        try:
            if reqs['cmd'] == ['get_config']:
                data = json.dumps(user_config.user_special,
                                  default=lambda o: o.__dict__)
            elif reqs['cmd'] == ['set_config']:
                appids = self.postvars['appid'][0]
                if appids != user_config.user_special.appid:
                    if appids and google_ip.good_ip_num:
                        fail_appid_list = test_appid.test_appids(appids)
                        if len(fail_appid_list):
                            fail_appid = "|".join(fail_appid_list)
                            return self.send_response_nc(
                                'text/html',
                                '{"res":"fail", "reason":"appid fail:%s"}' %
                                fail_appid)

                    appid_updated = True
                    user_config.user_special.appid = appids

                user_config.user_special.proxy_enable = self.postvars[
                    'proxy_enable'][0]
                user_config.user_special.proxy_type = self.postvars[
                    'proxy_type'][0]
                user_config.user_special.proxy_host = self.postvars[
                    'proxy_host'][0]
                user_config.user_special.proxy_port = self.postvars[
                    'proxy_port'][0]
                try:
                    user_config.user_special.proxy_port = int(
                        user_config.user_special.proxy_port)
                except:
                    user_config.user_special.proxy_port = 0

                user_config.user_special.proxy_user = self.postvars[
                    'proxy_user'][0]
                user_config.user_special.proxy_passwd = self.postvars[
                    'proxy_passwd'][0]
                user_config.user_special.host_appengine_mode = self.postvars[
                    'host_appengine_mode'][0]

                use_ipv6 = int(self.postvars['use_ipv6'][0])
                if user_config.user_special.use_ipv6 != use_ipv6:
                    if use_ipv6:
                        if not check_local_network.check_ipv6():
                            xlog.warn("IPv6 was enabled, but check failed.")
                            return self.send_response_nc(
                                'text/html',
                                '{"res":"fail", "reason":"IPv6 fail"}')

                    user_config.user_special.use_ipv6 = use_ipv6

                user_config.save()

                config.load()
                appid_manager.reset_appid()
                import connect_manager
                connect_manager.load_proxy_config()
                connect_manager.https_manager.load_config()
                if appid_updated:
                    http_dispatch.close_all_worker()

                google_ip.reset()
                check_ip.load_proxy_config()

                data = '{"res":"success"}'
                self.send_response_nc('text/html', data)
                #http_request("http://127.0.0.1:8085/init_module?module=gae_proxy&cmd=restart")
                return
        except Exception as e:
            xlog.exception("req_config_handler except:%s", e)
            data = '{"res":"fail", "except":"%s"}' % e
        self.send_response_nc('text/html', data)