From 7f3b6c7359fd8f293efbc1e8f8b1c2761d6ec40e Mon Sep 17 00:00:00 2001 From: idk Date: Mon, 23 Mar 2020 18:02:23 -0400 Subject: [PATCH] Fix bug with i2p+ console isolation for danrobi, which also requires creating a contextual identity for MuWire which makes this a pretty good commit to write a blog post about --- _locales/en/messages.json | 8 + background.js | 10 ++ bookmarks.js | 4 +- handler.js | 4 + host.js | 8 +- index.html | 353 ++++++++++++++++++-------------------- options/options.js | 2 +- scrub.js | 51 +++++- 8 files changed, 249 insertions(+), 191 deletions(-) diff --git a/_locales/en/messages.json b/_locales/en/messages.json index e925d6e..ae85926 100644 --- a/_locales/en/messages.json +++ b/_locales/en/messages.json @@ -203,6 +203,14 @@ "message": "Hidden Services Manager (Private)", "description": "Preface for the browser titlebar" }, + "muwirePreface": { + "message": "MuWire", + "description": "Preface for the browser titlebar" + }, + "muwirePrefacePrivate": { + "message": "MuWire (Private)", + "description": "Preface for the browser titlebar" + }, "resetMessage": { "message": "Reset Tunnel", "description": "Message for the Reset Tunnel button" diff --git a/background.js b/background.js index b068f45..13c9540 100644 --- a/background.js +++ b/background.js @@ -13,6 +13,7 @@ var tunnelprefpriv = chrome.i18n.getMessage("i2ptunnelPrefacePrivate"); var localpref = chrome.i18n.getMessage("localPreface"); var localprefpriv = chrome.i18n.getMessage("localPrefacePrivate"); var extensionpref = chrome.i18n.getMessage("extensionPreface"); +var muwirepref = chrome.i18n.getMessage("muwirePreface"); function onContextsGot(contexts) { var ids = []; @@ -84,6 +85,15 @@ function onContextsGot(contexts) { }) .then(onCreated, onNotCreated); } + if (ids.indexOf(localpref) == -1) { + browser.contextualIdentities + .create({ + name: muwirepref, + color: "turquoise", + icon: "gift" + }) + .then(onCreated, onNotCreated); + } } function onContextsError() { diff --git a/bookmarks.js b/bookmarks.js index 232c999..0b37b82 100644 --- a/bookmarks.js +++ b/bookmarks.js @@ -72,8 +72,7 @@ gettingInfo.then(got => { createBookmark.then(onCreated); } else { let createRhizomeBookmark = browser.bookmarks.create({ - url: - "http://" + control_host + ":" + control_port + "/home", + url: "http://" + control_host + ":" + control_port + "/home", title: "I2P Console", parentId: bookmarkToolbar[0].id }); @@ -176,7 +175,6 @@ gettingInfo.then(got => { title: "I2P Console" }); b4.then(bookConsole, onRejected); - } var bt = browser.bookmarks.search({ diff --git a/handler.js b/handler.js index d48f7b5..5aea5b4 100644 --- a/handler.js +++ b/handler.js @@ -1,6 +1,7 @@ function routerHost(url) { let hostname = ""; let path = ""; + console.log("(urlcheck)", url); function pathcheck(str) { if (str != undefined) { let final = str.split("/")[0]; @@ -13,6 +14,9 @@ function routerHost(url) { } else if (final === "webmail" || final === "susimail") { console.log("(urlcheck) application path", final); return "webmail"; + } else if (final.startsWith("MuWire") && !final.contains("png")) { + console.log("(urlcheck) application path", final); + return "muwire"; } else if ( final === "home" || final === "console" || diff --git a/host.js b/host.js index 3cfec2a..5627d6d 100644 --- a/host.js +++ b/host.js @@ -8,7 +8,9 @@ function proxyHost(url) { if (hostname == "proxy.i2p") { return true; } - if (hostname == "c6lilt4cr5x7jifxridpkesf2zgfwqfchtp6laihr4pdqomq25iq.b32.i2p") { + if ( + hostname == "c6lilt4cr5x7jifxridpkesf2zgfwqfchtp6laihr4pdqomq25iq.b32.i2p" + ) { return true; } return false; @@ -60,6 +62,7 @@ function i2pHost(url) { function routerHost(url) { let hostname = ""; let path = ""; + console.log("(urlcheck)", url); function pathcheck(str) { if (str != undefined) { let final = str.split("/")[0]; @@ -76,6 +79,9 @@ function routerHost(url) { } else if (final === "webmail" || final === "susimail") { console.log("(urlcheck) application path", final); return "webmail"; + } else if (final.startsWith("MuWire") && !final.contains("png")) { + console.log("(urlcheck) application path", final); + return "muwire"; } else if ( final === "home" || final === "console" || diff --git a/index.html b/index.html index e03eaa6..4ca8229 100644 --- a/index.html +++ b/index.html @@ -1,226 +1,209 @@ - I2P in Private Browsing Mode - - + I2P in Private Browsing Mode + + -

I2P in Private Browsing Mode(Firefox-Only)

+

I2P in Private Browsing Mode(Firefox-Only)

-

This is an webextension which introduces a set of new "Private Browsing" modes -to Firefox-based browsers(Supporting webextensions) that makes it easier to -configure a browser to use I2P securely and adds features for making I2P -applications easier to use. It does this by isolating I2P-specific settings to -Contextual Identities within Firefox, then loading them automatically when the -user requests them. It also adds convenience and management features, like an -embedded I2P console and Bittorrent integration with clients using the -transmission-rpc API.

+

This is an webextension which introduces a set of new "Private Browsing" modes to Firefox-based browsers(Supporting webextensions) that makes it easier to configure a browser to use I2P securely and adds features for making I2P applications easier to use. It does this by isolating I2P-specific settings to Contextual Identities within Firefox, then loading them automatically when the user requests them. It also adds convenience and management features, like an embedded I2P console and Bittorrent integration with clients using the transmission-rpc API.

-

Installation(Cross-Platform):

+

Installation(Cross-Platform):

-

For desktop users this addon is available from addons.mozilla.org, where you -will be able to recive automatic updates: -I2P in Private Browsing.

+

For desktop users this addon is available from addons.mozilla.org, where you will be able to recive automatic updates: I2P in Private Browsing.

-

Debian Installation:

+

Debian Installation:

-

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:

+

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
+    
    make deb
 
+

and then you can install it with:

-

and then you can install it with:

- -
    sudo apt install ../i2psetproxy.js_*.deb
+    
    sudo apt install ../i2psetproxy.js_*.deb
 
+

Bittorrent Download:

-

Bittorrent Download:

+

The self-hosted plugin is available from bittorrent both within the I2P and Clearnet Bittorrent network(With a web seed to support it in case one goes dead).

-

The self-hosted plugin is available from bittorrent both within the I2P and -Clearnet Bittorrent network(With a web seed to support it in case one goes -dead).

+ -

Usage:

+

Usage:

-
    -
  • Basically, it "Just Works." After you install the plugin, browsing to an I2P -domain will automatically stop the current tab and re-open the I2P site in an -I2P Browser tab.
  • -
  • Besides that, four bookmarks are added to the "Bookmarks Toolbar," which -will take you to visit your Java I2P applications, or the "Simplified I2P -Landing Page" embedded in the plugin:
  • -
  • Landing page
  • -
  • Also, there's a menu for accessing I2P functionality while you're browsing. -It lets you control a few settings in a granular way.
  • -
  • Menu
  • -
  • You can re-enable WebRTC but force it to always use the proxy that is -enforced by the tab.
  • -
  • You can either force the browser to delete all history for I2P sites -immediately, or you can close all your I2P Browser tabs at once and delete -the history for I2P browsing when you're done.
  • -
  • That's all there is to it! Your browser is configured to safely use and -administer I2P.
  • -
  • Optionally, you can add I2PSnark-RPC and use Bittorrent-over-I2P via the -transmission-rpc interface. To do this, have a look at the torrent guide: -Torrent guide
  • -
+
    +
  • Basically, it "Just Works." After you install the plugin, browsing to an I2P domain will automatically stop the current tab and re-open the I2P site in an I2P Browser tab.
  • -

    Features

    +
  • Besides that, four bookmarks are added to the "Bookmarks Toolbar," which will take you to visit your Java I2P applications, or the "Simplified I2P Landing Page" embedded in the plugin:
  • -
      -
    • [done] Provide a way to launch into an I2P-Specific contextual identity -(container). Intercept requests to .i2p domains and automatically route them -to the I2P container. Isolate the router console from other local -applications by automatically intercepting requests to the router console to -another container.
    • -
    • Visiting i2p-projekt.i2p
    • -
    • [done] Indicate the I2P browser is in use visually. Find an -acceptable way to indicate it on Android.
    • -
    • Visiting webmail
    • -
    • [done] Set the http proxy to use the local I2P proxy automatically. -Provide specific configuration for other types of I2P proxies(SOCKS, -isolating HTTP)
    • -
    • [done] Disable risky webRTC features/offer the option to re-enable -them with the proxy enforced.
    • -
    • [done] Change the color of the browser window to indicate that I2P is in -use
    • -
    • Visiting i2ptunnel
    • -
    • [ready] Provide help in a variety of languages.
    • -
    • [done] Monitor the health and readiness of the I2P router it is -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.
    • -
    • Visiting toopie.html
    • -
    • [Done] 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 -place each i2p application/plugin under it's own origin, shortening router -console URL's and placing applications under their own origin.
    • -
    • Visiting routerconsole
    • -
    • [Done] Handle Torrents by talking to i2psnark-rpc plugin and then -adding them directly into the Firefox downloads drop-downs, menus, etc. If I -can.
    • -
    • Visiting i2psnark
    • -
    • Monitoring torrents
    • -
    • [Started] Indicate the level of authenticity provided by TLS. TLS is -optional on I2P for now, but some sites offer it anyway. TLS support is -experimental and in the works.
    • -
    • [barely started] Isolate traffic by contextual identity to it's own HTTP -Proxy tunnel, each reflecting it's own pseudonymous identity within I2P. The -contextual identities. For now, the contextual identities used to manage -browsing are "I2P Browsing" and "Web Browsing" where I2P Browsing is capable -of using an outproxy but in the case of traffic destined for the clearnet -does not do header rewriting, and Web Browsing falls back to the Proxy -configured in Firefox. The I2P Browsing will be expanded to -
        -
      • I2P Amnesiac Browsing: Use for General Browsing, stores no history and -uses an HTTP Proxy with a very short tunnel-close timeout and no key-reuse.
      • -
      • I2P Social Networking: Use this for logging into social network accounts, -forums, and other interactive asynchronous public communication platforms -where your identity is behaviorally linkable. This has a very long -tunnel-close timeout and key-reuse until specifically invoked.
      • -
      • I2P Blogging: Use this for posting content to the web interface of your -blog or to other similar websites that you create content on.
      • -
    • -
    • Visiting clearweb
    • -
    +
  • Landing page +
  • -

    Video

    +
  • Also, there's a menu for accessing I2P functionality while you're browsing. It lets you control a few settings in a granular way.
  • -
      -
    • Video of the plugin in action
    • -
    +
  • Menu +
  • -

    Documents

    +
  • You can re-enable WebRTC but force it to always use the proxy that is enforced by the tab.
  • -
      -
    • Browser Outline: This document is an outline of each of -the browser extension's feature panels in presentation form.
    • -
    • Smart Lander Design: This is the original outline of -the smart landing page which became the I2P home page within the browser and -the drop-down control panel.
    • -
    • Other extensions: and how they work with this one.
    • -
    +
  • You can either force the browser to delete all history for I2P sites immediately, or you can close all your I2P Browser tabs at once and delete the history for I2P browsing when you're done.
  • -

    Super Extra Important Background Info:

    +
  • That's all there is to it! Your browser is configured to safely use and administer I2P.
  • -

    This plugin's viability is directly related to the viability of Mozilla and -Tor's work on hardening Firefox itself and of particular interest are the -"Uplift" and "Fusion(Firefox Using Onions)" projects.

    +
  • Optionally, you can add I2PSnark-RPC and use Bittorrent-over-I2P via the transmission-rpc interface. To do this, have a look at the torrent guide: Torrent guide +
  • +
-

Links about Project Uplift

+

Features

-
    -
  • Tor Uplift is a project which -brings important features of the Tor Browser to the mainstream of Firefox -users by including patches from Tor Browser Bundle into Firefox where it is -appropriate.
  • -
  • First Party Isolation -is a feature in Firefox and other browsers which keeps information from -leaking across first-party domains.
  • -
  • Fingerprinting is a -technique where a tracker attempts to extract unique information about a user -from a side-channel in order to create an identifier that can be used to -correlate the user across many sites.
  • -
  • Fennec is Firefox -for Android and this link has some analysis of the privacy consequences of the -Android platform.
  • -
  • Tracking in Firefox -is surveyed here.
  • -
+
    +
  • [done] Provide a way to launch into an I2P-Specific contextual identity (container). Intercept requests to .i2p domains and automatically route them to the I2P container. Isolate the router console from other local applications by automatically intercepting requests to the router console to another container.
  • -

    Project uplift seems to have largely been accomplished?

    +
  • Visiting i2p-projekt.i2p +
  • -

    Links about Project Fusion

    +
  • [done] Indicate the I2P browser is in use visually. Find an acceptable way to indicate it on Android.
  • -
      -
    • Project Fusion or Firefox using -Onions is a joint Mozilla/Tor effort to create an enhanced Private Browsing -mode for Firefox which uses Tor.
    • -
    • Notes -from a meeting about Fusion.
    • -
    • Tor at the Heart: Firefox is -a blog about Tor and the relationship they have to Firefox re: TBB, Fusion.
    • -
    +
  • Visiting webmail +
  • -

    The Old Version

    +
  • [done] Set the http proxy to use the local I2P proxy automatically. Provide specific configuration for other types of I2P proxies(SOCKS, isolating HTTP)
  • -

    New versions of this extension create an I2P in Private Browsing mode instead. -Since this is a drastic change to the behavior of the old plugin, a new entry -for the new plugin has been made at a new location on addons.mozilla.org.

    +
  • [done] Disable risky webRTC features/offer the option to re-enable them with the proxy enforced.
  • -
      -
    • This is the new version: [link]

    • -
    • This is the old version: [link]

    • -
    +
  • [done] Change the color of the browser window to indicate that I2P is in use
  • -

    Android usage:

    +
  • Visiting i2ptunnel +
  • -

    Open the following link -Github Releases Version -in the browser you want to use for I2P. Firefox will warn you that it is about -to install an extension and indicate the permissions required. Read them over -and when you're ready, accept them. That's all it should take, your browser is -now configured to use I2P.

    +
  • [ready] Provide help in a variety of languages.
  • -

    Android addons.mozilla.org(Temporarily Disabled)

    +
  • [done] Monitor the health and readiness of the I2P router it is 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.
  • -

    If you would prefer to recieve automatic updates from AMO, the correct product -page for this plugin is -I2P In Private Browsing. -This absolutely requires a working outproxy. If you want to avoid the use of AMO -for updates, you can download the identical plugin from this repository's -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.

    +
  • Visiting toopie.html +
  • + +
  • [Done] 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 place each i2p application/plugin under it's own origin, shortening router console URL's and placing applications under their own origin.
  • + +
  • Visiting routerconsole +
  • + +
  • [Done] Handle Torrents by talking to i2psnark-rpc plugin and then adding them directly into the Firefox downloads drop-downs, menus, etc. If I can.
  • + +
  • Visiting i2psnark +
  • + +
  • Monitoring torrents +
  • + +
  • [Started] Indicate the level of authenticity provided by TLS. TLS is optional on I2P for now, but some sites offer it anyway. TLS support is experimental and in the works.
  • + +
  • [barely started] Isolate traffic by contextual identity to it's own HTTP Proxy tunnel, each reflecting it's own pseudonymous identity within I2P. The contextual identities. For now, the contextual identities used to manage browsing are "I2P Browsing" and "Web Browsing" where I2P Browsing is capable of using an outproxy but in the case of traffic destined for the clearnet does not do header rewriting, and Web Browsing falls back to the Proxy configured in Firefox. The I2P Browsing will be expanded to +
      +
    • I2P Amnesiac Browsing: Use for General Browsing, stores no history and uses an HTTP Proxy with a very short tunnel-close timeout and no key-reuse.
    • + +
    • I2P Social Networking: Use this for logging into social network accounts, forums, and other interactive asynchronous public communication platforms where your identity is behaviorally linkable. This has a very long tunnel-close timeout and key-reuse until specifically invoked.
    • + +
    • I2P Blogging: Use this for posting content to the web interface of your blog or to other similar websites that you create content on.
    • +
    +
  • + +
  • Visiting clearweb +
  • +
+ +

Video

+ +
    +
  • Video of the plugin in action +
  • +
+ +

Documents

+ +
    +
  • Browser Outline: This document is an outline of each of the browser extension's feature panels in presentation form.
  • + +
  • Smart Lander Design: This is the original outline of the smart landing page which became the I2P home page within the browser and the drop-down control panel.
  • + +
  • Other extensions: and how they work with this one.
  • +
+ +

Super Extra Important Background Info:

+ +

This plugin's viability is directly related to the viability of Mozilla and Tor's work on hardening Firefox itself and of particular interest are the "Uplift" and "Fusion(Firefox Using Onions)" projects.

+ +

Links about Project Uplift

+ +
    +
  • + Tor Uplift is a project which brings important features of the Tor Browser to the mainstream of Firefox users by including patches from Tor Browser Bundle into Firefox where it is appropriate. +
  • + +
  • + First Party Isolation is a feature in Firefox and other browsers which keeps information from leaking across first-party domains. +
  • + +
  • + Fingerprinting is a technique where a tracker attempts to extract unique information about a user from a side-channel in order to create an identifier that can be used to correlate the user across many sites. +
  • + +
  • + Fennec is Firefox for Android and this link has some analysis of the privacy consequences of the Android platform. +
  • + +
  • + Tracking in Firefox is surveyed here. +
  • +
+ +

Project uplift seems to have largely been accomplished?

+ +

Links about Project Fusion

+ +
    +
  • + Project Fusion or Firefox using Onions is a joint Mozilla/Tor effort to create an enhanced Private Browsing mode for Firefox which uses Tor. +
  • + +
  • + Notes from a meeting about Fusion. +
  • + +
  • + Tor at the Heart: Firefox is a blog about Tor and the relationship they have to Firefox re: TBB, Fusion. +
  • +
+ +

The Old Version

+ +

New versions of this extension create an I2P in Private Browsing mode instead. Since this is a drastic change to the behavior of the old plugin, a new entry for the new plugin has been made at a new location on addons.mozilla.org.

+ +
    +
  • +

    This is the new version: [link]

    +
  • + +
  • +

    This is the old version: [link]

    +
  • +
+ +

Android usage:

+ +

Open the following link Github Releases Version in the browser you want to use for I2P. Firefox will warn you that it is about to install an extension and indicate the permissions required. Read them over and when you're ready, accept them. That's all it should take, your browser is now configured to use I2P.

+ +

Android addons.mozilla.org(Temporarily Disabled)

+ +

If you would prefer to recieve automatic updates from AMO, the correct product page for this plugin is I2P In Private Browsing. This absolutely requires a working outproxy. If you want to avoid the use of AMO for updates, you can download the identical plugin from this repository's 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.

diff --git a/options/options.js b/options/options.js index 53df2a8..9498f0f 100644 --- a/options/options.js +++ b/options/options.js @@ -319,7 +319,7 @@ function onError(e) { } function storeSettings() { - let storableSettings = {} + let storableSettings = {}; storableSettings["proxy_scheme"] = getScheme(); storableSettings["proxy_host"] = getHost(); storableSettings["proxy_port"] = getPort(); diff --git a/scrub.js b/scrub.js index 4108e7f..859f85e 100644 --- a/scrub.js +++ b/scrub.js @@ -6,6 +6,7 @@ var torrentpref = chrome.i18n.getMessage("torrentPreface"); var tunnelpref = chrome.i18n.getMessage("i2ptunnelPreface"); var localpref = chrome.i18n.getMessage("localPreface"); var extensionpref = chrome.i18n.getMessage("extensionPreface"); +var muwirepref = chrome.i18n.getMessage("muwirePreface"); var contextScrub = async function(requestDetails) { function onHeaderError() { @@ -107,6 +108,9 @@ var notMyContextNotMyProblem = async function() { var context6 = await browser.contextualIdentities.query({ name: localpref }); + var context7 = await browser.contextualIdentities.query({ + name: muwirepref + }); var othercontexts = []; console.log("Contexts:", contexts); for (context in contexts) { @@ -116,7 +120,8 @@ var notMyContextNotMyProblem = async function() { contexts[context].cookieStoreId == context3[0].cookieStoreId || contexts[context].cookieStoreId == context4[0].cookieStoreId || contexts[context].cookieStoreId == context5[0].cookieStoreId || - contexts[context].cookieStoreId == context6[0].cookieStoreId + contexts[context].cookieStoreId == context6[0].cookieStoreId || + contexts[context].cookieStoreId == context7[0].cookieStoreId ) { console.log( "Context found", @@ -298,6 +303,47 @@ var contextSetup = function(requestDetails) { console.log("(isolate)Context Error", error); } }; + var muwireTabFind = async function(tabId) { + try { + var context = await browser.contextualIdentities.query({ + name: muwirepref + }); + if (tabId.cookieStoreId != context[0].cookieStoreId) { + function Create() { + function onCreated(tab) { + function closeOldTab(tabs) { + if (tabId.id != tab.id) { + console.log("(isolate) Closing un-isolated tab", tabId.id); + console.log("in favor of", tab.id); + console.log("with context", tab.cookieStoreId); + browser.tabs.remove(tabId.id); + } + for (index = 0; index < tabs.length; index++) { + if (index != tabs.length - 1) + browser.tabs.remove(tabs[index].id); + } + } + var pins = browser.tabs.query({ + cookieStoreId: context[0].cookieStoreId + }); + pins.then(closeOldTab, onError); + } + var created = browser.tabs.create({ + active: true, + pinned: true, + cookieStoreId: context[0].cookieStoreId, + url: requestDetails.url + }); + created.then(onCreated, onContextError); + } + var gettab = browser.tabs.get(tabId.id); + gettab.then(Create, onContextError); + return tabId; + } + } catch (error) { + console.log("(isolate)Context Error", error); + } + }; var mailTabFind = async function(tabId) { try { var context = await browser.contextualIdentities.query({ @@ -498,6 +544,9 @@ var contextSetup = function(requestDetails) { } else if (routerhost === "routerconsole") { var routertab = tab.then(routerTabFind, onContextError); return requestDetails; + } else if (routerhost === "muwire") { + var routertab = tab.then(muwireTabFind, onContextError); + return requestDetails; } } else { if (localhost) {