19 Commits
0.41 ... 0.43

Author SHA1 Message Date
idk
f233972323 Merge pull request #22 from eyedeekay/more-isolation
additional isolation by contextual id
2019-11-11 16:46:24 -05:00
idk
f27a59c193 additional isolation by contextual id 2019-11-11 16:44:58 -05:00
idk
b9200a4313 Merge pull request #21 from eyedeekay/more-isolation
This forces a contextual identity for router applications, separate from the router console identity.
2019-11-11 16:37:56 -05:00
idk
b7ebbd5b79 additional isolation by contextual id 2019-11-11 16:34:41 -05:00
idk
e631c82363 fallback to about:config proxy in contextual tabs we don't own 2019-11-11 02:38:11 -05:00
idk
43e6818324 jsfmt, tidy 2019-11-11 01:48:37 -05:00
idk
fc019c58bb better settings guarantees and about:config proxy config compatibility so also i2pbrowser compatibility 2019-11-11 01:12:57 -05:00
idk
2e8a61de2e isolate by default, don't ever use firefox-default, replace with our own 2019-11-11 00:03:24 -05:00
idk
d770abcce8 jsfmt 2019-11-10 22:36:32 -05:00
idk
ecda2d7102 update the readme a bit 2019-11-10 22:28:16 -05:00
idk
f670bef983 introduce a proxy health check 2019-11-10 22:24:10 -05:00
idk
aa71f917a6 Merge pull request #20 from eyedeekay/blackhole
Blackhole non-routerconsole requests
2019-11-10 20:31:13 -05:00
idk
33cfbc324a update color schemes, blackhole non-routerconsole URL's on the localhost 2019-11-10 20:28:31 -05:00
idk
38d5dcb929 start messing with bookmarks and stuff 2019-11-05 22:11:00 -05:00
idk
994b021a95 start messing with bookmarks and stuff 2019-11-05 22:09:41 -05:00
idk
c2f321b26b Merge pull request #19 from eyedeekay/readme
Readme, Makefile, Release System Fiddlibits
2019-11-01 09:28:58 -04:00
idk
04d58b33be add screenshots 2019-10-31 14:50:33 -04:00
idk
a7562fd66e update makefile 2019-10-31 12:45:55 -04:00
idk
595f02c01b update makefile 2019-10-31 12:38:21 -04:00
19 changed files with 1089 additions and 284 deletions

2
.gitignore vendored
View File

@@ -1,2 +1,2 @@
README.md.asc
node_modules/

View File

