Пример #1
0
    def do_POST(self):
        xlog.debug('x-tunnel web_control %s %s %s ', self.address_string(), self.command, self.path)
        try:
            ctype, pdict = cgi.parse_header(self.headers.getheader('content-type'))
            if ctype == 'multipart/form-data':
                self.postvars = cgi.parse_multipart(self.rfile, pdict)
            elif ctype == 'application/x-www-form-urlencoded':
                length = int(self.headers.getheader('content-length'))
                self.postvars = urlparse.parse_qs(self.rfile.read(length), keep_blank_values=1)
            else:
                self.postvars = {}
        except:
            self.postvars = {}

        path = urlparse.urlparse(self.path).path
        if path == '/login':
            return self.req_login_handler()
        elif path == "/logout":
            return self.req_logout_handler()
        elif path == "/register":
            return self.req_login_handler()
        elif path == "/config":
            return self.req_config_handler()
        elif path == "/order":
            return self.req_order_handler()
        elif path == "/transfer":
            return self.req_transfer_handler()
        elif path.startswith("/cloudflare_front/"):
            path = path[17:]
            controler = cloudflare_web.ControlHandler(self.client_address,
                                                      self.headers,
                                                      self.command, path,
                                                      self.rfile, self.wfile)
            controler.do_POST()
        elif path.startswith("/cloudfront_front/"):
            path = path[17:]
            controler = cloudfront_web.ControlHandler(self.client_address,
                                                      self.headers,
                                                      self.command, path,
                                                      self.rfile, self.wfile)
            controler.do_POST()
        elif path.startswith("/heroku_front/"):
            path = path[13:]
            controler = heroku_web.ControlHandler(self.client_address,
                                                      self.headers,
                                                      self.command, path,
                                                      self.rfile, self.wfile)
            controler.do_POST()
        elif path.startswith("/tls_relay_front/"):
            path = path[16:]
            controler = tls_relay_web.ControlHandler(self.client_address,
                                                      self.headers,
                                                      self.command, path,
                                                      self.rfile, self.wfile)
            controler.do_POST()
        else:
            xlog.info('%s "%s %s HTTP/1.1" 404 -', self.address_string(), self.command, self.path)
            return self.send_not_found()
Пример #2
0
 def do_GET(self):
     path = urlparse.urlparse(self.path).path
     if path == "/log":
         return self.req_log_handler()
     elif path == "/debug":
         data = g.session.status()
         return self.send_response('text/html', data)
     elif path == "/info":
         return self.req_info_handler()
     elif path == "/config":
         return self.req_config_handler()
     elif path == "/get_history":
         return self.req_get_history_handler()
     elif path == "/status":
         return self.req_status()
     elif path.startswith("/cloudflare_front/"):
         path = self.path[17:]
         controler = cloudflare_web.ControlHandler(self.client_address,
                          self.headers,
                          self.command, path,
                          self.rfile, self.wfile)
         controler.do_GET()
     elif path.startswith("/cloudfront_front/"):
         path = self.path[17:]
         controler = cloudfront_web.ControlHandler(self.client_address,
                          self.headers,
                          self.command, path,
                          self.rfile, self.wfile)
         controler.do_GET()
     elif path.startswith("/heroku_front/"):
         path = self.path[13:]
         controler = heroku_web.ControlHandler(self.client_address,
                          self.headers,
                          self.command, path,
                          self.rfile, self.wfile)
         controler.do_GET()
     elif path.startswith("/tls_relay_front/"):
         path = self.path[16:]
         controler = tls_relay_web.ControlHandler(self.client_address,
                          self.headers,
                          self.command, path,
                          self.rfile, self.wfile)
         controler.do_GET()
     else:
         xlog.warn('Control Req %s %s %s ', self.address_string(), self.command, self.path)