[or-cvs] r19951: {torbutton} (in torbutton/branches/gsoc2009-koryk/src: chrome/content chrome/locale/en components defaults/preferences)
koryk at seul.org
koryk at seul.org
Wed Jul 8 18:16:05 UTC 2009
Author: koryk
Date: 2009-07-08 14:16:04 -0400 (Wed, 08 Jul 2009)
New Revision: 19951
Modified:
torbutton/branches/gsoc2009-koryk/src/chrome/content/preferences.js
torbutton/branches/gsoc2009-koryk/src/chrome/content/preferences.xul
torbutton/branches/gsoc2009-koryk/src/chrome/locale/en/torbutton.dtd
torbutton/branches/gsoc2009-koryk/src/components/torRefSpoofer.js
torbutton/branches/gsoc2009-koryk/src/defaults/preferences/preferences.js
Log:
Modified: torbutton/branches/gsoc2009-koryk/src/chrome/content/preferences.js
===================================================================
--- torbutton/branches/gsoc2009-koryk/src/chrome/content/preferences.js 2009-07-08 16:42:13 UTC (rev 19950)
+++ torbutton/branches/gsoc2009-koryk/src/chrome/content/preferences.js 2009-07-08 18:16:04 UTC (rev 19951)
@@ -239,7 +239,9 @@
doc.getElementById('torbutton_startPrevious');
break;
}
-
+
+ doc.getElementById('torbutton_refererSpoofGroup').selectedIndex = o_torprefs.getIntPref('refererspoof');
+
doc.getElementById('torbutton_torSessionStore').checked = !o_torprefs.getBoolPref('notor_sessionstore');
doc.getElementById('torbutton_nonTorSessionStore').checked = !o_torprefs.getBoolPref('nonontor_sessionstore');
@@ -257,7 +259,7 @@
doc.getElementById('torbutton_closeNonTor').checked = o_torprefs.getBoolPref('close_nontor');
doc.getElementById('torbutton_noUpdates').checked = o_torprefs.getBoolPref('no_updates');
doc.getElementById('torbutton_setUagent').checked = o_torprefs.getBoolPref('set_uagent');
- doc.getElementById('torbutton_noReferer').checked = o_torprefs.getBoolPref('disable_referer');
+ doc.getElementById('torbutton_spoofRefresh').checked = o_torprefs.getBoolPref('fakerefresh');
doc.getElementById('torbutton_spoofEnglish').checked = o_torprefs.getBoolPref('spoof_english');
doc.getElementById('torbutton_clearHttpAuth').checked = o_torprefs.getBoolPref('clear_http_auth');
doc.getElementById('torbutton_blockJSHistory').checked = o_torprefs.getBoolPref('block_js_history');
@@ -423,10 +425,11 @@
o_torprefs.setBoolPref('no_updates', doc.getElementById('torbutton_noUpdates').checked);
o_torprefs.setBoolPref('set_uagent', doc.getElementById('torbutton_setUagent').checked);
- o_torprefs.setBoolPref('disable_referer', doc.getElementById('torbutton_noReferer').checked);
+ o_torprefs.setBoolPref('fakerefresh', doc.getElementById('torbutton_spoofRefresh').checked);
o_torprefs.setBoolPref('spoof_english', doc.getElementById('torbutton_spoofEnglish').checked);
o_torprefs.setBoolPref('locked_mode', doc.getElementById('torbutton_lockedMode').checked);
+ o_torprefs.setIntPref('refererspoof',doc.getElementById('torbutton_refererSpoofGroup').selectedIndex);
/*
o_torprefs.setBoolPref('jar_certs', doc.getElementById('torbutton_jarCerts').checked);
o_torprefs.setBoolPref('jar_ca_certs',
Modified: torbutton/branches/gsoc2009-koryk/src/chrome/content/preferences.xul
===================================================================
--- torbutton/branches/gsoc2009-koryk/src/chrome/content/preferences.xul 2009-07-08 16:42:13 UTC (rev 19950)
+++ torbutton/branches/gsoc2009-koryk/src/chrome/content/preferences.xul 2009-07-08 18:16:04 UTC (rev 19951)
@@ -311,9 +311,17 @@
oncommand="torbutton_prefs_set_field_attributes(document)"/>
<checkbox id="torbutton_jarCACerts" label="&torbutton.prefs.jar_ca_certs;"
oncommand="torbutton_prefs_set_field_attributes(document)"/>
+
+ <checkbox id="torbutton_no er" label="&torbutton.prefs.disable_referer;"
+ oncommand="torbutton_prefs_set_field_attributes(document)"/>
-->
- <checkbox id="torbutton_noReferer" label="&torbutton.prefs.disable_referer;"
- oncommand="torbutton_prefs_set_field_attributes(document)"/>
+ <checkbox id="torbutton_spoofRefresh" label="&torbutton.prefs.spoofreresh;" oncommand="torbutton_prefs_set_field_attributes(document)" />
+ <radiogroup id="torbutton_refererSpoofGroup" label="&torbutton.prefs.refereroptions;">
+ <radio id="torbutton_noRefSpoof" label="&torbutton.prefs.nospoof;" oncommand="torbutton_prefs_set_field_attributes(document)" />
+ <radio id="torbutton_SpoofRoot" label="&torbutton.prefs.spoofroot;" selected="true" oncommand="torbutton_prefs_set_field_attributes(document)" />
+ <radio id="torbutton_SpoofDomain" label="&torbutton.prefs.spoofdomain;" oncommand="torbutton_prefs_set_field_attributes(document)" />
+ <radio id="torbutton_BlankReferer" label="&torbutton.prefs.spoofblank;" oncommand="torbutton_prefs_set_field_attributes(document)" />
+ </radiogroup>
</vbox>
</tabpanel>
</tabpanels>
Modified: torbutton/branches/gsoc2009-koryk/src/chrome/locale/en/torbutton.dtd
===================================================================
--- torbutton/branches/gsoc2009-koryk/src/chrome/locale/en/torbutton.dtd 2009-07-08 16:42:13 UTC (rev 19950)
+++ torbutton/branches/gsoc2009-koryk/src/chrome/locale/en/torbutton.dtd 2009-07-08 18:16:04 UTC (rev 19951)
@@ -90,3 +90,9 @@
<!ENTITY torbutton.prefs.tor_tabs "Tabs loaded in Tor">
<!ENTITY torbutton.prefs.socks_vfour "SOCKS v4">
<!ENTITY torbutton.prefs.socks_vfive "SOCKS v5">
+<!ENTITY torbutton.prefs.spoofreresh "Spoof Refresh">
+<!ENTITY torbutton.prefs.refereroptions "Referer Spoofing Options">
+<!ENTITY torbutton.prefs.nospoof "Do not spoof referer">
+<!ENTITY torbutton.prefs.spoofroot "Spoof the root of the site.">
+<!ENTITY torbutton.prefs.spoofdomain "Spoof the domain as referer.">
+<!ENTITY torbutton.prefs.spoofblank "Make referer blank.">
Modified: torbutton/branches/gsoc2009-koryk/src/components/torRefSpoofer.js
===================================================================
--- torbutton/branches/gsoc2009-koryk/src/components/torRefSpoofer.js 2009-07-08 16:42:13 UTC (rev 19950)
+++ torbutton/branches/gsoc2009-koryk/src/components/torRefSpoofer.js 2009-07-08 18:16:04 UTC (rev 19951)
@@ -1,8 +1,12 @@
function LOG(text)
{
- var logger = Components.classes["@torproject.org/torbutton-logger;1"].getService(Components.interfaces.nsISupports).wrappedJSObject;
- logger.log(text);
+ //var logger = Components.classes["@torproject.org/torbutton-logger;1"].getService(Components.interfaces.nsISupports).wrappedJSObject;
+ //logger.log("RefSpoof " + text);
+ var prompt = Components.classes["@mozilla.org/embedcomp/prompt-service;1"]
+ .getService(Components.interfaces.nsIPromptService);
+ prompt.alert(null, "debug", text);
+
}
@@ -11,19 +15,71 @@
observe: function(subject, topic, data)
{
if (topic == "http-on-modify-request") {
- LOG("----------------------------> (" + subject + ") mod request");
- var httpChannel = subject.QueryInterface(Components.interfaces.nsIHttpChannel);
- httpChannel.setRequestHeader("referer", "http://foo.com", false);
+ //LOG("----------------------------> (" + subject + ") mod request");
+ subject.QueryInterface(Components.interfaces.nsIHttpChannel);
+ this.onModifyRequest(subject);
return;
- }
+ }
if (topic == "app-startup") {
- LOG("----------------------------> app-startup");
+ //LOG("----------------------------> app-startup");
var os = Components.classes["@mozilla.org/observer-service;1"].getService(Components.interfaces.nsIObserverService);
os.addObserver(this, "http-on-modify-request", false);
return;
}
},
-
+ onModifyRequest: function(oHttpChannel)
+ {
+ var prefs = Components.classes["@mozilla.org/preferences-service;1"]
+ .getService(Components.interfaces.nsIPrefBranch);
+
+ var spoofmode = prefs.getIntPref("extensions.torbutton.refererspoof");
+ try {
+ oHttpChannel.QueryInterface(Components.interfaces.nsIChannel);
+ var requestURI = oHttpChannel.URI;
+
+
+ switch(spoofmode)
+ {
+ //no spoof, should give the regular referer (not recommended)
+ case 0:
+ return;
+ //spoof document root
+ case 1:
+ this.adjustRef(oHttpChannel, requestURI.host + requestURI.path);
+ break;
+ //spoof domain
+ case 2:
+ this.adjustRef(oHttpChannel, requestURI.host);
+ break;
+ //spoof no referer
+ case 3:
+ this.adjustRef(oHttpChannel, "");
+ break;
+ }
+
+ // handle wildcarding
+ // try matching "www.foo.example.com", "foo.example.com", "example.com", ...
+
+ // didn't find any matches, fall back on configured default action
+ } catch (ex) {
+ LOG("onModifyRequest: " + ex);
+ }
+ },
+ adjustRef: function(oChannel, sRef)
+ {
+ try {
+ if (oChannel.referrer)
+ {
+ oChannel.referrer.spec = sRef;
+ oChannel.setRequestHeader("Referer", sRef, false);
+ }
+ return true;
+ }
+ catch (ex) {
+ LOG("adjustRef: " + ex);
+ }
+ return false;
+ },
QueryInterface: function(iid)
{
if (!iid.equals(Components.interfaces.nsISupports) &&
@@ -38,17 +94,17 @@
myCID: Components.ID("65be2be0-ceb4-44c2-91a5-9c75c53430bf"),
myProgID: "@torproject.org/torRefSpoofer;1",
- myName: "Ref Spoofer Component",
+ myName: "RefSpoofComp",
registerSelf: function (compMgr, fileSpec, location, type) {
var compMgr = compMgr.QueryInterface(Components.interfaces.nsIComponentRegistrar);
compMgr.registerFactoryLocation(this.myCID,this.myName,this.myProgID,fileSpec,location,type);
- LOG("----------------------------> registerSelf");
+ //LOG("----------------------------> registerSelf");
var catMgr = Components.classes["@mozilla.org/categorymanager;1"].getService(Components.interfaces.nsICategoryManager);
catMgr.addCategoryEntry("app-startup", this.myName, this.myProgID, true, true);
},
getClassObject: function (compMgr, cid, iid) {
- LOG("----------------------------> getClassObject");
+ //LOG("----------------------------> getClassObject");
return this.myFactory;
},
@@ -78,7 +134,7 @@
{
if (outer != null)
throw Components.results.NS_ERROR_NO_AGGREGATION;
- return myObserver.QueryInterface(iid);
+ return refObserver.QueryInterface(iid);
}
}
};
Modified: torbutton/branches/gsoc2009-koryk/src/defaults/preferences/preferences.js
===================================================================
--- torbutton/branches/gsoc2009-koryk/src/defaults/preferences/preferences.js 2009-07-08 16:42:13 UTC (rev 19950)
+++ torbutton/branches/gsoc2009-koryk/src/defaults/preferences/preferences.js 2009-07-08 18:16:04 UTC (rev 19951)
@@ -136,6 +136,8 @@
pref("extensions.torbutton.tor_memory_jar",false);
pref("extensions.torbutton.nontor_memory_jar",false);
pref("extensions.torbutton.tz_string","");
+pref("extensions.torbutton.refererspoof", 0); //0=no spoof, 1=root spoof, 2=domain spoof, 3=blank spoof
+pref("extensions.torbutton.fakerefresh", false);
// User agent prefs:
pref("extensions.torbutton.appname_override","Netscape");
More information about the tor-commits
mailing list