@@ -4,12 +4,14 @@ default: zip
install: uninstall
mkdir -p $(PREFIX)/share/webext/i2ppb@eyedeekay.github.io \
$(PREFIX)/share/webext/i2ppb@eyedeekay.github.io/i2pcontrol \
$(PREFIX)/share/mozilla/extensions/{ec8030f7-c20a-464f-9b0e-13a3a9e97384}
cp -r ./chromium/ $(PREFIX)/share/webext/i2ppb@eyedeekay.github.io/
cp -r ./icons/ $(PREFIX)/share/webext/i2ppb@eyedeekay.github.io/
cp -r ./_locales/ $(PREFIX)/share/webext/i2ppb@eyedeekay.github.io/
cp -r ./options/ $(PREFIX)/share/webext/i2ppb@eyedeekay.github.io/
cp ./*.js $(PREFIX)/share/webext/i2ppb@eyedeekay.github.io/
cp ./i2pcontrol/i2pcontrol.js $(PREFIX)/share/webext/i2ppb@eyedeekay.github.io/i2pcontrol/i2pcontrol.js
cp ./*.html $(PREFIX)/share/webext/i2ppb@eyedeekay.github.io/
cp ./*.css $(PREFIX)/share/webext/i2ppb@eyedeekay.github.io/
cp ./*.md $(PREFIX)/share/webext/i2ppb@eyedeekay.github.io/
@@ -29,20 +31,42 @@ ls:
ls -lah $(PREFIX)/share/mozilla/extensions/{ec8030f7-c20a-464f-9b0e-13a3a9e97384}
clean:
rm -f ../i2psetproxy.js.zip ../i2p_proxy*.xpi
rm -fr ../i2psetproxy.js.zip ../i2p_proxy*.xpi ../i2p*.xpi #../i2psetproxy.js_*.*
## EVEN RELEASES are AMO RELEASES
## ODD RELEASES are SELFHOSTED RELEASES
MOZ_VERSION=0.38
VERSION=0.39
VERSION=$(MOZ_VERSION)
MOZ_VERSION=0.40
VERSION=0.41
#VERSION=$(MOZ_VERSION)
#VERSION=1.27
YELLOW=F7E59A
ORANGE=FFC56D
GREY=D9D9D6
BLUE=A4C8E1
PURPLE=A48fE1
colors:
@echo " yellow $(YELLOW) \n orange $(ORANGE) \n grey $(GREY) \n blue $(BLUE) \n purple $(PURPLE)"
amo-readme:
markdown README.md | \
sed 's|<p>||g' | \
sed 's|</p>||g' | \
sed 's|<h1>|<strong>|g' | \
sed 's|</h1>|</strong>|g' | \
sed 's|<h2>|<strong>|g' | \
sed 's|</h2>|</strong>|g' | \
sed 's|<h3>|<strong>|g' | \
sed 's|</h3>|</strong>|g' | \
grep -v '<img' > index.html
xpi:
wget -O ../i2ppb@eyedeekay.github.io.xpi \
https://addons.mozilla.org/firefox/downloads/file/3419789/i2psetproxyjs-$(MOZ_VERSION)-an+fx.xpi
cp ../i2ppb@eyedeekay.github.io.xpi ./i2ppb@eyedeekay.github.io.xpi
#wget -O ../i2ppb@eyedeekay.github.io.xpi \
#https://addons.mozilla.org/firefox/downloads/file/3419789/i2psetproxyjs-$(MOZ_VERSION)-an+fx.xpi
#cp ../i2ppb@eyedeekay.github.io.xpi ./i2ppb@eyedeekay.github.io.xpi
cp ~/Downloads/i2p_in_private_browsing-$(VERSION)-an+fx.xpi ./i2ppb@eyedeekay.github.io.xpi
version:
sed -i 's|$(shell grep "\"version\": " manifest.json)| \"version\": \"$(VERSION)\",|g' manifest.json
@@ -78,6 +102,9 @@ libpolyfill:
fmt:
find . -path ./node_modules -prune -o -name '*.js' -exec prettier --write {} \;
lint:
eslint --fix *.js
deborig:
rm -rf ../i2psetproxy.js-$(VERSION)
cp -r . ../i2psetproxy.js-$(VERSION)
@@ -85,6 +112,7 @@ deborig:
-cvz \
--exclude=.git \
--exclude=i2psetproxy.js.gif \
--exclude=node_modules \
-f ../i2psetproxy.js_$(VERSION).orig.tar.gz \
.

View File

@@ -40,6 +40,15 @@ releases page. The latest AMO Plugin will always be identical to the latest
github release, except for the version number, which must be incremented for
submission to AMO.
Debian usage:
-------------
Should you prefer, it is possible to install this extension system-wide by
side-loading it into Debian. You can generate your own deb file by running the
command:
make deb
### Features
* [done] **Provide** a way to launch into an I2P-Specific contextual identity
@@ -63,7 +72,10 @@ submission to AMO.
disabled*.
* [ready] **Provide** help in a variety of languages.
* [wip] **Monitor** the health and readiness of the I2P router it is
instructed to use.
instructed to use. Currently the plugin checks whether the HTTP Proxy is
working by fetching an image from "http://proxy.i2p" and displaying a result.
A work-in-progress binding to i2pcontrol is available in ./i2pcontrol, it is
inert at this time.
* [1/2] **Handle** router console applications under their own origins and
within their own contextual identity. (1) The router console is automatically
confined to it's own container tab. (2) Use a custom protocol handler to
@@ -77,6 +89,10 @@ submission to AMO.
![Visiting i2p-projekt.i2p](i2psetproxy.js.png)
![Visiting clearweb](clearweb.png)
![Visiting routerconsole](routerconsole.png)
![Video of the plugin in action](i2psetproxy.js.gif)
Super Extra Important Background Info:

View File

@@ -5,24 +5,60 @@ function onGot(contexts) {
ids.push(context.name);
}
console.log("Checking new contexts");
if (ids.indexOf("i2pbrowser") == -1) {
if (ids.indexOf("I2P Browsing") == -1) {
browser.contextualIdentities
.create({
name: "i2pbrowser",
color: "purple",
name: "I2P Browsing",
color: "orange",
icon: "fingerprint"
})
.then(onCreated, onError);
}
if (ids.indexOf("routerconsole") == -1) {
if (ids.indexOf("Web Browsing") == -1) {
browser.contextualIdentities
.create({
name: "routerconsole",
color: "turquoise",
name: "Web Browsing",
color: "red",
icon: "circle"
})
.then(onCreated, onError);
}
if (ids.indexOf("Router Console") == -1) {
browser.contextualIdentities
.create({
name: "Router Console",
color: "blue",
icon: "briefcase"
})
.then(onCreated, onError);
}
if (ids.indexOf("Hidden Services Manager") == -1) {
browser.contextualIdentities
.create({
name: "Hidden Services Manager",
color: "green",
icon: "tree"
})
.then(onCreated, onError);
}
if (ids.indexOf("Web Mail") == -1) {
browser.contextualIdentities
.create({
name: "Web Mail",
color: "yellow",
icon: "briefcase"
})
.then(onCreated, onError);
}
if (ids.indexOf("Bittorrent") == -1) {
browser.contextualIdentities
.create({
name: "Bittorrent",
color: "purple",
icon: "chill"
})
.then(onCreated, onError);
}
}
function onCreated(context) {
@@ -63,45 +99,100 @@ function themeWindow(window) {
// Check if the window is in private browsing
function logTabs(tabInfo) {
function onGot(context) {
if (context.name == "i2pbrowser") {
if (context.name == "I2P Browsing") {
console.log("Active in I2P window");
if (window.incognito) {
chrome.theme.update(window.id, {
colors: {
frame: "#2D4470",
toolbar: "#2D4470"
frame: "#FFC56D",
toolbar: "#FFC56D"
}
});
} else {
chrome.theme.update(window.id, {
colors: {
frame: "#9DABD5",
toolbar: "#9DABD5"
frame: "#FFC56D",
toolbar: "#FFC56D"
}
});
}
} else if (context.name == "routerconsole") {
console.log("Active in I2P window");
} else if (context.name == "Router Console") {
console.log("Active in Router Console window");
if (window.incognito) {
chrome.theme.update(window.id, {
colors: {
frame: "#00CED1",
toolbar: "#00CED1"
frame: "#A4C8E1",
toolbar: "#A4C8E1"
}
});
} else {
chrome.theme.update(window.id, {
colors: {
frame: "#40E0D0",
toolbar: "#40E0D0"
frame: "#A4C8E1",
toolbar: "#A4C8E1"
}
});
}
} else if (context.name == "Hidden Services Manager") {
console.log("Active in Hidden Services Manager window");
if (window.incognito) {
chrome.theme.update(window.id, {
colors: {
frame: "#D9D9D6",
toolbar: "#D9D9D6"
}
});
} else {
chrome.theme.update(window.id, {
colors: {
frame: "#D9D9D6",
toolbar: "#D9D9D6"
}
});
}
} else if (context.name == "Web Mail") {
console.log("Active in Web Mail window");
if (window.incognito) {
chrome.theme.update(window.id, {
colors: {
frame: "#F7E59A",
toolbar: "#F7E59A"
}
});
} else {
chrome.theme.update(window.id, {
colors: {
frame: "#F7E59A",
toolbar: "#F7E59A"
}
});
}
} else if (context.name == "Bittorrent") {
console.log("Active in Bittorrent window");
if (window.incognito) {
chrome.theme.update(window.id, {
colors: {
frame: "#A48FE1",
toolbar: "#A48FE1"
}
});
} else {
chrome.theme.update(window.id, {
colors: {
frame: "#A48FE1",
toolbar: "#A48FE1"
}
});
}
} else {
console.log("Not active in I2P window");
chrome.theme.reset(window.id);
}
}
if (tabInfo[0].cookieStoreId != "firefox-default") {
if (
tabInfo[0].cookieStoreId != "firefox-default" &&
tabInfo[0].cookieStoreId != "firefox-private"
) {
browser.contextualIdentities
.get(tabInfo[0].cookieStoreId)
.then(onGot, onError);
@@ -122,10 +213,69 @@ function setTitle(window) {
console.log(tabInfo);
function onGot(context) {
if (context.name == "i2pbrowser") {
if (context.name == "I2P Browsing") {
console.log("Active in I2P window");
if (window.incognito) {
chrome.windows.update(window.id, {
titlePreface: titleprefpriv
});
} else {
chrome.windows.update(window.id, {
titlePreface: titlepref
});
}
} else if (context.name == "Web Browsing") {
console.log("Active in Web window");
if (window.incognito) {
chrome.windows.update(window.id, {
titlePreface: titleprefpriv
});
} else {
chrome.windows.update(window.id, {
titlePreface: titlepref
});
}
} else if (context.name == "Router Console") {
console.log("Active in Router Console window");
if (window.incognito) {
chrome.windows.update(window.id, {
titlePreface: titleprefpriv
});
} else {
chrome.windows.update(window.id, {
titlePreface: titlepref
});
}
} else if (context.name == "Hidden Services Manager") {
console.log("Active in Hidden Services Manager window");
if (window.incognito) {
chrome.windows.update(window.id, {
titlePreface: titleprefpriv
});
} else {
chrome.windows.update(window.id, {
titlePreface: titlepref
});
}
} else if (context.name == "Web Mail") {
console.log("Active in Web Mail window");
if (window.incognito) {
chrome.windows.update(window.id, {
titlePreface: titleprefpriv
});
} else {
chrome.windows.update(window.id, {
titlePreface: titlepref
});
}
} else if (context.name == "Bittorrent") {
console.log("Active in I2P window");
if (window.incognito) {
chrome.windows.update(window.id, {
titlePreface: titleprefpriv
@@ -138,10 +288,24 @@ function setTitle(window) {
}
}
if (tabInfo[0].cookieStoreId != "firefox-default")
if (
tabInfo[0].cookieStoreId != "firefox-default" &&
tabInfo[0].cookieStoreId != "firefox-private"
) {
browser.contextualIdentities
.get(tabInfo[0].cookieStoreId)
.then(onGot, onError);
} else {
if (window.incognito) {
chrome.windows.update(window.id, {
titlePreface: ""
});
} else {
chrome.windows.update(window.id, {
titlePreface: ""
});
}
}
}
var querying = browser.tabs.query({
@@ -152,8 +316,8 @@ function setTitle(window) {
}
chrome.windows.onCreated.addListener(() => {
//var gettingStoredSettings = chrome.storage.local.get();
//gettingStoredSettings.then(setupProxy, onError);
/* var gettingStoredSettings = chrome.storage.local.get();
gettingStoredSettings.then(setupProxy, onError); */
chrome.storage.local.get(function(got) {
setupProxy();
});

View File

