Merge pull request #73 from eyedeekay/i2pcontrol

I2pcontrol + [WIP]Settings Fixup
This commit is contained in:
idk
2020-01-23 04:28:59 +00:00
committed by GitHub
33 changed files with 1403 additions and 556 deletions

94
COLORS.md Normal file
View File

@@ -0,0 +1,94 @@
WIP Style guidelines
--------------------
Colors currently in use from CSS
--------------------------------
home.css:100: color: #41465f;
home.css:10: color: #3b6bbf;
home.css:113: color: #41465f;
home.css:125: color: #41465f;
home.css:139: color: #3b6bbf;
home.css:17: color: #81888f;
home.css:26: color: #495057;
home.css:35: color: #3b6bbf;
home.css:49: color: #495057;
home.css:58: background-color: #f8f8ff;
home.css:66: color: #495057;
search.css:20: background-color: #ddd
search.css:23: background-color: #2196f3;
search.css:24: color: #fff
home.css:135: background: 0 0!important;
home.css:161: background: #dee2e6;
home.css:175: background: #dee2e6;
home.css:188: background: #a48fe1;
home.css:200: background: #dee2e6;
home.css:214: background: #dee2e6;
home.css:228: background: #d9d9d6;
home.css:246: background: #ffc56d;
home.css:260: background: #f7e59a;
home.css:50: background-attachment: fixed;
home.css:51: background-size: 100% 100%;
home.css:57:.background {
home.css:58: background-color: #f8f8ff;
home.css:79: background: #f8f8ff;
home.css:91: background: #f8f8ff;
search.css:20: background-color: #ddd
search.css:23: background-color: #2196f3;
search.css:5: background: #dee2e6;
Colors currently in use from Javascript
---------------------------------------
background.js:172: colors: {
background.js-173- frame: "#FFC56D",
background.js-174- toolbar: "#FFC56D"
background.js-175- }
--
background.js:179: colors: {
background.js-180- frame: "#FFC56D",
background.js-181- toolbar: "#FFC56D"
background.js-182- }
--
background.js:189: colors: {
background.js-190- frame: "#A4C8E1",
background.js-191- toolbar: "#A4C8E1"
background.js-192- }
--
background.js:196: colors: {
background.js-197- frame: "#A4C8E1",
background.js-198- toolbar: "#A4C8E1"
background.js-199- }
--
background.js:206: colors: {
background.js-207- frame: "#D9D9D6",
background.js-208- toolbar: "#D9D9D6"
background.js-209- }
--
background.js:213: colors: {
background.js-214- frame: "#D9D9D6",
background.js-215- toolbar: "#D9D9D6"
background.js-216- }
--
background.js:223: colors: {
background.js-224- frame: "#F7E59A",
background.js-225- toolbar: "#F7E59A"
background.js-226- }
--
background.js:230: colors: {
background.js-231- frame: "#F7E59A",
background.js-232- toolbar: "#F7E59A"
background.js-233- }
--
background.js:240: colors: {
background.js-241- frame: "#A48FE1",
background.js-242- toolbar: "#A48FE1"
background.js-243- }
--
background.js:247: colors: {
background.js-248- frame: "#A48FE1",
background.js-249- toolbar: "#A48FE1"
background.js-250- }

View File

@@ -73,6 +73,7 @@ index:
@echo "<head>" >> index.html
@echo " <title>I2P in Private Browsing Mode</title>" >> index.html
@echo " <link rel=\"stylesheet\" type=\"text/css\" href =\"home.css\" />" >> index.html
@echo " <link rel=\"stylesheet\" type=\"text/css\" href =\"sidebar.css\" />" >> index.html
@echo "</head>" >> index.html
@echo "<body>" >> index.html
sed "s|magnetsub|[Magnet Link]($(MAGNET))|g" README.md | markdown >> index.html
@@ -238,14 +239,20 @@ fmt:
cleancss -O1 all -O2 all --format beautify home.css -o .home.css && mv .home.css home.css
cleancss -O1 all -O2 all --format beautify info.css -o .info.css && mv .info.css info.css
cleancss -O1 all -O2 all --format beautify search.css -o .search.css && mv .search.css search.css
cleancss -O1 all -O2 all --format beautify sidebar.css -o .sidebar.css && mv .sidebar.css sidebar.css
cleancss -O1 all -O2 all --format beautify options/options.css -o options/.options.css && mv options/.options.css options/options.css
tidy --as-xhtml --drop-empty-elements no --input-xml --tidy-mark no -indent --indent-spaces 4 -wrap 0 --new-blocklevel-tags article,header,footer --new-inline-tags video,audio,canvas,ruby,rt,rp --break-before-br yes --sort-attributes alpha --vertical-space yes index.html > .index.html; mv .index.html index.html
tidy --as-xhtml --drop-empty-elements no --input-xml --tidy-mark no -indent --indent-spaces 4 -wrap 0 --new-blocklevel-tags article,header,footer --new-inline-tags video,audio,canvas,ruby,rt,rp --break-before-br yes --sort-attributes alpha --vertical-space yes window.html > .window.html; mv .window.html window.html
tidy --as-xhtml --drop-empty-elements no --input-xml --tidy-mark no -indent --indent-spaces 4 -wrap 0 --new-blocklevel-tags article,header,footer --new-inline-tags video,audio,canvas,ruby,rt,rp --break-before-br yes --sort-attributes alpha --vertical-space yes home.html > .home.html; mv .home.html home.html
tidy --as-xhtml --drop-empty-elements no --input-xml --tidy-mark no -indent --indent-spaces 4 -wrap 0 --new-blocklevel-tags article,header,footer --new-inline-tags video,audio,canvas,ruby,rt,rp --break-before-br yes --sort-attributes alpha --vertical-space yes toopie.html > .toopie.html; mv .toopie.html toopie.html
tidy --as-xhtml --drop-empty-elements no --input-xml --tidy-mark no -indent --indent-spaces 4 -wrap 0 --new-blocklevel-tags article,header,footer --new-inline-tags video,audio,canvas,ruby,rt,rp --break-before-br yes --sort-attributes alpha --vertical-space yes options/options.html > options/.options.html; mv options/.options.html options/options.html
find . -path ./node_modules -prune -o -name '*.js' -exec prettier --write {} \;
find . -path ./node_modules -prune -o -name '*.json' -exec prettier --write {} \;
lint:
eslint --color *.js
fixjsstyle *.js
gjslint *.js; true
#eslint --color *.js
deborig: fmt version
rm -rf ../i2psetproxy.js-$(VERSION)
@@ -283,3 +290,4 @@ rss: torrent
upload-rss:
gothub upload -R -u eyedeekay -r I2P-in-Private-Browsing-Mode-Firefox -t docs -n "releases.atom" -f releases.atom

View File

@@ -81,11 +81,12 @@ Usage:
use
* ![Visiting i2ptunnel](i2ptunnel.png)
* [ready] **Provide** help in a variety of languages.
* [wip] **Monitor** the health and readiness of the I2P router it is
* [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](toopie.png)
* [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
@@ -196,3 +197,5 @@ 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.
moz-extension://d63582fc-09fc-445a-b8aa-1c888ee2ffc0/toopie.html

View File

@@ -3,6 +3,10 @@
"message": "I2P In Private Browsing",
"description": "Name of the extension."
},
"toopieName": {
"message": "toopie.html",
"description": "Name of the sidebar."
},
"extensionDescription": {
"message": "Your browser is now set up to use I2P.",
"description": "Description of the extension."
@@ -131,6 +135,10 @@
"message": "I2P Browser (Private)",
"description": "Preface for the browser titlebar"
},
"extensionPreface": {
"message": "I2P Management",
"description": "Preface for the browser titlebar"
},
"webPreface": {
"message": "Web Browser",
"description": "Preface for the browser titlebar"
@@ -203,6 +211,10 @@
"message": "Visit the I2P Forum to learn more or ask for assistance",
"description": "Help Message"
},
"proxyHelpText": {
"message": "Configure your I2P proxy here.",
"description": "Help for configuring the options for the Reset Tunnel button"
},
"hostText": {
"message": "Host: ",
"description": "Host for the HTTP or SOCKS5 Proxy"
@@ -212,7 +224,7 @@
"description": "Port for the HTTP or SOCKS5 Proxy"
},
"controlHelpText": {
"message": "These options will be inert if used with the default i2p HTTP or SOCKS proxy.",
"message": "Configure your router console here.",
"description": "Help for configuring the options for the Reset Tunnel button"
},
"controlHostText": {

View File

@@ -12,11 +12,12 @@ var tunnelpref = chrome.i18n.getMessage("i2ptunnelPreface");
var tunnelprefpriv = chrome.i18n.getMessage("i2ptunnelPrefacePrivate");
var localpref = chrome.i18n.getMessage("localPreface");
var localprefpriv = chrome.i18n.getMessage("localPrefacePrivate");
var extensionpref = chrome.i18n.getMessage("extensionPreface");
function onContextsGot(contexts) {
var ids = [];
for (let context of contexts) {
console.log(`Name: ${context.name}`);
console.log(`Name : ${context.name}`);
ids.push(context.name);
}
console.log("Checking new contexts");
@@ -90,11 +91,11 @@ function onContextsError() {
}
function onCreated(context) {
console.log(`New identity's ID: ${context.cookieStoreId}.`);
console.log(" ID:", context.cookieStoreId, "created.");
}
function onNotCreated(context) {
console.log(`identity ID: ${context.cookieStoreId} not created`);
console.log("ID:", context.cookieStoreId, "not created.");
}
browser.contextualIdentities.query({}).then(onContextsGot, onContextsError);
@@ -402,11 +403,6 @@ gettingListenerInfo.then(got => {
console.log("Error finding platform info");
}
if (got.os != "android") {
browser.windows.onCreated.addListener(() => {
chrome.storage.local.get(function() {
setupProxy();
});
});
browser.tabs.onCreated.addListener(() => {
var getting = browser.windows.getCurrent({
populate: true
@@ -421,30 +417,7 @@ gettingListenerInfo.then(got => {
});
}
});
/*
var gettingInfo = browser.runtime.getPlatformInfo();
gettingInfo.then(got => {
if (got.os != "android") {
browser.tabs.onCreated.addListener(() => {
var getting = browser.windows.getCurrent({
populate: true
});
getting.then(setTitle, onError);
});
}
});
var gettingInfo = browser.runtime.getPlatformInfo();
gettingInfo.then(got => {
if (got.os != "android") {
browser.tabs.onActivated.addListener(() => {
var getting = browser.windows.getCurrent({
populate: true
});
getting.then(setTitle, onError);
});
}
});
*/
function handleUpdated(updateInfo) {
if (updateInfo.theme) {
console.log(`Theme was applied: ${updateInfo.theme}`);

View File

@@ -122,7 +122,7 @@ gettingInfo.then(got => {
}
function onRejected(error) {
console.log(`An error: ${error}`);
console.log(`An error : ${error}`);
}
function onCreated(node) {
console.log("Bookmarked", node);

18
config.js Normal file
View File

@@ -0,0 +1,18 @@
var proxy_scheme = "HTTP";
var proxy_host = "127.0.0.1";
var proxy_port = "4444";
var control_host = "127.0.0.1";
var control_port = "7657";
var rpc_host = "127.0.0.1";
var rpc_port = "7657";
var rpc_path = "jsonrpc";
var rpc_pass = "itoopie";
var bt_rpc_host = "127.0.0.1";
var bt_rpc_port = "7657";
var bt_rpc_path = "transmission/rpc";
var bt_rpc_pass = "transmission";
var disable_history = false;

View File

@@ -2,12 +2,12 @@
var titlepref = chrome.i18n.getMessage("titlePreface");
function onError(error) {
console.log(`Error: ${error}`);
console.log(`Error : ${error}`);
}
function eventHandler(event) {
function onCreated(windowInfo) {
console.log(`Created window: ${windowInfo.id}`);
console.log(`Created window : ${windowInfo.id}`);
browser.tabs.create({
windowId: windowInfo.id,
url: "about:blank",

View File

@@ -1,3 +1,56 @@
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" || final === "susimail") {
console.log("(urlcheck) application path", final);
return "webmail";
} else if (
final === "home" ||
final === "console" ||
final === "dns" ||
final.startsWith("config")
) {
console.log("(urlcheck) application path", final);
return "routerconsole";
}
}
return true;
}
if (url.indexOf("://") > -1) {
hostname = url.split("/")[2];
let prefix = url.substr(0, url.indexOf("://") + 3);
path = url.replace(prefix + hostname + "/", "");
} else if (identifyProtocolHandler(url)) {
let newurl = identifyProtocolHandler(url);
return routerHost(newurl);
} else {
hostname = url.split("/")[0];
path = url.replace(hostname + "/", "");
}
if (hostname === control_host + ":" + control_port) {
//console.log("(hostcheck) router console found on configured ports");
return pathcheck(path);
}
if (hostname === "localhost" + ":" + control_port) {
//console.log("(hostcheck) router console found on configured ports");
return pathcheck(path);
}
if (hostname === "127.0.0.1" + ":" + control_port) {
return pathcheck(path);
}
return false;
}
function identifyProtocolHandler(url) {
//console.log("looking for handler-able requests")
if (routerHost(url)) {

View File

@@ -100,7 +100,6 @@ h1 {
color: #41465f;
border: 1px solid #dee2e6;
border-radius: 2px 2px 0 0;
width: 90%;
padding-left: 5%
}
h2,
@@ -111,7 +110,6 @@ h3 {
font-size: 25px;
text-transform: uppercase;
color: #41465f;
border: 1px solid #dee2e6;
border-radius: 2px 2px 0 0;
width: 90%;
padding-left: 5%
@@ -167,9 +165,10 @@ li {
margin: .5rem .5rem .5rem 32%
}
#readyness {
min-height: 5rem;
padding: .5rem;
margin: .5rem;
float: left;
padding-top: 1rem;
padding-bottom: 1rem;
margin: 1rem;
width: 42%;
min-width: 42%;
background: #dee2e6;
@@ -182,6 +181,7 @@ li {
min-height: 5rem;
padding: .5rem;
margin: .5rem;
margin-top: 4rem;
width: 42%;
min-width: 42%;
font-size: 2rem;
@@ -192,13 +192,12 @@ li {
box-shadow: inset 0 0 0 1px #fff,0 0 1px #ccc
}
#i2pbrowser-description {
padding-top: 1rem;
padding-bottom: 1rem;
width: 50%;
min-width: 50%;
min-height: 5rem;
padding: .5rem;
display: inline;
display: inline-block;
background: #dee2e6;
float: right;
border: 1px solid #dee2e6;
border-radius: 2px;
box-shadow: inset 0 0 0 1px #fff,0 0 1px #ccc
@@ -224,7 +223,7 @@ li {
margin: .2rem;
width: 38%;
min-width: 38%;
display: inline;
display: inline-block;
background: #d9d9d6;
float: right;
text-align: center!important;
@@ -238,7 +237,7 @@ li {
margin: .2rem;
width: 38%;
min-width: 38%;
display: inline;
display: inline-block;
float: right;
text-align: center!important;
border: 1px solid #ffc56d;
@@ -252,7 +251,7 @@ li {
margin: .2rem;
width: 38%;
min-width: 38%;
display: inline;
display: inline-block;
float: left;
text-align: center!important;
border: 1px solid #f7e59a;

View File

@@ -4,6 +4,7 @@
<meta charset="utf-8">
<link href="home.css" rel="stylesheet">
<link href="search.css" rel="stylesheet">
<link href="sidebar.css" rel="stylesheet">
<title>
</title>
</head>
@@ -41,27 +42,27 @@
<div class="hideIfI2PConsoleOff" id="onboarding">
<h3 id="onboardingTitle">New to I2P? Learn more here.</h3>
<h4 id="onboardingZero"><button class="showhider" id="onboardingButtonZero" onclick="flipVisibility('onboardingContentZero')">Protect your Privacy</button>
<h4 id="onboardingZero"><button class="showhider" id="onboardingButtonZero">Protect your Privacy</button>
</h4>
<p class="onboardingContent" id="onboardingContentZero">I2P Browser allows you to surf the internet using the private and secure I2P network. When using it, you are protected against tracking, surveillance, and censorship as a first-class participant in the I2P network. I2P Browser isolates cookies and deletes your browser history after your session. These modifications ensure your privacy and security are protected in the browser.</p>
<h4 id="onboardingOne"><button class="showhider" id="onboardingButtonOne" onclick="flipVisibility('onboardingContentOne')">Configure your Experience</button>
<h4 id="onboardingOne"><button class="showhider" id="onboardingButtonOne">Configure your Experience</button>
</h4>
<p class="onboardingContent" id="onboardingContentOne">We also provide you with additional settings for bumping up your browser security. Our Security Settings allow you to block elements that could be used to attack your computer. Click below to see what the different options do. Note: By default, NoScript and HTTPS Everywhere are not included on the toolbar, but you can customize your toolbar to add them. With all the security and privacy features provided by I2P, your experience while browsing the internet may be a little different. Things may be a bit slower, and depending on your security level, some elements may not work or load. You may also be asked to prove you are a human and not a robot.</p>
<h4 id="onboardingTwo"><button class="showhider" id="onboardingButtonTwo" onclick="flipVisibility('onboardingContentTwo')">Share Files</button>
<h4 id="onboardingTwo"><button class="showhider" id="onboardingButtonTwo">Share Files</button>
</h4>
<p class="onboardingContent" id="onboardingContentTwo">I2P is capable of using peer-to-peer applications like BitTorrent, protecting your identity when you share files. Our anonymous bittorrent client is available in the browser.</p>
<h4 id="onboardingThree"><button class="showhider" id="onboardingButtonThree" onclick="flipVisibility('onboardingContentThree')">Hidden e-mail</button>
<h4 id="onboardingThree"><button class="showhider" id="onboardingButtonThree">Hidden e-mail</button>
</h4>
<p class="onboardingContent" id="onboardingContentThree">There is also an anonymous e-mail service available inside of I2P, which is accessible from our browser via the menu directly below.</p>
<h4 id="onboardingFour"><button class="showhider" id="onboardingButtonFour" onclick="flipVisibility('onboardingContentFour')">Experience Tips</button>
<h4 id="onboardingFour"><button class="showhider" id="onboardingButtonFour">Experience Tips</button>
</h4>
<p class="onboardingContent" id="onboardingContentFour">With all the security and privacy features provided by I2P, your experience while browsing the internet may be a little different. Things may be a bit slower, and depending on your security level, some elements may not work or load. You may also be asked to prove you are a human and not a robot.</p>
@@ -77,12 +78,17 @@
<p id="applicationExplain">These applications use I2P to provide them with security and privacy.</p>
<ul>
<li class="application">
<!--<li class="application">
<a class="applicationName" href="http://legwork.i2p" id="window-link-toopie" target="_blank">Search:</a> <span class="applicationDesc" id="search">Legwork is an in-I2P search engine.</span>
<div class="topnav">
<form action="http://legwork.i2p/yacysearch.html?" method="get">
<input id="search-query" name="query" placeholder="Search on legwork.i2p(Opens a new tab)" type="search"> <input id="search-submit" text="Submit" type="submit">
</form>
</div>
</li>-->
<li class="application">
<a class="applicationName" href="toopie.html" id="window-visit-toopie" target="_blank">Toopie</a> <span class="applicationDesc" id="toopie">For information about your I2P router status, go here:</span>
</li>
<li class="application">

View File

@@ -15,8 +15,9 @@ document.addEventListener("click", clickEvent => {
});
function flipVisibility(div) {
console.log("(home) seeking flippable", div);
let flippable = document.getElementById(div);
if (flippable.style.display === "none") {
if (flippable.style.display !== "block") {
flippable.style.display = "block";
} else {
flippable.style.display = "none";

34
host.js
View File

@@ -29,8 +29,14 @@ function localHost(url) {
}
function extensionHost(url) {
var res = url.startsWith(browser.runtime.getURL(""));
return res;
if (url.originUrl !== undefined) {
var res = url.originUrl.startsWith(browser.runtime.getURL(""));
if (res) return res;
}
if (url.url !== undefined) {
var res = url.url.startsWith(browser.runtime.getURL(""));
if (res) return res;
}
}
function i2pHostName(url) {
@@ -57,7 +63,11 @@ function routerHost(url) {
if (final === "i2ptunnelmgr" || final === "i2ptunnel") {
console.log("(urlcheck) application path", final);
return "i2ptunnelmgr";
} else if (final === "i2psnark" || final === "torrents") {
} else if (
final === "i2psnark" ||
final === "torrents" ||
final.startsWith("transmission")
) {
console.log("(urlcheck) application path", final);
return "i2psnark";
} else if (final === "webmail" || final === "susimail") {
@@ -66,6 +76,7 @@ function routerHost(url) {
} else if (
final === "home" ||
final === "console" ||
final === "dns" ||
final.startsWith("config")
) {
console.log("(urlcheck) application path", final);
@@ -86,23 +97,14 @@ function routerHost(url) {
path = url.replace(hostname + "/", "");
}
if (hostname === control_host + ":" + control_port) {
console.log("(hostcheck) router console found on configured ports");
return pathcheck(path);
} else if (hostname === "127.0.0.1:7657") {
return pathcheck(path);
} else if (hostname === "localhost:7657") {
//console.log("(hostcheck) router console found on configured ports");
return pathcheck(path);
}
if (hostname === "127.0.0.1:7657") {
return pathcheck(path);
} else if (hostname === "localhost:7657") {
if (hostname === "localhost" + ":" + control_port) {
//console.log("(hostcheck) router console found on configured ports");
return pathcheck(path);
}
if (hostname === "127.0.0.1:7070") {
return pathcheck(path);
} else if (hostname === "localhost:7070") {
if (hostname === "127.0.0.1" + ":" + control_port) {
return pathcheck(path);
}

5
i2pcontrol/README.md Normal file
View File

@@ -0,0 +1,5 @@
i2pcontrol.js
=============
This is inside of the webextension for now, but it's actually a fully-fledged,
standalone library for talking to i2pcontrol.

View File

@@ -1,61 +1,386 @@
function send(json) {
var hello = "hello i2pcontrol";
function makeid(length) {
var result = "";
var characters =
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
var charactersLength = characters.length;
for (var i = 0; i < length; i++) {
result += characters.charAt(Math.floor(Math.random() * charactersLength));
}
return result;
}
function send(
message,
control_host = "127.0.0.1",
control_port = "7657",
control_path = "jsonrpc"
) {
async function postData(url = "", data = {}) {
// Default options are marked with *
const response = await fetch(url, {
let requestBody = JSON.stringify(data);
//console.log("(i2pcontrol) sending request", requestBody);
let opts = {
method: "POST", // *GET, POST, PUT, DELETE, etc.
mode: "cors", // no-cors, *cors, same-origin
cache: "no-cache", // *default, no-cache, reload, force-cache, only-if-cached
credentials: "same-origin", // include, *same-origin, omit
headers: {
"Content-Type": "application/json"
// 'Content-Type': 'application/x-www-form-urlencoded',
},
redirect: "follow", // manual, *follow, error
referrerPolicy: "no-referrer", // no-referrer, *client
body: JSON.stringify(data) // body data type must match "Content-Type" header
});
body: requestBody // body data type must match "Content-Type" header
};
const response = await fetch(url, opts);
return await response.json(); // parses JSON response into native JavaScript objects
}
postData("http://127.0.0.1:7657/jsonrpc/", { answer: 42 }).then(data => {
console.log(data); // JSON data parsed by `response.json()` call
});
//console.log("http://" + control_host + ":" + control_port + "/" + control_path)
return postData(
"http://" + control_host + ":" + control_port + "/" + control_path + "/",
message
);
}
function authenticate(user, password) {
var json = {
jsonrpc: "2.0",
id: user,
method: "Authenticate",
params: {
API: 1,
Password: password
}
};
return send(json);
async function authenticate(
password = "itoopie",
control_host = "127.0.0.1",
control_port = "7657",
control_path = "jsonrpc"
) {
var json = new Object();
json["id"] = makeid(6);
json["jsonrpc"] = "2.0";
json["method"] = "Authenticate";
json["params"] = new Object();
json["params"]["API"] = 1;
json["params"]["Password"] = password;
return send(json, control_host, control_port, control_path);
}
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 = {
jsonrpc: "2.0",
id: username,
method: "Echo",
params: {
Token: resp.Token,
Echo: string
}
};
var controlMessage = document.getElementById(section);
console.log("(i2pcontrol) reply", xhr.responseText);
infoMessage.textContent = xhr.responseText;
};
async function GetToken(
password = "itoopie",
control_host = "127.0.0.1",
control_port = "7657",
control_path = "jsonrpc"
) {
function gettoken(authtoken) {
return authtoken.result.Token;
}
let me = authenticate(password, control_host, control_port, control_path);
return await me.then(gettoken);
}
echo("test", "test");
async function Echo(
message,
control_host = "127.0.0.1",
control_port = "7657",
control_path = "jsonrpc",
password = "itoopie"
) {
function echo(token) {
console.log("(i2pcontrol) testing I2PControl connection");
var json = new Object();
json["id"] = makeid(6);
json["jsonrpc"] = "2.0";
json["method"] = "Echo";
json["params"] = new Object();
json["params"]["Token"] = token;
json["params"]["Echo"] = message;
return send(json, control_host, control_port, control_path);
}
let token = GetToken(password, control_host, control_port, control_path);
let done = await token.then(echo);
return done;
}
function UpdateEchoElementByID(
Query,
ID,
control_host = "127.0.0.1",
control_port = "7657",
control_path = "jsonrpc"
) {
function updateelement(update) {
//console.log("(i2pcontrol)", update);
document.getElementById(ID).innerText = update;
}
let net = Echo(Query, control_host, control_port, control_path, password);
net.then(updateleement);
}
async function GetRate(
Query,
control_host = "127.0.0.1",
control_port = "7657",
control_path = "jsonrpc",
password = "itoopie"
) {
function getrate(token) {
var json = new Object();
json["id"] = makeid(6);
json["jsonrpc"] = "2.0";
json["method"] = "I2PControl";
json["params"] = new Object();
json["params"]["Token"] = token;
json["params"]["Stat"] = Query;
json["params"]["Period"] = 2000;
return send(json, control_host, control_port, control_path);
}
let token = GetToken(password, control_host, control_port, control_path);
let done = await token.then(getrate);
return done;
}
function UpdateGetRateElementByID(
Query,
ID,
control_host = "127.0.0.1",
control_port = "7657",
control_path = "jsonrpc"
) {
function updateelement(update) {
//console.log("(i2pcontrol)", update);
document.getElementById(ID).innerText = update;
}
let net = GetRate(Query, control_host, control_port, control_path, password);
net.then(updateleement);
}
async function I2PControl(
Query,
control_host = "127.0.0.1",
control_port = "7657",
control_path = "jsonrpc",
password = "itoopie"
) {
function i2pcontrol(token) {
var json = new Object();
json["id"] = makeid(6);
json["jsonrpc"] = "2.0";
json["method"] = "I2PControl";
json["params"] = new Object();
json["params"]["Token"] = token;
json["params"][Query] = null;
return send(json, control_host, control_port, control_path);
}
let token = GetToken(password, control_host, control_port, control_path);
let done = await token.then(i2pcontrol);
return done;
}
function UpdateI2PControlElementByID(
Query,
ID,
control_host = "127.0.0.1",
control_port = "7657",
control_path = "jsonrpc"
) {
function updateelement(update) {
//console.log("(i2pcontrol)", update);
document.getElementById(ID).innerText = update;
}
let net = I2PControl(
Query,
control_host,
control_port,
control_path,
password
);
net.then(updateleement);
}
async function RouterInfo(
Query,
control_host = "127.0.0.1",
control_port = "7657",
control_path = "jsonrpc",
password = "itoopie"
) {
function routerinfo(token) {
var json = new Object();
json["id"] = makeid(6);
json["jsonrpc"] = "2.0";
json["method"] = "RouterInfo";
json["params"] = new Object();
json["params"]["Token"] = token;
json["params"][Query] = null;
return send(json, control_host, control_port, control_path);
}
let token = GetToken(password, control_host, control_port, control_path);
let done = await token.then(routerinfo);
return done;
}
function UpdateRouterInfoElementByID(
Query,
ID,
control_host = "127.0.0.1",
control_port = "7657",
control_path = "jsonrpc",
password = "itoopie"
) {
function updateelement(update) {
/*console.log(
"(i2pcontrol) element",
update.result[Query],
ID,
document.getElementById(ID)
);*/
document.getElementById(ID).innerText = update.result[Query];
}
let net = RouterInfo(
Query,
control_host,
control_port,
control_path,
password
);
net.then(updateelement);
}
async function RouterManager(
Query,
control_host = "127.0.0.1",
control_port = "7657",
control_path = "jsonrpc",
password = "itoopie"
) {
function routermanager(token) {
var json = new Object();
json["id"] = makeid(6);
json["jsonrpc"] = "2.0";
json["method"] = "RouterManager";
json["params"] = new Object();
json["params"]["Token"] = token;
json["params"][Query] = null;
return send(json, control_host, control_port, control_path);
}
let token = GetToken(password, control_host, control_port, control_path);
let done = await token.then(routermanager);
return done;
}
function UpdateRouterManagerElementByID(
Query,
ID,
control_host = "127.0.0.1",
control_port = "7657",
control_path = "jsonrpc",
password = "itoopie"
) {
function updateelement(update) {
c; //onsole.log("(i2pcontrol)", update);
document.getElementById(ID).innerText = update;
}
let net = RouterManager(
Query,
control_host,
control_port,
control_path,
password
);
net.then(updateleement);
}
async function NetworkSetting(
Query,
control_host = "127.0.0.1",
control_port = "7657",
control_path = "jsonrpc",
password = "itoopie"
) {
function networksetting(token) {
var json = new Object();
json["id"] = makeid(6);
json["jsonrpc"] = "2.0";
json["method"] = "NetworkSetting";
json["params"] = new Object();
json["params"]["Token"] = token;
json["params"][Query] = null;
return send(json, control_host, control_port, control_path);
}
let token = GetToken(password, control_host, control_port, control_path);
let done = await token.then(networksetting);
return done;
}
function UpdateNetworkSettingElementByID(
Query,
ID,
control_host = "127.0.0.1",
control_port = "7657",
control_path = "jsonrpc",
password = "itoopie"
) {
function updateelement(update) {
//console.log("(i2pcontrol)", update);
document.getElementById(ID).innerText = update;
}
let net = NetworkSetting(
Query,
control_host,
control_port,
control_path,
password
);
net.then(updateleement);
}
function UpdateContents() {
UpdateRouterInfoElementByID("i2p.router.status", "router-status");
UpdateRouterInfoElementByID("i2p.router.uptime", "router-uptime");
UpdateRouterInfoElementByID("i2p.router.version", "router-version");
UpdateRouterInfoElementByID(
"i2p.router.net.bw.inbound.1s",
"router-net-bw-inbound-1s"
);
UpdateRouterInfoElementByID(
"i2p.router.net.bw.inbound.15s",
"router-net-bw-inbound-15s"
);
UpdateRouterInfoElementByID(
"i2p.router.net.bw.outbound.1s",
"router-net-bw-outbound-1s"
);
UpdateRouterInfoElementByID(
"i2p.router.net.bw.outbound.15s",
"router-net-bw-outbound-15s"
);
UpdateRouterInfoElementByID("i2p.router.net.status", "router-net-status");
UpdateRouterInfoElementByID(
"i2p.router.net.tunnels.participating",
"router-net-tunnels-participating"
);
UpdateRouterInfoElementByID(
"i2p.router.netdb.activepeers",
"router-netdb-activepeers"
);
UpdateRouterInfoElementByID(
"i2p.router.netdb.fastpeers",
"router-netdb-fastpeers"
);
UpdateRouterInfoElementByID(
"i2p.router.netdb.highcapacitypeers",
"router-netdb-highcapacitypeers"
);
UpdateRouterInfoElementByID(
"i2p.router.netdb.isreseeding",
"router-netdb-isreseeding"
);
UpdateRouterInfoElementByID(
"i2p.router.netdb.knownpeers",
"router-netdb-knownpeers"
);
}
var done = Echo(hello);
done.then(Done);
function Done(output) {
console.log("(i2pcontrol) I2PControl connection tested,", output);
return output;
}

BIN
icons/logo.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

BIN
icons/torrents.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

View File

@@ -3,6 +3,7 @@
<head>
<title>I2P in Private Browsing Mode</title>
<link href="home.css" rel="stylesheet" type="text/css">
<link href="sidebar.css" rel="stylesheet" type="text/css">
</head>
<body>
<h1>I2P in Private Browsing Mode(Firefox-Only)</h1>
@@ -83,14 +84,17 @@
<li>[ready] <strong>Provide</strong> help in a variety of languages.</li>
<li>[wip] <strong>Monitor</strong> 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.</li>
<li>[done] <strong>Monitor</strong> 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.</li>
<li><img alt="Visiting toopie.html" src="toopie.png" title="">
</li>
<li>[Done] <strong>Handle</strong> 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.</li>
<li><img alt="Visiting routerconsole" src="routerconsole.png" title="">
</li>
<li>[wip] <strong>Handle Torrents</strong> by talking to i2psnark-rpc plugin and then adding them directly into the Firefox downloads drop-downs, menus, etc. If I can. Right now instead of talking to snark-rpc, it uses a web-based protocl handler that simply auto-fills the torrent into i2psnark.</li>
<li>[wip] <strong>Handle Torrents</strong> by talking to i2psnark-rpc plugin and then adding them directly into the Firefox downloads drop-downs, menus, etc. If I can. Right now instead of talking to snark-rpc, it uses a web-based protocol handler that simply auto-fills the torrent into i2psnark.</li>
<li><img alt="Visiting i2psnark" src="i2psnark.png" title="">
</li>
@@ -191,5 +195,7 @@
<h3>Android addons.mozilla.org(Temporarily Disabled)</h3>
<p>If you would prefer to recieve automatic updates from AMO, the correct product page for this plugin is <a href="https://addons.mozilla.org/en-US/firefox/addon/i2p-in-private-browsing/">I2P In Private Browsing</a>. 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.</p>
<p>moz-extension://d63582fc-09fc-445a-b8aa-1c888ee2ffc0/toopie.html</p>
</body>
</html>

View File

@@ -51,4 +51,7 @@ img.readyness {
}
#consoleOn {
min-height: 2rem
}
#torrentpanel {
display: none
}

65
info.js
View File

@@ -71,18 +71,33 @@ document.addEventListener("click", clickEvent => {
};
}
refreshIdentity();
} else if (clickEvent.target.id === "label-router-restart") {
console.log("attempting to initiate graceful restart");
RouterManager("RestartGraceful");
} else if (clickEvent.target.id === "label-router-shutdown") {
console.log("attempting to initiate graceful shutdown");
RouterManager("ShutdownGraceful");
} else if (clickEvent.target.id === "search-submit") {
console.log("attempting to create search tab");
goSearch();
} else if (clickEvent.target.id === "browser-action") {
console.log("showing a browser action");
showBrowsing();
} else if (clickEvent.target.id === "torrent-action") {
console.log("showing a torrent action");
showTorrents();
} else if (clickEvent.target.id === "window-preface-title") {
console.log("attempting to create homepage tab");
goHome();
} else if (clickEvent.target.id === "window-visit-index") {
console.log("attempting to create homepage tab");
console.log("attempting to create index tab");
goIndex();
} else if (clickEvent.target.id === "window-visit-homepage") {
console.log("attempting to create homepage tab");
goHome();
} else if (clickEvent.target.id === "window-visit-toopie") {
console.log("attempting to create toopie tab");
goToopie();
} else if (clickEvent.target.id === "window-visit-i2ptunnel") {
console.log("attempting to create i2ptunnel tab");
goTunnel();
@@ -127,6 +142,20 @@ gettingInfo.then(got => {
}
});
function showBrowsing() {
var x = document.getElementById("browserpanel");
x.style.display = "block";
var y = document.getElementById("torrentpanel");
y.style.display = "none";
}
function showTorrents() {
var x = document.getElementById("browserpanel");
x.style.display = "none";
var y = document.getElementById("torrentpanel");
y.style.display = "block";
}
function goHome() {
function gotProxyInfo(info) {
let port = info.value.http.split(":")[1];
@@ -136,12 +165,14 @@ function goHome() {
};
console.log("visiting homepage");
let creating = browser.tabs.create(createRhizomeData);
creating.then(onTabCreated, onTabError);
} else {
let createData = {
url: "home.html"
};
console.log("visiting homepage");
let creating = browser.tabs.create(createData);
creating.then(onTabCreated, onTabError);
}
console.log("(bookmarks) adding home page bookmark");
}
@@ -159,7 +190,16 @@ function goIndex() {
};
console.log("visiting help");
let creating = browser.tabs.create(createData);
creating(onTabCreated, onTabError);
creating.then(onTabCreated, onTabError);
}
function goToopie() {
function onTabError() {
console.log("Toopie tab created");
}
console.log("visiting toopie");
let creating = browser.sidebarAction.open();
creating.then(onTabCreated, onTabError);
}
function onTabCreated() {
@@ -178,7 +218,7 @@ function goSearch() {
};
console.log("visiting legwork");
let creating = browser.tabs.create(createData);
creating(onTabCreated, onTabError);
creating.then(onTabCreated, onTabError);
}
function goTunnel() {
@@ -186,11 +226,11 @@ function goTunnel() {
console.log("I2PTunnel tab created");
}
let createData = {
url: "http://" + "127.0.0.1" + ":" + "7657" + "/i2ptunnel"
url: "http://" + control_host + ":" + control_port + "/i2ptunnel"
};
console.log("visiting i2ptunnel");
let creating = browser.tabs.create(createData);
creating(onTabCreated, onTabError);
creating.then(onTabCreated, onTabError);
}
function goMail() {
@@ -198,7 +238,7 @@ function goMail() {
console.log("Mail tab created");
}
let createData = {
url: "http://" + "127.0.0.1" + ":" + "7657" + "/susimail"
url: "http://" + control_host + ":" + control_port + "/susimail"
};
console.log("visiting mail");
let creating = browser.tabs.create(createData);
@@ -210,11 +250,11 @@ function goSnark() {
console.log("Snark tab created");
}
let createData = {
url: "http://" + "127.0.0.1" + ":" + "7657" + "/i2psnark"
url: "http://" + control_host + ":" + control_port + "/i2psnark"
};
console.log("visiting snark");
let creating = browser.tabs.create(createData);
creating(onTabCreated, onTabError);
creating.then(onTabCreated, onTabError);
}
function onVisited(historyItem) {
@@ -240,3 +280,12 @@ function onVisited(historyItem) {
deletingUrl.then(onRemoved);
}
}
UpdateContents();
const minutes = 0.2;
const interval = minutes * 60 * 1000;
setInterval(function() {
UpdateContents();
}, interval);

Binary file not shown.

Before

Width:  |  Height:  |  Size: 71 KiB

After

Width:  |  Height:  |  Size: 237 KiB

View File

@@ -27,7 +27,7 @@
"version": "0.57",
"version_name": "0.57",
"description": "__MSG_extensionDescription__",
"homepage_url": "https://github.com/eyedeekay/i2psetproxy.js",
"homepage_url": "https://github.com/eyedeekay/I2P-in-Private-Browsing-Mode-Firefox",
"icons": {
"48": "icons/toopie.png"
},
@@ -37,20 +37,28 @@
"default_title": "__MSG_extensionName__",
"default_popup": "window.html"
},
"sidebar_action": {
"browser_style": true,
"default_icon": "icons/logo.png",
"default_title": "__MSG_toopieName__",
"default_panel": "toopie.html",
"open_at_install": false
},
"options_ui": {
"page": "options/options.html"
},
"background": {
"scripts": [
"config.js",
"i2pcontrol/i2pcontrol.js",
"host.js",
"privacy.js",
"platform.js",
"background.js",
"host.js",
"handler.js",
"proxy.js",
"info.js",
"home.js",
"i2pcontrol/i2pcontrol.js",
"scrub.js",
"bookmarks.js"
]

BIN
menu.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 105 KiB

After

Width:  |  Height:  |  Size: 97 KiB

View File

@@ -1,62 +1,51 @@
body {
width: 25em;
font-family: "Open Sans Light", sans-serif;
font-family: "Open Sans Light",sans-serif;
font-size: 0.9em;
font-weight: 300;
font-weight: 300
}
section.scheme-options {
padding: 0.5em 0;
margin: 1em 0;
margin: 1em 0
}
#clear-button {
margin: 0 1.3em 1em 0;
margin: 0 1.3em 1em 0
}
#clear-button,
section.scheme-options input,
section.scheme-options>select,
#clear-button {
float: right;
section.scheme-options>select {
float: right
}
label {
display: block;
padding: 0.2em 0;
margin-top: 1em
}
label:hover {
background-color: #EAEFF2;
background-color: #eaeff2
}
.title {
font-size: 1.2em;
margin-bottom: 0.5em;
margin-bottom: 0.5em
}
html, body {
width: 350px;
body,
html {
width: 350px
}
a {
margin: 10px;
display: inline-block;
display: inline-block
}
.panel {
margin: 5px;
margin: 5px
}
span.identity {
width: 100px;
display: inline-block;
margin-left: 1em;
margin-left: 1em
}
.control-options {
display: none;
}
.identity-options {
display: none;
display: none
}
input {
display: inline
}

View File

@@ -1,51 +1,88 @@
<!DOCTYPE html>
<html>
<head>
<head>
<meta charset="utf-8">
<link rel="stylesheet" href="options.css"/>
</head>
<body>
<link href="/home.css" rel="stylesheet">
<link href="options.css" rel="stylesheet">
<title>
</title>
</head>
<body>
<section class="scheme-options">
<span class="title">Proxy Scheme:</span>
<select id="proxy_scheme">
<option value="http" selected="selected">HTTP</option>
<option value="socks5">SOCKS5</option>
</select>
<span class="title">Proxy Scheme:</span> <select id="proxy_scheme">
<option selected value="http">
HTTP
</option>
<option value="socks5">
SOCKS5
</option>
</select>
</section>
<section class="scheme-options proxy-options">
<div class="title" >Proxy Options</div>
<label id="portText">Host: </label>
<input type="text" data="host" id="host" value="127.0.0.1"/>
<br>
<label id="hostText">Port: </label>
<input type="text" data="port" id="port" value="4444"/>
<div class="title">
Proxy Options
</div>
<p id="proxyHelpText">
</p>
<label id="portText">Host:</label> <input data="host" id="host" type="text" value="127.0.0.1">
<br>
<label id="hostText">Port:</label> <input data="port" id="port" type="text" value="4444">
</section>
<section class="scheme-options identity-options">
<!--<section class="scheme-options identity-options">
<div class="panel">
<div id="identity-list">Identity list?</div>
</div>
</section>-->
<section class="scheme-options control-options">
<div>
<div class="title">
Router Console Options
</div>
<p id="controlHelpText">Configure your router console options here.</p>
<label id="controlPortText">Console Host:</label> <input data="controlhost" id="controlhost" type="text" value="127.0.0.1">
<br>
<label id="controlHostText">Console Port:</label> <input data="controlport" id="controlport" type="text" value="7657">
</div>
</section>
<section class="scheme-options control-options">
<div class="title" >Controller Options</div>
<p id="controlHelpText"> These options will be inert if used with the default i2p HTTP or SOCKS
proxy. </p>
<label id="controlPortText">Control Host: </label>
<input type="text" data="controlhost" id="controlhost" value="127.0.0.1"/>
<br>
<label id="controlHostText">Control Port: </label>
<input type="text" data="controlport" id="controlport" value="4444"/>
<div>
<div class="title">
I2PControl RPC Client Options
</div>
<p id="rpcHelpText">Configure your I2PControl options here.</p>
<label id="rpcPortText">Control Host:</label> <input data="rpchost" id="rpchost" type="text" value="127.0.0.1">
<br>
<label id="rpcHostText">Control Port:</label> <input data="rpcport" id="rpcport" type="text" value="7657">
<br>
<label id="rpcPathText">Control Path:</label> <input data="rpcpath" id="rpcpath" type="text" value="jsonrpc">
<br>
<label id="rpcPassText">Control Password:</label> <input data="rpcpass" id="rpcpass" type="text" value="itoopie">
</div>
</section>
<input type="button" value="Save preferences" id="save-button"/>
<section class="scheme-options control-options">
<div>
<div class="title">
Bittorrent RPC Client Options
</div>
<p id="rpcHelpText">Configure your Bittorrent options here.</p>
<label id="btRpcPortText">Torrent RPC Host:</label> <input data="btrpchost" id="btrpchost" type="text" value="127.0.0.1">
<br>
<label id="btRpcHostText">Torrent RPC Port:</label> <input data="btrpcport" id="btrpcport" type="text" value="7657">
<br>
<label id="btRpcPathText">Torrent RPC Path:</label> <input data="btrpcpath" id="btrpcpath" type="text" value="transmission/rpc">
<br>
<label id="rpcPassText">Torrent RPC Password:</label> <input data="btrpcpass" id="btrpcpass" type="text" value="itoopie">
</div>
</section>
<input id="save-button" type="button" value="Save preferences">
<script src="options.js"></script>
</body>
</body>
</html>

View File

@@ -8,6 +8,11 @@ function SetPortText() {
portid.textContent = chrome.i18n.getMessage("portText");
}
function SetPortHelpText() {
var portid = document.getElementById("proxyHelpText");
portid.textContent = chrome.i18n.getMessage("proxyHelpText");
}
function SetControlHostText() {
var controlhostid = document.getElementById("controlHostText");
controlhostid.textContent = chrome.i18n.getMessage("controlHostText");
@@ -25,19 +30,21 @@ function SetControlHelpText() {
function getScheme() {
const proxy_scheme = document.querySelector("#proxy_scheme");
console.log("Got i2p proxy scheme:", proxy_scheme.value);
if (proxy_scheme == "HTTP") {
console.log("(options)Got i2p proxy scheme:", proxy_scheme.value);
if (proxy_scheme.value == "HTTP") {
return "http";
}
if (proxy_scheme == "SOCKS") {
if (proxy_scheme.value == "SOCKS") {
return "socks";
}
return proxy_scheme.value;
if (proxy_scheme.value == "http") return "http";
if (proxy_scheme.value == "socks") return "socks";
else return "http";
}
function getHost() {
proxy_host = document.getElementById("host").value;
console.log("Got i2p proxy host:", proxy_host);
console.log("(options)Got i2p proxy host:", proxy_host);
if (proxy_host == undefined) {
return "127.0.0.1";
}
@@ -46,7 +53,7 @@ function getHost() {
function getPort() {
proxy_port = document.getElementById("port").value;
console.log("Got i2p proxy port:", proxy_port);
console.log("(options)Got i2p proxy port:", proxy_port);
if (proxy_port == undefined) {
return "4444";
}
@@ -55,7 +62,7 @@ function getPort() {
function getControlHost() {
control_host = document.getElementById("controlhost").value;
console.log("Got i2p control host:", control_host);
console.log("(options)Got i2p control host:", control_host);
if (control_host == undefined) {
return "127.0.0.1";
}
@@ -64,154 +71,238 @@ function getControlHost() {
function getControlPort() {
control_port = document.getElementById("controlport").value;
console.log("Got i2p control port:", control_port);
console.log("(options)Got i2p control port:", control_port);
if (control_port == undefined) {
return "4444";
}
return control_port;
}
function getRPCHost() {
rpc_host = document.getElementById("rpchost").value;
console.log("(options)Got i2pcontrol rpc host:", rpc_host);
if (rpc_host == undefined) {
return "127.0.0.1";
}
return rpc_host;
}
function getRPCPort() {
rpc_port = document.getElementById("rpcport").value;
console.log("(options)Got i2pcontrol rpc port:", rpc_port);
if (rpc_port == undefined) {
return "7657";
}
return rpc_port;
}
function getRPCPath() {
rpc_path = document.getElementById("rpcpath").value;
console.log("(options)Got i2pcontrol rpc path:", rpc_path);
if (rpc_path == undefined) {
return "jsonrpc";
}
return rpc_path;
}
function getRPCPass() {
rpc_pass = document.getElementById("rpcpass").value;
console.log("(options)Got i2pcontrol rpc password:");
if (rpc_pass == undefined) {
return "itoopie";
}
return rpc_pass;
}
function getBTRPCHost() {
bt_rpc_host = document.getElementById("btrpchost").value;
console.log("(options)Got torrent rpc host:", bt_rpc_host);
if (bt_rpc_host == undefined) {
return "127.0.0.1";
}
return bt_rpc_host;
}
function getBTRPCPort() {
bt_rpc_port = document.getElementById("btrpcport").value;
console.log("(options)Got torrent rpc port:", bt_rpc_port);
if (bt_rpc_port == undefined) {
return "7657";
}
return bt_rpc_port;
}
function getBTRPCPath() {
bt_rpc_path = document.getElementById("btrpcpath").value;
console.log("(options)Got torrent rpc path:", bt_rpc_path);
if (bt_rpc_path == undefined) {
return "transmission/rpc";
}
return bt_rpc_path;
}
function getBTRPCPass() {
bt_rpc_pass = document.getElementById("btrpcpass").value;
console.log("(options)Got torrent rpc password:");
if (bt_rpc_pass == undefined) {
return "itoopie";
}
return bt_rpc_pass;
}
function checkStoredSettings(storedSettings) {
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) {
if (port != 7644) {
port = undefined;
}
console.log("(options)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);
else defaultSettings["proxy_scheme"] = storedSettings["proxy_scheme"];
if (!storedSettings["proxy_host"]) {
if (host == "") defaultSettings["proxy_host"] = "127.0.0.1";
else defaultSettings["proxy_host"] = host;
} else defaultSettings["proxy_host"] = storedSettings["proxy_host"];
if (!storedSettings["proxy_port"]) {
if (port == undefined) defaultSettings["proxy_port"] = 4444;
else if (port == 7644) defaultSettings["proxy_port"] = port;
else defaultSettings["proxy_port"] = 4444;
} 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 defaultSettings["control_host"] = storedSettings.control_host;
if (!storedSettings["control_port"]) {
defaultSettings["control_port"] = 7657;
} else defaultSettings["control_port"] = storedSettings.control_port;
if (!storedSettings["rpc_host"]) {
if (host == "") defaultSettings["rpc_host"] = "127.0.0.1";
else defaultSettings["rpc_host"] = host;
} else defaultSettings["rpc_host"] = storedSettings.rpc_host;
if (!storedSettings["rpc_port"]) {
defaultSettings["rpc_port"] = 7657;
} else defaultSettings["rpc_port"] = storedSettings.rpc_port;
if (!storedSettings["rpc_path"]) {
defaultSettings["rpc_path"] = "jsonrpc";
} else defaultSettings["rpc_path"] = storedSettings.rpc_path;
if (!storedSettings["rpc_pass"]) {
defaultSettings["rpc_pass"] = "itoopie";
} else defaultSettings["rpc_pass"] = storedSettings.rpc_pass;
if (!storedSettings["bt_rpc_host"]) {
if (host == "") defaultSettings["bt_rpc_host"] = "127.0.0.1";
else defaultSettings["bt_rpc_host"] = host;
} else defaultSettings["bt_rpc_host"] = storedSettings.bt_rpc_host;
if (!storedSettings["bt_rpc_port"]) {
defaultSettings["bt_rpc_port"] = 7657;
} else defaultSettings["bt_rpc_port"] = storedSettings.bt_rpc_port;
if (!storedSettings["bt_rpc_path"]) {
defaultSettings["bt_rpc_path"] = "transmission/rpc";
} else defaultSettings["bt_rpc_path"] = storedSettings.bt_rpc_path;
if (!storedSettings["bt_rpc_pass"]) {
defaultSettings["bt_rpc_pass"] = "transmission";
} else defaultSettings["bt_rpc_pass"] = storedSettings.bt_rpc_pass;
console.log("(options)(browserinfo) NATIVE PROXYSETTINGS", info.value);
console.log(
"(options)",
defaultSettings["proxy_sheme"],
defaultSettings["proxy_host"],
defaultSettings["proxy_port"],
defaultSettings["control_host"],
defaultSettings["control_port"]
);
chrome.storage.local.set(defaultSettings);
return defaultSettings;
}
var gettingInfo = browser.proxy.settings.get({});
gettingInfo.then(gotProxyInfo);
return gettingInfo.then(gotProxyInfo);
}
function checkAndroidStoredSettings(storedSettings) {
let defaultSettings = {};
let host = "";
let port = "";
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;
}
}
if (!storedSettings["proxy_scheme"]) defaultSettings["proxy_scheme"] = "http";
else defaultSettings["proxy_scheme"] = storedSettings["proxy_scheme"];
if (!storedSettings["proxy_host"]) {
if (host == "") defaultSettings["proxy_host"] = "127.0.0.1";
else defaultSettings["proxy_host"] = host;
} else defaultSettings["proxy_host"] = storedSettings["proxy_host"];
if (!storedSettings["proxy_port"]) {
if (port == undefined) defaultSettings["proxy_port"] = 4444;
else if (port == 7644) defaultSettings["proxy_port"] = port;
else defaultSettings["proxy_port"] = 4444;
} 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 defaultSettings["control_host"] = storedSettings.control_host;
if (!storedSettings["control_port"]) {
defaultSettings["control_port"] = 7657;
} else defaultSettings["control_port"] = storedSettings.control_port;
if (!storedSettings["rpc_host"]) {
if (host == "") defaultSettings["rpc_host"] = "127.0.0.1";
else defaultSettings["rpc_host"] = host;
} else defaultSettings["rpc_host"] = storedSettings.rpc_host;
if (!storedSettings["rpc_port"]) {
defaultSettings["rpc_port"] = 7657;
} else defaultSettings["rpc_port"] = storedSettings.rpc_port;
if (!storedSettings["rpc_path"]) {
defaultSettings["rpc_path"] = "jsonrpc";
} else defaultSettings["rpc_path"] = storedSettings.rpc_path;
if (!storedSettings["rpc_pass"]) {
defaultSettings["rpc_pass"] = "itoopie";
} else defaultSettings["rpc_pass"] = storedSettings.rpc_pass;
if (!storedSettings["bt_rpc_host"]) {
if (host == "") defaultSettings["bt_rpc_host"] = "127.0.0.1";
else defaultSettings["bt_rpc_host"] = host;
} else defaultSettings["bt_rpc_host"] = storedSettings.bt_rpc_host;
if (!storedSettings["bt_rpc_port"]) {
defaultSettings["bt_rpc_port"] = 7657;
} else defaultSettings["bt_rpc_port"] = storedSettings.bt_rpc_port;
if (!storedSettings["bt_rpc_path"]) {
defaultSettings["bt_rpc_path"] = "transmission/rpc";
} else defaultSettings["bt_rpc_path"] = storedSettings.bt_rpc_path;
if (!storedSettings["bt_rpc_pass"]) {
defaultSettings["bt_rpc_pass"] = "transmission";
} else defaultSettings["bt_rpc_pass"] = storedSettings.bt_rpc_pass;
console.log("(options)(browserinfo) NATIVE PROXYSETTINGS", info.value);
console.log(
"(options)",
defaultSettings["proxy_scheme"],
defaultSettings["proxy_host"],
defaultSettings["proxy_port"],
defaultSettings["control_host"],
defaultSettings["control_port"]
);
chrome.storage.local.set(defaultSettings);
return defaultSettings;
}
function onError(e) {
@@ -224,43 +315,93 @@ function storeSettings() {
let proxy_port = getPort();
let control_host = getControlHost();
let control_port = getControlPort();
let rpc_host = getRPCHost();
let rpc_port = getRPCPort();
let rpc_path = getRPCPath();
let rpc_pass = getRPCPass();
let bt_rpc_host = getBTRPCHost();
let bt_rpc_port = getBTRPCPort();
let bt_rpc_path = getBTRPCPath();
let bt_rpc_pass = getBTRPCPass();
chrome.storage.local.set({
proxy_scheme,
proxy_host,
proxy_port,
control_host,
control_port
control_port,
rpc_host,
rpc_port,
rpc_path,
rpc_pass,
bt_rpc_host,
bt_rpc_port,
bt_rpc_path,
bt_rpc_pass
});
console.log("storing proxy scheme:", proxy_scheme);
console.log("storing proxy host:", proxy_host);
console.log("storing proxy port:", proxy_port);
console.log("storing control host:", control_host);
console.log("storing control port:", control_port);
}
function updateUI(restoredSettings) {
const selectList = document.querySelector("#proxy_scheme");
selectList.value = restoredSettings.proxy_scheme;
console.log("showing proxy scheme:", selectList.value);
if (selectList == undefined) selectList.value = restoredSettings.proxy_scheme;
//console.log("(options)showing proxy scheme:", selectList.value);
const hostitem = document.getElementById("host");
hostitem.value = restoredSettings.proxy_host;
console.log("showing proxy host:", hostitem.value);
if (hostitem == undefined) hostitem.value = restoredSettings.proxy_host;
//console.log("(options)showing proxy host:", hostitem.value);
const portitem = document.getElementById("port");
portitem.value = restoredSettings.proxy_port;
console.log("showing proxy port:", portitem.value);
if (portitem == undefined) portitem.value = restoredSettings.proxy_port;
//console.log("(options)showing proxy port:", portitem.value);
const controlhostitem = document.getElementById("controlhost");
controlhostitem.value = restoredSettings.control_host;
console.log("showing control host:", controlhostitem.value);
if (controlhostitem == undefined)
controlhostitem.value = restoredSettings.control_host;
//console.log("(options)showing control host:", controlhostitem.value);
const controlportitem = document.getElementById("controlport");
controlportitem.value = restoredSettings.control_port;
console.log("showing control port:", controlportitem.value);
if (controlportitem == undefined)
controlportitem.value = restoredSettings.control_port;
//console.log("(options)showing control port:", controlportitem.value);
const rpchostitem = document.getElementById("rpchost");
if (rpchostitem == undefined) rpchostitem.value = restoredSettings.rpc_host;
//console.log("(options)showing rpc host:", rpchostitem.value);
const rpcportitem = document.getElementById("rpcport");
if (rpcportitem == undefined) rpcportitem.value = restoredSettings.rpc_port;
//console.log("(options)showing rpc port:", rpcportitem.value);
const rpcpathitem = document.getElementById("rpcpath");
if (rpcpathitem == undefined) rpcpathitem.value = restoredSettings.rpc_path;
//console.log("(options)showing rpc path:", rpcpathitem.value);
const rpcpassitem = document.getElementById("rpcpass");
if (rpcpassitem == undefined) rpcpassitem.value = restoredSettings.rpc_pass;
//console.log("(options)showing rpc pass:");
const btrpchostitem = document.getElementById("btrpchost");
if (btrpchostitem == undefined)
btrpchostitem.value = restoredSettings.rpc_host;
//console.log("(options)showing bt rpc host:", btrpchostitem.value);
const btrpcportitem = document.getElementById("btrpcport");
if (btrpcportitem == undefined)
btrpcportitem.value = restoredSettings.rpc_port;
//console.log("(options)showing rbt pc port:", rpcportitem.value);
const btrpcpathitem = document.getElementById("btrpcpath");
if (btrpcpathitem == undefined)
btrpcpathitem.value = restoredSettings.rpc_path;
//console.log("(options)showing bt rpc path:", btrpcpathitem.value);
const btrpcpassitem = document.getElementById("btrpcpass");
if (btrpcpassitem == undefined)
btrpcpassitem.value = restoredSettings.rpc_pass;
//console.log("(options)showing bt rpc pass:");
SetHostText();
SetPortText();
SetPortHelpText();
SetControlHostText();
SetControlPortText();
SetControlHelpText();
@@ -274,8 +415,8 @@ var gettingInfo = browser.runtime.getPlatformInfo();
gettingInfo.then(got => {
if (got.os != "android") {
chrome.storage.local.get(function(got) {
checkStoredSettings(got);
updateUI(got);
let settings = checkStoredSettings(got);
settings.then(updateUI);
});
} else {
chrome.storage.local.get(function(got) {
@@ -287,5 +428,3 @@ gettingInfo.then(got => {
const saveButton = document.querySelector("#save-button");
saveButton.addEventListener("click", storeSettings);
//EXPERIMENTAL: Open in I2P Tab

153
proxy.js
View File

@@ -38,9 +38,9 @@ var handleContextProxyRequest = async function(requestDetails) {
host: getHost(),
port: getPort()
};
console.log("(proxy)", context.name);
/*console.log("(proxy)", context.name);
console.log("Using", proxy.type);
console.log("proxy ", proxy.host + ":" + proxy.port);
console.log("proxy ", proxy.host + ":" + proxy.port);*/
return proxy;
} else if (context.name == routerpref) {
if (routerHost(requestDetails.url)) {
@@ -57,9 +57,9 @@ var handleContextProxyRequest = async function(requestDetails) {
host: getHost(),
port: getPort()
};
console.log("(proxy)", context.name);
/*console.log("(proxy)", context.name);
console.log("Using", proxy.type);
console.log("proxy ", proxy.host + ":" + proxy.port);
console.log("proxy ", proxy.host + ":" + proxy.port);*/
return proxy;
} else if (context.name == webpref) {
if (localHost(requestDetails.url)) {
@@ -100,7 +100,7 @@ var handleContextProxyRequest = async function(requestDetails) {
};
var contextGet = async function(tabInfo) {
try {
console.log("(proxy)Tab info from Function", tabInfo);
//console.log("(proxy)Tab info from Function", tabInfo);
context = await browser.contextualIdentities.get(tabInfo.cookieStoreId);
return context;
} catch (error) {
@@ -110,7 +110,7 @@ var handleContextProxyRequest = async function(requestDetails) {
};
var tabGet = async function(tabId) {
try {
console.log("(proxy)Tab ID from Request", tabId);
//console.log("(proxy)Tab ID from Request", tabId);
let tabInfo = await browser.tabs.get(tabId);
return tabInfo;
} catch (error) {
@@ -132,7 +132,6 @@ var handleContextProxyRequest = async function(requestDetails) {
return browser.proxy.settings.get({});
}
if (requestDetails.tabId > 0) {
console.log("manifest", requestDetails);
if (proxyHost(requestDetails.url)) {
proxy = {
type: getScheme(),
@@ -143,7 +142,6 @@ var handleContextProxyRequest = async function(requestDetails) {
} else if (extensionHost(requestDetails.url)) {
return;
} else if (i2pHost(requestDetails.url)) {
console.log("(Proxy)I2P URL detected, ");
var tab = tabGet(requestDetails.tabId);
requestDetails.tabId = tab;
var context = tab.then(contextGet);
@@ -154,7 +152,7 @@ var handleContextProxyRequest = async function(requestDetails) {
var tab = tabGet(requestDetails.tabId);
var context = tab.then(contextGet);
var proxy = await context.then(handleProxyRequest);
console.log("(proxy)Returning I2P Proxy", proxy);
//console.log("(proxy)Returning I2P Proxy", proxy);
return proxy;
}
/*proxy = {};
@@ -166,13 +164,6 @@ var handleContextProxyRequest = async function(requestDetails) {
}
};
var proxy_scheme = "HTTP";
var proxy_host = "127.0.0.1";
var proxy_port = "4444";
var control_host = "127.0.0.1";
var control_port = "7657";
var disable_history = false;
function SetupSettings() {
console.log("Initialising Settings");
function onSetupError() {
@@ -180,12 +171,10 @@ function SetupSettings() {
}
//
function checkSchemeStoredSettings(storedSettings) {
if (storedSettings.proxy_scheme === undefined) {
proxy_scheme = "http";
storedSettings.proxy_scheme = proxy_scheme;
} else {
proxy_scheme = storedSettings.proxy_scheme;
}
if (storedSettings.proxy_scheme == undefined)
storedSettings.proxy_scheme = "http";
else proxy_scheme = storedSettings.proxy_scheme;
console.log("Initialising Proxy Scheme", storedSettings.proxy_scheme);
setupProxy();
}
@@ -194,12 +183,10 @@ function SetupSettings() {
//
function checkHostStoredSettings(storedSettings) {
if (storedSettings.proxy_host == undefined) {
proxy_host = "127.0.0.1";
storedSettings.proxy_host = proxy_host;
} else {
proxy_host = storedSettings.proxy_host;
}
if (storedSettings.proxy_host == undefined)
storedSettings.proxy_host = "127.0.0.1";
else proxy_host = storedSettings.proxy_host;
console.log("Initialising Host", storedSettings.proxy_host);
setupProxy();
}
@@ -208,12 +195,10 @@ function SetupSettings() {
//
function checkPortStoredSettings(storedSettings) {
if (storedSettings.proxy_port == undefined) {
proxy_port = "4444";
storedSettings.proxy_port = proxy_port;
} else {
proxy_port = storedSettings.proxy_port;
}
if (storedSettings.proxy_port == undefined)
storedSettings.proxy_port = "4444";
else proxy_port = storedSettings.proxy_port;
console.log("Initialising Port", storedSettings.proxy_port);
setupProxy();
}
@@ -222,12 +207,10 @@ function SetupSettings() {
//
function checkControlHostStoredSettings(storedSettings) {
if (storedSettings.control_host == undefined) {
control_host = "127.0.0.1";
storedSettings.control_host = control_host;
} else {
control_host = storedSettings.control_host;
}
if (storedSettings.control_host == undefined)
storedSettings.control_host = "127.0.0.1";
else control_host = storedSettings.control_host;
console.log("Initialising Control Host", storedSettings.control_host);
setupProxy();
}
@@ -241,12 +224,10 @@ function SetupSettings() {
//
function checkControlPortStoredSettings(storedSettings) {
if (storedSettings.control_port == undefined) {
let new_control_port = "7657";
storedSettings.control_port = new_control_port;
} else {
let control_port = storedSettings.control_port;
}
if (storedSettings.control_port == undefined)
storedSettings.control_port = "7657";
else control_port = storedSettings.control_port;
console.log("Initialising Control Port", storedSettings.control_port);
setupProxy();
}
@@ -260,12 +241,10 @@ function SetupSettings() {
//
function checkHistoryStoredSettings(storedSettings) {
if (storedSettings.disable_history == undefined) {
disable_history = false;
storedSettings.disable_history = disable_history;
} else {
disable_history = storedSettings.disable_history;
}
if (storedSettings.disable_history == undefined)
storedSettings.disable_history = false;
else disable_history = storedSettings.disable_history;
console.log(
"Initialising Disabled History",
storedSettings.disable_history
@@ -279,20 +258,11 @@ function SetupSettings() {
}
function getScheme() {
if (proxy_scheme == undefined) {
proxy_scheme = "http";
}
if (proxy_scheme == "HTTP") {
proxy_scheme = "http";
}
if (proxy_scheme == "SOCKS") {
proxy_scheme = "socks";
}
if (proxy_scheme != "http" && proxy_scheme != "socks") {
proxy_scheme = "http";
}
//console.log("Got i2p proxy scheme:", proxy_scheme);
return proxy_scheme;
if (proxy_scheme == "HTTP") return "http";
if (proxy_scheme == "SOCKS") return "socks";
if (proxy_scheme == "http") return "http";
if (proxy_scheme == "socks") return "socks";
else return "http";
}
function getHost() {
@@ -305,37 +275,18 @@ function getHost() {
function getPort() {
if (proxy_port == undefined) {
var scheme = getScheme();
if (scheme == "socks") {
proxy_port = "4446";
} else {
proxy_port = "4444";
}
if (scheme == "socks") proxy_port = "4446";
else proxy_port = "4444";
}
return proxy_port;
}
function getControlHost() {
if (control_host == undefined) {
return "127.0.0.1";
}
return control_host;
}
function getControlPort() {
if (control_port == undefined) {
return "7657";
}
return control_port;
}
function setupProxy() {
/**/
console.log("Setting up Firefox WebExtension proxy");
browser.proxy.onRequest.addListener(handleContextProxyRequest, {
urls: ["<all_urls>"]
});
console.log("i2p settings created for WebExtension Proxy");
/**/
}
function update() {
@@ -348,25 +299,29 @@ function update() {
function updateFromStorage() {
console.log("updating settings from storage");
chrome.storage.local.get(function() {
SetupSettings();
update();
setupProxy();
});
var gettingInfo = browser.runtime.getPlatformInfo();
gettingInfo.then(got => {
if (got.os == "android") {
chrome.storage.local.get(function() {
SetupSettings();
update();
setupProxy();
});
} else {
if (got.os != "android") {
browser.windows.getAll().then(wins => wins.forEach(themeWindow));
chrome.storage.local.get(function() {
SetupSettings();
update();
setupProxy();
});
}
});
}
updateFromStorage();
browser.storage.onChanged.addListener(updateFromStorage);
SetupSettings();
setupProxy();
var gettingListenerInfo = browser.runtime.getPlatformInfo();
gettingListenerInfo.then(got => {
browser.windows.onCreated.addListener(() => {
chrome.storage.local.get(function() {
setupProxy();
});
});
});

View File

@@ -5,17 +5,17 @@ var mailpref = chrome.i18n.getMessage("mailPreface");
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 contextScrub = async function(requestDetails) {
function onHeaderError() {
console.log("Header scrub error");
}
console.log("(scrub)Scrubbing info from contextualized request");
//console.log("(scrub)Scrubbing info from contextualized request");
try {
var headerScrub = function(context) {
var ua = "MYOB/6.66 (AN/ON)";
if (!context) {
console.log("Context not found", context);
} else if (context.name == titlepref) {
if (i2pHost(requestDetails.url)) {
for (var header of requestDetails.requestHeaders) {
@@ -44,7 +44,7 @@ var contextScrub = async function(requestDetails) {
};
var contextGet = async function(tabInfo) {
try {
console.log("(scrub)Tab info from Function", tabInfo);
//console.log("(scrub)Tab info from Function", tabInfo);
let context = await browser.contextualIdentities.get(
tabInfo.cookieStoreId
);
@@ -55,7 +55,7 @@ var contextScrub = async function(requestDetails) {
};
var tabGet = async function(tabId) {
try {
console.log("(scrub)Tab ID from Request", tabId);
//console.log("(scrub)Tab ID from Request", tabId);
let tabInfo = await browser.tabs.get(tabId);
return tabInfo;
} catch (error) {
@@ -67,17 +67,17 @@ var contextScrub = async function(requestDetails) {
var context = {};
var req = {};
if (i2pHost(requestDetails.url)) {
console.log("(scrub)I2P URL detected, ");
//console.log("(scrub)I2P URL detected, ");
tab = tabGet(requestDetails.tabId);
context = tab.then(contextGet, onHeaderError);
req = await context.then(headerScrub, onHeaderError);
console.log("(scrub)Scrubbing I2P Request", req);
//console.log("(scrub)Scrubbing I2P Request", req);
return req;
} else if (routerHost(requestDetails.url)) {
tab = tabGet(requestDetails.tabId);
context = tab.then(contextGet, onHeaderError);
req = await context.then(headerScrub, onHeaderError);
console.log("(scrub)Scrubbing non-I2P Request", req);
//console.log("(scrub)Scrubbing non-I2P Request", req);
return req;
}
return req;
@@ -91,7 +91,7 @@ var contextSetup = function(requestDetails) {
function onContextError() {
console.log("Context launcher error");
}
console.log("(isolate)Forcing I2P requests into context");
//console.log("(isolate)Forcing I2P requests into context");
try {
var i2pTabFind = async function(tabId) {
try {
@@ -99,8 +99,6 @@ var contextSetup = function(requestDetails) {
name: titlepref
});
if (tabId.cookieStoreId != context[0].cookieStoreId) {
console.log("(isolate) I2P context", context[0].cookieStoreId);
console.log("tab context", tabId.cookieStoreId);
function Create() {
function onCreated(tab) {
function closeOldTab() {
@@ -134,8 +132,6 @@ var contextSetup = function(requestDetails) {
name: routerpref
});
if (tabId.cookieStoreId != context[0].cookieStoreId) {
console.log("(isolate) I2P context", context[0].cookieStoreId);
console.log("tab context", tabId.cookieStoreId);
function Create() {
function onCreated(tab) {
function closeOldTab() {
@@ -169,8 +165,6 @@ var contextSetup = function(requestDetails) {
name: tunnelpref
});
if (tabId.cookieStoreId != context[0].cookieStoreId) {
console.log("(isolate) I2P context", context[0].cookieStoreId);
console.log("tab context", tabId.cookieStoreId);
function Create() {
function onCreated(tab) {
function closeOldTab() {
@@ -204,8 +198,6 @@ var contextSetup = function(requestDetails) {
name: torrentpref
});
if (tabId.cookieStoreId != context[0].cookieStoreId) {
console.log("(isolate) I2P context", context[0].cookieStoreId);
console.log("tab context", tabId.cookieStoreId);
function Create() {
function onCreated(tab) {
function closeOldTab() {
@@ -239,8 +231,6 @@ var contextSetup = function(requestDetails) {
name: mailpref
});
if (tabId.cookieStoreId != context[0].cookieStoreId) {
console.log("(isolate) I2P context", context[0].cookieStoreId);
console.log("tab context", tabId.cookieStoreId);
function Create() {
function onCreated(tab) {
function closeOldTab() {
@@ -274,8 +264,6 @@ var contextSetup = function(requestDetails) {
name: localpref
});
if (tabId.cookieStoreId != context[0].cookieStoreId) {
console.log("(isolate) I2P context", context[0].cookieStoreId);
console.log("tab context", tabId.cookieStoreId);
function Create() {
function onCreated(tab) {
function closeOldTab() {
@@ -314,8 +302,6 @@ var contextSetup = function(requestDetails) {
tabId.cookieStoreId == "firefox-private"
) {
if (tabId.cookieStoreId != context[0].cookieStoreId) {
console.log("(isolate) I2P context", context[0].cookieStoreId);
console.log("tab context", tabId.cookieStoreId);
function Create() {
function onCreated(tab) {
function closeOldTab() {
@@ -346,7 +332,7 @@ var contextSetup = function(requestDetails) {
};
var tabGet = async function(tabId) {
try {
console.log("(isolate)Tab ID from Request", tabId);
//console.log("(isolate)Tab ID from Request", tabId);
let tabInfo = await browser.tabs.get(tabId);
return tabInfo;
} catch (error) {
@@ -356,20 +342,17 @@ var contextSetup = function(requestDetails) {
if (requestDetails == undefined) {
return requestDetails;
}
if (extensionHost(requestDetails.url)) {
if (proxyHost(requestDetails.url)) {
setcookie = browser.cookies.set({
firstPartyDomain: i2pHostName(requestDetails.url),
url: requestDetails.url,
secure: true
});
setcookie.then(onContextGotLog, onContextError);
return requestDetails;
}
if (requestDetails.tabId > 0) {
if (proxyHost(requestDetails.url)) {
setcookie = browser.cookies.set({
firstPartyDomain: i2pHostName(requestDetails.url),
url: requestDetails.url,
secure: true
});
setcookie.then(onContextGotLog, onContextError);
return requestDetails;
}
console.log("(isolate)Request Details", requestDetails);
var tab = tabGet(requestDetails.tabId);
if (i2pHost(requestDetails.url)) {
var setcookie = browser.cookies.set({
@@ -381,6 +364,9 @@ var contextSetup = function(requestDetails) {
var i2ptab = tab.then(i2pTabFind, onContextError);
return requestDetails;
}
if (extensionHost(requestDetails)) {
return requestDetails;
}
let localhost = localHost(requestDetails.url);
let routerhost = routerHost(requestDetails.url);
if (!routerhost) {

10
sidebar.css Normal file
View File

@@ -0,0 +1,10 @@
li {
width: 90%;
margin-left: 0
}
#readyness {
margin-top: -.5rem
}
#applicationExplain {
float: unset
}

62
toopie.html Normal file
View File

@@ -0,0 +1,62 @@
<!DOCTYPE html>
<html>
<head>
<title>I2P Router Information</title>
<link href="home.css" rel="stylesheet" type="text/css">
<link href="sidebar.css" rel="stylesheet" type="text/css">
</head>
<body>
<h1>I2P Router Information</h1>
<ul>
<li><button id="label-router-restart" target="_blank">Restart: <span id="router-restart">Gracefully restart router</span></button>
</li>
<li><button id="label-router-shutdown" target="_blank">Shutdown: <span id="router-shutdown">Gracefully shutdown router</span></button>
</li>
</ul>
<ul>
<li><span id="label-router-status">Router Status:</span> <span id="router-status">Replace with Router Status</span></li>
<li><span id="label-router-uptime">Router Uptime(Ms):</span> <span id="router-uptime">Replace with Router Uptime</span></li>
<li><span id="label-router-version">Router Version:</span> <span id="router-version">Replace with Router Version</span></li>
<li>
<ul>
<li><span id="label-router-bw-outbound-1s">Outbound bw 1s:</span> <span id="router-net-bw-outbound-1s">Replace with Router Bandwidth Outbound 1s</span></li>
<li><span id="label-router-bw-outbound-15s">Outbound bw 15s:</span> <span id="router-net-bw-outbound-15s">Replace with Router Bandwidth Outbound 15s</span></li>
<li><span id="label-router-bw-inbound-1s">Inbound bw 1s:</span> <span id="router-net-bw-inbound-1s">Replace with Router Bandwidth Inbound 1s</span></li>
<li><span id="label-router-bw-inbound-15s">Inbound bw 15s:</span> <span id="router-net-bw-inbound-15s">Replace with Router Bandwidth Outbound 15s</span></li>
</ul>
</li>
<!--<li>
<span id="label-router-net-status">Network Status:</span>
<span id="router-net-status">Replace with Router Network Status</span>
</li>-->
<li>
<ul>
<li><span id="label-router-net-tunnels-participating">Participating Tunnels:</span> <span id="router-net-tunnels-participating">Replace with Router Participating Tunnel Count</span></li>
<li><span id="label-router-activepeers">Active Peers:</span> <span id="router-netdb-activepeers">Replace with Router Active Peers</span></li>
<li><span id="label-router-netdb-fastpeers">Fast Peers:</span> <span id="router-netdb-fastpeers">Replace with Router Fast Peers</span></li>
<li><span id="label-router-netdb-highcapacitypeers">High Capacity Peers:</span> <span id="router-netdb-highcapacitypeers">Replace with High Capacity Peers</span></li>
<li><span id="label-router-netdb-isreseeding">Reseed status:</span> <span id="router-netdb-isreseeding">Replace with Router netDB Reseeding Status</span></li>
<li><span id="label-router-netdb-knownpeers">Known Peers:</span> <span id="router-netdb-knownpeers">Replace with Router Known Peers</span></li>
</ul>
</li>
</ul>
<script src="i2pcontrol/i2pcontrol.js"></script>
<script src="info.js"></script>
<script src="content.js"></script>
</body>
</html>

BIN
toopie.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 68 KiB

82
torrent/torrent.js Normal file
View File

@@ -0,0 +1,82 @@
var hello = "hello bittorrent";
function makeid(length) {
var result = "";
var characters =
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
var charactersLength = characters.length;
for (var i = 0; i < length; i++) {
result += characters.charAt(Math.floor(Math.random() * charactersLength));
}
return result;
}
function send(
message,
control_host = "127.0.0.1",
control_port = "7657",
control_path = "transmission/rpc"
) {
async function postData(url = "", data = {}) {
// Default options are marked with *
let requestBody = JSON.stringify(data);
//console.log("(i2pcontrol)", requestBody, data);
let opts = {
method: "POST", // *GET, POST, PUT, DELETE, etc.
mode: "cors", // no-cors, *cors, same-origin
cache: "no-cache", // *default, no-cache, reload, force-cache, only-if-cached
credentials: "same-origin", // include, *same-origin, omit
headers: {
"Content-Type": "application/json"
},
redirect: "follow", // manual, *follow, error
referrerPolicy: "no-referrer", // no-referrer, *client
body: requestBody // body data type must match "Content-Type" header
};
const response = await fetch(url, opts);
return await response.json(); // parses JSON response into native JavaScript objects
}
return postData(
"http://" + control_host + ":" + control_port + "/" + control_path + "/",
message
);
}
function authenticate(
password = "transmission",
control_host = "127.0.0.1",
control_port = "7657",
control_path = "transmission/rpc"
) {
let store = browser.storage.local.get("rpc_pass");
if (store != undefined) {
console.log("Stored password found");
password = store;
}
function auth(got) {
var json = new Object();
json["id"] = makeid(6);
json["jsonrpc"] = "2.0";
json["method"] = "Authenticate";
json["params"] = new Object();
json["params"]["API"] = 1;
json["params"]["Password"] = password;
return send(json);
}
store.then(auth);
}
async function GetToken(
password,
control_host = "127.0.0.1",
control_port = "7657",
control_path = "transmission/rpc"
) {
let me = authenticate(password);
return await me.then(gettoken);
}
function gettoken(authtoken) {
return authtoken.result.Token;
}

View File

@@ -9,106 +9,128 @@
</title>
</head>
<body>
<div class="panel">
<div class="section-header panel-section panel-section-header">
<div class="text-section-header" id="text-section-header">
<h1>The Invisible Internet Browser</h1>
</div>
</div>
<div class="topnav">
<a class="applicationName window-visit-homepage" href="#" id="window-visit-homepage" target="_blank">Home Page</a>
<form action="http://legwork.i2p/yacysearch.html?" method="get">
<input id="search-query" name="query" placeholder="Search on legwork.i2p(Opens a new tab)" type="search"> <input id="search-submit" text="Submit" type="submit">
</form>
</div>
<div class="panel-section-separator">
</div>
<div id="i2pbrowser-version">
</div>
<div id="i2pbrowser-description">
<p id="description">You are now able to use I2P in this browser.</p>
<p id="beta">It is experimental.</p>
</div>
<div class="hideIfI2PProxyOff" id="readyness">
<img class="readyness" src="http://proxy.i2p/themes/console/images/local_up.png"> <span id="proxy-check">Proxy is ready.</span>
</div>
<div class="section-header panel-section panel-section-header" id="topbar">
<!--<div class="text-section-header" id="text-section-header">-->
<img height="32px" src="icons/toopie.png" width="32px"> <a href="#" id="browser-action">Browse</a> <img height="32px" src="icons/torrents.png" width="32px"> <a href="#" id="torrent-action">Download</a> <!--</div>-->
</div>
<div class="panel-section-separator">
</div>
<div class="browser-info">
<p class="hideIfI2PConsoleOff">
</p>
<h3 id="controlHeader">Controls</h3>
<p id="controlExplain">These controls are used to tailor your I2P Browsing Experience</p>
<ul>
<li class="application">
<a href="#" id="clear-browser-data">Clear Browsing Data:</a> <span class="applicationDesc" id="clear-desc">Use this to erase your browsing data.</span>
</li>
<li class="application"><input id="enable-web-rtc" name="enablewebrtc" type="checkbox" value="webrtc"> <label for="enable-web-rtc">Enable WebRTC <strong>with Proxy?</strong></label> <span class="applicationDesc" id="rtcDesc">WebRTC is disabled by default, but can be enabled by checking this box.</span></li>
<li class="application">
<div class="panel-section-separator">
<div id="browserpanel">
<div class="panel">
<div class="section-header panel-section panel-section-header">
<div class="text-section-header" id="text-section-header">
<h1>The Invisible Internet Browser</h1>
</div>
</div>
<div class="panel-section-identity">
<div id="identity-list">
<div class="topnav">
<a class="applicationName window-visit-homepage" href="#" id="window-visit-homepage" target="_blank">Home Page</a> <!--<form action="http://legwork.i2p/yacysearch.html?" method="get">
<input id="search-query" name="query" placeholder="Search on legwork.i2p(Opens a new tab)" type="search"> <input id="search-submit" text="Submit" type="submit">
</form>-->
</div>
<div class="panel-section-separator">
</div>
<div id="i2pbrowser-version">
</div>
<div class="hideIfI2PProxyOff" id="readyness">
<img class="readyness" src="http://proxy.i2p/themes/console/images/local_up.png"> <span id="proxy-check">Proxy is ready.</span>
</div>
<div id="i2pbrowser-description">
<p id="description">You are now able to use I2P in this browser.</p>
<p id="beta">It is experimental.</p>
</div>
<div class="panel-section-separator">
</div>
<div class="browser-info">
<p class="hideIfI2PConsoleOff">
</p>
<h3 id="controlHeader">Controls</h3>
<p id="controlExplain">These controls are used to tailor your I2P Browsing Experience</p>
<ul>
<li class="application">
<a href="#" id="clear-browser-data">Clear Browsing Data:</a> <span class="applicationDesc" id="clear-desc">Use this to erase your browsing data.</span>
</li>
<li class="application"><input id="enable-web-rtc" name="enablewebrtc" type="checkbox" value="webrtc"> <label for="enable-web-rtc">Enable WebRTC <strong>with Proxy?</strong></label> <span class="applicationDesc" id="rtcDesc">WebRTC is disabled by default, but can be enabled by checking this box.</span></li>
<li class="application">
<div class="panel-section-separator">
</div>
<div class="panel-section-identity">
<div id="identity-list">
</div>
</div>
</li>
<li class="application"><input id="disable-history" name="disablehistory" type="checkbox" value="history"> <label for="disable-history">Disable History in I2P Tabs</label> <span class="applicationDesc" id="histDesc">History is automatically cleared when your I2P tabs are closed. If you want to clear history as you go, check this box.</span></li>
</ul>
<p>
</p>
<p>
</p>
</div>
<div class="panel-section-separator">
</div>
<div class="application-info">
<p class="hideIfI2PConsoleOff">
</p>
<h3 id="applicationHeader">Applications</h3>
<p id="applicationExplain">These applications use I2P to provide them with security and privacy.</p>
<ul>
<li class="application"><button class="applicationName window-visit-homepage" href="#" id="window-visit-index" target="_blank">Help Page</button> <span class="applicationDesc" id="abouthome">For more information about this extension, go here:</span></li>
<li class="application"><button class="applicationName window-visit-toopie" href="#" id="window-visit-toopie" target="_blank">Toopie</button> <span class="applicationDesc" id="toopie">For information about your I2P router status, go here:</span></li>
<li class="application"><button class="applicationName" id="window-visit-i2ptunnel" target="_blank">Hidden Services Manager</button> <span class="applicationDesc" id="i2ptunnel">I2P has a web-based interface for configuring .i2p services like web sites, to set up your own web sites, go here:</span></li>
<li class="application"><button class="applicationName" id="window-visit-susimail" target="_blank">E-Mail</button> <span class="applicationDesc" id="susimail">I2P also bundles a webmail client which can be used to access in-I2P e-mail. To use it, go here:</span></li>
<li class="application"><button class="applicationName" id="window-visit-snark" target="_blank">BitTorrent</button> <span class="applicationDesc" id="snark">I2P is capable of anonymous Peer-to-Peer file sharing, to use the built-in bittorrent client go here:</span></li>
</ul>
<p>
</p>
<p>
</p>
</div>
<div id="torrentpanel">
<div class="panel" id="torrentstatus">
<div class="section-header panel-section panel-section-header">
<div class="text-section-header" id="text-section-torrents-header">
<h3>Torrent Downloads</h3>
</div>
</div>
<div id="torrentsection">
Torrents go here.
</div>
</div>
</li>
<li class="application"><input id="disable-history" name="disablehistory" type="checkbox" value="history"> <label for="disable-history">Disable History in I2P Tabs</label> <span class="applicationDesc" id="histDesc">History is automatically cleared when your I2P tabs are closed. If you want to clear history as you go, check this box.</span></li>
</ul>
<p>
</p>
<p>
</p>
</div>
<script src="context.js"></script>
<script src="privacy.js"></script>
<script src="info.js"></script>
<script crossorigin="anonymous" src="content.js"></script>
<script src="i2pcontrol/i2pcontrol.js"></script>
</div>
</div>
<div class="panel-section-separator">
</div>
<div class="application-info">
<p class="hideIfI2PConsoleOff">
</p>
<h3 id="applicationHeader">Applications</h3>
<p id="applicationExplain">These applications use I2P to provide them with security and privacy.</p>
<ul>
<li class="application"><button class="applicationName window-visit-homepage" href="#" id="window-visit-index" target="_blank">Help Page</button> <span class="applicationDesc" id="abouthome">For more information about this extension, go here:</span></li>
<li class="application"><button class="applicationName" id="window-visit-i2ptunnel" target="_blank">Hidden Services Manager</button> <span class="applicationDesc" id="i2ptunnel">I2P has a web-based interface for configuring .i2p services like web sites, to set up your own web sites, go here:</span></li>
<li class="application"><button class="applicationName" id="window-visit-susimail" target="_blank">E-Mail</button> <span class="applicationDesc" id="susimail">I2P also bundles a webmail client which can be used to access in-I2P e-mail. To use it, go here:</span></li>
<li class="application"><button class="applicationName" id="window-visit-snark" target="_blank">BitTorrent</button> <span class="applicationDesc" id="snark">I2P is capable of anonymous Peer-to-Peer file sharing, to use the built-in bittorrent client go here:</span></li>
</ul>
<p>
</p>
<p>
</p>
</div>
<script src="context.js"></script>
<script src="privacy.js"></script>
<script src="info.js"></script>
<script crossorigin="anonymous" src="content.js"></script>
<script src="i2pcontrol/i2pcontrol.js"></script>
</body>
</html>