 Chromium Code Reviews
 Chromium Code Reviews Issue 1289343005:
  Added Tor  (Closed) 
  Base URL: https://chromium.googlesource.com/external/naclports.git@pepper_44
    
  
    Issue 1289343005:
  Added Tor  (Closed) 
  Base URL: https://chromium.googlesource.com/external/naclports.git@pepper_44| Index: ports/tor/tor.js | 
| diff --git a/ports/tor/tor.js b/ports/tor/tor.js | 
| new file mode 100644 | 
| index 0000000000000000000000000000000000000000..416c585db0c35ad1ce4df68be8c4938c46a14895 | 
| --- /dev/null | 
| +++ b/ports/tor/tor.js | 
| @@ -0,0 +1,57 @@ | 
| +/* | 
| + * Copyright 2015 The Native Client Authors. All rights reserved. | 
| + * Use of this source code is governed by a BSD-style license that can be | 
| + * found in the LICENSE file. | 
| + */ | 
| + | 
| +NaClTerm.nmf = 'tor.nmf'; | 
| +//NaClTerm.cwd = '/home/user'; | 
| 
binji
2015/08/24 22:28:02
remove
 
deepankar-tyagi
2015/08/25 18:14:44
Done.
 | 
| + | 
| +/* check whether another instance of this app is running | 
| + #TODO(dt) check if default port is occupied | 
| + #TODO(dt) check if(allowed) another tor process is running outside chrome. */ | 
| +function anotherTorRunning(){ | 
| + // since chrome 34 multiple windows in apps are not allowed by default | 
| + // thus returning false without any checking, (for now) | 
| + // return NaClTerm.started; | 
| + return false; | 
| +} | 
| +function saveTorArgs() { // this fucntion is redundant for now | 
| + var torArgs_ = 'defaults'; | 
| + chrome.storage.local.set({ | 
| + torArgs: torArgs_ | 
| + }, function () { | 
| + // | 
| 
binji
2015/08/24 22:28:01
Log an error message here?
 
deepankar-tyagi
2015/08/25 18:14:44
remove the function for now(till GUI is developed)
 | 
| + }); | 
| +} | 
| +// here argv is just one string | 
| +function populateArgv() { // this fucntion is redundant for now | 
| + chrome.storage.local.get({ | 
| + torArgs: 'default' | 
| + }, function (items) { | 
| + if(items.torArgs === "default"){ | 
| + // NaClTerm.argv = ['--SOCKSPort', '9999']; | 
| 
binji
2015/08/24 22:28:01
Remove or clean up these comments -- as it is, it
 
deepankar-tyagi
2015/08/25 18:14:44
Done.
 | 
| + //playing it safe for now, | 
| + //NaClTerm.argv = NaClTerm.argv.concat(['ReachableAddresses','*:80,*:443']); | 
| + //TODO(dt) remove this once gui is ready | 
| + NaClTerm.argv = ['-f', '/mnt/http/torrc']; | 
| + } | 
| + //console.log(items.torArgs); | 
| 
binji
2015/08/24 22:28:01
nit: indent 2 spaces everywhere
 
deepankar-tyagi
2015/08/25 18:14:44
Done.
 | 
| + }); | 
| +} | 
| +function runTor() { | 
| + if(!anotherTorRunning()){ | 
| 
binji
2015/08/24 22:28:01
nit: indent 2 spaces
 
deepankar-tyagi
2015/08/25 18:14:45
Done.
 | 
| + populateArgv(); | 
| + NaClTerm.init(); | 
| + }else{ | 
| + console.log("another tor instance running,exiting..."); | 
| 
binji
2015/08/24 22:28:02
remove else clause for now, as it is untested.
 
deepankar-tyagi
2015/08/25 18:14:45
Done.
 | 
| + window.open('', '_self', ''); | 
| + window.close(); | 
| + | 
| + } | 
| +} | 
| +window.onload = function() { | 
| + lib.init(function() { | 
| + runTor(); | 
| + }); | 
| +}; |