Files
I2P_in_Private_Browsing_Mod…/host.js

137 lines
3.5 KiB
JavaScript
Raw Normal View History

2019-11-23 18:41:18 -05:00
function proxyHost(url) {
2020-06-22 21:49:14 -04:00
let hostname = '';
if (url.indexOf('://') > -1) {
hostname = url.split('/')[2];
2019-11-23 18:41:18 -05:00
} else {
2020-06-22 21:49:14 -04:00
hostname = url.split('/')[0];
2019-11-23 18:41:18 -05:00
}
2020-06-22 21:49:14 -04:00
if (hostname == 'proxy.i2p') {
2019-11-23 18:41:18 -05:00
return true;
}
if (
2020-06-22 21:49:14 -04:00
hostname == 'c6lilt4cr5x7jifxridpkesf2zgfwqfchtp6laihr4pdqomq25iq.b32.i2p'
) {
2020-03-17 22:53:41 -04:00
return true;
}
2019-11-23 18:41:18 -05:00
return false;
}
function localHost(url) {
2020-06-22 21:49:14 -04:00
let hostname = '';
if (url.indexOf('://') > -1) {
hostname = url.split('/')[2];
2019-11-23 18:41:18 -05:00
} else {
2020-06-22 21:49:14 -04:00
hostname = url.split('/')[0];
2019-11-23 18:41:18 -05:00
}
2020-06-22 21:49:14 -04:00
hostname = hostname.split(':')[0];
if (hostname === '127.0.0.1') {
2019-11-23 18:41:18 -05:00
return true;
2020-06-22 21:49:14 -04:00
} else if (hostname === 'localhost') {
2019-11-23 18:41:18 -05:00
return true;
}
return false;
}
function extensionHost(url) {
2020-01-14 10:26:35 -05:00
if (url.originUrl !== undefined) {
2020-06-22 21:49:14 -04:00
var res = url.originUrl.startsWith(browser.runtime.getURL(''));
2020-01-14 10:26:35 -05:00
if (res) return res;
}
if (url.url !== undefined) {
2020-06-22 21:49:14 -04:00
var res = url.url.startsWith(browser.runtime.getURL(''));
2020-01-14 10:26:35 -05:00
if (res) return res;
}
}
2019-11-23 18:41:18 -05:00
function i2pHostName(url) {
2020-06-22 21:49:14 -04:00
let hostname = '';
if (url.indexOf('://') > -1) {
hostname = url.split('/')[2];
2019-11-23 18:41:18 -05:00
} else {
2020-06-22 21:49:14 -04:00
hostname = url.split('/')[0];
2019-11-23 18:41:18 -05:00
}
return hostname;
}
function i2pHost(url) {
let hostname = i2pHostName(url);
2020-06-22 21:49:14 -04:00
return hostname.endsWith('.i2p');
2019-11-23 18:41:18 -05:00
}
function routerHost(url) {
2020-06-22 21:49:14 -04:00
let hostname = '';
let path = '';
2019-11-23 18:41:18 -05:00
function pathcheck(str) {
if (str != undefined) {
2020-06-22 21:49:14 -04:00
let final = str.split('/')[0];
if (final === 'i2ptunnelmgr' || final === 'i2ptunnel') {
console.log('(urlcheck) Tunnel application path', final);
return 'i2ptunnelmgr';
2020-01-13 20:12:09 -05:00
} else if (
2020-06-22 21:49:14 -04:00
final === 'i2psnark' ||
final === 'torrents' ||
final.startsWith('transmission') ||
final.startsWith('tracker')
2020-01-13 20:12:09 -05:00
) {
2020-06-22 21:49:14 -04:00
console.log('(urlcheck) Torrent application path', final);
return 'i2psnark';
} else if (final === 'webmail' || final === 'susimail') {
console.log('(urlcheck) Mail application path', final);
return 'webmail';
} else if (final.startsWith('MuWire')) {
if (!url.includes('.png')) {
console.log('(urlcheck) MuWire application path', final);
return 'muwire';
2020-03-24 19:46:37 -04:00
}
2019-11-23 18:41:18 -05:00
} else if (
2020-06-22 21:49:14 -04:00
final === 'home' ||
final === 'console' ||
final === 'dns' ||
final === 'sitemap' ||
final.startsWith('config')
2019-11-23 18:41:18 -05:00
) {
2020-06-22 21:49:14 -04:00
console.log('(urlcheck) Console application path', final);
return 'routerconsole';
2019-11-23 18:41:18 -05:00
}
}
return true;
}
2020-06-22 21:49:14 -04:00
if (url.indexOf('://') > -1) {
hostname = url.split('/')[2];
let prefix = url.substr(0, url.indexOf('://') + 3);
path = url.replace(prefix + hostname + '/', '');
2019-11-23 18:41:18 -05:00
} else if (identifyProtocolHandler(url)) {
let newurl = identifyProtocolHandler(url);
return routerHost(newurl);
2019-11-23 18:41:18 -05:00
} else {
2020-06-22 21:49:14 -04:00
hostname = url.split('/')[0];
path = url.replace(hostname + '/', '');
2019-11-23 18:41:18 -05:00
}
2020-06-22 21:49:14 -04:00
if (hostname === control_host + ':' + control_port) {
return pathcheck(path);
2019-11-23 18:41:18 -05:00
}
if (hostname === control_host + ':' + '7662') {
return pathcheck(path);
}
if (hostname === 'localhost' + ':' + '7662') {
return pathcheck(path);
}
if (hostname === '127.0.0.1' + ':' + '7662') {
return pathcheck(path);
}
2020-06-22 21:49:14 -04:00
if (hostname === 'localhost' + ':' + control_port) {
return pathcheck(path);
}
2020-06-22 21:49:14 -04:00
if (hostname === '127.0.0.1' + ':' + control_port) {
return pathcheck(path);
}
2020-06-22 21:49:14 -04:00
if (hostname === 'localhost' + ':' + 7070) {
return pathcheck(path);
}
2020-06-22 21:49:14 -04:00
if (hostname === '127.0.0.1' + ':' + 7070) {
return pathcheck(path);
}
2019-11-23 18:41:18 -05:00
return false;
}