@@ -17,6 +17,7 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
"use strict";
if (
@@ -28,15 +29,15 @@
const SEND_RESPONSE_DEPRECATION_WARNING =
"Returning a Promise is the preferred way to send a reply from an onMessage/onMessageExternal listener, as the sendResponse will be removed from the specs (See https://developer.mozilla.org/docs/Mozilla/Add-ons/WebExtensions/API/runtime/onMessage)";
// Wrapping the bulk of this polyfill in a one-time-use function is a minor
// optimization for Firefox. Since Spidermonkey does not fully parse the
// contents of a function until the first time it's called, and since it will
// never actually need to be called, this allows the polyfill to be included
// in Firefox nearly for free.
/* Wrapping the bulk of this polyfill in a one-time-use function is a minor
optimization for Firefox. Since Spidermonkey does not fully parse the
contents of a function until the first time it's called, and since it will
never actually need to be called, this allows the polyfill to be included
in Firefox nearly for free. */
const wrapAPIs = extensionAPIs => {
// NOTE: apiMetadata is associated to the content of the api-metadata.json file
// at build time by replacing the following "include" with the content of the
// JSON file.
/* NOTE: apiMetadata is associated to the content of the api-metadata.json file
at build time by replacing the following "include" with the content of the
JSON file. */
const apiMetadata = {
alarms: {
clear: {
@@ -734,12 +735,8 @@
* @param {*} value The value to test.
* @returns {boolean} True if the value is thenable.
*/
const isThenable = value => {
return (
value && typeof value === "object" && typeof value.then === "function"
);
};
const isThenable = value =>
value && typeof value === "object" && typeof value.then === "function";
/**
* Creates and returns a function which, when called, will resolve or reject
* the given promise based on how it is called:
@@ -767,19 +764,17 @@
* @returns {function}
* The generated callback function.
*/
const makeCallback = (promise, metadata) => {
return (...callbackArgs) => {
if (extensionAPIs.runtime.lastError) {
promise.reject(extensionAPIs.runtime.lastError);
} else if (
metadata.singleCallbackArg ||
(callbackArgs.length <= 1 && metadata.singleCallbackArg !== false)
) {
promise.resolve(callbackArgs[0]);
} else {
promise.resolve(callbackArgs);
}
};
const makeCallback = (promise, metadata) => (...callbackArgs) => {
if (extensionAPIs.runtime.lastError) {
promise.reject(extensionAPIs.runtime.lastError);
} else if (
metadata.singleCallbackArg ||
(callbackArgs.length <= 1 && metadata.singleCallbackArg !== false)
) {
promise.resolve(callbackArgs[0]);
} else {
promise.resolve(callbackArgs);
}
};
const pluralizeArguments = numArgs =>
@@ -807,8 +802,8 @@
* @returns {function(object, ...*)}
* The generated wrapper function.
*/
const wrapAsyncFunction = (name, metadata) => {
return function asyncFunctionWrapper(target, ...args) {
const wrapAsyncFunction = (name, metadata) =>
function asyncFunctionWrapper(target, ...args) {
if (args.length < metadata.minArgs) {
throw new Error(
`Expected at least ${metadata.minArgs} ${pluralizeArguments(
@@ -827,9 +822,9 @@
return new Promise((resolve, reject) => {
if (metadata.fallbackToNoCallback) {
// This API method has currently no callback on Chrome, but it return a promise on Firefox,
// and so the polyfill will try to call it with a callback first, and it will fallback
// to not passing the callback if the first call fails.
/* This API method has currently no callback on Chrome, but it return a promise on Firefox,
and so the polyfill will try to call it with a callback first, and it will fallback
to not passing the callback if the first call fails. */
try {
target[name](
...args,
@@ -844,8 +839,8 @@
target[name](...args);
// Update the API method metadata, so that the next API calls will not try to
// use the unsupported callback anymore.
/* Update the API method metadata, so that the next API calls will not try to
use the unsupported callback anymore. */
metadata.fallbackToNoCallback = false;
metadata.noCallback = true;
@@ -862,7 +857,6 @@
}
});
};
};
/**
* Wraps an existing method of the target object, so that calls to it are
@@ -883,13 +877,12 @@
* A Proxy object for the given method, which invokes the given wrapper
* method in its place.
*/
const wrapMethod = (target, method, wrapper) => {
return new Proxy(method, {
const wrapMethod = (target, method, wrapper) =>
new Proxy(method, {
apply(targetMethod, thisObj, args) {
return wrapper.call(thisObj, target, ...args);
}
});
};
let hasOwnProperty = Function.call.bind(Object.prototype.hasOwnProperty);
@@ -935,20 +928,20 @@
let value = target[prop];
if (typeof value === "function") {
// This is a method on the underlying object. Check if we need to do
// any wrapping.
/* This is a method on the underlying object. Check if we need to do
any wrapping. */
if (typeof wrappers[prop] === "function") {
// We have a special-case wrapper for this method.
value = wrapMethod(target, target[prop], wrappers[prop]);
} else if (hasOwnProperty(metadata, prop)) {
// This is an async method that we have metadata for. Create a
// Promise wrapper for it.
/* This is an async method that we have metadata for. Create a
Promise wrapper for it. */
let wrapper = wrapAsyncFunction(prop, metadata[prop]);
value = wrapMethod(target, target[prop], wrapper);
} else {
// This is a method that we don't know or care about. Return the
// original method, bound to the underlying object.
/* This is a method that we don't know or care about. Return the
original method, bound to the underlying object. */
value = value.bind(target);
}
} else if (
@@ -956,13 +949,13 @@
value !== null &&
(hasOwnProperty(wrappers, prop) || hasOwnProperty(metadata, prop))
) {
// This is an object that we need to do some wrapping for the children
// of. Create a sub-object wrapper for it with the appropriate child
// metadata.
/* This is an object that we need to do some wrapping for the children
of. Create a sub-object wrapper for it with the appropriate child
metadata. */
value = wrapObject(value, wrappers[prop], metadata[prop]);
} else {
// We don't need to do any wrapping for this property,
// so just forward all access to the underlying object.
/* We don't need to do any wrapping for this property,
so just forward all access to the underlying object. */
Object.defineProperty(cache, prop, {
configurable: true,
enumerable: true,
@@ -999,16 +992,15 @@
}
};
// Per contract of the Proxy API, the "get" proxy handler must return the
// original value of the target if that value is declared read-only and
// non-configurable. For this reason, we create an object with the
// prototype set to `target` instead of using `target` directly.
// Otherwise we cannot return a custom object for APIs that
// are declared read-only and non-configurable, such as `chrome.devtools`.
//
// The proxy handlers themselves will still use the original `target`
// instead of the `proxyTarget`, so that the methods and properties are
// dereferenced via the original targets.
/* Per contract of the Proxy API, the "get" proxy handler must return the
original value of the target if that value is declared read-only and
non-configurable. For this reason, we create an object with the
prototype set to `target` instead of using `target` directly.
Otherwise we cannot return a custom object for APIs that
are declared read-only and non-configurable, such as `chrome.devtools`.
The proxy handlers themselves will still use the original `target`
instead of the `proxyTarget`, so that the methods and properties are
dereferenced via the original targets. */
let proxyTarget = Object.create(target);
return new Proxy(proxyTarget, handlers);
};
@@ -1095,17 +1087,17 @@
const isResultThenable = result !== true && isThenable(result);
// If the listener didn't returned true or a Promise, or called
// wrappedSendResponse synchronously, we can exit earlier
// because there will be no response sent from this listener.
/* If the listener didn't returned true or a Promise, or called
wrappedSendResponse synchronously, we can exit earlier
because there will be no response sent from this listener. */
if (result !== true && !isResultThenable && !didCallSendResponse) {
return false;
}
// A small helper to send the message if the promise resolves
// and an error if the promise rejects (a wrapped sendMessage has
// to translate the message into a resolved promise or a rejected
// promise).
/* A small helper to send the message if the promise resolves
and an error if the promise rejects (a wrapped sendMessage has
to translate the message into a resolved promise or a rejected
promise). */
const sendPromisedResult = promise => {
promise
.then(
@@ -1114,8 +1106,8 @@
sendResponse(msg);
},
error => {
// Send a JSON representation of the error if the rejected value
// is an instance of error, or the object itself otherwise.
/* Send a JSON representation of the error if the rejected value
is an instance of error, or the object itself otherwise. */
let message;
if (
error &&
@@ -1139,9 +1131,9 @@
});
};
// If the listener returned a Promise, send the resolved value as a
// result, otherwise wait the promise related to the wrappedSendResponse
// callback to resolve and send it as a response.
/* If the listener returned a Promise, send the resolved value as a
result, otherwise wait the promise related to the wrappedSendResponse
callback to resolve and send it as a response. */
if (isResultThenable) {
sendPromisedResult(result);
} else {
@@ -1155,9 +1147,9 @@
const wrappedSendMessageCallback = ({ reject, resolve }, reply) => {
if (extensionAPIs.runtime.lastError) {
// Detect when none of the listeners replied to the sendMessage call and resolve
// the promise to undefined as in Firefox.
// See https://github.com/mozilla/webextension-polyfill/issues/130
/* Detect when none of the listeners replied to the sendMessage call and resolve
the promise to undefined as in Firefox.
See https://github.com/mozilla/webextension-polyfill/issues/130 */
if (
extensionAPIs.runtime.lastError.message ===
CHROME_SEND_MESSAGE_CALLBACK_NO_RESPONSE_MESSAGE
@@ -1167,8 +1159,8 @@
reject(extensionAPIs.runtime.lastError);
}
} else if (reply && reply.__mozWebExtensionPolyfillReject__) {
// Convert back the JSON representation of the error into
// an Error instance.
/* Convert back the JSON representation of the error into
an Error instance. */
reject(new Error(reply.message));
} else {
resolve(reply);
@@ -1251,8 +1243,8 @@
);
}
// The build process adds a UMD wrapper around this file, which makes the
// `module` variable available.
/* The build process adds a UMD wrapper around this file, which makes the
`module` variable available. */
module.exports = wrapAPIs(chrome);
} else {
module.exports = browser;

BIN
clearweb.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 169 KiB

View File

@@ -1,19 +1,20 @@
//var windowIds = []
function onCreated(windowInfo) {
console.log(`Created window: ${windowInfo.id}`);
browser.tabs.create({
windowId: windowInfo.id,
url: "about:blank",
cookieStoreId: event.target.dataset.identity
});
}
function onError(error) {
console.log(`Error: ${error}`);
}
function eventHandler(event) {
if (event.target.dataset.action == "create") {
function onCreated(windowInfo) {
console.log(`Created window: ${windowInfo.id}`);
browser.tabs.create({
windowId: windowInfo.id,
url: "about:blank",
cookieStoreId: event.target.dataset.identity
});
}
function onError(error) {
console.log(`Error: ${error}`);
}
var creating = browser.windows.create({
cookieStoreId: event.target.dataset.identity
});
@@ -51,7 +52,7 @@ if (browser.contextualIdentities === undefined) {
} else {
browser.contextualIdentities
.query({
name: "i2pbrowser"
name: "I2P Browsing"
})
.then(identities => {
if (!identities.length) {

8
debian/changelog vendored
View File

@@ -1,3 +1,10 @@
i2psetproxy.js (0.41-1) UNRELEASED; urgency=low
* Only open tabs, not windows
* Optionally enable WebRTC
-- idk <hankhill19580@gmail.com> Thu, 31 OCT 2019 12:41:33 -0400
i2psetproxy.js (0.37-1) UNRELEASED; urgency=low
* Honor contextual ID when deleting history
@@ -10,7 +17,6 @@ i2psetproxy.js (0.35-1) UNRELEASED; urgency=low
-- idk <hankhill19580@gmail.com> Thu, 01 Aug 2019 00:32:39 -0400
i2psetproxy.js (0.31-1) UNRELEASED; urgency=low
* Initial release. Closes: #nnnn

2
debian/rules vendored
View File

@@ -5,12 +5,14 @@
override_dh_auto_install:
mkdir -p $$(pwd)/debian/i2psetproxy.js/usr/share/webext/i2ppb@eyedeekay.github.io \
$$(pwd)/debian/i2psetproxy.js/usr/share/webext/i2ppb@eyedeekay.github.io/i2pcontrol \
$$(pwd)/debian/i2psetproxy.js/usr/share/mozilla/extensions/{ec8030f7-c20a-464f-9b0e-13a3a9e97384}
cp -r ./chromium/ $$(pwd)/debian/i2psetproxy.js/usr/share/webext/i2ppb@eyedeekay.github.io/
cp -r ./icons/ $$(pwd)/debian/i2psetproxy.js/usr/share/webext/i2ppb@eyedeekay.github.io/
cp -r ./options/ $$(pwd)/debian/i2psetproxy.js/usr/share/webext/i2ppb@eyedeekay.github.io/
cp -r ./_locales/ $$(pwd)/debian/i2psetproxy.js/usr/share/webext/i2ppb@eyedeekay.github.io/
cp ./*.js $$(pwd)/debian/i2psetproxy.js/usr/share/webext/i2ppb@eyedeekay.github.io/
cp ./i2pcontrol/i2pcontrol.js $$(pwd)/debian/i2psetproxy.js/usr/share/webext/i2ppb@eyedeekay.github.io/i2pcontrol/
cp ./*.html $$(pwd)/debian/i2psetproxy.js/usr/share/webext/i2ppb@eyedeekay.github.io/
cp ./*.css $$(pwd)/debian/i2psetproxy.js/usr/share/webext/i2ppb@eyedeekay.github.io/
cp ./*.md $$(pwd)/debian/i2psetproxy.js/usr/share/webext/i2ppb@eyedeekay.github.io/

View File

@@ -4,7 +4,7 @@ function send(json) {
const url = "http://" + "127.0.0.1" + ":" + "7650";
Http.open("POST", url);
Http.send(json);
console.log(Http);
//console.log(Http);
return Http;
}
@@ -21,11 +21,12 @@ function authenticate(user, password) {
return send(json);
}
username = "";
password = "";
var username = "";
var password = "";
function echo(string, section) {
var xhr = authenticate(username, password);
console.log("(i2pcontrol) echo", xhr);
xhr.onload = function() {
resp = JSON.Parse(xhr.responseText);
json = {
@@ -38,6 +39,9 @@ function echo(string, section) {
}
};
var controlMessage = document.getElementById(section);
console.log("(i2pcontrol) reply", xhr.responseText);
infoMessage.textContent = xhr.responseText;
};
}
echo("test", "test");

View File

@@ -16,3 +16,7 @@ span.identity {
display: inline-block;
margin-left: 1em;
}
figcaption {
display: inline;
}

44
info.js
View File

@@ -55,3 +55,47 @@ document.addEventListener("click", e => {
e.preventDefault();
});
function proxyReadiness() {
console.log(this.responseText);
}
//document.addEventListener("onpageshow", e => {
console.log("(Check) Checking Proxy Readiness");
const Http = new XMLHttpRequest();
Http.addEventListener("load", proxyReadiness);
const url = "http://proxy.i2p"; ///themes/console/images/favicon.ico";
Http.open("GET", url);
Http.send();
//});
function transferComplete(evt) {
console.log(
"The transfer is complete.",
this.status,
this.statusText,
this.responseText
);
}
function transferFailed(evt) {
console.log(
"An error occurred while transferring the file.",
this.status,
this.statusText,
this.responseText
);
}
function transferCanceled(evt) {
console.log(
"The transfer has been canceled by the user.",
this.status,
this.statusText,
this.responseText
);
}
Http.addEventListener("load", transferComplete);
Http.addEventListener("error", transferFailed);
Http.addEventListener("abort", transferCanceled);

View File

@@ -5,9 +5,13 @@
"strict_min_version": "60.0"
}
},
"chrome_settings_overrides": {
"homepage": "home.html"
},
"permissions": [
"theme",
"browsingData",
"bookmarks",
"notifications",
"proxy",
"privacy",
@@ -22,7 +26,7 @@
],
"manifest_version": 2,
"name": "__MSG_extensionName__",
"version": "0.37",
"version": "0.41",
"description": "__MSG_extensionDescription__",
"homepage_url": "https://github.com/eyedeekay/i2psetproxy.js",
"icons": {
@@ -44,8 +48,9 @@
"background.js",
"proxy.js",
"info.js",
"i2pcontrol.js",
"scrub.js"
"i2pcontrol/i2pcontrol.js",
"scrub.js",
"bookmarks.js"
]
},
"protocol_handlers": [{

View File

@@ -24,47 +24,172 @@ function SetControlHostText() {
controlhostid.textContent = chrome.i18n.getMessage("controlHostText");
}
var handleContextProxyRequest = async function(requestDetails) {
console.log("(proxy)Searching for proxy by context");
try {
var handleProxyRequest = function(context) {
proxy = {
failoverTimeout: 0,
proxyDns: false
};
if (context != undefined) {
if (context.name == "i2pbrowser") {
proxy = {
type: getScheme(),
host: getHost(),
port: getPort()
};
console.log(
"(proxy)",
context.name,
"Using",
proxy.type,
"proxy ",
proxy.host + ":" + proxy.port
);
return proxy;
} else if (context.name == "routerconsole") {
if (routerHost(requestDetails.url)) {
return proxy;
} else if (!routerHost(requestDetails.url)) {
proxy = {
type: "http",
host: "localhost",
port: "65535"
};
}
proxy = {
type: getScheme(),
host: getHost(),
port: getPort()
};
console.log(
"(proxy)",
context.name,
"Using",
proxy.type,
"proxy ",
proxy.host + ":" + proxy.port
);
return proxy;
} else if (context.name == "fenced-default") {
if (localHost(requestDetails.url)) {
if (!routerHost(requestDetails.url)) {
proxy = {
type: "http",
host: "localhost",
port: "65535"
};
}
}
console.log(
"(proxy)",
context.name,
"Using",
proxy.type,
"proxy ",
proxy.host + ":" + proxy.port
);
return proxy;
}
}
if (!routerHost(requestDetails.url)) {
proxy = {
type: "http",
host: "localhost",
port: "65535"
};
} else if (i2pHost(requestDetails.url)) {
proxy = {
type: getScheme(),
host: getHost(),
port: getPort()
};
}
return proxy;
};
var contextGet = async function(tabInfo) {
try {
console.log("(proxy)Tab info from Function", tabInfo);
context = await browser.contextualIdentities.get(tabInfo.cookieStoreId);
return context;
} catch (error) {
console.log("(proxy)Context Error", error);
}
};
var tabFind = async function(tabId) {
try {
context = await browser.contextualIdentities.query({
name: "i2pbrowser"
});
tabId.cookieStoreId = context[0].cookieStoreId;
console.log("(proxy) forcing context", tabId.cookieStoreId);
return tabId;
} catch (error) {
console.log("(proxy)Context Error", error);
}
};
var tabGet = async function(tabId) {
try {
console.log("(proxy)Tab ID from Request", tabId);
let tabInfo = await browser.tabs.get(tabId);
return tabInfo;
} catch (error) {
console.log("(proxy)Tab error", error);
}
};
if (requestDetails.tabId > 0) {
if (proxyHost(requestDetails.url)) {
console.log("(Proxy)I2P Proxy test URL detected, ", requestDetails.url);
return {
type: getScheme(),
host: getHost(),
port: getPort()
};
} else if (i2pHost(requestDetails.url)) {
console.log("(Proxy)I2P URL detected, ");
var tab = tabGet(requestDetails.tabId);
var mtab = tab.then(tabFind);
requestDetails.tabId = mtab;
var context = mtab.then(contextGet);
var proxy = await context.then(handleProxyRequest);
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);
return proxy;
}
proxy = {
type: getScheme(),
host: getHost(),
port: getPort()
};
console.log("(proxy)Returning I2P Proxy", proxy);
return proxy;
}
} catch (error) {
console.log("(proxy)Not using I2P Proxy.", error);
}
};
function setupProxy() {
var controlHost = getControlHost();
var controlPort = getControlPort();
var Host = getHost();
var Port = getPort();
var Scheme = getScheme();
if (!getChrome()) {
function handleProxyRequest(requestInfo) {
console.log("proxying request via listener");
console.log(" ", Scheme, Host, ":", Port);
return {
type: Scheme,
host: Host,
port: Port,
proxyDns: true
};
}
console.log("Setting up Firefox WebExtension proxy");
browser.proxy.onRequest.addListener(handleProxyRequest, {
urls: ["<all_urls>"]
});
console.log("i2p settings created for WebExtension Proxy");
} else {
var config = {
mode: "fixed_servers",
rules: {
singleProxy: {
scheme: Scheme,
host: Host,
port: parseInt(Port)
}
}
};
chrome.proxy.settings.set(
{
value: config,
scope: "regular"
},
function() {}
);
}
/**/
console.log("Setting up Firefox WebExtension proxy");
browser.proxy.onRequest.addListener(handleContextProxyRequest, {
urls: ["<all_urls>"]
});
console.log("i2p settings created for WebExtension Proxy");
/**/
}
function SetControlPortText() {
@@ -126,23 +251,77 @@ function getControlPort() {
}
function checkStoredSettings(storedSettings) {
let defaultSettings = {};
if (!storedSettings.proxy_scheme) {
defaultSettings["proxy_scheme"] = "http";
function gotProxyInfo(info) {
let defaultSettings = {};
let host = info.value.http.split(":")[0];
let port = info.value.http.split(":")[1];
console.log("proxy", "'" + host + "'", ":", port);
if (!storedSettings.proxy_scheme) {
defaultSettings["proxy_scheme"] = "http";
}
if (!storedSettings.proxy_host) {
if (host == "") {
defaultSettings["proxy_host"] = "127.0.0.1";
} else {
defaultSettings["proxy_host"] = host;
}
} else {
if (host != "") {
defaultSettings["proxy_host"] = host;
} else {
defaultSettings["proxy_host"] = storedSettings.proxy_host;
}
}
if (!storedSettings.proxy_port) {
if (port == undefined) {
defaultSettings["proxy_port"] = 4444;
} else {
defaultSettings["proxy_port"] = port;
}
} else {
if (port != undefined) {
defaultSettings["proxy_port"] = port;
} else {
defaultSettings["proxy_port"] = storedSettings.proxy_port;
}
}
if (!storedSettings.control_host) {
if (host == "") {
defaultSettings["control_host"] = "127.0.0.1";
} else {
defaultSettings["control_host"] = host;
}
} else {
if (host != "") {
defaultSettings["control_host"] = host;
} else {
defaultSettings["control_host"] = storedSettings.control_host;
}
}
if (!storedSettings.control_port) {
if (port == undefined) {
defaultSettings["control_port"] = 4444;
} else {
defaultSettings["control_port"] = port;
}
} else {
if (port != undefined) {
defaultSettings["control_port"] = port;
} else {
defaultSettings["control_port"] = storedSettings.control_port;
}
}
console.log("(browserinfo) NATIVE PROXYSETTINGS", info.value);
console.log(
defaultSettings["proxy_host"],
defaultSettings["proxy_port"],
defaultSettings["control_host"],
defaultSettings["control_port"]
);
chrome.storage.local.set(defaultSettings);
}
if (!storedSettings.proxy_host) {
defaultSettings["proxy_host"] = "127.0.0.1";
}
if (!storedSettings.proxy_port) {
defaultSettings["proxy_port"] = 4444;
}
if (!storedSettings.control_host) {
defaultSettings["control_host"] = "127.0.0.1";
}
if (!storedSettings.control_port) {
defaultSettings["control_port"] = 4444;
}
chrome.storage.local.set(defaultSettings);
var gettingInfo = browser.proxy.settings.get({});
gettingInfo.then(gotProxyInfo);
}
function onError(e) {

View File

@@ -6,8 +6,8 @@ function onSet(result) {
}
}
// This disables queries to centralized databases of bad URLs to screen for
// risky sites in your browser
/* This disables queries to centralized databases of bad URLs to screen for
risky sites in your browser */
function disableHyperlinkAuditing() {
var setting = browser.privacy.websites.hyperlinkAuditingEnabled.set({
value: false
@@ -29,9 +29,9 @@ function enableFirstPartyIsolation() {
setting.then(onSet);
}
// This rejects tracking cookies and third-party cookies but it
// LEAVES "Persistent" Cookies unmodified in favor of an option in the content
// interface for now
/* This rejects tracking cookies and third-party cookies but it
LEAVES "Persistent" Cookies unmodified in favor of an option in the content
interface for now */
function disableEvilCookies() {
var getting = browser.privacy.websites.cookieConfig.get({});
getting.then(got => {
@@ -95,8 +95,8 @@ function enableTrackingProtection() {
setting.then(onSet);
}
// This disables protected content, which is a form of digital restrictions
// management dependent on identifying information
/* This disables protected content, which is a form of digital restrictions
management dependent on identifying information */
function disableDigitalRestrictionsManagement() {
var gettingInfo = browser.runtime.getPlatformInfo();
gettingInfo.then(got => {
@@ -201,15 +201,9 @@ function forgetBrowsingData(storedSettings) {
}
const times = {
hour: () => {
return 1000 * 60 * 60;
},
day: () => {
return 1000 * 60 * 60 * 24;
},
week: () => {
return 1000 * 60 * 60 * 24 * 7;
}
hour: () => 1000 * 60 * 60,
day: () => 1000 * 60 * 60 * 24,
week: () => 1000 * 60 * 60 * 24 * 7
};
const sinceMilliseconds = times[selectedSince].call();
@@ -233,7 +227,7 @@ function forgetBrowsingData(storedSettings) {
browser.notifications.create({
type: "basic",
title: "Removed browsing data",
message: `Removed ${dataTypesString}\n for i2pbrowser`
message: `Removed ${dataTypesString}\n for I2P Browsing`
});
}
@@ -249,34 +243,34 @@ function forgetBrowsingData(storedSettings) {
browser.browsingData
.removePasswords({
hostnames: [i2pHostName(item.url)],
since: since
since
})
.then(onGot);
console.log("cleared Passwords");
browser.browsingData
.removeDownloads({
hostnames: [i2pHostName(item.url)],
since: since
since
})
.then(onGot);
console.log("cleared Downloads");
browser.browsingData
.removeFormData({
hostnames: [i2pHostName(item.url)],
since: since
since
})
.then(onGot);
console.log("cleared Form Data");
browser.browsingData
.removeLocalStorage({
hostnames: [i2pHostName(item.url)],
since: since
since
})
.then(onGot);
console.log("cleared Local Storage");
contexts = browser.contextualIdentities.query({
name: "i2pbrowser"
name: "I2P Browsing"
});
function deepCleanCookies(cookies) {

191
proxy.js
View File

@@ -20,22 +20,87 @@ var handleContextProxyRequest = async function(requestDetails) {
var handleProxyRequest = function(context) {
proxy = {
failoverTimeout: 0,
type: "direct",
proxyDns: false
};
if (context.name == "i2pbrowser") {
if (context != undefined) {
if (context.name == "I2P Browsing") {
proxy = {
type: getScheme(),
host: getHost(),
port: getPort()
};
console.log(
"(proxy)",
context.name,
"Using",
proxy.type,
"proxy ",
proxy.host + ":" + proxy.port
);
return proxy;
} else if (context.name == "Router Console") {
if (routerHost(requestDetails.url)) {
return proxy;
} else if (!routerHost(requestDetails.url)) {
proxy = {
type: "http",
host: "localhost",
port: "65535"
};
}
proxy = {
type: getScheme(),
host: getHost(),
port: getPort()
};
console.log(
"(proxy)",
context.name,
"Using",
proxy.type,
"proxy ",
proxy.host + ":" + proxy.port
);
return proxy;
} else if (context.name == "Web Browsing") {
if (localHost(requestDetails.url)) {
if (!routerHost(requestDetails.url)) {
proxy = {
type: "http",
host: "localhost",
port: "65535"
};
}
}
console.log(
"(proxy)",
context.name,
"Using",
proxy.type,
"proxy ",
proxy.host + ":" + proxy.port
);
return proxy;
}
}
if (!routerHost(requestDetails.url)) {
if (localHost(requestDetails.url)) {
console.log(
"(proxy) non-routerconsole localhost url, dropping",
requestDetails.url
);
proxy = {
type: "http",
host: "localhost",
port: "65535"
};
}
} else if (i2pHost(requestDetails.url)) {
proxy = {
type: getScheme(),
host: getHost(),
port: getPort()
};
console.log(
"(proxy)Using",
proxy.type,
"proxy ",
proxy.host + ":" + proxy.port
);
return proxy;
}
return proxy;
};
@@ -50,10 +115,6 @@ var handleContextProxyRequest = async function(requestDetails) {
};
var tabFind = async function(tabId) {
try {
context = await browser.contextualIdentities.query({
name: "i2pbrowser"
});
tabId.cookieStoreId = context[0].cookieStoreId;
console.log("(proxy) forcing context", tabId.cookieStoreId);
return tabId;
} catch (error) {
@@ -71,13 +132,7 @@ var handleContextProxyRequest = async function(requestDetails) {
};
if (requestDetails.tabId > 0) {
if (proxyHost(requestDetails.url)) {
return {
type: getScheme(),
host: getHost(),
port: getPort()
};
} else if (i2pHost(requestDetails.url)) {
if (i2pHost(requestDetails.url)) {
console.log("(Proxy)I2P URL detected, ");
var tab = tabGet(requestDetails.tabId);
var mtab = tab.then(tabFind);
@@ -93,6 +148,9 @@ var handleContextProxyRequest = async function(requestDetails) {
console.log("(proxy)Returning I2P Proxy", proxy);
return proxy;
}
proxy = {};
console.log("(proxy)Returning unset Proxy", proxy);
return proxy;
}
} catch (error) {
console.log("(proxy)Not using I2P Proxy.", error);
@@ -175,25 +233,86 @@ function setupProxy() {
}
function checkStoredSettings(storedSettings) {
let defaultSettings = {};
if (!storedSettings.proxy_scheme) {
defaultSettings["proxy_scheme"] = "http";
function gotProxyInfo(info) {
let defaultSettings = {};
let host = info.value.http.split(":")[0];
let port = info.value.http.split(":")[1];
console.log("proxy", "'" + host + "'", ":", port);
if (!storedSettings.proxy_scheme) {
defaultSettings["proxy_scheme"] = "http";
}
if (!storedSettings.proxy_host) {
if (host == "") {
defaultSettings["proxy_host"] = "127.0.0.1";
} else {
defaultSettings["proxy_host"] = host;
}
} else {
if (host != "") {
defaultSettings["proxy_host"] = host;
} else {
defaultSettings["proxy_host"] = storedSettings.proxy_host;
}
}
if (!storedSettings.proxy_port) {
if (port == undefined) {
defaultSettings["proxy_port"] = 4444;
} else {
defaultSettings["proxy_port"] = port;
}
} else {
if (port != undefined) {
defaultSettings["proxy_port"] = port;
} else {
defaultSettings["proxy_port"] = storedSettings.proxy_port;
}
}
if (!storedSettings.control_host) {
if (host == "") {
defaultSettings["control_host"] = "127.0.0.1";
} else {
defaultSettings["control_host"] = host;
}
} else {
if (host != "") {
defaultSettings["control_host"] = host;
} else {
defaultSettings["control_host"] = storedSettings.control_host;
}
}
if (!storedSettings.control_port) {
if (port == undefined) {
defaultSettings["control_port"] = 4444;
} else {
defaultSettings["control_port"] = port;
}
} else {
if (port != undefined) {
defaultSettings["control_port"] = port;
} else {
defaultSettings["control_port"] = storedSettings.control_port;
}
}
console.log("(browserinfo) NATIVE PROXYSETTINGS", info.value);
console.log(
defaultSettings["proxy_host"],
defaultSettings["proxy_port"],
defaultSettings["control_host"],
defaultSettings["control_port"]
);
chrome.storage.local.set(defaultSettings);
}
if (!storedSettings.proxy_host) {
defaultSettings["proxy_host"] = "127.0.0.1";
}
if (!storedSettings.proxy_port) {
defaultSettings["proxy_port"] = 4444;
}
if (!storedSettings.control_host) {
defaultSettings["control_host"] = "127.0.0.1";
}
if (!storedSettings.control_port) {
defaultSettings["control_port"] = 4444;
}
chrome.storage.local.set(defaultSettings);
var gettingInfo = browser.proxy.settings.get({});
gettingInfo.then(gotProxyInfo);
}
//function gotProxyInfo(info) {
//console.log("(browserinfo)", info.value);
//}
//var gettingInfo = browser.proxy.settings.get({});
//gettingInfo.then(gotProxyInfo);
function update(restoredSettings) {
proxy_scheme = restoredSettings.proxy_scheme;
console.log("restoring proxy scheme:", proxy_scheme);

BIN
routerconsole.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 696 KiB

330
scrub.js
View File

@@ -4,21 +4,33 @@ var contextScrub = async function(requestDetails) {
var headerScrub = function(context) {
if (!context) {
console.error("Context not found");
} else {
if ((context.name = "i2pbrowser")) {
var ua = "MYOB/6.66 (AN/ON)";
if (i2pHost(requestUrl.url)) {
for (var header of requestDetails.requestHeaders) {
if (header.name.toLowerCase() === "user-agent") {
header.value = ua;
console.log("(scrub)User-Agent header modified", header.value);
}
} else if (context.name == "I2P Browsing") {
var ua = "MYOB/6.66 (AN/ON)";
if (i2pHost(requestDetails.url)) {
for (var header of requestDetails.requestHeaders) {
if (header.name.toLowerCase() === "user-agent") {
header.value = ua;
console.log("(scrub)User-Agent header modified", header.value);
}
}
return {
requestHeaders: requestDetails.requestHeaders
};
}
return {
requestHeaders: requestDetails.requestHeaders
};
} else if (context.name == "Router Console") {
var ua = "MYOB/6.66 (AN/ON)";
if (i2pHost(requestDetails.url)) {
for (var header of requestDetails.requestHeaders) {
if (header.name.toLowerCase() === "user-agent") {
header.value = ua;
console.log("(scrub)User-Agent header modified", header.value);
}
}
} else if (routerHost(requestDetails.url)) {
}
return {
requestHeaders: requestDetails.requestHeaders
};
}
};
var contextGet = async function(tabInfo) {
@@ -33,7 +45,7 @@ var contextScrub = async function(requestDetails) {
var tabFind = async function(tabId) {
try {
context = await browser.contextualIdentities.query({
name: "i2pbrowser"
name: "I2P Browsing"
});
tabId.cookieStoreId = context[0].cookieStoreId;
console.log("(scrub) forcing context", tabId.cookieStoreId);
@@ -52,22 +64,26 @@ var contextScrub = async function(requestDetails) {
}
};
if (requestDetails.tabId > 0) {
var tab = {};
var context = {};
var req = {};
if (i2pHost(requestDetails.url)) {
console.log("(Proxy)I2P URL detected, ");
var tab = tabGet(requestDetails.tabId);
tab = tabGet(requestDetails.tabId);
var mtab = tab.then(tabFind);
requestDetails.tabId = mtab;
var context = mtab.then(contextGet);
var req = await context.then(headerScrub);
context = mtab.then(contextGet);
req = await context.then(headerScrub);
console.log("(scrub)Scrubbing I2P Request", req);
return req;
} else {
var tab = tabGet(requestDetails.tabId);
var context = tab.then(contextGet);
var req = await context.then(headerScrub);
console.log("(scrub)Scrubbing I2P Request", req);
} else if (routerHost(requestDetails.url)) {
tab = tabGet(requestDetails.tabId);
context = tab.then(contextGet);
req = await context.then(headerScrub);
console.log("(scrub)Scrubbing non-I2P Request", req);
return req;
}
return req;
}
} catch (error) {
console.log("(scrub)Not scrubbing non-I2P request.", error);
@@ -79,12 +95,12 @@ var contextSetup = async function(requestDetails) {
try {
var tabFind = async function(tabId) {
try {
context = await browser.contextualIdentities.query({
name: "i2pbrowser"
var context = await browser.contextualIdentities.query({
name: "I2P Browsing"
});
if (tabId.cookieStoreId != context[0].cookieStoreId) {
console.log(
"(isolate) forcing",
"(isolate) forcing I2P Browsing",
requestDetails.url,
" context",
tabId.cookieStoreId,
@@ -92,14 +108,14 @@ var contextSetup = async function(requestDetails) {
);
function Create(window) {
function onCreated(tab) {
console.log("(isolate) Closing old, un-isolated tab");
console.log("(isolate) Closing old, un-isolated tab", window);
browser.tabs.remove(tabId.id);
browser.tabs.remove(window.tabs[0].id);
}
function onError(error) {
console.log(`Error: ${error}`);
}
created = browser.tabs.create({
var created = browser.tabs.create({
active: true,
cookieStoreId: context[0].cookieStoreId,
url: requestDetails.url,
@@ -107,7 +123,7 @@ var contextSetup = async function(requestDetails) {
});
created.then(onCreated, onError);
}
getting = browser.windows.getCurrent();
var getting = browser.windows.getCurrent();
getting.then(Create);
return tabId;
}
@@ -117,12 +133,12 @@ var contextSetup = async function(requestDetails) {
};
var routerTabFind = async function(tabId) {
try {
context = await browser.contextualIdentities.query({
name: "routerconsole"
var context = await browser.contextualIdentities.query({
name: "Router Console"
});
if (tabId.cookieStoreId != context[0].cookieStoreId) {
console.log(
"(isolate) forcing",
"(isolate) forcing Router Console",
requestDetails.url,
" context",
tabId.cookieStoreId,
@@ -137,7 +153,7 @@ var contextSetup = async function(requestDetails) {
function onError(error) {
console.log(`Error: ${error}`);
}
created = browser.tabs.create({
var created = browser.tabs.create({
active: true,
cookieStoreId: context[0].cookieStoreId,
url: requestDetails.url,
@@ -145,7 +161,7 @@ var contextSetup = async function(requestDetails) {
});
created.then(onCreated, onError);
}
getting = browser.windows.getCurrent();
var getting = browser.windows.getCurrent();
getting.then(Create);
return tabId;
}
@@ -153,6 +169,166 @@ var contextSetup = async function(requestDetails) {
console.log("(isolate)Context Error", error);
}
};
var i2ptunnelTabFind = async function(tabId) {
try {
var context = await browser.contextualIdentities.query({
name: "Hidden Services Manager"
});
if (tabId.cookieStoreId != context[0].cookieStoreId) {
console.log(
"(isolate) forcing HSM context",
requestDetails.url,
" context",
tabId.cookieStoreId,
context[0].cookieStoreId
);
function Create(window) {
function onCreated(tab) {
console.log("(isolate) Closing old, un-isolated tab");
browser.tabs.remove(tabId.id);
if (window != undefined) {
browser.tabs.remove(window.tabs[0].id);
}
}
function onError(error) {
console.log(`Error: ${error}`);
}
var created = browser.tabs.create({
active: true,
cookieStoreId: context[0].cookieStoreId,
url: requestDetails.url,
windowId: window.id
});
created.then(onCreated, onError);
}
var getting = browser.windows.getCurrent();
getting.then(Create);
return tabId;
}
} catch (error) {
console.log("(isolate)Context Error", error);
}
};
var snarkTabFind = async function(tabId) {
try {
var context = await browser.contextualIdentities.query({
name: "Bittorrent"
});
if (tabId.cookieStoreId != context[0].cookieStoreId) {
console.log(
"(isolate) forcing Bittorrent",
requestDetails.url,
" context",
tabId.cookieStoreId,
context[0].cookieStoreId
);
function Create(window) {
function onCreated(tab) {
console.log("(isolate) Closing old, un-isolated tab");
browser.tabs.remove(tabId.id);
browser.tabs.remove(window.tabs[0].id);
}
function onError(error) {
console.log(`Error: ${error}`);
}
var created = browser.tabs.create({
active: true,
cookieStoreId: context[0].cookieStoreId,
url: requestDetails.url,
windowId: window.id
});
created.then(onCreated, onError);
}
var getting = browser.windows.getCurrent();
getting.then(Create);
return tabId;
}
} catch (error) {
console.log("(isolate)Context Error", error);
}
};
var mailTabFind = async function(tabId) {
try {
var context = await browser.contextualIdentities.query({
name: "Web Mail"
});
if (tabId.cookieStoreId != context[0].cookieStoreId) {
console.log(
"(isolate) forcing Web Mail",
requestDetails.url,
" context",
tabId.cookieStoreId,
context[0].cookieStoreId
);
function Create(window) {
function onCreated(tab) {
console.log("(isolate) Closing old, un-isolated tab");
browser.tabs.remove(tabId.id);
browser.tabs.remove(window.tabs[0].id);
}
function onError(error) {
console.log(`Error: ${error}`);
}
var created = browser.tabs.create({
active: true,
cookieStoreId: context[0].cookieStoreId,
url: requestDetails.url,
windowId: window.id
});
created.then(onCreated, onError);
}
var getting = browser.windows.getCurrent();
getting.then(Create);
return tabId;
}
} catch (error) {
console.log("(isolate)Context Error", error);
}
};
var anyTabFind = async function(tabId) {
try {
var context = await browser.contextualIdentities.query({
name: "Web Browsing"
});
console.log("(ISOLATE)", tabId.cookieStoreId);
if (
tabId.cookieStoreId == "firefox-default" ||
tabId.cookieStoreId == "firefox-private"
) {
if (tabId.cookieStoreId != context[0].cookieStoreId) {
console.log(
"(isolate) forcing Web Browsing",
requestDetails.url,
" context",
tabId.cookieStoreId,
context[0].cookieStoreId
);
function Create(window) {
function onCreated(tab) {
console.log("(isolate) Closing old, un-isolated tab");
browser.tabs.remove(tabId.id);
browser.tabs.remove(window.tabs[0].id);
}
function onError(error) {
console.log(`Error: ${error}`);
}
var created = browser.tabs.create({
active: true,
cookieStoreId: context[0].cookieStoreId,
url: requestDetails.url,
windowId: window.id
});
created.then(onCreated, onError);
}
var getting = browser.windows.getCurrent();
getting.then(Create);
return tabId;
}
}
} catch (error) {
console.log("(isolate)Context Error", error);
}
};
var tabGet = async function(tabId) {
try {
console.log("(isolate)Tab ID from Request", tabId);
@@ -163,22 +339,44 @@ var contextSetup = async function(requestDetails) {
}
};
if (requestDetails.tabId > 0) {
if (proxyHost(requestDetails.url)) {
return requestDetails;
}
if (i2pHost(requestDetails.url)) {
var tab = tabGet(requestDetails.tabId);
var mtab = tab.then(tabFind);
return requestDetails;
}
if (routerHost(requestDetails.url)) {
let routerhost = routerHost(requestDetails.url);
if (routerhost) {
if (routerhost === "i2ptunnelmgr") {
var tab = tabGet(requestDetails.tabId);
var mtab = tab.then(i2ptunnelTabFind);
return requestDetails;
} else if (routerhost === "i2psnark") {
var tab = tabGet(requestDetails.tabId);
var mtab = tab.then(snarkTabFind);
return requestDetails;
} else if (routerhost === "webmail") {
var tab = tabGet(requestDetails.tabId);
var mtab = tab.then(mailTabFind);
return requestDetails;
} else if (routerhost === "routerconsole") {
var tab = tabGet(requestDetails.tabId);
var mtab = tab.then(routerTabFind);
return requestDetails;
}
} else {
var tab = tabGet(requestDetails.tabId);
var mtab = tab.then(routerTabFind);
var mtab = tab.then(anyTabFind);
return requestDetails;
}
}
//var tab = tabGet(requestDetails.tabId);
//var mtab = tab.then(anyTabFind);
return requestDetails;
} catch (error) {
console.log(
"(isolate)Not an I2P request, no need to force into alternate cookiestore.",
error
);
console.log("(isolate)Not an I2P request, blackholing", error);
}
};
@@ -210,23 +408,69 @@ function proxyHost(url) {
return false;
}
function routerHost(url) {
function localHost(url) {
let hostname = "";
if (url.indexOf("://") > -1) {
hostname = url.split("/")[2];
} else {
hostname = url.split("/")[0];
}
if (hostname === "127.0.0.1:7657") {
hostname = hostname.split(":")[0];
if (hostname === "127.0.0.1") {
return true;
} else if (hostname === "localhost:7657") {
} else if (hostname === "localhost") {
return true;
}
return false;
}
function routerHost(url) {
let hostname = "";
let path = "";
function pathcheck(str) {
if (str != undefined) {
let final = str.split("/")[0];
if (final === "i2ptunnelmgr" || final === "i2ptunnel") {
console.log("(urlcheck) application path", final);
return "i2ptunnelmgr";
} else if (final === "i2psnark" || final == "torrents") {
console.log("(urlcheck) application path", final);
return "i2psnark";
} else if (final === "webmail") {
console.log("(urlcheck) application path", final);
return "webmail";
} else if (final == "") {
console.log("(urlcheck) application path", final);
return "routerconsole";
}
}
return true;
}
if (url.indexOf("://") > -1) {
hostname = url.split("/")[2];
prefix = url.substr(0, url.indexOf("://") + 3);
path = url.replace(prefix + hostname + "/", "");
} else {
hostname = url.split("/")[0];
path = url.replace(hostname + "/", "");
}
if (hostname === "127.0.0.1:7657") {
return pathcheck(path);
} else if (hostname === "localhost:7657") {
return pathcheck(path);
}
if (hostname === "127.0.0.1:7647") {
return pathcheck(path);
} else if (hostname === "localhost:7647") {
return pathcheck(path);
}
if (hostname === "127.0.0.1:7070") {
return true;
return pathcheck(path);
} else if (hostname === "localhost:7070") {
return true;
return pathcheck(path);
}
return false;

View File

@@ -35,12 +35,15 @@
<input type="checkbox" id="enable-web-rtc" name="enablewebrtc" value="webrtc">
<label for="enable-web-rtc">Enable WebRTC <strong>with Proxy?</strong></label>
<div class="panel-section-separator"></div>
<a href="#" id="check-i2p-control">Check I2P Router Health</a><div id="panel-section-i2pcontrol-check"></div>
<!--<a href="#" id="check-i2p-control">Check I2P Router Health</a><div id="panel-section-i2pcontrol-check"></div>-->
<figure>
<img src="http://proxy.i2p/themes/console/images/favicon.ico" id="panel-proxy-check" alt="Proxy is not ready yet"/>
<figcaption>I2P Proxy is Ready</figcaption>
</figure>
<div class="panel-section-separator"></div>
<div class="panel-section-identity">
<div id="identity-list"></div>
</div>
</div>
@@ -48,7 +51,7 @@
<script src="privacy.js"></script>
<script src="info.js"></script>
<script src="content.js" crossorigin="anonymous"></script>
<script src="i2pcontrol.js"></script>
<script src="i2pcontrol/i2pcontrol.js"></script>
</body>