From 0ab95a5cb4b2ac1883ebbc5be0609a927a424baa Mon Sep 17 00:00:00 2001 From: idk Date: Fri, 3 May 2019 18:40:46 -0400 Subject: [PATCH] finally a semi-universal fix for the android issues --- Makefile | 8 ++++++++ options/options.js | 30 +++++++++++++++++------------- proxy.js | 39 +++++++++++++++++++++++---------------- 3 files changed, 48 insertions(+), 29 deletions(-) diff --git a/Makefile b/Makefile index 93d40e7..0e8f8c6 100644 --- a/Makefile +++ b/Makefile @@ -46,3 +46,11 @@ profile-install: sudo cp ./i2psetproxy.js@eyedeekay.github.io.xpi /usr/local/lib/firefox.profile.i2p/firefox.profile.i2p/extensions/ pi: profile-install + +DESC="A simple plugin for configuring an i2p browser." + +release: + gothub release -u eyedeekay -r i2psetproxy.js -t $(VERSION) -n $(VERSION) -d $(DESC) + +upload: + gothub upload -u eyedeekay -r i2psetproxy.js -t $(VERSION) -n "i2psetproxy.js@eyedeekay.github.io.xpi" -f "../i2psetproxy.js@eyedeekay.github.io.xpi" diff --git a/options/options.js b/options/options.js index 343cd94..21c2f3c 100644 --- a/options/options.js +++ b/options/options.js @@ -119,23 +119,27 @@ function setupProxy() { //var controlPort = getControlPort() var Host = getHost() var Port = getPort() - console.log("Setting up Firefox Desktop proxy") - var proxySettings = { - proxyType: "manual", - http: Host+":"+Port, - passthrough: "", - httpProxyAll: true - }; - browser.proxy.settings.set({value:proxySettings}); - console.log("i2p settings created for Firefox Desktop") if (isDroid()) { console.log("Setting up Firefox Android proxy") - if (Port == "7950") { - browser.proxy.register("android-ext.pac"); - }else{ - browser.proxy.register("android.pac"); + function handleProxyRequest(requestInfo) { + if (shouldProxyRequest(requestInfo)) { + console.log(`Proxying: ${requestInfo.url}`); + return {type: "http", host: Host, port: Port}; + } + return {type: "http", host: Host, port: Port}; } + browser.proxy.onRequest.addListener(handleProxyRequest, {urls: [""]}); console.log("i2p settings created for Firefox Android") + }else{ + console.log("Setting up Firefox Desktop proxy") + var proxySettings = { + proxyType: "manual", + http: Host+":"+Port, + passthrough: "", + httpProxyAll: true + }; + browser.proxy.settings.set({value:proxySettings}); + console.log("i2p settings created for Firefox Desktop") } } diff --git a/proxy.js b/proxy.js index aa20ba9..838a8b9 100644 --- a/proxy.js +++ b/proxy.js @@ -24,28 +24,36 @@ chrome.privacy.network.webRTCIPHandlingPolicy.set({value: "disable_non_proxied_u console.log("Preliminarily disabled WebRTC.") +function shouldProxyRequest(requestInfo) { + return true; //requestInfo.parentFrameId != -1; +} + function setupProxy() { var controlHost = "127.0.0.1" //getControlHost() var controlPort = "7951" //getControlPort(); - var Host = getHost() - var Port = getPort() - console.log("Setting up Firefox Desktop proxy") - var proxySettings = { - proxyType: "manual", - http: Host+":"+Port, - passthrough: "", - httpProxyAll: true - }; - browser.proxy.settings.set({value:proxySettings}); - console.log("i2p settings created for Firefox Desktop") + var Host = "127.0.0.1" //getHost() + var Port = "4444" //getPort() if (isDroid()) { console.log("Setting up Firefox Android proxy") - if (Port == "7950") { - browser.proxy.register("android-ext.pac"); - }else{ - browser.proxy.register("android.pac"); + function handleProxyRequest(requestInfo) { + if (shouldProxyRequest(requestInfo)) { + console.log(`Proxying: ${requestInfo.url}`); + return {type: "http", host: Host, port: Port}; + } + return {type: "http", host: Host, port: Port}; } + browser.proxy.onRequest.addListener(handleProxyRequest, {urls: [""]}); console.log("i2p settings created for Firefox Android") + }else{ + console.log("Setting up Firefox Desktop proxy") + var proxySettings = { + proxyType: "manual", + http: Host+":"+Port, + passthrough: "", + httpProxyAll: true + }; + browser.proxy.settings.set({value:proxySettings}); + console.log("i2p settings created for Firefox Desktop") } } @@ -55,6 +63,5 @@ if (isFirefox()){ } if (isFirefox()) { - setAllPrivacy() setupProxy() }