Class: Commands

Commands

Aggregates commands to manage GlaceJS proxy.


new Commands(config [, opts])

Creates commands instance.

Parameters:
Name Type Argument Description
config object

Commands config.

opts object <optional>

Commands options.

Properties
Name Type Argument Default Description
logger function <optional>

Commands logger. Default is system logger.

colored boolean <optional>
false

Flag to use ANSI color in log message.

GlobalProxy object <optional>

Global proxy class.

HttpProxy object <optional>

HTTP proxy class.

isRunning object <optional>

Function to detect is process launched.

Source:

Methods


<protected> _checkProxy()

Helper to check whether any proxy is launched.

Source:
Returns:

true if proxy exists and launched, false otherwise.

Type
boolean

<protected> _chromeUrl()

Helper to get URL to open in chrome browser. If HTTP proxy is launched, it will return proxy URL.

Source:
Returns:

URL to open chrome.

Type
string

<protected> _isChromeLaunched()

Helper to define whether chrome is launched.

Source:
Returns:
Type
boolean

<protected> _isGlobalProxyLaunched()

Helper to define whether global proxy is running.

Source:
Returns:
Type
boolean

<protected> _isHttpProxyLaunched()

Helper to define whether http proxy is running.

Source:
Returns:
Type
boolean

<async> clearProxyCache()

Command to clear proxy cache.

Source:
Returns:

true when cache will be cleared.

Type
Promise.<boolean>

<async> closeChrome()

Command to close chrome browser.

Source:
Returns:

true if chrome browser was closed. false if command can't be executed. Causes to not close chrome browser:

  • Chrome browser isn't launched yet.
Type
Promise.<boolean>

<async> disableProxyCache()

Command to disable proxy cache.

Source:
Returns:

true if proxy cache wasn't disabled. false if command can't be executed. Causes to not disable proxy cache:

  • HTTP proxy isn't launched.
Type
Promise.<boolean>

<async> enableProxyCache()

Command to enable proxy cache.

Source:
Returns:

true if proxy cache wasn't enabled. false if command can't be executed. Causes to not enable proxy cache:

  • HTTP proxy isn't launched.
Type
Promise.<boolean>

<async> launchChrome( [opts])

Command to launch chrome browser.

Parameters:
Name Type Argument Description
opts object <optional>

Options.

Properties
Name Type Argument Default Description
chromeOpts Array.<string> <optional>
[]

Chrome options list.

Source:
Returns:

true if chrome browser was launched. false if command can't be executed. Causes to not launch chrome browser:

  • HTTP proxy isn't launched yet.
  • Chrome browser is launched already.
Type
Promise.<boolean>

<async> launchGlobalProxy()

Command to launch global transparent proxy.

Source:
Returns:

true if global transparent proxy isn't launched. false if command can't be executed. Causes to not launch global transparent proxy:

  • Global transparent proxy is launched already.
Type
Promise.<boolean>

<async> launchHttpProxy()

Command to launch HTTP proxy.

Source:
Returns:

true if HTTP proxy was launched. false if command can't be executed. Causes to not launch HTTP proxy:

  • HTTP proxy is launched already.
  • Proxied URL isn't specified.
Type
Promise.<boolean>

<async> resetProxySpeed()

Command to reset proxy speed.

Source:
Returns:

true if proxy speed was reset. false if command can't be executed. Causes to not reset proxy speed:

  • HTTP proxy isn't launched.
Type
Promise.<boolean>

<async> restartChrome()

Command to restart chrome browser.

Source:
Returns:

true if chrome browser was restarted. false if command can't be executed. Causes to not restart chrome browser are the the same as for command to launch chrome browser.

Type
Promise.<boolean>

<async> restartGlobalProxy()

Command to restart global transparent proxy.

Source:
Returns:

true if global transparent proxy was restarted. false if command can't be executed. Causes to not restart global transparent proxy are the same as for command to launch global transparent proxy.

Type
Promise.<boolean>

<async> restartHttpProxy()

Command to restart HTTP proxy.

Source:
Returns:

true if HTTP proxy was restarted. false if command can't be executed. Causes to not restart HTTP proxy are the same as for command to launch HTTP proxy.

Type
Promise.<boolean>

<async> setProxiedUrl()

Command to set proxied URL.

Source:
Returns:
Type
Promise

<async> setProxySpeed(speed)

Command to set proxy speed.

Parameters:
Name Type Description
speed number

Proxy speed, kb/s.

Properties
Name Type Argument Description
req number <optional>
<nullable>

Requests speed, kb/s.

res number <optional>
<nullable>

Responses speed, kb/s.

Source:
Returns:

true if proxy speed was set. false if command can't be executed. Causes to not set proxy speed:

  • HTTP proxy isn't launched.
Type
Promise.<boolean>

<async> stopGlobalProxy( [opts])

Command to stop global transparent proxy.

Parameters:
Name Type Argument Description
opts object <optional>

Options.

Properties
Name Type Argument Default Description
restartChrome boolean <optional>
true

Restart chrome.

Source:
Returns:

true if global transparent proxy was stopped. false if command can't be executed. Causes to not stop global transparent proxy:

  • Global transparent proxy isn't launched yet.
Type
Promise.<boolean>

<async> stopHttpProxy( [opts])

Command to stop HTTP proxy.

Parameters:
Name Type Argument Description
opts object <optional>

Options.

Properties
Name Type Argument Default Description
restartChrome boolean <optional>
true

Restart chrome.

Source:
Returns:

true if HTTP proxy was stopped. false if command can't be executed. Causes to not stop HTTP proxy:

  • HTTP proxy isn't launched yet.
Type
Promise.<boolean>