2022-10-07 13:26:09 -04:00
|
|
|
function proxyHost(requestDetails) {
|
2022-10-24 16:04:35 -04:00
|
|
|
if (requestDetails.originUrl != browser.runtime.getURL('window.html')) {
|
|
|
|
} else if (requestDetails.originUrl != browser.runtime.getURL('home.html')) {
|
2022-10-16 16:50:28 -04:00
|
|
|
} else {
|
|
|
|
return false;
|
|
|
|
}
|
2022-10-16 15:00:54 -04:00
|
|
|
|
2022-10-24 16:04:35 -04:00
|
|
|
let hostname = '';
|
|
|
|
if (requestDetails.url.indexOf('://') > -1) {
|
|
|
|
hostname = requestDetails.url.split('/')[2];
|
2022-10-16 16:50:28 -04:00
|
|
|
} else {
|
2022-10-24 16:04:35 -04:00
|
|
|
hostname = requestDetails.url.split('/')[0];
|
2022-10-16 16:50:28 -04:00
|
|
|
}
|
2022-10-24 16:04:35 -04:00
|
|
|
console.warn('(host) hostname', hostname);
|
|
|
|
if (hostname == 'proxy.i2p') {
|
|
|
|
console.warn('(host) is proxy.i2p', hostname);
|
2022-10-16 16:50:28 -04:00
|
|
|
return true;
|
|
|
|
}
|
2022-10-16 16:08:01 -04:00
|
|
|
|
2022-10-24 16:04:35 -04:00
|
|
|
console.warn('(host) requestDetails', requestDetails.url);
|
2022-10-16 16:50:28 -04:00
|
|
|
if (
|
2022-10-24 16:04:35 -04:00
|
|
|
hostname == 'c6lilt4cr5x7jifxridpkesf2zgfwqfchtp6laihr4pdqomq25iq.b32.i2p'
|
2022-10-16 16:50:28 -04:00
|
|
|
) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
2019-11-23 18:41:18 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
function localHost(url) {
|
2022-10-24 16:04:35 -04:00
|
|
|
let hostname = '';
|
|
|
|
if (url.indexOf('://') > -1) {
|
|
|
|
hostname = url.split('/')[2];
|
2022-10-16 16:50:28 -04:00
|
|
|
} else {
|
2022-10-24 16:04:35 -04:00
|
|
|
hostname = url.split('/')[0];
|
|
|
|
}
|
|
|
|
hostname = hostname.split(':')[0];
|
|
|
|
console.log('(urlcheck) hostname localhost', hostname);
|
|
|
|
console.log('(urlcheck) url localhost', url);
|
|
|
|
if (hostname === '127.0.0.1') {
|
|
|
|
if (url.indexOf(':8084') != -1) return 'blog';
|
|
|
|
if (url.indexOf(':7669') != -1) return 'irc';
|
|
|
|
if (url.indexOf(':7695') != -1) return 'tor';
|
|
|
|
} else if (hostname === 'localhost') {
|
|
|
|
if (url.indexOf(':8084') != -1) return 'blog';
|
|
|
|
if (url.indexOf(':7669') != -1) return 'irc';
|
|
|
|
if (url.indexOf(':7695') != -1) return 'tor';
|
2022-10-16 16:50:28 -04:00
|
|
|
}
|
2019-11-23 18:41:18 -05:00
|
|
|
|
2022-10-16 16:50:28 -04:00
|
|
|
return false;
|
2019-11-23 18:41:18 -05:00
|
|
|
}
|
|
|
|
|
2019-11-26 01:07:48 -05:00
|
|
|
function extensionHost(url) {
|
2022-10-16 16:50:28 -04:00
|
|
|
var prefix = browser.runtime
|
2022-10-24 16:04:35 -04:00
|
|
|
.getURL('')
|
|
|
|
.replace('moz-extension://', '')
|
|
|
|
.replace('/', '');
|
2022-10-16 16:50:28 -04:00
|
|
|
if (url.originUrl !== undefined) {
|
|
|
|
var originUrl = url.originUrl
|
2022-10-24 16:04:35 -04:00
|
|
|
.replace('moz-extension://', '')
|
|
|
|
.replace('/', '');
|
2022-10-16 16:50:28 -04:00
|
|
|
// console.log("(urlcheck) Extension application path", originUrl);
|
|
|
|
// console.log("(urlcheck) Extension application path", prefix);
|
|
|
|
var res = originUrl.startsWith(prefix);
|
|
|
|
// console.log("(urlcheck) Extension application path", res);
|
|
|
|
if (res) return res;
|
|
|
|
}
|
|
|
|
if (url.documentUrl !== undefined) {
|
|
|
|
// console.log("(urlcheck) Extension application path", originUrl);
|
|
|
|
// console.log("(urlcheck) Extension application path", prefix);
|
|
|
|
var res = originUrl.startsWith(prefix);
|
|
|
|
// console.log("(urlcheck) Extension application path", res);
|
|
|
|
if (res) return res;
|
|
|
|
}
|
2022-10-24 16:04:35 -04:00
|
|
|
console.log('(urlcheck) Extension application path', url);
|
2019-11-26 01:07:48 -05:00
|
|
|
}
|
|
|
|
|
2019-11-23 18:41:18 -05:00
|
|
|
function i2pHostName(url) {
|
2022-10-24 16:04:35 -04:00
|
|
|
let hostname = '';
|
|
|
|
console.log('(hosts)', url);
|
2022-10-16 16:50:28 -04:00
|
|
|
let u = new URL(url);
|
2022-10-24 16:04:35 -04:00
|
|
|
if (u.host.endsWith('.i2p')) {
|
2022-10-16 16:50:28 -04:00
|
|
|
hostname = u.host;
|
2022-10-24 16:04:35 -04:00
|
|
|
} else if (url.includes('=')) {
|
|
|
|
if (url.includes('.i2p')) {
|
|
|
|
lsit = url.split('=');
|
2022-10-16 16:50:28 -04:00
|
|
|
for (let item in lsit) {
|
|
|
|
var items = lsit[item].split(`\ % `); //"\%")
|
|
|
|
for (let p in items) {
|
2022-10-24 16:04:35 -04:00
|
|
|
if (items[p].includes('.i2p')) {
|
|
|
|
hostname = items[p].replace('3D', 1);
|
2022-10-16 16:50:28 -04:00
|
|
|
}
|
|
|
|
break;
|
2022-10-07 19:32:52 -04:00
|
|
|
}
|
2022-10-24 16:04:35 -04:00
|
|
|
if (hostname != '') {
|
2022-10-16 16:50:28 -04:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2022-10-24 16:04:35 -04:00
|
|
|
} else if (url.indexOf('://') > -1) {
|
|
|
|
hostname = url.split('/')[2];
|
2022-10-16 16:50:28 -04:00
|
|
|
} else {
|
2022-10-24 16:04:35 -04:00
|
|
|
hostname = url.split('/')[0];
|
2022-10-16 16:50:28 -04:00
|
|
|
}
|
2022-10-24 16:04:35 -04:00
|
|
|
console.log('(hosts) scrub', hostname);
|
2022-10-16 16:50:28 -04:00
|
|
|
return hostname;
|
2019-11-23 18:41:18 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
function i2pHost(url) {
|
2022-10-16 16:50:28 -04:00
|
|
|
if (proxyHost(url)) {
|
2022-10-24 16:04:35 -04:00
|
|
|
console.warn('(host) proxy.i2p', url.url);
|
2022-10-16 16:50:28 -04:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
let hostname = i2pHostName(url.url);
|
2022-10-24 16:04:35 -04:00
|
|
|
let postname = hostname.split(':')[0];
|
|
|
|
if (postname.endsWith('proxy.i2p')) {
|
2022-10-16 16:50:28 -04:00
|
|
|
return false;
|
|
|
|
}
|
2022-10-24 16:04:35 -04:00
|
|
|
return postname.endsWith('.i2p');
|
2019-11-23 18:41:18 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
function routerHost(url) {
|
2022-10-16 16:50:28 -04:00
|
|
|
// console.log("(urlcheck) HOST URL CHECK");
|
2022-10-24 16:04:35 -04:00
|
|
|
let hostname = '';
|
|
|
|
let path = '';
|
2022-02-15 21:15:47 -05:00
|
|
|
|
2022-10-16 16:50:28 -04:00
|
|
|
function pathcheck(str) {
|
|
|
|
if (str != undefined) {
|
2022-10-24 16:04:35 -04:00
|
|
|
let final = str.split('/')[0];
|
|
|
|
if (final === 'i2ptunnelmgr' || final === 'i2ptunnel') {
|
|
|
|
console.log('(urlcheck) Tunnel application path', final);
|
|
|
|
return 'i2ptunnelmgr';
|
2022-10-16 16:50:28 -04:00
|
|
|
} else if (
|
2022-10-24 16:04:35 -04:00
|
|
|
final === 'i2psnark' ||
|
|
|
|
final === 'torrents' ||
|
|
|
|
final.startsWith('transmission') ||
|
|
|
|
final.startsWith('tracker') ||
|
|
|
|
url.includes(':7662')
|
2022-10-16 16:50:28 -04:00
|
|
|
) {
|
2022-10-24 16:04:35 -04:00
|
|
|
console.log('(urlcheck) Torrent application path', final);
|
|
|
|
return 'i2psnark';
|
|
|
|
} else if (final === 'webmail' || final === 'susimail') {
|
|
|
|
if (!url.includes('.css')) {
|
|
|
|
console.log('(urlcheck) Mail application path', final);
|
|
|
|
return 'webmail';
|
2022-10-07 19:32:52 -04:00
|
|
|
}
|
2022-10-24 16:04:35 -04:00
|
|
|
} else if (final.startsWith('MuWire')) {
|
|
|
|
if (!url.includes('.png')) {
|
|
|
|
console.log('(urlcheck) MuWire application path', final);
|
|
|
|
return 'muwire';
|
2022-10-16 16:50:28 -04:00
|
|
|
}
|
2022-10-24 16:04:35 -04:00
|
|
|
} else if (final.startsWith('i2pbote')) {
|
|
|
|
if (!url.includes('.png')) {
|
|
|
|
console.log('(urlcheck) I2PBote application path', final);
|
|
|
|
return 'i2pbote';
|
2022-10-16 16:50:28 -04:00
|
|
|
}
|
|
|
|
} else if (
|
2022-10-24 16:04:35 -04:00
|
|
|
final === 'home' ||
|
|
|
|
final === 'console' ||
|
|
|
|
final === 'dns' ||
|
|
|
|
final === 'susidns' ||
|
|
|
|
final.startsWith('susidns') ||
|
|
|
|
final === 'sitemap' ||
|
|
|
|
final.startsWith('config')
|
2022-10-16 16:50:28 -04:00
|
|
|
) {
|
2022-10-24 16:04:35 -04:00
|
|
|
console.log('(urlcheck) Console application path', final);
|
|
|
|
return 'routerconsole';
|
2022-10-16 16:50:28 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
2022-10-24 16:04:35 -04:00
|
|
|
if (url.indexOf('://') > -1) {
|
|
|
|
hostname = url.split('/')[2];
|
|
|
|
let prefix = url.substr(0, url.indexOf('://') + 3);
|
|
|
|
path = url.replace(prefix + hostname + '/', '');
|
2022-10-16 16:50:28 -04:00
|
|
|
} else if (identifyProtocolHandler(url)) {
|
|
|
|
let newurl = identifyProtocolHandler(url);
|
|
|
|
return routerHost(newurl);
|
|
|
|
} else {
|
2022-10-24 16:04:35 -04:00
|
|
|
hostname = url.split('/')[0];
|
|
|
|
path = url.replace(hostname + '/', '');
|
2022-10-16 16:50:28 -04:00
|
|
|
}
|
2022-10-24 16:04:35 -04:00
|
|
|
if (hostname === control_host + ':' + control_port) {
|
2022-10-16 16:50:28 -04:00
|
|
|
return pathcheck(path);
|
|
|
|
}
|
2022-10-24 16:04:35 -04:00
|
|
|
if (hostname === 'localhost' + ':' + control_port) {
|
2022-10-16 16:50:28 -04:00
|
|
|
return pathcheck(path);
|
|
|
|
}
|
2022-10-24 16:04:35 -04:00
|
|
|
if (hostname === '127.0.0.1' + ':' + control_port) {
|
2022-10-16 16:50:28 -04:00
|
|
|
return pathcheck(path);
|
|
|
|
}
|
2022-10-24 16:04:35 -04:00
|
|
|
if (hostname === 'localhost' + ':' + 7070) {
|
2022-10-16 16:50:28 -04:00
|
|
|
return pathcheck(path);
|
|
|
|
}
|
2022-10-24 16:04:35 -04:00
|
|
|
if (hostname === '127.0.0.1' + ':' + 7070) {
|
2022-10-16 16:50:28 -04:00
|
|
|
return pathcheck(path);
|
|
|
|
}
|
2022-10-24 16:04:35 -04:00
|
|
|
if (hostname === 'localhost' + ':' + 7667) {
|
2022-10-16 16:50:28 -04:00
|
|
|
return pathcheck(path);
|
|
|
|
}
|
2022-10-24 16:04:35 -04:00
|
|
|
if (hostname === '127.0.0.1' + ':' + 7667) {
|
2022-10-16 16:50:28 -04:00
|
|
|
return pathcheck(path);
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|