Merge pull request #17 from eyedeekay/webrtc

Webrtc
This commit is contained in:
idk
2019-10-28 01:17:26 -04:00
committed by GitHub
13 changed files with 266 additions and 211 deletions

View File

@@ -34,8 +34,9 @@ clean:
## EVEN RELEASES are AMO RELEASES
## ODD RELEASES are SELFHOSTED RELEASES
MOZ_VERSION=0.36
VERSION=0.36
MOZ_VERSION=0.38
VERSION=0.39
VERSION=$(MOZ_VERSION)
#VERSION=1.27
xpi:
@@ -78,9 +79,14 @@ fmt:
find . -path ./node_modules -prune -o -name '*.js' -exec prettier --write {} \;
deborig:
rm -rfv ../i2psetproxy.js-$(VERSION)
cp -rv . ../i2psetproxy.js-$(VERSION)
tar --exclude='./.git' --exclude="./node_modules" -cvzf ../i2psetproxy.js_$(VERSION).orig.tar.gz .
rm -rf ../i2psetproxy.js-$(VERSION)
cp -r . ../i2psetproxy.js-$(VERSION)
tar \
-cvz \
--exclude=.git \
--exclude=i2psetproxy.js.gif \
-f ../i2psetproxy.js_$(VERSION).orig.tar.gz \
.
deb: deborig
cd ../i2psetproxy.js-$(VERSION) && debuild -us -uc -rfakeroot

View File

