tested fixed-up settings

This commit is contained in:
idk
2020-01-13 15:20:32 -05:00
parent 72954ceda6
commit 2831ab9759
6 changed files with 33 additions and 78 deletions

View File

@@ -402,11 +402,6 @@ gettingListenerInfo.then(got => {
console.log("Error finding platform info");
}
if (got.os != "android") {
browser.windows.onCreated.addListener(() => {
chrome.storage.local.get(function() {
setupProxy();
});
});
browser.tabs.onCreated.addListener(() => {
var getting = browser.windows.getCurrent({
populate: true

16
host.js
View File

@@ -88,22 +88,6 @@ function routerHost(url) {
if (hostname === control_host + ":" + control_port) {
console.log("(hostcheck) router console found on configured ports");
return pathcheck(path);
} else if (hostname === "127.0.0.1:7657") {
return pathcheck(path);
} else if (hostname === "localhost:7657") {
return pathcheck(path);
}
if (hostname === "127.0.0.1:7657") {
return pathcheck(path);
} else if (hostname === "localhost:7657") {
return pathcheck(path);
}
if (hostname === "127.0.0.1:7070") {
return pathcheck(path);
} else if (hostname === "localhost:7070") {
return pathcheck(path);
}
return false;

View File

@@ -207,7 +207,7 @@ function goTunnel() {
console.log("I2PTunnel tab created");
}
let createData = {
url: "http://" + "127.0.0.1" + ":" + "7657" + "/i2ptunnel"
url: "http://" + control_host + ":" + control_port + "/i2ptunnel"
};
console.log("visiting i2ptunnel");
let creating = browser.tabs.create(createData);
@@ -219,7 +219,7 @@ function goMail() {
console.log("Mail tab created");
}
let createData = {
url: "http://" + "127.0.0.1" + ":" + "7657" + "/susimail"
url: "http://" + control_host + ":" + control_port + "/susimail"
};
console.log("visiting mail");
let creating = browser.tabs.create(createData);
@@ -231,7 +231,7 @@ function goSnark() {
console.log("Snark tab created");
}
let createData = {
url: "http://" + "127.0.0.1" + ":" + "7657" + "/i2psnark"
url: "http://" + control_host + ":" + control_port + "/i2psnark"
};
console.log("visiting snark");
let creating = browser.tabs.create(createData);

View File

@@ -37,8 +37,9 @@ function getScheme() {
if (proxy_scheme.value == "SOCKS") {
return "socks";
}
if (proxy_scheme.value != "http" && proxy_scheme.value != "socks")
return "http";
if (proxy_scheme.value == "http") return "http";
if (proxy_scheme.value == "socks") return "socks";
else return "http";
}
function getHost() {
@@ -189,11 +190,7 @@ function storeSettings() {
control_host,
control_port
});
console.log("(options)storing proxy scheme:", proxy_scheme);
console.log("(options)storing proxy host:", proxy_host);
console.log("(options)storing proxy port:", proxy_port);
console.log("(options)storing control host:", control_host);
console.log("(options)storing control port:", control_port);
storeSettings();
}
function updateUI(restoredSettings) {

View File

@@ -38,9 +38,9 @@ var handleContextProxyRequest = async function(requestDetails) {
host: getHost(),
port: getPort()
};
console.log("(proxy)", context.name);
/*console.log("(proxy)", context.name);
console.log("Using", proxy.type);
console.log("proxy ", proxy.host + ":" + proxy.port);
console.log("proxy ", proxy.host + ":" + proxy.port);*/
return proxy;
} else if (context.name == routerpref) {
if (routerHost(requestDetails.url)) {
@@ -57,9 +57,9 @@ var handleContextProxyRequest = async function(requestDetails) {
host: getHost(),
port: getPort()
};
console.log("(proxy)", context.name);
/*console.log("(proxy)", context.name);
console.log("Using", proxy.type);
console.log("proxy ", proxy.host + ":" + proxy.port);
console.log("proxy ", proxy.host + ":" + proxy.port);*/
return proxy;
} else if (context.name == webpref) {
if (localHost(requestDetails.url)) {
@@ -100,7 +100,7 @@ var handleContextProxyRequest = async function(requestDetails) {
};
var contextGet = async function(tabInfo) {
try {
console.log("(proxy)Tab info from Function", tabInfo);
//console.log("(proxy)Tab info from Function", tabInfo);
context = await browser.contextualIdentities.get(tabInfo.cookieStoreId);
return context;
} catch (error) {
@@ -110,7 +110,7 @@ var handleContextProxyRequest = async function(requestDetails) {
};
var tabGet = async function(tabId) {
try {
console.log("(proxy)Tab ID from Request", tabId);
//console.log("(proxy)Tab ID from Request", tabId);
let tabInfo = await browser.tabs.get(tabId);
return tabInfo;
} catch (error) {
@@ -143,18 +143,18 @@ var handleContextProxyRequest = async function(requestDetails) {
} else if (extensionHost(requestDetails.url)) {
return;
} else if (i2pHost(requestDetails.url)) {
console.log("(Proxy)I2P URL detected, ");
//console.log("(Proxy)I2P URL detected, ");
var tab = tabGet(requestDetails.tabId);
requestDetails.tabId = tab;
var context = tab.then(contextGet);
var proxy = await context.then(handleProxyRequest);
console.log("(proxy)Returning I2P Proxy", proxy);
//console.log("(proxy)Returning I2P Proxy", proxy);
return proxy;
} else {
var tab = tabGet(requestDetails.tabId);
var context = tab.then(contextGet);
var proxy = await context.then(handleProxyRequest);
console.log("(proxy)Returning I2P Proxy", proxy);
//console.log("(proxy)Returning I2P Proxy", proxy);
return proxy;
}
/*proxy = {};
@@ -260,20 +260,11 @@ function SetupSettings() {
}
function getScheme() {
if (proxy_scheme == undefined) {
proxy_scheme = "http";
}
if (proxy_scheme == "HTTP") {
proxy_scheme = "http";
}
if (proxy_scheme == "SOCKS") {
proxy_scheme = "socks";
}
if (proxy_scheme != "http" && proxy_scheme != "socks") {
proxy_scheme = "http";
}
//console.log("Got i2p proxy scheme:", proxy_scheme);
return proxy_scheme;
if (proxy_scheme == "HTTP") return "http";
if (proxy_scheme == "SOCKS") return "socks";
if (proxy_scheme == "http") return "http";
if (proxy_scheme == "socks") return "socks";
else return "http";
}
function getHost() {
@@ -286,37 +277,18 @@ function getHost() {
function getPort() {
if (proxy_port == undefined) {
var scheme = getScheme();
if (scheme == "socks") {
proxy_port = "4446";
} else {
proxy_port = "4444";
}
if (scheme == "socks") proxy_port = "4446";
else proxy_port = "4444";
}
return proxy_port;
}
function getControlHost() {
if (control_host == undefined) {
return "127.0.0.1";
}
return control_host;
}
function getControlPort() {
if (control_port == undefined) {
return "7657";
}
return control_port;
}
function setupProxy() {
/**/
console.log("Setting up Firefox WebExtension proxy");
browser.proxy.onRequest.addListener(handleContextProxyRequest, {
urls: ["<all_urls>"]
});
console.log("i2p settings created for WebExtension Proxy");
/**/
}
function update() {
@@ -329,13 +301,11 @@ function update() {
function updateFromStorage() {
console.log("updating settings from storage");
chrome.storage.local.get(function() {
SetupSettings();
update();
setupProxy();
});
var gettingInfo = browser.runtime.getPlatformInfo();
gettingInfo.then(got => {
if (got.os != "android") {
@@ -343,7 +313,17 @@ function updateFromStorage() {
}
});
}
updateFromStorage();
browser.storage.onChanged.addListener(updateFromStorage);
SetupSettings();
setupProxy();
var gettingListenerInfo = browser.runtime.getPlatformInfo();
gettingListenerInfo.then(got => {
browser.windows.onCreated.addListener(() => {
chrome.storage.local.get(function() {
setupProxy();
});
});
});

View File

@@ -369,7 +369,6 @@ var contextSetup = function(requestDetails) {
setcookie.then(onContextGotLog, onContextError);
return requestDetails;
}
console.log("(isolate)Request Details", requestDetails);
var tab = tabGet(requestDetails.tabId);
if (i2pHost(requestDetails.url)) {
var setcookie = browser.cookies.set({