-
Notifications
You must be signed in to change notification settings - Fork 8
/
run.js
40 lines (35 loc) · 1.12 KB
/
run.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
var pwdGenerator = require('./hashPwdGenerator.js');
var fs = require('fs');
var shell = require('shelljs');
// command full ./tor-browser_en-US/Browser/TorBrowser/Tor/tor
const MY_TORRC_FILE = './tor_conf/my-torrc';
const tor = './tor-browser_en-US/Browser/TorBrowser/Tor/tor';
function generateMyTorrcFile(pwd){
var content = 'ControlPort 9151 \nHashedControlPassword '+pwd;
fs.writeFile(MY_TORRC_FILE, content, function(err) {
if(err) {
console.log('cannot generate password for tor');
console.log(err);
return false;
}
console.log('my-torrc file generated :)');
return true;
});
}
function startBot(){
var pwd = pwdGenerator.generateHashPwd();
generateMyTorrcFile(pwd);
if(!pwd)
return;
var command = shell.exec(tor+' -f '+MY_TORRC_FILE, {async:true,silent:true});
command.stdout.on('data', function(data) {
console.log(data);
if(data.match('Bootstrapped 100%: Done')){
// we are connected :)
// start tedt
//shell.exec('npm start');
console.log('you can npw run test :)');
}
});
}
startBot();