update proxy code to support more types
This commit is contained in:
parent
63996ce416
commit
a457c60f32
6 changed files with 21 additions and 70 deletions
|
@ -2,7 +2,7 @@
|
|||
"name": "testpilot-containers",
|
||||
"title": "Multi-Account Containers",
|
||||
"description": "Containers helps you keep all the parts of your online life contained in different tabs. Custom labels and color-coded tabs help keep different activities — like online shopping, travel planning, or checking work email — separate.",
|
||||
"version": "7.1.0",
|
||||
"version": "8.0.0",
|
||||
"author": "Andrea Marchesini, Luke Crouch and Jonathan Kingston",
|
||||
"bugs": {
|
||||
"url": "https://github.com/mozilla/multi-account-containers/issues"
|
||||
|
@ -22,9 +22,9 @@
|
|||
"nyc": "^15.0.0",
|
||||
"sinon": "^7.5.0",
|
||||
"sinon-chai": "^3.3.0",
|
||||
"stylelint-order": "^4.0.0",
|
||||
"stylelint": "^13.5.0",
|
||||
"stylelint-config-standard": "^20.0.0",
|
||||
"stylelint-order": "^4.0.0",
|
||||
"web-ext": "^2.9.3",
|
||||
"webextensions-jsdom": "^1.2.1"
|
||||
},
|
||||
|
|
|
@ -743,33 +743,9 @@ Logic.registerPanel(P_CONTAINER_INFO, {
|
|||
// Note: this is not implemented in messageHandler.js
|
||||
let incompatible = false;
|
||||
try {
|
||||
const incompatible = await browser.runtime.sendMessage({
|
||||
incompatible = await browser.runtime.sendMessage({
|
||||
method: "checkIncompatibleAddons"
|
||||
});
|
||||
const moveTabsEl = document.querySelector("#container-info-movetabs");
|
||||
if (incompatible) {
|
||||
const fragment = document.createDocumentFragment();
|
||||
const incompatEl = document.createElement("div");
|
||||
|
||||
moveTabsEl.classList.remove("clickable");
|
||||
moveTabsEl.setAttribute("title", "Moving container tabs is incompatible with Pulse, PageShot, and SnoozeTabs.");
|
||||
|
||||
fragment.appendChild(incompatEl);
|
||||
incompatEl.setAttribute("id", "container-info-movetabs-incompat");
|
||||
incompatEl.textContent = "Incompatible with other Experiments.";
|
||||
incompatEl.classList.add("container-info-tab-row");
|
||||
|
||||
moveTabsEl.parentNode.insertBefore(fragment, moveTabsEl.nextSibling);
|
||||
} else {
|
||||
Logic.addEnterHandler(moveTabsEl, async function () {
|
||||
await browser.runtime.sendMessage({
|
||||
method: "moveTabsToWindow",
|
||||
windowId: browser.windows.WINDOW_ID_CURRENT,
|
||||
cookieStoreId: Logic.currentIdentity().cookieStoreId,
|
||||
});
|
||||
window.close();
|
||||
});
|
||||
}
|
||||
} catch (e) {
|
||||
throw new Error("Could not check for incompatible add-ons.");
|
||||
}
|
||||
|
@ -1391,10 +1367,12 @@ Logic.registerPanel(P_CONTAINER_EDIT, {
|
|||
document.querySelector("#edit-container-panel-proxy").value = "";
|
||||
|
||||
const edit_proxy_dom = function(result) {
|
||||
if(result.type === "http")
|
||||
document.querySelector("#edit-container-panel-proxy").value = `${result.host}:${result.port}`;
|
||||
else if(result.type === "direct")
|
||||
document.querySelector("#edit-container-panel-proxy").value = "";
|
||||
const proxyInput = document.querySelector("#edit-container-panel-proxy");
|
||||
if (result.type === "direct" || typeof result.type === "undefined") {
|
||||
proxyInput.value = "";
|
||||
return;
|
||||
}
|
||||
proxyInput.value = `${result.type}://${result.host}:${result.port}`;
|
||||
};
|
||||
|
||||
proxifiedContainers.retrieve(identity.cookieStoreId).then((result) => {
|
||||
|
|
|
@ -1,20 +1,3 @@
|
|||
// Below lets us print errors, huge thanks to Jonathan @ https://stackoverflow.com/questions/18391212/is-it-not-possible-to-stringify-an-error-using-json-stringify
|
||||
if (!("toJSON" in Error.prototype))
|
||||
Object.defineProperty(Error.prototype, "toJSON", {
|
||||
value: function() {
|
||||
const alt = {};
|
||||
|
||||
Object.getOwnPropertyNames(this).forEach(function(key) {
|
||||
alt[key] = this[key];
|
||||
}, this);
|
||||
|
||||
return alt;
|
||||
},
|
||||
configurable: true,
|
||||
writable: true
|
||||
});
|
||||
|
||||
|
||||
// This object allows other scripts to access the list mapping containers to their proxies
|
||||
proxifiedContainers = {
|
||||
|
||||
|
@ -79,6 +62,7 @@ proxifiedContainers = {
|
|||
});
|
||||
});
|
||||
},
|
||||
|
||||
set(cookieStoreId, proxy, initialize = false) {
|
||||
return new Promise((resolve, reject) => {
|
||||
if (initialize === true) {
|
||||
|
@ -125,25 +109,14 @@ proxifiedContainers = {
|
|||
});
|
||||
},
|
||||
|
||||
//Parses a proxy description string of the format host[:port] or username:password@host[:port] (port is optional)
|
||||
//Parses a proxy description string of the format type://host[:port] or type://username:password@host[:port] (port is optional)
|
||||
parseProxy(proxy_str) {
|
||||
const regexp = /(\b(\w+):(\w+)@)?(((?:\d{1,3}\.){3}\d{1,3}\b)|(\b(\w+)(\.(\w+))+))(:(\d+))?/;
|
||||
if (regexp.test(proxy_str) !== true)
|
||||
const proxyRegexp = /(?<type>(https?)|(socks4?)):\/\/(\b(?<username>\w+):(?<password>\w+)@)?(?<host>((?:\d{1,3}\.){3}\d{1,3}\b)|(\b(\w+)(\.(\w+))+))(:(?<port>\d+))?/;
|
||||
if (proxyRegexp.test(proxy_str) !== true) {
|
||||
return false;
|
||||
|
||||
else {
|
||||
const matches = regexp.exec(proxy_str);
|
||||
|
||||
const result = {
|
||||
type: "http",
|
||||
host: matches[4],
|
||||
port: parseInt(matches[11], 10) || 8080,
|
||||
username: matches[2] || "",
|
||||
password: matches[3] || ""
|
||||
};
|
||||
|
||||
return result;
|
||||
}
|
||||
const matches = proxyRegexp.exec(proxy_str);
|
||||
return matches.groups;
|
||||
},
|
||||
|
||||
// Deletes the proxy information object for a specified cookieStoreId [useful for cleaning]
|
||||
|
|
|
@ -52,7 +52,7 @@ const Utils = {
|
|||
// The only issue with this approach is that if (for some unknown reason) pregeneratedString is not saved, it will result in an infinite loop - but better than a privacy leak!
|
||||
return getBogusProxy();
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Escapes any occurances of &, ", <, > or / with XML entities.
|
||||
|
@ -167,6 +167,8 @@ const Utils = {
|
|||
}
|
||||
};
|
||||
|
||||
window.Utils = Utils;
|
||||
|
||||
// The following creates a fake (but convincing) constant Utils.DEFAULT_PROXY
|
||||
Object.defineProperty(window.Utils, "DEFAULT_PROXY", {
|
||||
value: Object.freeze({type: "direct"}),
|
||||
|
@ -176,5 +178,3 @@ Object.defineProperty(window.Utils, "DEFAULT_PROXY", {
|
|||
// Setting configurable to false avoids deletion of Utils.DEFAULT_PROXY
|
||||
configurable: false
|
||||
});
|
||||
|
||||
window.Utils = Utils;
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
{
|
||||
"manifest_version": 2,
|
||||
"name": "Firefox Multi-Account Containers",
|
||||
"version": "7.1.0",
|
||||
"version": "8.0.0",
|
||||
"incognito": "not_allowed",
|
||||
"description": "Multi-Account Containers helps you keep all the parts of your online life contained in different tabs. Custom labels and color-coded tabs help keep different activities — like online shopping, travel planning, or checking work email — separate.",
|
||||
"icons": {
|
||||
|
|
|
@ -300,8 +300,8 @@
|
|||
<legend class="form-header">Icon</legend>
|
||||
</fieldset>
|
||||
<fieldset>
|
||||
<legend>HTTP Proxy (Optional)</legend>
|
||||
<input type="text" name="container-proxy" id="edit-container-panel-proxy" maxlength="15" placeholder="IP:PORT or USER:PASS@IP:PORT"/>
|
||||
<legend>Proxy (Optional)</legend>
|
||||
<input type="text" name="container-proxy" id="edit-container-panel-proxy" maxlength="50" placeholder="type://host:port"/>
|
||||
</fieldset>
|
||||
</form>
|
||||
<div id="edit-container-options">
|
||||
|
|
Loading…
Add table
Reference in a new issue