make passwords configurable
This commit is contained in:
12
config.js
12
config.js
@@ -1,6 +1,18 @@
|
||||
var proxy_scheme = "HTTP";
|
||||
var proxy_host = "127.0.0.1";
|
||||
var proxy_port = "4444";
|
||||
|
||||
var control_host = "127.0.0.1";
|
||||
var control_port = "7657";
|
||||
|
||||
var rpc_host = "127.0.0.1";
|
||||
var rpc_port = "7657";
|
||||
var rpc_path = "jsonrpc";
|
||||
var rpc_pass = "itoopie";
|
||||
|
||||
var bt_rpc_host = "127.0.0.1";
|
||||
var bt_rpc_port = "7657";
|
||||
var bt_rpc_path = "transmission/rpc";
|
||||
var bt_rpc_pass = "transmission";
|
||||
|
||||
var disable_history = false;
|
||||
|
@@ -37,7 +37,7 @@ function routerHost(url) {
|
||||
path = url.replace(hostname + "/", "");
|
||||
}
|
||||
if (hostname === control_host + ":" + control_port) {
|
||||
console.log("(hostcheck) router console found on configured ports");
|
||||
//console.log("(hostcheck) router console found on configured ports");
|
||||
return pathcheck(path);
|
||||
}
|
||||
|
||||
|
2
host.js
2
host.js
@@ -97,7 +97,7 @@ function routerHost(url) {
|
||||
path = url.replace(hostname + "/", "");
|
||||
}
|
||||
if (hostname === control_host + ":" + control_port) {
|
||||
console.log("(hostcheck) router console found on configured ports");
|
||||
//console.log("(hostcheck) router console found on configured ports");
|
||||
return pathcheck(path);
|
||||
}
|
||||
|
||||
|
@@ -20,7 +20,7 @@ function send(
|
||||
async function postData(url = "", data = {}) {
|
||||
// Default options are marked with *
|
||||
let requestBody = JSON.stringify(data);
|
||||
//console.log("(i2pcontrol)", requestBody, data);
|
||||
//console.log("(i2pcontrol) sending request", requestBody);
|
||||
let opts = {
|
||||
method: "POST", // *GET, POST, PUT, DELETE, etc.
|
||||
mode: "cors", // no-cors, *cors, same-origin
|
||||
@@ -37,62 +37,51 @@ function send(
|
||||
return await response.json(); // parses JSON response into native JavaScript objects
|
||||
}
|
||||
|
||||
//console.log("http://" + control_host + ":" + control_port + "/" + control_path)
|
||||
return postData(
|
||||
"http://" + control_host + ":" + control_port + "/" + control_path,
|
||||
"http://" + control_host + ":" + control_port + "/" + control_path + "/",
|
||||
message
|
||||
);
|
||||
}
|
||||
|
||||
function authenticate(
|
||||
async function authenticate(
|
||||
password = "itoopie",
|
||||
control_host = "127.0.0.1",
|
||||
control_port = "7657",
|
||||
control_path = "jsonrpc"
|
||||
) {
|
||||
let store = browser.storage.local.get("rpc_pass");
|
||||
if (store != undefined) {
|
||||
console.log("Stored password found");
|
||||
password = store;
|
||||
}
|
||||
function auth(got) {
|
||||
var json = new Object();
|
||||
json["id"] = makeid(6);
|
||||
json["jsonrpc"] = "2.0";
|
||||
json["method"] = "Authenticate";
|
||||
json["params"] = new Object();
|
||||
json["params"]["API"] = 1;
|
||||
json["params"]["Password"] = password;
|
||||
return send(json);
|
||||
}
|
||||
store.then(auth);
|
||||
var json = new Object();
|
||||
json["id"] = makeid(6);
|
||||
json["jsonrpc"] = "2.0";
|
||||
json["method"] = "Authenticate";
|
||||
json["params"] = new Object();
|
||||
json["params"]["API"] = 1;
|
||||
json["params"]["Password"] = password;
|
||||
return send(json, control_host, control_port, control_path);
|
||||
}
|
||||
|
||||
async function GetToken(
|
||||
password,
|
||||
password = "itoopie",
|
||||
control_host = "127.0.0.1",
|
||||
control_port = "7657",
|
||||
control_path = "jsonrpc"
|
||||
) {
|
||||
let me = authenticate(password);
|
||||
function gettoken(authtoken) {
|
||||
return authtoken.result.Token;
|
||||
}
|
||||
let me = authenticate(password, control_host, control_port, control_path);
|
||||
return await me.then(gettoken);
|
||||
}
|
||||
|
||||
function gettoken(authtoken) {
|
||||
return authtoken.result.Token;
|
||||
}
|
||||
|
||||
function Done(output) {
|
||||
//console.log("(i2pcontrol) I2PControl connection tested,", output);
|
||||
return output;
|
||||
}
|
||||
|
||||
function Echo(
|
||||
async function Echo(
|
||||
message,
|
||||
control_host = "127.0.0.1",
|
||||
control_port = "7657",
|
||||
control_path = "jsonrpc"
|
||||
control_path = "jsonrpc",
|
||||
password = "itoopie"
|
||||
) {
|
||||
function echo(token) {
|
||||
console.log("(i2pcontrol) testing I2PControl connection");
|
||||
var json = new Object();
|
||||
json["id"] = makeid(6);
|
||||
json["jsonrpc"] = "2.0";
|
||||
@@ -100,10 +89,10 @@ function Echo(
|
||||
json["params"] = new Object();
|
||||
json["params"]["Token"] = token;
|
||||
json["params"]["Echo"] = message;
|
||||
return send(json);
|
||||
return send(json, control_host, control_port, control_path);
|
||||
}
|
||||
let token = GetToken(password);
|
||||
let done = token.then(echo);
|
||||
let token = GetToken(password, control_host, control_port, control_path);
|
||||
let done = await token.then(echo);
|
||||
return done;
|
||||
}
|
||||
|
||||
@@ -118,15 +107,16 @@ function UpdateEchoElementByID(
|
||||
//console.log("(i2pcontrol)", update);
|
||||
document.getElementById(ID).innerText = update;
|
||||
}
|
||||
let net = Echo(Query, control_host, control_port, control_path);
|
||||
let net = Echo(Query, control_host, control_port, control_path, password);
|
||||
net.then(updateleement);
|
||||
}
|
||||
|
||||
function GetRate(
|
||||
async function GetRate(
|
||||
Query,
|
||||
control_host = "127.0.0.1",
|
||||
control_port = "7657",
|
||||
control_path = "jsonrpc"
|
||||
control_path = "jsonrpc",
|
||||
password = "itoopie"
|
||||
) {
|
||||
function getrate(token) {
|
||||
var json = new Object();
|
||||
@@ -137,10 +127,10 @@ function GetRate(
|
||||
json["params"]["Token"] = token;
|
||||
json["params"]["Stat"] = Query;
|
||||
json["params"]["Period"] = 2000;
|
||||
return send(json);
|
||||
return send(json, control_host, control_port, control_path);
|
||||
}
|
||||
let token = GetToken(password);
|
||||
let done = token.then(getrate);
|
||||
let token = GetToken(password, control_host, control_port, control_path);
|
||||
let done = await token.then(getrate);
|
||||
return done;
|
||||
}
|
||||
|
||||
@@ -155,15 +145,16 @@ function UpdateGetRateElementByID(
|
||||
//console.log("(i2pcontrol)", update);
|
||||
document.getElementById(ID).innerText = update;
|
||||
}
|
||||
let net = GetRate(Query, control_host, control_port, control_path);
|
||||
let net = GetRate(Query, control_host, control_port, control_path, password);
|
||||
net.then(updateleement);
|
||||
}
|
||||
|
||||
function I2PControl(
|
||||
async function I2PControl(
|
||||
Query,
|
||||
control_host = "127.0.0.1",
|
||||
control_port = "7657",
|
||||
control_path = "jsonrpc"
|
||||
control_path = "jsonrpc",
|
||||
password = "itoopie"
|
||||
) {
|
||||
function i2pcontrol(token) {
|
||||
var json = new Object();
|
||||
@@ -173,10 +164,10 @@ function I2PControl(
|
||||
json["params"] = new Object();
|
||||
json["params"]["Token"] = token;
|
||||
json["params"][Query] = null;
|
||||
return send(json);
|
||||
return send(json, control_host, control_port, control_path);
|
||||
}
|
||||
let token = GetToken(password);
|
||||
let done = token.then(i2pcontrol);
|
||||
let token = GetToken(password, control_host, control_port, control_path);
|
||||
let done = await token.then(i2pcontrol);
|
||||
return done;
|
||||
}
|
||||
|
||||
@@ -191,15 +182,22 @@ function UpdateI2PControlElementByID(
|
||||
//console.log("(i2pcontrol)", update);
|
||||
document.getElementById(ID).innerText = update;
|
||||
}
|
||||
let net = I2PControl(Query, control_host, control_port, control_path);
|
||||
let net = I2PControl(
|
||||
Query,
|
||||
control_host,
|
||||
control_port,
|
||||
control_path,
|
||||
password
|
||||
);
|
||||
net.then(updateleement);
|
||||
}
|
||||
|
||||
function RouterInfo(
|
||||
async function RouterInfo(
|
||||
Query,
|
||||
control_host = "127.0.0.1",
|
||||
control_port = "7657",
|
||||
control_path = "jsonrpc"
|
||||
control_path = "jsonrpc",
|
||||
password = "itoopie"
|
||||
) {
|
||||
function routerinfo(token) {
|
||||
var json = new Object();
|
||||
@@ -209,10 +207,10 @@ function RouterInfo(
|
||||
json["params"] = new Object();
|
||||
json["params"]["Token"] = token;
|
||||
json["params"][Query] = null;
|
||||
return send(json);
|
||||
return send(json, control_host, control_port, control_path);
|
||||
}
|
||||
let token = GetToken(password);
|
||||
let done = token.then(routerinfo);
|
||||
let token = GetToken(password, control_host, control_port, control_path);
|
||||
let done = await token.then(routerinfo);
|
||||
return done;
|
||||
}
|
||||
|
||||
@@ -221,26 +219,35 @@ function UpdateRouterInfoElementByID(
|
||||
ID,
|
||||
control_host = "127.0.0.1",
|
||||
control_port = "7657",
|
||||
control_path = "jsonrpc"
|
||||
control_path = "jsonrpc",
|
||||
password = "itoopie"
|
||||
) {
|
||||
function updateelement(update) {
|
||||
/*console.log(
|
||||
"(i2pcontrol)",
|
||||
"(i2pcontrol) element",
|
||||
update.result[Query],
|
||||
ID,
|
||||
document.getElementById(ID)
|
||||
);*/
|
||||
document.getElementById(ID).innerText = update.result[Query];
|
||||
}
|
||||
let net = RouterInfo(Query, control_host, control_port, control_path);
|
||||
|
||||
let net = RouterInfo(
|
||||
Query,
|
||||
control_host,
|
||||
control_port,
|
||||
control_path,
|
||||
password
|
||||
);
|
||||
net.then(updateelement);
|
||||
}
|
||||
|
||||
function RouterManager(
|
||||
async function RouterManager(
|
||||
Query,
|
||||
control_host = "127.0.0.1",
|
||||
control_port = "7657",
|
||||
control_path = "jsonrpc"
|
||||
control_path = "jsonrpc",
|
||||
password = "itoopie"
|
||||
) {
|
||||
function routermanager(token) {
|
||||
var json = new Object();
|
||||
@@ -250,10 +257,10 @@ function RouterManager(
|
||||
json["params"] = new Object();
|
||||
json["params"]["Token"] = token;
|
||||
json["params"][Query] = null;
|
||||
return send(json);
|
||||
return send(json, control_host, control_port, control_path);
|
||||
}
|
||||
let token = GetToken(password);
|
||||
let done = token.then(routermanager);
|
||||
let token = GetToken(password, control_host, control_port, control_path);
|
||||
let done = await token.then(routermanager);
|
||||
return done;
|
||||
}
|
||||
|
||||
@@ -262,21 +269,29 @@ function UpdateRouterManagerElementByID(
|
||||
ID,
|
||||
control_host = "127.0.0.1",
|
||||
control_port = "7657",
|
||||
control_path = "jsonrpc"
|
||||
control_path = "jsonrpc",
|
||||
password = "itoopie"
|
||||
) {
|
||||
function updateelement(update) {
|
||||
//console.log("(i2pcontrol)", update);
|
||||
c; //onsole.log("(i2pcontrol)", update);
|
||||
document.getElementById(ID).innerText = update;
|
||||
}
|
||||
let net = RouterManage(Query, control_host, control_port, control_path);
|
||||
let net = RouterManager(
|
||||
Query,
|
||||
control_host,
|
||||
control_port,
|
||||
control_path,
|
||||
password
|
||||
);
|
||||
net.then(updateleement);
|
||||
}
|
||||
|
||||
function NetworkSetting(
|
||||
async function NetworkSetting(
|
||||
Query,
|
||||
control_host = "127.0.0.1",
|
||||
control_port = "7657",
|
||||
control_path = "jsonrpc"
|
||||
control_path = "jsonrpc",
|
||||
password = "itoopie"
|
||||
) {
|
||||
function networksetting(token) {
|
||||
var json = new Object();
|
||||
@@ -286,10 +301,10 @@ function NetworkSetting(
|
||||
json["params"] = new Object();
|
||||
json["params"]["Token"] = token;
|
||||
json["params"][Query] = null;
|
||||
return send(json);
|
||||
return send(json, control_host, control_port, control_path);
|
||||
}
|
||||
let token = GetToken(password);
|
||||
let done = token.then(networksetting);
|
||||
let token = GetToken(password, control_host, control_port, control_path);
|
||||
let done = await token.then(networksetting);
|
||||
return done;
|
||||
}
|
||||
|
||||
@@ -298,13 +313,20 @@ function UpdateNetworkSettingElementByID(
|
||||
ID,
|
||||
control_host = "127.0.0.1",
|
||||
control_port = "7657",
|
||||
control_path = "jsonrpc"
|
||||
control_path = "jsonrpc",
|
||||
password = "itoopie"
|
||||
) {
|
||||
function updateelement(update) {
|
||||
//console.log("(i2pcontrol)", update);
|
||||
document.getElementById(ID).innerText = update;
|
||||
}
|
||||
let net = NetworkSetting(Query, control_host, control_port, control_path);
|
||||
let net = NetworkSetting(
|
||||
Query,
|
||||
control_host,
|
||||
control_port,
|
||||
control_path,
|
||||
password
|
||||
);
|
||||
net.then(updateleement);
|
||||
}
|
||||
|
||||
@@ -357,3 +379,8 @@ function UpdateContents() {
|
||||
|
||||
var done = Echo(hello);
|
||||
done.then(Done);
|
||||
|
||||
function Done(output) {
|
||||
console.log("(i2pcontrol) I2PControl connection tested,", output);
|
||||
return output;
|
||||
}
|
||||
|
31
scrub.js
31
scrub.js
@@ -11,12 +11,11 @@ var contextScrub = async function(requestDetails) {
|
||||
function onHeaderError() {
|
||||
console.log("Header scrub error");
|
||||
}
|
||||
console.log("(scrub)Scrubbing info from contextualized request");
|
||||
//console.log("(scrub)Scrubbing info from contextualized request");
|
||||
try {
|
||||
var headerScrub = function(context) {
|
||||
var ua = "MYOB/6.66 (AN/ON)";
|
||||
if (!context) {
|
||||
console.log("Context not found", context);
|
||||
} else if (context.name == titlepref) {
|
||||
if (i2pHost(requestDetails.url)) {
|
||||
for (var header of requestDetails.requestHeaders) {
|
||||
@@ -45,7 +44,7 @@ var contextScrub = async function(requestDetails) {
|
||||
};
|
||||
var contextGet = async function(tabInfo) {
|
||||
try {
|
||||
console.log("(scrub)Tab info from Function", tabInfo);
|
||||
//console.log("(scrub)Tab info from Function", tabInfo);
|
||||
let context = await browser.contextualIdentities.get(
|
||||
tabInfo.cookieStoreId
|
||||
);
|
||||
@@ -56,7 +55,7 @@ var contextScrub = async function(requestDetails) {
|
||||
};
|
||||
var tabGet = async function(tabId) {
|
||||
try {
|
||||
console.log("(scrub)Tab ID from Request", tabId);
|
||||
//console.log("(scrub)Tab ID from Request", tabId);
|
||||
let tabInfo = await browser.tabs.get(tabId);
|
||||
return tabInfo;
|
||||
} catch (error) {
|
||||
@@ -68,17 +67,17 @@ var contextScrub = async function(requestDetails) {
|
||||
var context = {};
|
||||
var req = {};
|
||||
if (i2pHost(requestDetails.url)) {
|
||||
console.log("(scrub)I2P URL detected, ");
|
||||
//console.log("(scrub)I2P URL detected, ");
|
||||
tab = tabGet(requestDetails.tabId);
|
||||
context = tab.then(contextGet, onHeaderError);
|
||||
req = await context.then(headerScrub, onHeaderError);
|
||||
console.log("(scrub)Scrubbing I2P Request", req);
|
||||
//console.log("(scrub)Scrubbing I2P Request", req);
|
||||
return req;
|
||||
} else if (routerHost(requestDetails.url)) {
|
||||
tab = tabGet(requestDetails.tabId);
|
||||
context = tab.then(contextGet, onHeaderError);
|
||||
req = await context.then(headerScrub, onHeaderError);
|
||||
console.log("(scrub)Scrubbing non-I2P Request", req);
|
||||
//console.log("(scrub)Scrubbing non-I2P Request", req);
|
||||
return req;
|
||||
}
|
||||
return req;
|
||||
@@ -92,7 +91,7 @@ var contextSetup = function(requestDetails) {
|
||||
function onContextError() {
|
||||
console.log("Context launcher error");
|
||||
}
|
||||
console.log("(isolate)Forcing I2P requests into context");
|
||||
//console.log("(isolate)Forcing I2P requests into context");
|
||||
try {
|
||||
var i2pTabFind = async function(tabId) {
|
||||
try {
|
||||
@@ -100,8 +99,6 @@ var contextSetup = function(requestDetails) {
|
||||
name: titlepref
|
||||
});
|
||||
if (tabId.cookieStoreId != context[0].cookieStoreId) {
|
||||
console.log("(isolate) I2P context", context[0].cookieStoreId);
|
||||
console.log("tab context", tabId.cookieStoreId);
|
||||
function Create() {
|
||||
function onCreated(tab) {
|
||||
function closeOldTab() {
|
||||
@@ -135,8 +132,6 @@ var contextSetup = function(requestDetails) {
|
||||
name: routerpref
|
||||
});
|
||||
if (tabId.cookieStoreId != context[0].cookieStoreId) {
|
||||
console.log("(isolate) I2P context", context[0].cookieStoreId);
|
||||
console.log("tab context", tabId.cookieStoreId);
|
||||
function Create() {
|
||||
function onCreated(tab) {
|
||||
function closeOldTab() {
|
||||
@@ -170,8 +165,6 @@ var contextSetup = function(requestDetails) {
|
||||
name: tunnelpref
|
||||
});
|
||||
if (tabId.cookieStoreId != context[0].cookieStoreId) {
|
||||
console.log("(isolate) I2P context", context[0].cookieStoreId);
|
||||
console.log("tab context", tabId.cookieStoreId);
|
||||
function Create() {
|
||||
function onCreated(tab) {
|
||||
function closeOldTab() {
|
||||
@@ -205,8 +198,6 @@ var contextSetup = function(requestDetails) {
|
||||
name: torrentpref
|
||||
});
|
||||
if (tabId.cookieStoreId != context[0].cookieStoreId) {
|
||||
console.log("(isolate) I2P context", context[0].cookieStoreId);
|
||||
console.log("tab context", tabId.cookieStoreId);
|
||||
function Create() {
|
||||
function onCreated(tab) {
|
||||
function closeOldTab() {
|
||||
@@ -240,8 +231,6 @@ var contextSetup = function(requestDetails) {
|
||||
name: mailpref
|
||||
});
|
||||
if (tabId.cookieStoreId != context[0].cookieStoreId) {
|
||||
console.log("(isolate) I2P context", context[0].cookieStoreId);
|
||||
console.log("tab context", tabId.cookieStoreId);
|
||||
function Create() {
|
||||
function onCreated(tab) {
|
||||
function closeOldTab() {
|
||||
@@ -275,8 +264,6 @@ var contextSetup = function(requestDetails) {
|
||||
name: localpref
|
||||
});
|
||||
if (tabId.cookieStoreId != context[0].cookieStoreId) {
|
||||
console.log("(isolate) I2P context", context[0].cookieStoreId);
|
||||
console.log("tab context", tabId.cookieStoreId);
|
||||
function Create() {
|
||||
function onCreated(tab) {
|
||||
function closeOldTab() {
|
||||
@@ -315,8 +302,6 @@ var contextSetup = function(requestDetails) {
|
||||
tabId.cookieStoreId == "firefox-private"
|
||||
) {
|
||||
if (tabId.cookieStoreId != context[0].cookieStoreId) {
|
||||
console.log("(isolate) I2P context", context[0].cookieStoreId);
|
||||
console.log("tab context", tabId.cookieStoreId);
|
||||
function Create() {
|
||||
function onCreated(tab) {
|
||||
function closeOldTab() {
|
||||
@@ -347,7 +332,7 @@ var contextSetup = function(requestDetails) {
|
||||
};
|
||||
var tabGet = async function(tabId) {
|
||||
try {
|
||||
console.log("(isolate)Tab ID from Request", tabId);
|
||||
//console.log("(isolate)Tab ID from Request", tabId);
|
||||
let tabInfo = await browser.tabs.get(tabId);
|
||||
return tabInfo;
|
||||
} catch (error) {
|
||||
|
@@ -38,7 +38,7 @@ function send(
|
||||
}
|
||||
|
||||
return postData(
|
||||
"http://" + control_host + ":" + control_port + "/" + control_path,
|
||||
"http://" + control_host + ":" + control_port + "/" + control_path + "/",
|
||||
message
|
||||
);
|
||||
}
|
||||
|
Reference in New Issue
Block a user