From 2831ab9759a0e94c4f1bce31fca9df3f0ebf9e4f Mon Sep 17 00:00:00 2001 From: idk Date: Mon, 13 Jan 2020 15:20:32 -0500 Subject: [PATCH] tested fixed-up settings --- background.js | 5 ---- host.js | 16 ----------- info.js | 6 ++-- options/options.js | 11 +++---- proxy.js | 72 +++++++++++++++++----------------------------- scrub.js | 1 - 6 files changed, 33 insertions(+), 78 deletions(-) diff --git a/background.js b/background.js index 42366c4..d7e4e2f 100644 --- a/background.js +++ b/background.js @@ -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 diff --git a/host.js b/host.js index 5721500..6fb877f 100644 --- a/host.js +++ b/host.js @@ -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; diff --git a/info.js b/info.js index 799a360..2b42694 100644 --- a/info.js +++ b/info.js @@ -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); diff --git a/options/options.js b/options/options.js index 470e46f..be9d0d4 100644 --- a/options/options.js +++ b/options/options.js @@ -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) { diff --git a/proxy.js b/proxy.js index 15309b3..effc60d 100644 --- a/proxy.js +++ b/proxy.js @@ -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: [""] }); 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(); + }); + }); +}); diff --git a/scrub.js b/scrub.js index 7bd47b3..468733b 100644 --- a/scrub.js +++ b/scrub.js @@ -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({