aboutsummaryrefslogtreecommitdiffstats
path: root/js
diff options
context:
space:
mode:
Diffstat (limited to 'js')
-rw-r--r--js/background.js1
-rw-r--r--js/settings.js1
-rw-r--r--js/vapi-background.js47
3 files changed, 43 insertions, 6 deletions
diff --git a/js/background.js b/js/background.js
index 7ac9ef2..9f14a36 100644
--- a/js/background.js
+++ b/js/background.js
@@ -174,6 +174,7 @@ var ηMatrix = (function () {
processHyperlinkAuditing: true,
processReferer: false,
disableUpdateIcon: false,
+ resolveCname: false,
},
rawSettingsDefault: rawSettingsDefault,
diff --git a/js/settings.js b/js/settings.js
index 8a8d25a..6984b2e 100644
--- a/js/settings.js
+++ b/js/settings.js
@@ -83,6 +83,7 @@
case 'iconBadgeEnabled':
case 'processHyperlinkAuditing':
case 'disableUpdateIcon':
+ case 'resolveCname':
changeUserSettings(target.id, target.checked);
break;
case 'collapseBlocked':
diff --git a/js/vapi-background.js b/js/vapi-background.js
index e5e6998..061ae29 100644
--- a/js/vapi-background.js
+++ b/js/vapi-background.js
@@ -313,12 +313,7 @@
return this.mimeTypeMap[mime.slice(0, pos)] || 0;
},
- observe: function (channel, topic) {
- if (channel instanceof Ci.nsIHttpChannel === false) {
- return;
- }
-
- let URI = channel.URI;
+ operate: function (channel, URI, topic) {
let channelData = this.channelDataFromChannel(channel);
if (topic.lastIndexOf('http-on-examine-', 0) === 0) {
@@ -423,6 +418,46 @@
// Carry data for behind-the-scene redirects
channel.setProperty(this.REQDATAKEY, [tabId, rawType]);
},
+ observe: function (channel, topic) {
+ if (channel instanceof Ci.nsIHttpChannel === false) {
+ return;
+ }
+
+ let URI = channel.URI;
+ let channelData = this.channelDataFromChannel(channel);
+
+ if (ηMatrix.userSettings.resolveCname === true) {
+ let CC = Components.classes;
+ let CI = Components.interfaces;
+
+ let dns = CC['@mozilla.org/network/dns-service;1']
+ .createInstance(CI.nsIDNSService);
+
+ let listener = {
+ onLookupComplete: function (req, rec, stat) {
+ if (!Components.isSuccessCode(stat)) {
+ console.error("can't resolve canonical name");
+ return;
+ }
+ let addr = rec.canonicalName;
+
+ let ios = CC['@mozilla.org/network/io-service;1']
+ .createInstance(CI.nsIIOService);
+
+ let uri = ios.newURI(URI.scheme+'://'+addr, null, null);
+
+ vAPI.httpObserver.operate(channel, uri, topic);
+ },
+ };
+
+ dns.asyncResolve(URI.host,
+ CI.nsIDNSService.RESOLVE_CANONICAL_NAME,
+ listener,
+ null);
+ } else {
+ this.operate(channel, URI, topic);
+ }
+ },
asyncOnChannelRedirect: function (oldChannel, newChannel,
flags, callback) {
// contentPolicy.shouldLoad doesn't detect redirects, this