bulb/context~ TorContext

new TorContext(torConfigopt, torControlopt)

Primary interface for doing things "over tor". Manages a tor process, creates and establishes a control connection, and offers it's own interface for creating and handling connections made through the tor network.

Parameters:
NameTypeAttributesDescription
torConfigmodule:bulb/config~TorConfig | object<optional>

Configuration for the tor process

torControlmodule:bulb/control~TorControl | object<optional>

Control connection to a tor process

Members

control

Connection to the to control port.

Properties
NameTypeDescription
controlmodule:bulb/control~TorControl

process

Child tor process managed by this context.

Properties
NameTypeDescription
processchild_process.ChildProcess

Methods

connect(optionsopt) → {Promise.<module:bulb/network~HiddenSocket>}

Parameters:
NameTypeAttributesDescription
optionsmodule:bulb/network~HiddenSocket~ConnectOptions<optional>

Passed to the created module:bulb/network~HiddenSocket.

Returns:
Type: 
Promise.<module:bulb/network~HiddenSocket>

createConnection(connectListeneropt) → {module:bulb/network~HiddenSocket}

Create a "tor-ified" TCP socket in this module:bulb/context~TorContext.

Parameters:
NameTypeAttributesDescription
connectListenermodule:bulb/network~HiddenSocket~ConnectListener<optional>

Sets a one time listener for module:bulb/network~HiddenSocket#events:connect.

createServer(optionsopt, connectionListeneropt) → {module:bulb/network~HiddenServer}

Create a "tor-ified" TCP server in this context. Exposes an onion service.

Parameters:
NameTypeAttributesDescription
optionsmodule:bulb/network~HiddenServer~ServerOptions<optional>

Passed to the created modulex:bulb/network~HiddenServer.

connectionListenermodule:bulb/network~HiddenServer~ConnectionListener<optional>

Passed to the created module:bulb/network~HiddenServer.

createTorHttpAgent() → {module:bulb/network~TorHttpAgent}

Create a "tor-ified" http.Agent for sending HTTP requests through this context.

openControlConnection(optionsopt) → {Promise.<module:bulb/control~TorControl>}

Connects the module:bulb/control~TorControl to the child process.

Parameters:
NameTypeAttributesDescription
optionsobject<optional>
Properties
NameTypeAttributesDescription
retrynumber<optional>

If unsuccessful connecting, try again

delaynumber<optional>

Wait time between retries

Returns:
Type: 
Promise.<module:bulb/control~TorControl>

readControlPort(delayopt) → {Promise.<number>}

Reads the tor process control port.

Parameters:
NameTypeAttributesDefaultDescription
delaynumber<optional>
10

Milliseconds to wait before read

Returns:

port

Type: 
Promise.<number>

readSocksPort() → {Promise.<number>}

Reads the tor process SOCKSv5 proxy port.

Returns:

port

Type: 
Promise.<number>

spawnTorChildProcess(argsopt) → {Promise.<process.ChildProcess>}

Spawns a tor process for this context.

Parameters:
NameTypeAttributesDescription
argsArray.<string><optional>

Arguments to pass the tor executable

Returns:
Type: 
Promise.<process.ChildProcess>

(static) create(optionsopt) → {Promise.<module:bulb/context~TorContext>}

Parameters:
NameTypeAttributesDescription
optionsmodule:bulb/config~TorConfig | object<optional>

Passed to the created module:bulb/context~TorContext.

Returns:
Type: 
Promise.<module:bulb/context~TorContext>

(static) getExecPath(platformopt) → {string}

Returns the local path to the tor bundle.

Parameters:
NameTypeAttributesDefaultDescription
platformstring<optional>
os.platform()

OS identifier

Returns:
Type: 
string