Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to connect to a Tor bridge from node.js?

Tags:

node.js

https

tor

I am new to Tor. I have recently managed to execute a query from node.js while running a tor server instance on my PC.

I have used the following piece of code:

var Agent = require('socks5-https-client/lib/Agent');
var request = require("request");

var q = "https://www.example.com/";

request({
    url: q,
    agentClass: Agent,
    agentOptions: {
        socksHost: 'localhost',
        socksPort: 9050 // Defaults to 1080.
    }
}, function(err, res) {
    console.log(err || res.body);
});

I would like to connect to Tor without running a Tor server on my PC. I believe this is possible with a Tor bridge. I have retrieved an IP address from https://bridges.torproject.org/bridges:

2.91.117.71:443 3C2AAD50197ACE1A43C822BBE282E0534603A31F

I am not really sure how to use this information. I have tried to set:

    agentOptions: {
        socksHost: '2.91.117.71',
        socksPort: 443
    }

but I get a timeout:

{ [Error: connect ETIMEDOUT] code: 'ETIMEDOUT', errno: 'ETIMEDOUT', syscall: 'connect' }

My questions are:

  1. Is it possible to connect to a public Tor server with https from node.js?
  2. If yes how?
like image 485
Jérôme Verstrynge Avatar asked May 20 '15 08:05

Jérôme Verstrynge


People also ask

How do I connect to Tor Bridge?

If you're starting Tor Browser for the first time, click "Tor Network Settings" to open the Tor settings window. Under the "Bridges" section, select the checkbox "Use a bridge", choose "Provide a bridge I know" and enter each bridge address on a separate line. Click "Connect" to save your settings.

How does a Tor bridge work?

Tor bridges are secret Tor relays that keep your connection to the Tor network hidden. Use a bridge as your first Tor relay if connecting to Tor is blocked or if using Tor could look suspicious to someone who monitors your Internet connection.

Should I use a Tor bridge?

Bridges are a great option if you can only run a Tor node from your home network, have only one static IP address, and don't have a huge amount of bandwidth to donate -- we recommend giving your bridge at least 1 Mbit/sec and it should run 24/7.


1 Answers

A Tor-Bridge is used for people who are not able to connect to the normal Tor-Network because their ISP is blocking the publicly known Tor-Servers. If the first connection is done through a Bridge you wont have problems afterwards because usually these Bridges are not known to everyone so they are usually not blocked by the ISPs as they look like normal servers.

You still need a Tor-Client to connect to them.

There is no way to connect to the Tor network without having a Tor Client.

In your first code your Tor-Client is acting like a socks-proxy and just proxying your requests through the Tor network.

You could try if this library works.

like image 167
B4dT0bi Avatar answered Nov 04 '22 05:11

B4dT0bi