From 3e4f9191cdaf793b8596413514b02a8fd3155c63 Mon Sep 17 00:00:00 2001 From: "eric@ericjung.net" Date: Tue, 10 Dec 2019 21:04:49 -0700 Subject: [PATCH 01/68] patch from community member -- untested --- src/scripts/background.js | 127 +++++++++++++++++++++++++++++++++++++- 1 file changed, 125 insertions(+), 2 deletions(-) diff --git a/src/scripts/background.js b/src/scripts/background.js index c5d105a..ac5fd7b 100644 --- a/src/scripts/background.js +++ b/src/scripts/background.js @@ -146,6 +146,7 @@ function proxyRequest(requestInfo) { function setActiveSettings(settings) { browser.proxy.onRequest.hasListener(proxyRequest) && browser.proxy.onRequest.removeListener(proxyRequest); + browser.webRequest.onBeforeSendHeaders.hasListener(check_proxy) && browser.webRequest.onBeforeSendHeaders.removeListener(check_proxy); const pref = settings; const prefKeys = Object.keys(pref).filter(item => !['mode', 'logging', 'sync'].includes(item)); // not for these @@ -186,6 +187,7 @@ function setActiveSettings(settings) { activeSettings.proxySettings[idx].whitePatterns = processPatternObjects(activeSettings.proxySettings[idx].whitePatterns); } browser.proxy.onRequest.addListener(proxyRequest, {urls: [""]}); + browser.webRequest.onBeforeSendHeaders.addListener(check_proxy, {urls: [""]}, ["blocking", "requestHeaders"]); Utils.updateIcon('images/icon.svg', null, 'patterns', 'patterns'); console.log(activeSettings, "activeSettings in patterns mode"); } @@ -195,6 +197,7 @@ function setActiveSettings(settings) { if (settings[mode]) { activeSettings.proxySettings = [settings[mode]]; browser.proxy.onRequest.addListener(proxyRequest, {urls: [""]}); + browser.webRequest.onBeforeSendHeaders.addListener(check_proxy,{urls: [""]}, ["blocking", "requestHeaders"]); Utils.updateIcon('images/icon.svg', settings[mode].color, 'forAll', true, Utils.getProxyTitle(settings[mode]), false); console.log(activeSettings, "activeSettings in fixed mode"); } @@ -212,6 +215,7 @@ function setActiveSettings(settings) { function setDisabled(isError) { browser.proxy.onRequest.hasListener(proxyRequest) && browser.proxy.onRequest.removeListener(proxyRequest); + browser.webRequest.onBeforeSendHeaders.hasListener(check_proxy) && browser.webRequest.onBeforeSendHeaders.removeListener(check_proxy); chrome.runtime.sendMessage({mode: 'disabled'}); // Update the options.html UI if it's open Utils.updateIcon('images/icon-off.svg', null, 'disabled', true); console.log('******* disabled mode'); @@ -220,8 +224,19 @@ function setDisabled(isError) { // ----------------- Proxy Authentication ------------------ // ----- session global -let authData = {}; +// stopp using authData in its current implementation - we are using "proxy_for_requestID" now +//let authData = {}; let authPending = {}; +let proxy_for_requestID = {}; + +// Might be set from GUI in future, if feature gets implemented: +let force_global_reauth = false; +let force_global_reauth_username = ''; + +function reset_global_reauth() { + force_global_reauth = false; + force_global_reauth_username = ''; +} async function sendAuth(request) { // Do nothing if this not proxy auth request: @@ -274,4 +289,112 @@ function clearPending(request) { } delete authPending[request.requestId]; // no error -} \ No newline at end of file +} + +// Work around bug: https://bugzilla.mozilla.org/show_bug.cgi?id=1510510 +// Should force reauthentication for http-proxy: +// - using digest authentication after changing the username +// - using basic authentication after changing the username and/or password. +// Does not work until browser establishes new connection to proxy. +// Established TCP connections might need to be closed first (keep-alive has to expire). +// +// This works by examining the headers sent by the browser and deleting the +// authentication header if it doesn't seem to match what the current +// FoxyProxy configuration expects. +// +// Browser does not always fires "onAuthRequired" and asks extensions to provide +// auth credentials, if he has some (working) credentials cached. Therefore +// an extension has no chance to make the browser aware of edited +// username/password. This applies for different pattern based proxy +// configurations as well, where address and port of proxies are the same but +// the user wants to (or has to) use differnt username/password based on some +// pattern in FoxyProxy, if he enables/disables a proxy config inside FoxyProxy +// or if he changes the order of proxy configs. +// Browser will keep using the first working proxy, at least until proxy +// refuses CONNECT, while FoxyProxy shows in her gui that the correct proxy was +// used. Actually FoxyProxy can not know which proxy config with same +// address/port is used, if it was not asked for auth credentials. +// +// This check gives user the chance to edit/correct credentials or invalidate +// credentials that were sent before (and accepted by proxy) via FoxyProxy +// without having to restart the browser. +// But this might be considered expensive (header check runs for every +// request), especially if no authentication is used. +// So it might be useful to provide a switch in the gui to pref this check on/off. +// +// Further tests and improvements welcome! + +function check_proxy(request) { + var asyncRewrite = new Promise((resolve, reject) => { + let send_original_headers = false; + let new_requestHeaders = []; + if (!proxy_for_requestID[request.requestId]) { + send_original_headers = true; + } else if (!proxy_for_requestID[request.requestId].username) { + send_original_headers = true; + } else if (!request.proxyInfo) { + send_original_headers = true; + } else if (request.proxyInfo.type == "http") { + for (var header of request.requestHeaders) { + if (header.name.toLowerCase() === "proxy-authorization") { + let force_rauth = false; + const headerValues = header.value.split(","); + for (var i=0; i= 1) { + let basicAuthClear = proxy_for_requestID[request.requestId].username + ":" + proxy_for_requestID[request.requestId].password; + let credentials_planned = window.atob(basicAuth_pre[1]); + // not used + //let credentials_planned_list = credentials_planned.split(":"); + if (basicAuthClear != credentials_planned) { + force_rauth = true; + } else if (force_global_reauth && force_global_reauth_username != "" && force_global_reauth_username == proxy_for_requestID[request.requestId].username) { + force_rauth = true; + reset_global_reauth(); + } + } + break; + } + }; + if (!force_rauth) { + new_requestHeaders.push(header); + } + } else { + new_requestHeaders.push(header); + } + } + } else { + send_original_headers = true; + } + if (send_original_headers) { + new_requestHeaders = request.requestHeaders; + } + resolve({requestHeaders: new_requestHeaders}); + }); + return asyncRewrite; +} + +function clearProxyrRequestID(request) { + + if (proxy_for_requestID[request.requestId]) { + delete proxy_for_requestID[request.requestId]; + } From 5f77bcc2910d1c4583212dbd7f6ab5c770387895 Mon Sep 17 00:00:00 2001 From: josef radinger Date: Wed, 11 Dec 2019 10:11:54 +0100 Subject: [PATCH 02/68] fix typo --- src/_locales/en/messages.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/_locales/en/messages.json b/src/_locales/en/messages.json index b5fa152..58fcc20 100644 --- a/src/_locales/en/messages.json +++ b/src/_locales/en/messages.json @@ -55,13 +55,13 @@ "errorWas": { "message": "There was an error. Please try again." }, "errorSlash": { "message": "No slash in wildcard patterns. You cannot match URL paths because of Firefox restrictions." }, - "errorEmpty": { "message": "Filed can not be empty." }, + "errorEmpty": { "message": "Field can not be empty." }, "importEnd": { "message": "Settings were successfully imported" }, "patternsChanged": { "message": "Some patterns were changed because they contained slashes. Slashes in patterns are not supported anymore." }, "importEndSlash": { "message": "Import finished. Slashes in patterns are not supported because of a Firefox bug. Please review your patterns and remove slashes, if any." }, - "errorUserPass": { "message": "Please fill both Username & Password." }, + "errorUserPass": { "message": "Please enter both Username & Password." }, "errorFetch": { "message": "There was an error with the operation" }, From c72871fbadb44bf456cee82b7bfffda84c881dae Mon Sep 17 00:00:00 2001 From: "eric@ericjung.net" Date: Thu, 26 Dec 2019 14:38:15 -0700 Subject: [PATCH 03/68] fix for https://github.com/foxyproxy/firefox-extension/issues/58 --- src/scripts/background.js | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/src/scripts/background.js b/src/scripts/background.js index c5d105a..4527196 100644 --- a/src/scripts/background.js +++ b/src/scripts/background.js @@ -24,18 +24,15 @@ class Logger { this.matchedList = []; this.unmatchedList = []; } - - add(item, list) { - list.push(item); // adds to the end - list = list.slice(-this.size); // slice to the ending size entries - } addMatched(item) { - this.add(item, this.matchedList); + this.matchedList.push(item); + this.matchedList = this.matchedList.slice(-this.size); // slice to the ending size entries } addUnmatched(item) { - this.add(item, this.unmatchedList); + this.unmatchedList.push(item); + this.unmatchedList = this.unmatchedList.slice(-this.size); // slice to the ending size entries } updateStorage() { From b8d0452c12113f0e4a67ba2944b72da31eee6a09 Mon Sep 17 00:00:00 2001 From: "eric@ericjung.net" Date: Thu, 26 Dec 2019 14:38:15 -0700 Subject: [PATCH 04/68] fix for https://github.com/foxyproxy/firefox-extension/issues/58 --- src/scripts/background.js | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/src/scripts/background.js b/src/scripts/background.js index c5d105a..4527196 100644 --- a/src/scripts/background.js +++ b/src/scripts/background.js @@ -24,18 +24,15 @@ class Logger { this.matchedList = []; this.unmatchedList = []; } - - add(item, list) { - list.push(item); // adds to the end - list = list.slice(-this.size); // slice to the ending size entries - } addMatched(item) { - this.add(item, this.matchedList); + this.matchedList.push(item); + this.matchedList = this.matchedList.slice(-this.size); // slice to the ending size entries } addUnmatched(item) { - this.add(item, this.unmatchedList); + this.unmatchedList.push(item); + this.unmatchedList = this.unmatchedList.slice(-this.size); // slice to the ending size entries } updateStorage() { From 31d3a93a4992a9cff63cda4878b8e88baba61dd5 Mon Sep 17 00:00:00 2001 From: "eric@ericjung.net" Date: Sun, 29 Dec 2019 13:00:30 -0700 Subject: [PATCH 05/68] version bump --- src/about.html | 18 +++++------------- src/manifest.json | 2 +- 2 files changed, 6 insertions(+), 14 deletions(-) diff --git a/src/about.html b/src/about.html index f3eab6d..13d148a 100644 --- a/src/about.html +++ b/src/about.html @@ -56,6 +56,11 @@

Support Me

Eric H. Jung
Denver, Colorado, USA

Release Notes for Recent Releases

+

Version 7.4.3

+
    +
  • Fixed "log limit ignored" bug discussed here.
  • +
  • Fixed spelling errors. Patch submitted here by cheese1.
  • +

Version 7.4.2

  • Improved Logging — see URLs that matched blacklist patterns and URLs that didn't match anything are now in their own section.
  • @@ -69,19 +74,6 @@

    Version 7.4.2

  • Remove unneeded console log messages.
  • Faster deletion of patterns (faster animation)
-

Version 7.4.1

-
    -
  • Fixes so that FoxyProxy Basic can share the same codebase as FoxyProxy Standard again. Version number alignment: for the first time since FoxyProxy Basic - was introduced, it will share the same version number as FoxyProxy Standard.
  • -
  • Exported settings now include FoxyProxy edition — Standard or Basic. However, they are interchangeable.
  • -
  • Removed link to Community Support Forums. - We are shutting the forums down. People just don't use forums anymore; we only get spam there. - And have many other support chanels: email, ticket system, github, facebook, twitter, chat, etc.
  • -
  • Escape button works to close the current FoxyProxy window and return to the previous (if there is a previous).
  • -
  • Dialog box color changes for consistency
  • -
  • Import optimizations and increase on import file size from 5 MB to 10 MB
  • -
  • Show help text if no proxy settings are defined; hide all proxy selectors too including 'turn off'.
  • -
diff --git a/src/manifest.json b/src/manifest.json index eea43dc..6401c37 100644 --- a/src/manifest.json +++ b/src/manifest.json @@ -3,7 +3,7 @@ "name": "__MSG_extensionName__", "description": "__MSG_extensionDescription__", - "version": "7.4.2", + "version": "7.4.3", "default_locale": "en", "homepage_url": "https://getfoxyproxy.org/", "author": "Eric Jung", From 192d23c27e478d906530079fdc9a89674967f789 Mon Sep 17 00:00:00 2001 From: "eric@ericjung.net" Date: Sun, 29 Dec 2019 13:10:04 -0700 Subject: [PATCH 06/68] better notes on building foxyproxy basic --- README.md | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index c7a1c93..d291e42 100644 --- a/README.md +++ b/README.md @@ -28,7 +28,10 @@ FoxyProxy is internationalized! Translate [messages.json](https://github.com/fox ## Building -FoxyProxy **Standard** edition is built by default. To build FoxyProxy **Basic** edition, set `FOXYPROXY_BASIC` to `true` in [utils.js](https://github.com/foxyproxy/firefox-extension/blob/master/src/scripts/utils.js) before building. +FoxyProxy **Standard** edition is built by default. To build FoxyProxy **Basic** edition: + +* change `FOXYPROXY_BASIC` from `false` to `true` in [utils.js](https://github.com/foxyproxy/firefox-extension/blob/master/src/scripts/utils.js) +* change browser_specific_settings.id in [manifest.json](https://github.com/foxyproxy/firefox-extension/blob/master/src/manifest.json) from `foxyproxy@eric.h.jung` to `foxyproxy-basic@eric.h.jung` ### Building With Grunt @@ -60,3 +63,4 @@ Note some items are cached by Firefox. Please refer to other online documentatio This project is licensed under the GPL 2.0 License. Commercial re-licensing may be available on request. +## Feature Requests / RoadMap \ No newline at end of file From ccc702e62ca9dbb41df34dbf173facf1ec317869 Mon Sep 17 00:00:00 2001 From: "eric@ericjung.net" Date: Tue, 31 Dec 2019 09:25:54 -0700 Subject: [PATCH 07/68] initial commit for import from list --- src/_locales/en/messages.json | 12 +++- src/import-bulk.html | 114 ++++++++++++++++++++++++++++++++++ src/options.html | 4 ++ src/scripts/import-bulk.js | 40 ++++++++++++ src/scripts/options.js | 6 +- 5 files changed, 171 insertions(+), 5 deletions(-) create mode 100644 src/import-bulk.html create mode 100644 src/scripts/import-bulk.js diff --git a/src/_locales/en/messages.json b/src/_locales/en/messages.json index b5fa152..1626f79 100644 --- a/src/_locales/en/messages.json +++ b/src/_locales/en/messages.json @@ -11,6 +11,7 @@ "deleteAll": { "message": "Delete All" }, "export": { "message": "Export" }, "import": { "message": "Import" }, + "bulk": { "message": "Bulk" }, "log": { "message": "Log" }, "myIP": { "message": "What's My IP?" }, "deleteAllmessage": { "message": "All data deleted" }, @@ -156,5 +157,14 @@ "timestamp": { "message": "Timestamp" }, "notApplicable": {"message": "n/a"}, "matchedURLs": {"message": "URLs That Matched Patterns"}, - "unmatchedURLs": {"message": "URLs That Did Not Match Patterns"} + "unmatchedURLs": {"message": "URLs That Did Not Match Patterns"}, + + "bulkImport": { "message": "Bulk Import" }, + "simple": { "message": "simple" }, + "complete": { "message": "complete" }, + "simpleFormat": { "message": "Use this format to specify just ip address (or servername) and port. You will be prompted for proxy type (http, ssl, socks). The format is:"}, + "completeFormat": { "message": "Use this format to specify all options in the import. The format is:"}, + "overwriteProxies": { "message": "Overwrite existing proxies" }, + "overwritProxiesHelp1": { "message": "Check to delete all existing proxies and replace them with proxies from this list." }, + "overwritProxiesHelp2": { "message": "Uncheck to append proxies in this list to existing proxies." } } \ No newline at end of file diff --git a/src/import-bulk.html b/src/import-bulk.html new file mode 100644 index 0000000..7de51ef --- /dev/null +++ b/src/import-bulk.html @@ -0,0 +1,114 @@ + + + + + FoxyProxy + + + + + + + + +
+ + +
+ + +
+
+ Paste a proxy list below. Choose from +
+
+
+

ip:port
ip:port
ip:port

+
+
+
+

Example

+ 78.205.12.1:6001
12.999.51.81:3128
192.168.100.9:12001 +
+
+
+ or +
+ formats. +
+
+
+
+
+
+

Examples


+

proxy://johnconnor:hunterkiller@78.205.12.1:1080
+ socks5://johnconnor:hunterkiller@12.999.51.81:331
+ socks4://johnconnor:hunterkiller@192.168.100.9:5192
+ ssl://johnconnor:hunterkiller@78.205.12.1:21&color=#ff00bc&name=my%20special%20proxy

+
+
+ Click here for help. +
+
+
+

+ + + +
+ +
+ +
+
+ +
+
+ +
+
+
+ +
+
+
+
+ + + +
+ +
+ +
+ + + + + diff --git a/src/options.html b/src/options.html index 821c03d..eb1ac78 100644 --- a/src/options.html +++ b/src/options.html @@ -42,6 +42,9 @@ font-size: 0.8em; width: 3em; } + .indent { + margin-left: 2em; + } @@ -65,6 +68,7 @@