@@ -18,7 +18,7 @@ for the new plugin has been made at a new location on addons.mozilla.org.
Android usage:
--------------
Open the following link [Github Releases Version](https://github.com/eyedeekay/i2psetproxy.js/releases/download/1.26/i2psetproxy.js@eyedeekay.github.io.xpi)
Open the following link [Github Releases Version](https://github.com/eyedeekay/i2psetproxy.js/releases/)
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

View File

@@ -6,13 +6,6 @@ function onGot(contexts) {
}
console.log("Checking new contexts");
if (ids.indexOf("i2pbrowser") == -1) {
function onCreated(context) {
console.log(`New identity's ID: ${context.cookieStoreId}.`);
}
function onError(e) {
console.error(e);
}
browser.contextualIdentities
.create({
name: "i2pbrowser",
@@ -22,13 +15,6 @@ function onGot(contexts) {
.then(onCreated, onError);
}
if (ids.indexOf("routerconsole") == -1) {
function onCreated(context) {
console.log(`New identity's ID: ${context.cookieStoreId}.`);
}
function onError(e) {
console.error(e);
}
browser.contextualIdentities
.create({
name: "routerconsole",
@@ -39,6 +25,10 @@ function onGot(contexts) {
}
}
function onCreated(context) {
console.log(`New identity's ID: ${context.cookieStoreId}.`);
}
function onError(e) {
console.error(e);
}
@@ -47,6 +37,8 @@ browser.contextualIdentities.query({}).then(onGot, onError);
if (!isDroid()) {
chrome.windows.onCreated.addListener(themeWindow);
chrome.windows.onFocusChanged.addListener(themeWindow);
chrome.windows.onRemoved.addListener(themeWindow);
chrome.tabs.onUpdated.addListener(themeWindowByTab);
chrome.tabs.onActivated.addListener(themeWindowByTab);
}
@@ -54,16 +46,22 @@ if (!isDroid()) {
var titlepref = chrome.i18n.getMessage("titlePreface");
var titleprefpriv = chrome.i18n.getMessage("titlePrefacePrivate");
function themeWindowByTab(tab) {
getwindow = browser.windows.get(tab.windowId);
getwindow.then(themeWindow);
function themeWindowByTab(tabId) {
function tabWindow(tab) {
getwindow = browser.windows.get(tab.windowId);
getwindow.then(themeWindow);
}
if (typeof tabId === "number") {
tab = browser.tabs.get(tabId);
tab.then(tabWindow);
} else {
tabWindow(tabId);
}
}
function themeWindow(window) {
// Check if the window is in private browsing
function logTabs(tabInfo) {
console.log(tabInfo);
function onGot(context) {
if (context.name == "i2pbrowser") {
console.log("Active in I2P window");
@@ -103,10 +101,6 @@ function themeWindow(window) {
console.log("Not active in I2P window");
}
}
function onError(e) {
console.error(e);
}
if (tabInfo[0].cookieStoreId != "firefox-default") {
browser.contextualIdentities
.get(tabInfo[0].cookieStoreId)
@@ -116,9 +110,6 @@ function themeWindow(window) {
}
}
function onError(error) {
console.log(`Error: ${error}`);
}
var querying = browser.tabs.query({
currentWindow: true,
active: true
@@ -147,18 +138,12 @@ function setTitle(window) {
}
}
function onError(e) {
console.error(e);
}
if (tabInfo[0].cookieStoreId != "firefox-default")
browser.contextualIdentities
.get(tabInfo[0].cookieStoreId)
.then(onGot, onError);
}
function onError(error) {
console.log(`Error: ${error}`);
}
var querying = browser.tabs.query({
currentWindow: true,
active: true

View File

@@ -15,3 +15,22 @@ newsMessage.textContent = chrome.i18n.getMessage("newsMessage");
var clearData = document.getElementById("clear-browser-data");
clearData.textContent = chrome.i18n.getMessage("clearData");
/*
document.addEventListener("click", e => {
browser.runtime.sendMessage({ url: "http://proxy.i2p" });
});
function proxyContent(message) {
var proxyData = document.getElementById("proxy-health");
proxyData.textContent = message;
console.log("Event occurred", message);
}
browser.runtime.onMessage.addListener(proxyContent);
*/
/*
function signalWebRTC(val){
console.log("signal", val)
}
*/

6
debian/changelog vendored
View File

@@ -1,3 +1,9 @@
i2psetproxy.js (0.37-1) UNRELEASED; urgency=low
* Honor contextual ID when deleting history
-- idk <hankhill19580@gmail.com> Thu, 17 OCT 2019 00:52:19 -0400
i2psetproxy.js (0.35-1) UNRELEASED; urgency=low
* Automatically activate contexts

43
i2pcontrol.js Normal file
View File

@@ -0,0 +1,43 @@
function send(json) {
const Http = new XMLHttpRequest();
Http.withCredentials = false;
const url = "http://" + "127.0.0.1" + ":" + "7650";
Http.open("POST", url);
Http.send(json);
console.log(Http);
return Http;
}
function authenticate(user, password) {
var json = {
jsonrpc: "2.0",
id: user,
method: "Authenticate",
params: {
API: 1,
Password: password
}
};
return send(json);
}
username = "";
password = "";
function echo(string, section) {
var xhr = authenticate(username, password);
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);
infoMessage.textContent = xhr.responseText;
};
}

View File

@@ -44,6 +44,13 @@ document.addEventListener("click", e => {
forgetBrowsingData();
} else if (e.target.id === "check-i2p-control") {
echo("I2P Router Detected", "panel-section-i2pcontrol-check");
} else if (e.target.id === "enable-web-rtc") {
if (e.target.checked) {
browser.runtime.sendMessage({ rtc: "enableWebRTC" });
} else {
browser.runtime.sendMessage({ rtc: "disableWebRTC" });
}
return;
}
e.preventDefault();

View File

@@ -22,7 +22,7 @@
],
"manifest_version": 2,
"name": "__MSG_extensionName__",
"version": "0.36",
"version": "0.37",
"description": "__MSG_extensionDescription__",
"homepage_url": "https://github.com/eyedeekay/i2psetproxy.js",
"icons": {
@@ -39,7 +39,6 @@
},
"background": {
"scripts": [
"chromium/browser-polyfill.js",
"privacy.js",
"platform.js",
"background.js",

View File

@@ -1,23 +1,13 @@
function getChrome() {
if (browser.runtime.getBrowserInfo == undefined) {
console.log("Running in Chrome detected");
return true;
}
return false;
}
function isDroid() {
if (!getChrome()) {
var gettingInfo = browser.runtime.getPlatformInfo();
gettingInfo.then(got => {
if (got.os == "android") {
console.log("Running in Android detected");
return true;
} else {
console.log("Running in Desktop detected");
return false;
}
});
}
var gettingInfo = browser.runtime.getPlatformInfo();
gettingInfo.then(got => {
if (got.os == "android") {
console.log("Running in Android detected");
return true;
} else {
console.log("Running in Desktop detected");
return false;
}
});
return false;
}

View File

@@ -1,10 +1,3 @@
function getChrome() {
if (chrome.runtime.getBrowserInfo == undefined) {
return true;
}
return false;
}
function onSet(result) {
if (result) {
console.log("->: Value was updated");
@@ -16,52 +9,46 @@ function onSet(result) {
// This disables queries to centralized databases of bad URLs to screen for
// risky sites in your browser
function disableHyperlinkAuditing() {
if (!getChrome()) {
var setting = browser.privacy.websites.hyperlinkAuditingEnabled.set({
value: false
});
console.log("Disabling hyperlink auditing/val=", {
value: false
});
setting.then(onSet);
}
var setting = browser.privacy.websites.hyperlinkAuditingEnabled.set({
value: false
});
console.log("Disabling hyperlink auditing/val=", {
value: false
});
setting.then(onSet);
}
// This enables first-party isolation
function enableFirstPartyIsolation() {
if (!getChrome()) {
var setting = browser.privacy.websites.firstPartyIsolate.set({
value: true
});
console.log("Enabling first party isolation/val=", {
value: true
});
setting.then(onSet);
}
var setting = browser.privacy.websites.firstPartyIsolate.set({
value: true
});
console.log("Enabling first party isolation/val=", {
value: true
});
setting.then(onSet);
}
// This rejects tracking cookies and third-party cookies but it
// LEAVES "Persistent" Cookies unmodified in favor of an option in the content
// interface for now
function disableEvilCookies() {
if (!getChrome()) {
var getting = browser.privacy.websites.cookieConfig.get({});
getting.then(got => {
var setting = browser.privacy.websites.cookieConfig.set({
value: {
behavior: "reject_third_party",
nonPersistentCookies: got.value.nonPersistentCookies
}
});
console.log("Setting cookie behavior/val=", {
value: {
behavior: "reject_third_party",
nonPersistentCookies: got.value.nonPersistentCookies
}
});
setting.then(onSet);
var getting = browser.privacy.websites.cookieConfig.get({});
getting.then(got => {
var setting = browser.privacy.websites.cookieConfig.set({
value: {
behavior: "reject_third_party",
nonPersistentCookies: got.value.nonPersistentCookies
}
});
}
console.log("Setting cookie behavior/val=", {
value: {
behavior: "reject_third_party",
nonPersistentCookies: got.value.nonPersistentCookies
}
});
setting.then(onSet);
});
}
// Make sure that they're gone
@@ -77,63 +64,55 @@ function disableEvilCookies() {
// this disables the use of referrer headers
function disableReferrers() {
if (!getChrome()) {
var setting = browser.privacy.websites.referrersEnabled.set({
value: false
});
console.log("Disabling referrer headers/val=", {
value: false
});
setting.then(onSet);
}
var setting = browser.privacy.websites.referrersEnabled.set({
value: false
});
console.log("Disabling referrer headers/val=", {
value: false
});
setting.then(onSet);
}
// enable fingerprinting resistent features(letterboxing and stuff)
function enableResistFingerprinting() {
if (!getChrome()) {
var setting = browser.privacy.websites.referrersEnabled.set({
value: true
});
console.log("Enabling resist fingerprinting/val=", {
value: true
});
setting.then(onSet);
}
var setting = browser.privacy.websites.referrersEnabled.set({
value: true
});
console.log("Enabling resist fingerprinting/val=", {
value: true
});
setting.then(onSet);
}
// This is essentially a blocklist of clearnet web-sites known to do bad tracking
function enableTrackingProtection() {
if (!getChrome()) {
var setting = browser.privacy.websites.trackingProtectionMode.set({
value: "always"
});
console.log("Enabling tracking protection/val=", {
value: "always"
});
setting.then(onSet);
}
var setting = browser.privacy.websites.trackingProtectionMode.set({
value: "always"
});
console.log("Enabling tracking protection/val=", {
value: "always"
});
setting.then(onSet);
}
// This disables protected content, which is a form of digital restrictions
// management dependent on identifying information
function disableDigitalRestrictionsManagement() {
if (!getChrome()) {
var gettingInfo = browser.runtime.getPlatformInfo();
gettingInfo.then(got => {
if (got.os == "win") {
var setting = browser.privacy.websites.protectedContentEnabled.set({
var gettingInfo = browser.runtime.getPlatformInfo();
gettingInfo.then(got => {
if (got.os == "win") {
var setting = browser.privacy.websites.protectedContentEnabled.set({
value: false
});
console.log(
"Setting Protected Content(Digital Restrictions Management) false/val=",
{
value: false
});
console.log(
"Setting Protected Content(Digital Restrictions Management) false/val=",
{
value: false
}
);
setting.then(onSet);
}
});
}
}
);
setting.then(onSet);
}
});
}
function setAllPrivacy() {
@@ -149,14 +128,12 @@ function setAllPrivacy() {
setAllPrivacy();
function ResetPeerConnection() {
if (!getChrome()) {
browser.privacy.network.peerConnectionEnabled.set({
value: false
});
browser.privacy.network.networkPredictionEnabled.set({
value: false
});
}
browser.privacy.network.peerConnectionEnabled.set({
value: false
});
browser.privacy.network.networkPredictionEnabled.set({
value: false
});
chrome.privacy.network.webRTCIPHandlingPolicy.set({
value: "disable_non_proxied_udp"
});
@@ -164,14 +141,12 @@ function ResetPeerConnection() {
}
function EnablePeerConnection() {
if (!getChrome()) {
browser.privacy.network.peerConnectionEnabled.set({
value: true
});
browser.privacy.network.networkPredictionEnabled.set({
value: false
});
}
browser.privacy.network.peerConnectionEnabled.set({
value: true
});
browser.privacy.network.networkPredictionEnabled.set({
value: false
});
chrome.privacy.network.webRTCIPHandlingPolicy.set({
value: "disable_non_proxied_udp"
});
@@ -214,10 +189,8 @@ function checkStoredSettings(storedSettings) {
chrome.storage.local.set(appSettings);
}
if (!getChrome()) {
const gettingStoredSettings = browser.storage.local.get();
gettingStoredSettings.then(checkStoredSettings, onError);
}
const gettingStoredSettings = browser.storage.local.get();
gettingStoredSettings.then(checkStoredSettings, onError);
function clearCookiesContext(cookieStoreId) {}
@@ -315,7 +288,7 @@ function forgetBrowsingData(storedSettings) {
});
removing.then(onGot, onError);
}
console.log("Cleared cookies")
console.log("Cleared cookies");
}
function deepCleanContext(cookieStoreIds) {
@@ -368,8 +341,15 @@ function onGot(contexts) {
}
}
function onError(e) {
console.error(e);
}
browser.runtime.onMessage.addListener(message);
//browser.contextualIdentities.query("i2pbrowser").then(clearCookiesContext, onError);
function message(message) {
console.log(message);
if (message.rtc === "enableWebRTC") {
console.log("enableWebRTC");
EnablePeerConnection();
} else {
console.log("disableWebRTC");
ResetPeerConnection();
}
}

View File

@@ -1,9 +1,7 @@
if (!getChrome()) {
browser.privacy.network.peerConnectionEnabled.set({
value: false
});
console.log("Preliminarily disabled WebRTC.");
}
browser.privacy.network.peerConnectionEnabled.set({
value: false
});
console.log("Preliminarily disabled WebRTC.");
chrome.privacy.network.networkPredictionEnabled.set({
value: false
@@ -73,7 +71,13 @@ var handleContextProxyRequest = async function(requestDetails) {
};
if (requestDetails.tabId > 0) {
if (i2pHost(requestDetails.url)) {
if (proxyHost(requestDetails.url)) {
return {
type: getScheme(),
host: getHost(),
port: getPort()
};
} else if (i2pHost(requestDetails.url)) {
console.log("(Proxy)I2P URL detected, ");
var tab = tabGet(requestDetails.tabId);
var mtab = tab.then(tabFind);
@@ -160,33 +164,14 @@ function setupProxy() {
var Host = getHost();
var Port = getPort();
var Scheme = getScheme();
if (!getChrome()) {
/**/
console.log("Setting up Firefox WebExtension proxy");
browser.proxy.onRequest.addListener(handleContextProxyRequest, {
urls: ["<all_urls>"]
});
console.log("i2p settings created for WebExtension Proxy");
/**/
} else {
var config = {
mode: "fixed_servers",
rules: {
singleProxy: {
scheme: Scheme,
host: Host,
port: parseInt(Port)
}
}
};
chrome.proxy.settings.set(
{
value: config,
scope: "regular"
},
function() {}
);
}
/**/
console.log("Setting up Firefox WebExtension proxy");
browser.proxy.onRequest.addListener(handleContextProxyRequest, {
urls: ["<all_urls>"]
});
console.log("i2p settings created for WebExtension Proxy");
/**/
}
function checkStoredSettings(storedSettings) {
@@ -229,8 +214,6 @@ chrome.storage.local.get(function(got) {
});
// Theme all currently open windows
if (!getChrome()) {
if (!isDroid()) {
browser.windows.getAll().then(wins => wins.forEach(themeWindow));
}
if (!isDroid()) {
browser.windows.getAll().then(wins => wins.forEach(themeWindow));
}

View File

@@ -197,6 +197,19 @@ function i2pHost(url) {
return hostname.endsWith(".i2p");
}
function proxyHost(url) {
let hostname = "";
if (url.indexOf("://") > -1) {
hostname = url.split("/")[2];
} else {
hostname = url.split("/")[0];
}
if (hostname == "proxy.i2p") {
return true;
}
return false;
}
function routerHost(url) {
let hostname = "";
if (url.indexOf("://") > -1) {
@@ -230,3 +243,25 @@ browser.webRequest.onBeforeSendHeaders.addListener(
{ urls: ["<all_urls>"] },
["blocking", "requestHeaders"]
);
/*
function notify(message) {
var response = await fetch('https://proxy.i2p', {
credentials: 'include'
});
const myJson = await response.json();
console.log(JSON.stringify(myJson));
console.log(message);
const Http = new XMLHttpRequest();
Http.mozAnon = true;
Http.withCredentials = true;
const url = "http://proxy.i2p";
Http.open("GET", url);
Http.send();
Http.onreadystatechange = e => {
console.log(Http.responseText);
browser.runtime.sendMessage(Http.responseText);
};
}
*/

View File

@@ -27,14 +27,16 @@
<!-- <a href="#" id="generate-fresh-tunnel> Generate a Fresh Tunnel</a>"-->
<!-- -->
<strong><a href="#" id="clear-browser-data">Clear all browsing data</a></strong><br>
<!--<strong><a href="#" id="temp-enable-webrtc">Temporarily enable WebRTC</a></strong><br>-->
<div class="panel-section-separator"></div>
<a href="http://i2pforum.i2p" id="window-create-forum-panel">Visit the I2P Forums</a><br>
<a href="http://i2p-projekt.i2p/blog" id="window-create-news-panel">Get the latest I2P News</a><br>
<div class="panel-section-separator"></div>
<!--<div id="proxy-health">Proxy is:</div>-->
<input type="checkbox" id="enable-web-rtc" name="enablewebrtc" value="webrtc">
<label for="enable-web-rtc">Enable WebRTC <strong>with Proxy?</strong></label>
<div class="panel-section-separator"></div>
<a href="#" id="check-i2p-control">Check I2P Router Health</a><div id="panel-section-i2pcontrol-check"></div>
<div class="panel-section-separator"></div>
<div class="panel-section-identity">
<div id="identity-list"></div>
</div>
@@ -45,7 +47,7 @@
<script src="context.js"></script>
<script src="privacy.js"></script>
<script src="info.js"></script>
<script src="content.js"></script>
<script src="content.js" crossorigin="anonymous"></script>
<script src="i2pcontrol.js"></script>
</body>