Skip to content
This repository has been archived by the owner on Jun 13, 2024. It is now read-only.

Commit

Permalink
Update add-on and local-script
Browse files Browse the repository at this point in the history
- replaced deprecated functions in ReadFileFunctions
- fixed bug on Windows getRealIP func
- edited error message for Windows users on torify funcs
- added warn messages for MacOS users on OS funcs
  • Loading branch information
Alessandro committed Apr 9, 2022
1 parent 39238cb commit 2dfe9d8
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 35 deletions.
44 changes: 15 additions & 29 deletions socket-tropea/tropea.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
const WebSocket = require("ws");
var fs = require('fs');
const { exec } = require("child_process"); // Execute command in shell

var path = {
torrcPath: "",
Expand Down Expand Up @@ -71,9 +72,6 @@ ws.on("connection", ws => {
});
});

// Execute command in shell
const { exec } = require("child_process");

/**Set Torrc File Path */
function setTorrcFilePath(message) {
const getPath = message.split('$>', 2);
Expand Down Expand Up @@ -204,20 +202,17 @@ function generateAllSettings(ws) {
resetData();
data.TorBrowserPath = path.torPath;
try {
const lineReader = require('read-each-line-sync');
lineReader(path.torrcPath, 'utf8', function (line) {
//console.log("[.]" + line)
var lines = fs.readFileSync(path.torrcPath, 'utf8')
.split('\n')
.filter(Boolean);
lines.forEach(function (line) {
if (line.startsWith(PATTERN.EntryNodes)) {
//console.log("[@]" + line)
data.EntryNodes = line;
} else if (line.startsWith(PATTERN.ExitNodes)) {
// console.log("[*]" + line)
data.ExitNodes = line;
} else if (line.startsWith(PATTERN.ExcludeNodes)) {
// console.log("[+]" + line)
data.ExcludeNodes = line;
} else if (line.startsWith(PATTERN.ExcludeExitNodes)) {
// console.log("[-]" + line)
data.ExcludeExitNodes = line;
} else if (line.startsWith(PATTERN.GeoIPExcludeUnknown)) {
data.GeoIPExcludeUnknown = line;
Expand Down Expand Up @@ -294,31 +289,24 @@ function addLineToTorrcFile(ws, newLine, pattern) {
* Torify Function
*/
function getAndSendIP(ws, realOrTorified) {
const { exec } = require("child_process");
var opsys = process.platform;
if (realOrTorified) {
if (opsys == "darwin") {
// exec("ls -la", (error, stdout, stderr) => {
// console.log(`stdout: ${stdout}`);
// });
ws.send("function-not-tested-for-macos");
} else if (opsys == "win32" || opsys == "win64") {
// exec("curl ifconfig.me", (error, stdout, stderr) => {
// ws.send(`RealIP$>${stdout}`);
// });
exec("curl ifconfig.me", (error, stdout, stderr) => {
ws.send(`RealIP$>${stdout}`);
});
} else if (opsys == "linux") {
exec("curl ifconfig.me 2> /dev/null", (error, stdout, stderr) => {
ws.send(`RealIP$>${stdout}`);
});
}
} else {
if (opsys == "darwin") {
// exec("ls -la", (error, stdout, stderr) => {
// console.log(`stdout: ${stdout}`);
// });
} else if (opsys == "win32" || opsys == "win64") {
// exec("ls -la", (error, stdout, stderr) => {
// console.log(`stdout: ${stdout}`);
// });
ws.send("function-not-tested-for-macos");
} else if (opsys == "win32" || opsys == "win64") {
ws.send("function-not-supported-for-windows");
} else if (opsys == "linux") {
exec("torify curl ifconfig.me 2> /dev/null", (error, stdout, stderr) => {
ws.send(`TorifiedIP$>${stdout}`);
Expand All @@ -333,14 +321,12 @@ function torifyApp(ws, message) {
const { exec } = require("child_process");
var opsys = process.platform;
if (opsys == "darwin") {
// exec("ls -la", (error, stdout, stderr) => {
// console.log(`stdout: ${stdout}`);
// });
ws.send("function-not-tested-for-macos");
} else if (opsys == "win32" || opsys == "win64") {
ws.send("TorifiedAPP$>Windows");
ws.send("function-not-supported-for-windows");
} else if (opsys == "linux") {
exec("torify " + path + " 2> /dev/null", (error, stdout, stderr) => {
ws.send(`TorifiedAPP$>${stdout}`);
ws.send("TorifiedAPP");
});
}
}
Expand Down
6 changes: 5 additions & 1 deletion tropea/AdvancedTropea/js/settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,11 @@ ws.onmessage = function (event) {
} else if (e.data.includes("TorifiedIP")) {
updateTorifiedIP(e.data);
} else if (e.data.includes("TorifiedAPP")) {
console.log("[+] " + e.data);
alert("If the app allow the torify function it will start soon, else read the FAQ about torify-app.")
} else if (e.data.includes("function-not-supported-for-windows")){
alert("This functions is not supported fot Windows!")
} else if (e.data.includes("function-not-tested-for-macos")){
alert("This functions is not tested fot MacOS, contact us if you want to contribute to the project.")
} else {

if (!e.data.includes("EntryNodes")) return
Expand Down
5 changes: 0 additions & 5 deletions tropea/AdvancedTropea/js/torify.js

This file was deleted.

0 comments on commit 2dfe9d8

Please sign in to comment.