コード例 #1
0
ファイル: server.py プロジェクト: andresp99999/splash
def splash_server(portnum, slots, network_manager, get_splash_proxy_factory=None,
                  js_profiles_path=None, disable_proxy=False, proxy_portnum=None):
    from twisted.internet import reactor
    from twisted.web.server import Site
    from splash.resources import Root
    from splash.pool import RenderPool
    from twisted.python import log

    slots = defaults.SLOTS if slots is None else slots
    log.msg("slots=%s" % slots)

    pool = RenderPool(
        slots=slots,
        network_manager=network_manager,
        get_splash_proxy_factory=get_splash_proxy_factory,
        js_profiles_path=js_profiles_path
    )

    # HTTP API
    root = Root(pool)
    factory = Site(root)
    reactor.listenTCP(portnum, factory)

    # HTTP Proxy
    if disable_proxy is False:
        from splash.proxy_server import SplashProxyFactory
        splash_proxy_factory = SplashProxyFactory(pool)
        proxy_portnum = defaults.PROXY_PORT if proxy_portnum is None else proxy_portnum
        reactor.listenTCP(proxy_portnum, splash_proxy_factory)
コード例 #2
0
def splash_server(portnum, slots, network_manager_factory, max_timeout,
                  splash_proxy_factory_cls=None,
                  js_profiles_path=None,
                  ui_enabled=True,
                  lua_enabled=True,
                  lua_sandbox_enabled=True,
                  lua_package_path="",
                  lua_sandbox_allowed_modules=(),
                  argument_cache_max_entries=None,
                  verbosity=None):
    from twisted.internet import reactor
    from twisted.web.server import Site
    from splash.resources import Root
    from splash.pool import RenderPool
    from twisted.python import log
    from splash import lua

    verbosity = defaults.VERBOSITY if verbosity is None else verbosity
    log.msg("verbosity=%d" % verbosity)

    slots = defaults.SLOTS if slots is None else slots
    log.msg("slots=%s" % slots)

    if argument_cache_max_entries:
        log.msg("argument_cache_max_entries=%s" % argument_cache_max_entries)

    pool = RenderPool(
        slots=slots,
        network_manager_factory=network_manager_factory,
        splash_proxy_factory_cls=splash_proxy_factory_cls,
        js_profiles_path=js_profiles_path,
        verbosity=verbosity,
    )

    if not lua.is_supported() and lua_enabled:
        lua_enabled = False
        log.msg("WARNING: Lua is not available, but --disable-lua option is not passed")

    # HTTP API
    onoff = {True: "enabled", False: "disabled"}
    log.msg(
        "Web UI: %s, Lua: %s (sandbox: %s)" % (
            onoff[ui_enabled],
            onoff[lua_enabled],
            onoff[lua_sandbox_enabled],
        )
    )

    root = Root(
        pool=pool,
        ui_enabled=ui_enabled,
        lua_enabled=lua_enabled,
        lua_sandbox_enabled=lua_sandbox_enabled,
        lua_package_path=lua_package_path,
        lua_sandbox_allowed_modules=lua_sandbox_allowed_modules,
        max_timeout=max_timeout,
        argument_cache_max_entries=argument_cache_max_entries,
    )
    factory = Site(root)
    reactor.listenTCP(portnum, factory)
コード例 #3
0
def splash_server(portnum,
                  slots,
                  network_manager,
                  max_timeout,
                  splash_proxy_factory_cls=None,
                  js_profiles_path=None,
                  disable_proxy=False,
                  proxy_portnum=None,
                  ui_enabled=True,
                  lua_enabled=True,
                  lua_sandbox_enabled=True,
                  lua_package_path="",
                  lua_sandbox_allowed_modules=(),
                  verbosity=None):
    from twisted.internet import reactor
    from twisted.web.server import Site
    from splash.resources import Root
    from splash.pool import RenderPool
    from twisted.python import log

    verbosity = defaults.VERBOSITY if verbosity is None else verbosity
    log.msg("verbosity=%d" % verbosity)

    slots = defaults.SLOTS if slots is None else slots
    log.msg("slots=%s" % slots)

    pool = RenderPool(
        slots=slots,
        network_manager=network_manager,
        splash_proxy_factory_cls=splash_proxy_factory_cls,
        js_profiles_path=js_profiles_path,
        verbosity=verbosity,
    )

    # HTTP API
    onoff = {True: "enabled", False: "disabled"}
    log.msg("Web UI: %s, Lua: %s (sandbox: %s), Proxy Server: %s" % (
        onoff[ui_enabled],
        onoff[lua_enabled],
        onoff[lua_sandbox_enabled],
        onoff[not disable_proxy],
    ))

    root = Root(pool=pool,
                ui_enabled=ui_enabled,
                lua_enabled=lua_enabled,
                lua_sandbox_enabled=lua_sandbox_enabled,
                lua_package_path=lua_package_path,
                lua_sandbox_allowed_modules=lua_sandbox_allowed_modules,
                max_timeout=max_timeout)
    factory = Site(root)
    reactor.listenTCP(portnum, factory)

    # HTTP Proxy
    if not disable_proxy:
        from splash.proxy_server import SplashProxyServerFactory
        proxy_server_factory = SplashProxyServerFactory(
            pool, max_timeout=max_timeout)
        proxy_portnum = defaults.PROXY_PORT if proxy_portnum is None else proxy_portnum
        reactor.listenTCP(proxy_portnum, proxy_server_factory)
コード例 #4
0
def splash_server(portnum, ip, slots, network_manager_factory, max_timeout,
                  splash_proxy_factory_cls=None,
                  js_profiles_path=None,
                  ui_enabled=True,
                  lua_enabled=True,
                  lua_sandbox_enabled=True,
                  lua_package_path="",
                  lua_sandbox_allowed_modules=(),
                  strict_lua_runner=False,
                  argument_cache_max_entries=None,
                  disable_browser_caches=False,
                  verbosity=None):
    from twisted.internet import reactor
    from twisted.web.server import Site
    from splash.resources import Root
    from splash.pool import RenderPool
    from twisted.python import log
    from splash import lua

    verbosity = defaults.VERBOSITY if verbosity is None else verbosity
    slots = defaults.SLOTS if slots is None else slots

    log.msg("verbosity={}, slots={}, argument_cache_max_entries={}, max-timeout={}".format(
        verbosity, slots, argument_cache_max_entries, max_timeout
    ))

    pool = RenderPool(
        slots=slots,
        network_manager_factory=network_manager_factory,
        splash_proxy_factory_cls=splash_proxy_factory_cls,
        js_profiles_path=js_profiles_path,
        verbosity=verbosity,
    )

    if not lua.is_supported() and lua_enabled:
        lua_enabled = False
        log.msg("WARNING: Lua is not available, but --disable-lua option is not passed")

    # HTTP API
    log.msg(
        "Web UI: %s, Lua: %s (sandbox: %s)" % (
            ONOFF[ui_enabled],
            ONOFF[lua_enabled],
            ONOFF[lua_sandbox_enabled],
        )
    )
    root = Root(
        pool=pool,
        ui_enabled=ui_enabled,
        lua_enabled=lua_enabled,
        lua_sandbox_enabled=lua_sandbox_enabled,
        lua_package_path=lua_package_path,
        lua_sandbox_allowed_modules=lua_sandbox_allowed_modules,
        max_timeout=max_timeout,
        argument_cache_max_entries=argument_cache_max_entries,
        strict_lua_runner=strict_lua_runner,
    )
    factory = Site(root)
    reactor.listenTCP(portnum, factory, interface=ip)
    log.msg("Server listening on http://%s:%s" % (ip, portnum))