GitLab is used only for code review, issue tracking and project management. Canonical locations for source code are still https://gitweb.torproject.org/ https://git.torproject.org/ and git-rw.torproject.org.

Commit ef321f7e authored by Kathleen Brade's avatar Kathleen Brade
Browse files

Bug 6009: Tor Launcher initial commit.

parents
### Copyright (c) 2013, The Tor Project, Inc.
### See src/LICENSE for licensing information.
EXT_NAME=torlauncher
XPI_NAME:=$(shell echo "$(EXT_NAME)-`grep em:version src/install.rdf | sed -e 's/[<>]/ /g' | cut -f3`.xpi")
AVAIL_TARGETS=help package clean
ifeq ($(VERBOSE),1)
ZIP=zip
else
ZIP=zip -q
endif
help:
@echo "Available targets:"; \
for t in $(AVAIL_TARGETS); do \
echo " make $$t"; \
done
package: clean
@mkdir -p pkg
@(cd src; $(ZIP) -X9r "../pkg/$(XPI_NAME)" ./ -x "*.diff")
@echo "Created package pkg/$(XPI_NAME)"
clean:
@rm -f "pkg/$(XPI_NAME)"
zip:
@TMPFILE=/tmp/$(EXT_NAME)-`date '+%Y-%m-%d-%s'`.zip; \
CURDIR=`pwd`; \
BASEDIR=`basename $$CURDIR`; \
cd ..; zip -q -r $$TMPFILE $$BASEDIR -x $$BASEDIR/build/\*; \
rm $$TMPFILE
.PHONY: help clean zip
Copyright (c) 2013, The Tor Project, Inc.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the following disclaimer
in the documentation and/or other materials provided with the
distribution.
* Neither the names of the copyright owners nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
### Copyright (c) 2013, The Tor Project, Inc.
### See LICENSE for licensing information.
content torlauncher chrome/content/
locale torlauncher af chrome/locale/af/
locale torlauncher ak chrome/locale/ak/
locale torlauncher am chrome/locale/am/
locale torlauncher ar chrome/locale/ar/
locale torlauncher arn chrome/locale/arn/
locale torlauncher ast chrome/locale/ast/
locale torlauncher az chrome/locale/az/
locale torlauncher be chrome/locale/be/
locale torlauncher bg chrome/locale/bg/
locale torlauncher bms chrome/locale/bms/
locale torlauncher bn chrome/locale/bn/
locale torlauncher bn-IN chrome/locale/bn-IN/
locale torlauncher bo chrome/locale/bo/
locale torlauncher br chrome/locale/br/
locale torlauncher bs chrome/locale/bs/
locale torlauncher ca chrome/locale/ca/
locale torlauncher cs chrome/locale/cs/
locale torlauncher csb chrome/locale/csb/
locale torlauncher cy chrome/locale/cy/
locale torlauncher da chrome/locale/da/
locale torlauncher de chrome/locale/de/
locale torlauncher dz chrome/locale/dz/
locale torlauncher el chrome/locale/el/
locale torlauncher en chrome/locale/en/
locale torlauncher eo chrome/locale/eo/
locale torlauncher es chrome/locale/es/
locale torlauncher et chrome/locale/et/
locale torlauncher eu chrome/locale/eu/
locale torlauncher fa chrome/locale/fa/
locale torlauncher fi chrome/locale/fi/
locale torlauncher fil chrome/locale/fil/
locale torlauncher fo chrome/locale/fo/
locale torlauncher fr chrome/locale/fr/
locale torlauncher fur chrome/locale/fur/
locale torlauncher fy chrome/locale/fy/
locale torlauncher ga chrome/locale/ga/
locale torlauncher gl chrome/locale/gl/
locale torlauncher gu chrome/locale/gu/
locale torlauncher gun chrome/locale/gun/
locale torlauncher ha chrome/locale/ha/
locale torlauncher he chrome/locale/he/
locale torlauncher hi chrome/locale/hi/
locale torlauncher hr chrome/locale/hr/
locale torlauncher ht chrome/locale/ht/
locale torlauncher hu chrome/locale/hu/
locale torlauncher hy chrome/locale/hy/
locale torlauncher id chrome/locale/id/
locale torlauncher is chrome/locale/is/
locale torlauncher it chrome/locale/it/
locale torlauncher ja chrome/locale/ja/
locale torlauncher jv chrome/locale/jv/
locale torlauncher ka chrome/locale/ka/
locale torlauncher km chrome/locale/km/
locale torlauncher kn chrome/locale/kn/
locale torlauncher ko chrome/locale/ko/
locale torlauncher ku chrome/locale/ku/
locale torlauncher kw chrome/locale/kw/
locale torlauncher ky chrome/locale/ky/
locale torlauncher lb chrome/locale/lb/
locale torlauncher lg chrome/locale/lg/
locale torlauncher ln chrome/locale/ln/
locale torlauncher lo chrome/locale/lo/
locale torlauncher lt chrome/locale/lt/
locale torlauncher lv chrome/locale/lv/
locale torlauncher mg chrome/locale/mg/
locale torlauncher mi chrome/locale/mi/
locale torlauncher mk chrome/locale/mk/
locale torlauncher ml chrome/locale/ml/
locale torlauncher mn chrome/locale/mn/
locale torlauncher mr chrome/locale/mr/
locale torlauncher ms chrome/locale/ms/
locale torlauncher mt chrome/locale/mt/
locale torlauncher my chrome/locale/my/
locale torlauncher nah chrome/locale/nah/
locale torlauncher nap chrome/locale/nap/
locale torlauncher nb chrome/locale/nb/
locale torlauncher ne chrome/locale/ne/
locale torlauncher nl chrome/locale/nl/
locale torlauncher nn chrome/locale/nn/
locale torlauncher nso chrome/locale/nso/
locale torlauncher oc chrome/locale/oc/
locale torlauncher or chrome/locale/or/
locale torlauncher pa chrome/locale/pa/
locale torlauncher pap chrome/locale/pap/
locale torlauncher pl chrome/locale/pl/
locale torlauncher pms chrome/locale/pms/
locale torlauncher ps chrome/locale/ps/
locale torlauncher pt chrome/locale/pt/
locale torlauncher pt-BR chrome/locale/pt-BR/
locale torlauncher ro chrome/locale/ro/
locale torlauncher ru chrome/locale/ru/
locale torlauncher sco chrome/locale/sco/
locale torlauncher sk chrome/locale/sk/
locale torlauncher sl chrome/locale/sl/
locale torlauncher so chrome/locale/so/
locale torlauncher son chrome/locale/son/
locale torlauncher sq chrome/locale/sq/
locale torlauncher sr chrome/locale/sr/
locale torlauncher st chrome/locale/st/
locale torlauncher su chrome/locale/su/
locale torlauncher sv chrome/locale/sv/
locale torlauncher sw chrome/locale/sw/
locale torlauncher ta chrome/locale/ta/
locale torlauncher te chrome/locale/te/
locale torlauncher tg chrome/locale/tg/
locale torlauncher th chrome/locale/th/
locale torlauncher ti chrome/locale/ti/
locale torlauncher tk chrome/locale/tk/
locale torlauncher tr chrome/locale/tr/
locale torlauncher uk chrome/locale/uk/
locale torlauncher ur chrome/locale/ur/
locale torlauncher ve chrome/locale/ve/
locale torlauncher vi chrome/locale/vi/
locale torlauncher wa chrome/locale/wa/
locale torlauncher wo chrome/locale/wo/
locale torlauncher zh-CN chrome/locale/zh-CN/
locale torlauncher zh-HK chrome/locale/zh-HK/
locale torlauncher zh-TW chrome/locale/zh-TW/
locale torlauncher zu chrome/locale/zu/
skin torlauncher classic/1.0 chrome/skin/
resource torlauncher /
# Firefox 4-style component registration
component {4F476361-23FB-43EF-A427-B36A14D3208E} components/tl-protocol.js
contract @torproject.org/torlauncher-protocol-service;1 {4F476361-23FB-43EF-A427-B36A14D3208E}
component {FE7B4CAF-BCF4-4848-8BFF-EFA66C9AFDA1} components/tl-process.js
contract @torproject.org/torlauncher-process-service;1 {FE7B4CAF-BCF4-4848-8BFF-EFA66C9AFDA1}
category profile-after-change TorProcessService @torproject.org/torlauncher-process-service;1
// Copyright (c) 2013, The Tor Project, Inc.
// See LICENSE for licensing information.
//
// vim: set sw=2 sts=2 ts=8 et syntax=javascript:
const Cc = Components.classes;
const Ci = Components.interfaces;
const Cu = Components.utils;
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
XPCOMUtils.defineLazyModuleGetter(this, "TorLauncherUtil",
"resource://torlauncher/modules/tl-util.jsm");
XPCOMUtils.defineLazyModuleGetter(this, "TorLauncherLogger",
"resource://torlauncher/modules/tl-logger.jsm");
const kPrefPromptAtStartup = "extensions.torlauncher.prompt_at_startup";
const kUseProxyCheckbox = "useProxy";
const kProxyTypeMenulist = "proxyType";
const kProxyAddr = "proxyAddr";
const kProxyPort = "proxyPort";
const kProxyUsername = "proxyUsername";
const kProxyPassword = "proxyPassword";
const kUseFirewallPortsCheckbox = "useFirewallPorts";
const kFirewallAllowedPorts = "firewallAllowedPorts";
const kUseBridgesCheckbox = "useBridges";
const kBridgeList = "bridgeList";
const kTorConfKeyDisableNetwork = "DisableNetwork";
const kTorConfKeySocks4Proxy = "Socks4Proxy";
const kTorConfKeySocks5Proxy = "Socks5Proxy";
const kTorConfKeySocks5ProxyUsername = "Socks5ProxyUsername";
const kTorConfKeySocks5ProxyPassword = "Socks5ProxyPassword";
const kTorConfKeyHTTPSProxy = "HTTPSProxy";
const kTorConfKeyHTTPSProxyAuthenticator = "HTTPSProxyAuthenticator";
const kTorConfKeyReachableAddresses = "ReachableAddresses";
const kTorConfKeyUseBridges = "UseBridges";
const kTorConfKeyBridgeList = "Bridge";
var gProtocolSvc = null;
var gTorProcessService = null;
var gIsInitialBootstrap = false;
var gIsBootstrapComplete = false;
function initDialog()
{
var okBtn = document.documentElement.getButton("accept");
gIsInitialBootstrap = TorLauncherUtil.getBoolPref(kPrefPromptAtStartup);
if (gIsInitialBootstrap)
{
document.documentElement.setAttribute("class", "initialBootstrap");
var cancelBtn = document.documentElement.getButton("cancel");
var quitKey = (TorLauncherUtil.isWindows) ? "quit_win" : "quit";
cancelBtn.label = TorLauncherUtil.getLocalizedString(quitKey);
okBtn.label = TorLauncherUtil.getLocalizedString("connect");
}
okBtn.focus();
try
{
var svc = Cc["@torproject.org/torlauncher-protocol-service;1"]
.getService(Ci.nsISupports);
gProtocolSvc = svc.wrappedJSObject;
}
catch (e) { dump(e + "\n"); }
try
{
var svc = Cc["@torproject.org/torlauncher-process-service;1"]
.getService(Ci.nsISupports);
gTorProcessService = svc.wrappedJSObject;
}
catch (e) { dump(e + "\n"); }
TorLauncherLogger.log(2, "initDialog retrieving tor settings " +
"----------------------------------------------");
var didSucceed = false;
try
{
// TODO: retrieve > 1 key at one time inside initProxySettings() et al.
didSucceed = initProxySettings() && initFirewallSettings() &&
initBridgeSettings();
}
catch (e) { TorLauncherLogger.safelog(4, "Error in initDialog: ", e); }
if (!didSucceed)
{
// Unable to communicate with tor. Hide settings and display an error.
setElemValue(kUseProxyCheckbox, false);
setElemValue(kUseFirewallPortsCheckbox, false);
setElemValue(kUseBridgesCheckbox, false);
setTimeout(function()
{
var details = TorLauncherUtil.getLocalizedString(
"ensure_tor_is_running");
var s = TorLauncherUtil.getFormattedLocalizedString(
"failed_to_get_settings", [details], 1);
TorLauncherUtil.showAlert(window, s);
close();
}, 0);
}
TorLauncherLogger.log(2, "initDialog done\n\n\n");
}
function onCancel()
{
if (gIsInitialBootstrap) try
{
var obsSvc = Cc["@mozilla.org/observer-service;1"]
.getService(Ci.nsIObserverService);
obsSvc.notifyObservers(null, "TorUserRequestedQuit", null);
} catch (e) {}
return true;
}
// Returns true if successful.
function initProxySettings()
{
var proxyType, proxyAddrPort, proxyUsername, proxyPassword;
var reply = gProtocolSvc.TorGetConfStr(kTorConfKeySocks4Proxy, null);
if (!gProtocolSvc.TorCommandSucceeded(reply))
return false;
if (reply.retVal)
{
proxyType = "SOCKS4";
proxyAddrPort = reply.retVal;
// TODO: disable user and password fields.
}
else
{
var reply = gProtocolSvc.TorGetConfStr(kTorConfKeySocks5Proxy, null);
if (!gProtocolSvc.TorCommandSucceeded(reply))
return false;
if (reply.retVal)
{
proxyType = "SOCKS5";
proxyAddrPort = reply.retVal;
var reply = gProtocolSvc.TorGetConfStr(kTorConfKeySocks5ProxyUsername,
null);
if (!gProtocolSvc.TorCommandSucceeded(reply))
return false;
proxyUsername = reply.retVal;
var reply = gProtocolSvc.TorGetConfStr(kTorConfKeySocks5ProxyPassword,
null);
if (!gProtocolSvc.TorCommandSucceeded(reply))
return false;
proxyPassword = reply.retVal;
}
else
{
var reply = gProtocolSvc.TorGetConfStr(kTorConfKeyHTTPSProxy, null);
if (!gProtocolSvc.TorCommandSucceeded(reply))
return false;
if (reply.retVal)
{
proxyType = "HTTP";
proxyAddrPort = reply.retVal;
var reply = gProtocolSvc.TorGetConfStr(
kTorConfKeyHTTPSProxyAuthenticator, null);
if (!gProtocolSvc.TorCommandSucceeded(reply))
return false;
var values = parseColonStr(reply.retVal);
proxyUsername = values[0];
proxyPassword = values[1];
}
}
}
setElemValue(kUseProxyCheckbox, (proxyType != undefined));
setElemValue(kProxyTypeMenulist, proxyType);
var proxyAddr, proxyPort;
if (proxyAddrPort)
{
var values = parseColonStr(proxyAddrPort);
proxyAddr = values[0];
proxyPort = values[1];
}
setElemValue(kProxyAddr, proxyAddr);
setElemValue(kProxyPort, proxyPort);
setElemValue(kProxyUsername, proxyUsername);
setElemValue(kProxyPassword, proxyPassword);
return true;
} // initProxySettings
// Returns true if successful.
function initFirewallSettings()
{
var allowedPorts;
var reply = gProtocolSvc.TorGetConfStr(kTorConfKeyReachableAddresses, null);
if (!gProtocolSvc.TorCommandSucceeded(reply))
return false;
if (reply.retVal)
{
var portStrArray = reply.retVal.split(',');
for (var i = 0; i < portStrArray.length; i++)
{
var values = parseColonStr(portStrArray[i]);
if (values[1])
{
if (allowedPorts)
allowedPorts += ',' + values[1];
else
allowedPorts = values[1];
}
}
}
setElemValue(kUseFirewallPortsCheckbox, (allowedPorts != undefined));
if (allowedPorts)
setElemValue(kFirewallAllowedPorts, allowedPorts);
return true;
}
// Returns true if successful.
function initBridgeSettings()
{
var reply = gProtocolSvc.TorGetConfBool(kTorConfKeyUseBridges, false);
if (!gProtocolSvc.TorCommandSucceeded(reply))
return false;
setElemValue(kUseBridgesCheckbox, reply.retVal);
var bridgeReply = gProtocolSvc.TorGetConf(kTorConfKeyBridgeList);
if (!gProtocolSvc.TorCommandSucceeded(bridgeReply))
return false;
setElemValue(kBridgeList, bridgeReply.lineArray);
return true;
}
// Returns true if settings were successfully applied.
function applySettings()
{
TorLauncherLogger.log(2, "applySettings ---------------------" +
"----------------------------------------------");
var didSucceed = false;
try
{
didSucceed = applyProxySettings() && applyFirewallSettings() &&
applyBridgeSettings();
}
catch (e) { TorLauncherLogger.safelog(4, "Error in applySettings: ", e); }
if (didSucceed)
{
var settings = {};
settings[kTorConfKeyDisableNetwork] = "0";
this.setConfAndReportErrors(settings);
gProtocolSvc.TorSendCommand("SAVECONF");
// Start bootstrap monitor before we open the modal progress dialog.
gTorProcessService.TorMonitorBootstrap(true);
openProgressDialog();
if (gIsBootstrapComplete)
close();
}
TorLauncherLogger.log(2, "applySettings done\n\n\n");
return false;
}
function openProgressDialog()
{
var chromeURL = "chrome://torlauncher/content/progress.xul";
var features = "chrome,dialog=yes,modal=yes,dependent=yes";
window.openDialog(chromeURL, "_blank", features, onProgressDialogClose);
}
function onProgressDialogClose(aBootstrapCompleted)
{
gIsBootstrapComplete = aBootstrapCompleted;
}
// Returns true if settings were successfully applied.
function applyProxySettings()
{
// TODO: validate user-entered data. See Vidalia's NetworkPage::save()
var settings = {};
settings[kTorConfKeySocks4Proxy] = null;
settings[kTorConfKeySocks5Proxy] = null;
settings[kTorConfKeySocks5ProxyUsername] = null;
settings[kTorConfKeySocks5ProxyPassword] = null;
settings[kTorConfKeyHTTPSProxy] = null;
settings[kTorConfKeyHTTPSProxyAuthenticator] = null;
var proxyType, proxyAddrPort, proxyUsername, proxyPassword;
var useProxy = getElemValue(kUseProxyCheckbox, false);
if (useProxy)
{
proxyAddrPort = createColonStr(getElemValue(kProxyAddr, null),
getElemValue(kProxyPort, null));
if (!proxyAddrPort)
{
reportValidationError("error_proxy_addr_missing");
return false;
}
proxyType = getElemValue(kProxyTypeMenulist, null);
if (!proxyType)
{
reportValidationError("error_proxy_type_missing");
return false;
}
if ("SOCKS4" != proxyType)
{
proxyUsername = getElemValue(kProxyUsername);
proxyPassword = getElemValue(kProxyPassword);
}
}
if ("SOCKS4" == proxyType)
{
settings[kTorConfKeySocks4Proxy] = proxyAddrPort;
}
else if ("SOCKS5" == proxyType)
{
settings[kTorConfKeySocks5Proxy] = proxyAddrPort;
settings[kTorConfKeySocks5ProxyUsername] = proxyUsername;
settings[kTorConfKeySocks5ProxyPassword] = proxyPassword;
}
else if ("HTTP" == proxyType)
{
settings[kTorConfKeyHTTPSProxy] = proxyAddrPort;
// TODO: Does any escaping need to be done?
settings[kTorConfKeyHTTPSProxyAuthenticator] =
createColonStr(proxyUsername, proxyPassword);
}
return this.setConfAndReportErrors(settings);
} // applyProxySettings
function reportValidationError(aStrKey)
{
showSaveSettingsAlert(TorLauncherUtil.getLocalizedString(aStrKey));
}
// Returns true if settings were successfully applied.
function applyFirewallSettings()
{
// TODO: validate user-entered data. See Vidalia's NetworkPage::save()
var settings = {};
settings[kTorConfKeyReachableAddresses] = null;
var useFirewallPorts = getElemValue(kUseFirewallPortsCheckbox, false);
var allowedPorts = getElemValue(kFirewallAllowedPorts, null);
if (useFirewallPorts && allowedPorts)
{
var portsConfStr;
var portsArray = allowedPorts.split(',');
for (var i = 0; i < portsArray.length; ++i)
{
var s = portsArray[i].trim();
if (s.length > 0)
{
if (!portsConfStr)
portsConfStr = "*:" + s;
else
portsConfStr += ",*:" + s;
}
}
if (portsConfStr)
settings[kTorConfKeyReachableAddresses] = portsConfStr;
}
return this.setConfAndReportErrors(settings);
}
// Returns true if settings were successfully applied.
function applyBridgeSettings()
{
// TODO: validate user-entered data. See Vidalia's NetworkPage::save()
var settings = {};
settings[kTorConfKeyUseBridges] = null;