talmobi / tor-request

light Tor proxy wrapper for request library
http://tor.jin.fi/
311 stars 43 forks source link

Improve error messages -- tell user if tor client is found or not #5

Closed talmobi closed 6 years ago

talmobi commented 6 years ago

Improved error messages have now been added that will detect common errors and provide links and useful guidelines on how to fix.

Examples:

no tor running

v2.1.1

(node:52167) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): Error: connect ECONNREFUSED 127.0.0.1:9050
 - Are you running `tor`?
See easy guide here (OSX, Linux, Windows):
https://github.com/talmobi/tor-request#requirements

 Quickfixes:
  OSX: `brew install tor && tor`         # installs and runs tor
  Debian/Ubuntu: `apt-get install tor`   # should auto run as daemon after install

v1.2.2

Error: Socket Closed - Are you running `tor`?
See easy guide here (OSX, Linux, Windows):
https://github.com/talmobi/tor-request#requirements

 Quickfixes:
  OSX: `brew install tor && tor`         # installs and runs tor
  Debian/Ubuntu: `apt-get install tor`   # should auto run as daemon after install

    at Socket.<anonymous> (/Users/mollie/tmp/tor-request/node_modules/socks/lib/socks-client.js:61:20)
    at Socket.g (events.js:292:16)
    at emitOne (events.js:96:13)
    at Socket.emit (events.js:188:7)
    at TCP._handle.close [as _onclose] (net.js:497:12)

no ControlPort when requesting new session

v2.1.1

Error: connect ECONNREFUSED 127.0.0.1:9051 - Have you enabled the ControlPort in your `torrc` file? (/usr/local/etc/tor/torrc ?)

See easy guide here (OSX, Linux, Windows):
https://github.com/talmobi/tor-request#optional-configuring-tor-enabling-the-controlport

 Sample torrc file:
     ControlPort 9051
     HashedControlPassword 16:AEBC98A67.....E81DF

   Generate HashedControlPassword with (last output line):
     `tor --hash-password my_secret_password`

   Tell tor-request the password to use:
     `require( "tor-request" ).TorControlPort.password = "my_secret_password"`

    at Object.exports._errnoException (util.js:1020:11)
    at exports._exceptionWithHostPort (util.js:1043:20)
    at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1090:14)

v1.2.2

Error: connect ECONNREFUSED 127.0.0.1:9051 - Have you enabled the ControlPort in your `torrc` file? (/usr/local/etc/tor/torrc ?)

See easy guide here (OSX, Linux, Windows):
https://github.com/talmobi/tor-request#optional-configuring-tor-enabling-the-controlport

 Sample torrc file:
     ControlPort 9051
     HashedControlPassword 16:AEBC98A67.....E81DF

   Generate HashedControlPassword with (last output line):
     `tor --hash-password my_secret_password`

   Tell tor-request the password to use:
     `require( "tor-request" ).TorControlPort.password = "my_secret_password"`

    at Object.exports._errnoException (util.js:1020:11)
    at exports._exceptionWithHostPort (util.js:1043:20)
    at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1090:14)

ControlPort wrong password used

v2.1.1

Error: Error communicating with Tor ControlPort
515 Authentication failed: Password did not match HashedControlPassword value from configuration
 - Have you enabled the ControlPort in your `torrc` file? (/usr/local/etc/tor/torrc ?)

See easy guide here (OSX, Linux, Windows):
https://github.com/talmobi/tor-request#optional-configuring-tor-enabling-the-controlport

 Sample torrc file:
     ControlPort 9051
     HashedControlPassword 16:AEBC98A67.....E81DF

   Generate HashedControlPassword with (last output line):
     `tor --hash-password my_secret_password`

   Tell tor-request the password to use:
     `require( "tor-request" ).TorControlPort.password = "my_secret_password"`

    at /Users/mollie/code/tor-request/index.js:303:19
    at Socket.<anonymous> (/Users/mollie/code/tor-request/index.js:272:7)
    at emitNone (events.js:91:20)
    at Socket.emit (events.js:185:7)
    at endReadableNT (_stream_readable.js:974:12)
    at _combinedTickCallback (internal/process/next_tick.js:80:11)
    at process._tickCallback (internal/process/next_tick.js:104:9)

v1.2.2

Error: Error communicating with Tor ControlPort
515 Authentication failed: Password did not match HashedControlPassword value from configuration
 - Have you enabled the ControlPort in your `torrc` file? (/usr/local/etc/tor/torrc ?)

See easy guide here (OSX, Linux, Windows):
https://github.com/talmobi/tor-request#optional-configuring-tor-enabling-the-controlport

 Sample torrc file:
     ControlPort 9051
     HashedControlPassword 16:AEBC98A67.....E81DF

   Generate HashedControlPassword with (last output line):
     `tor --hash-password my_secret_password`

   Tell tor-request the password to use:
     `require( "tor-request" ).TorControlPort.password = "my_secret_password"`

    at /Users/mollie/tmp/tor-request/index.js:268:19
    at Socket.<anonymous> (/Users/mollie/tmp/tor-request/index.js:238:7)
    at emitNone (events.js:91:20)
    at Socket.emit (events.js:185:7)
    at endReadableNT (_stream_readable.js:974:12)
    at _combinedTickCallback (internal/process/next_tick.js:80:11)
    at process._tickCallback (internal/process/next_tick.js:104:9)
talmobi commented 6 years ago

https://github.com/talmobi/tor-request/commit/4c69ae62b000f05b3c2b1f73e1fce609f8b4ae04 https://github.com/talmobi/tor-request/commit/b5e24d60e7ecb7a0e0ac835dd994e4c5ddf42ac3

https://github.com/talmobi/tor-request/issues/20 https://github.com/talmobi/tor-request/issues/11 https://github.com/talmobi/tor-request/issues/3 https://github.com/talmobi/tor-request/issues/1