Example #1
0
File: local.py Project: QiTai/Fukei
 def on_upstream_connect(self, _dummy):
     config = Config.current()
     self.write_reply(0x00, socket.inet_aton('0.0.0.0')
                      + struct.pack("!H", config.server_port))
     self.write_request()
     on_finish = functools.partial(self.on_socks_data, finished=True)
     self.stream.read_until_close(on_finish, self.on_socks_data)
Example #2
0
 def on_upstream_connect(self, _dummy):
     config = Config.current()
     self.write_reply(
         0x00,
         socket.inet_aton('0.0.0.0') +
         struct.pack("!H", config.server_port))
     self.write_request()
     on_finish = functools.partial(self.on_socks_data, finished=True)
     self.stream.read_until_close(on_finish, self.on_socks_data)
Example #3
0
File: local.py Project: QiTai/Fukei
    def do_connect(self):
        config = Config.current()

        logger.debug("server : %s, %s" % (config.server, config.server_port))
        logger.debug("server dest: %s, %s" % self.dest)
        dest = (config.server, config.server_port)
        self.upstream = self.upstream_cls(dest, socket.AF_INET,
                    self.on_upstream_connect, self.on_upstream_error,
                    self.on_upstream_data, self.on_upstream_close)
Example #4
0
    def do_connect(self):
        config = Config.current()

        logger.debug("server : %s, %s" % (config.server, config.server_port))
        logger.debug("server dest: %s, %s" % self.dest)
        dest = (config.server, config.server_port)
        self.upstream = self.upstream_cls(dest, socket.AF_INET,
                                          self.on_upstream_connect,
                                          self.on_upstream_error,
                                          self.on_upstream_data,
                                          self.on_upstream_close)
Example #5
0
 def on_upstream_connect(self, _dummy):
     config = Config.current()
     self.write_request()
     on_finish = functools.partial(self.on_socks_data, finished=True)
     self.stream.read_until_close(on_finish, self.on_socks_data)
     self.stream.write(b'HTTP/1.0 200 Connection established\r\n\r\n')
Example #6
0
        self.upstream.set_close_callback(self.on_close)
        self.upstream.connect(dest, self.on_connect)


    @tornado.web.asynchronous
    def post(self):
        return self.get()

    @tornado.web.asynchronous
    def connect(self):
        logger.debug('Start CONNECT to %s', self.request.uri)
        host, port = self.request.uri.split(':')
        connection = LocalConnectionHttps(self.request.connection.stream, (host, int(port)), fukei.upstream.local.LocalUpstream)


if __name__ == '__main__':
    config_path = os.path.join(os.path.abspath(os.path.join(os.path.dirname(__file__))), 'config', 'config.json')
    config = Config.current(config_path)
    crypto.setup_table(config.password, config.method)

    from fukei.utils import log_config
    log_config('FukeiLocal', config.debug)

    app = tornado.web.Application([
        (r'.*', ProxyHandler),
    ], debug=config.debug)

    app.listen(config.local_port)
    # print ("Starting HTTP proxy on port %d" % config.local_port)
    tornado.ioloop.IOLoop.instance().start()