commit a0aa256c3bf692b31117acb6d885a0b012661014
Author: David Fifield <david(a)bamsoftware.com>
Date: Fri Feb 22 16:42:41 2019 -0700
Minor refactoring of meek-client-torbrowser.
---
meek-client-torbrowser/meek-client-torbrowser.go | 65 ++++++++++++------------
1 file changed, 32 insertions(+), 33 deletions(-)
diff --git a/meek-client-torbrowser/meek-client-torbrowser.go b/meek-client-torbrowser/meek-client-torbrowser.go
index 2daa108..f3ffc68 100644
--- a/meek-client-torbrowser/…
[View More]meek-client-torbrowser.go
+++ b/meek-client-torbrowser/meek-client-torbrowser.go
@@ -203,6 +203,30 @@ func isBrowserProfileUpToDate(templatePath string, profilePath string) bool {
// the path to the Firefox profile to use. Otherwise, the profile is chosen in a
// platform-specific way (see linux.go, mac.go, windows.go).
func runFirefox() (cmd *exec.Cmd, stdout io.Reader, err error) {
+ // Unset environment variables that Firefox sets after a restart (as
+ // caused by, for example, an update or the installation of an add-on).
+ // XRE_PROFILE_PATH, in particular, overrides the -profile option that
+ // runFirefox sets, causing Firefox to run with profile.default instead
+ // of profile.meek-http-helper, which conflicts with the profile.default
+ // that is already running. See https://bugs.torproject.org/13247,
+ // particularly #comment:17 and #comment:18. The environment variable
+ // names come from
+ // https://hg.mozilla.org/mozilla-central/file/cfde3603b020/toolkit/xre/nsAppR…
+ for _, varname := range []string{
+ "XRE_PROFILE_PATH",
+ "XRE_PROFILE_LOCAL_PATH",
+ "XRE_PROFILE_NAME",
+ "XRE_START_OFFLINE",
+ "NO_EM_RESTART",
+ "XUL_APP_FILE",
+ "XRE_BINARY_PATH",
+ } {
+ err = os.Unsetenv(varname)
+ if err != nil {
+ return
+ }
+ }
+
// Mac OS X needs absolute paths for firefox and for the profile.
var absFirefoxPath string
absFirefoxPath, err = filepath.Abs(firefoxPath)
@@ -327,29 +351,14 @@ func main() {
sigChan := make(chan os.Signal, 1)
signal.Notify(sigChan, syscall.SIGTERM)
- // Unset environment variables that Firefox sets after a restart (as
- // caused by, for example, an update or the installation of an add-on).
- // XRE_PROFILE_PATH, in particular, overrides the -profile option that
- // runFirefox sets, causing Firefox to run with profile.default instead
- // of profile.meek-http-helper, which conflicts with the profile.default
- // that is already running. See https://bugs.torproject.org/13247,
- // particularly #comment:17 and #comment:18. The environment variable
- // names come from
- // https://hg.mozilla.org/mozilla-central/file/cfde3603b020/toolkit/xre/nsAppR…
- var firefoxRestartEnvVars = []string{
- "XRE_PROFILE_PATH",
- "XRE_PROFILE_LOCAL_PATH",
- "XRE_PROFILE_NAME",
- "XRE_START_OFFLINE",
- "NO_EM_RESTART",
- "XUL_APP_FILE",
- "XRE_BINARY_PATH",
- }
- for _, varname := range firefoxRestartEnvVars {
- err := os.Unsetenv(varname)
- if err != nil {
- log.Fatal(err)
- }
+ if os.Getenv("TOR_PT_EXIT_ON_STDIN_CLOSE") == "1" {
+ // This environment variable means we should treat EOF on stdin
+ // just like SIGTERM: https://bugs.torproject.org/15435.
+ go func() {
+ io.Copy(ioutil.Discard, os.Stdin)
+ log.Print("synthesizing SIGTERM because of stdin close")
+ sigChan <- syscall.SIGTERM
+ }()
}
// Start firefox.
@@ -375,16 +384,6 @@ func main() {
}
defer logKill(meekClientCmd.Process)
- if os.Getenv("TOR_PT_EXIT_ON_STDIN_CLOSE") == "1" {
- // This environment variable means we should treat EOF on stdin
- // just like SIGTERM: https://bugs.torproject.org/15435.
- go func() {
- io.Copy(ioutil.Discard, os.Stdin)
- log.Printf("synthesizing SIGTERM because of stdin close")
- sigChan <- syscall.SIGTERM
- }()
- }
-
sig := <-sigChan
log.Printf("sig %s", sig)
err = logSignal(meekClientCmd.Process, sig)
[View Less]
commit cf1e51dfe922c2c7965494e21bcc18bf9771f367
Author: David Fifield <david(a)bamsoftware.com>
Date: Thu Mar 7 14:30:41 2019 -0700
Make a separate webextension/browser directory.
---
webextension/README | 14 +++++++-------
webextension/{ => browser}/Makefile | 0
webextension/{ => browser}/background.js | 0
webextension/{ => browser}/manifest.json | 0
webextension/{ => native}/meek.http.helper.json | 0
5 …
[View More]files changed, 7 insertions(+), 7 deletions(-)
diff --git a/webextension/README b/webextension/README
index a728842..5b958cb 100644
--- a/webextension/README
+++ b/webextension/README
@@ -12,18 +12,18 @@ These instructions require Firefox 65.
1. Compile the native application.
cd native && go build
-2. Edit meek.http.helper.json and set the "path" field to the path to
- the native application.
+2. Edit native/meek.http.helper.json and set the "path" field to the
+ path to the native application.
"path": "/where/you/installed/native",
-3. Copy the edited meek.http.helper.json file to the OS-appropriate
- location.
+3. Copy the edited native/meek.http.helper.json file to the
+ OS-appropriate location.
# macOS
mkdir -p ~/"Library/Application Support/Mozilla/NativeMessagingHosts/"
- cp meek.http.helper.json ~/"Library/Application Support/Mozilla/NativeMessagingHosts/"
+ cp native/meek.http.helper.json ~/"Library/Application Support/Mozilla/NativeMessagingHosts/"
# other Unix
mkdir -p ~/.mozilla/native-messaging-hosts/
- cp meek.http.helper.json ~/.mozilla/native-messaging-hosts/
+ cp native/meek.http.helper.json ~/.mozilla/native-messaging-hosts/
The meek.http.helper.json file is called the "host manifest" or "app
manifest" and it tells the browser where to find the native part of
the WebExtension. More information:
@@ -35,7 +35,7 @@ These instructions require Firefox 65.
This enables the extension to write to stdout.
5. In Firefox, go to about:debugging and click "Load Temporary
- Add-on...". Find manifest.json and click Open.
+ Add-on...". Find browser/manifest.json and click Open.
More information:
https://developer.mozilla.org/en-US/docs/Tools/about:debugging#Loading_a_te…
In the terminal, you should see a line like this, with a random port
diff --git a/webextension/Makefile b/webextension/browser/Makefile
similarity index 100%
rename from webextension/Makefile
rename to webextension/browser/Makefile
diff --git a/webextension/background.js b/webextension/browser/background.js
similarity index 100%
rename from webextension/background.js
rename to webextension/browser/background.js
diff --git a/webextension/manifest.json b/webextension/browser/manifest.json
similarity index 100%
rename from webextension/manifest.json
rename to webextension/browser/manifest.json
diff --git a/webextension/meek.http.helper.json b/webextension/native/meek.http.helper.json
similarity index 100%
rename from webextension/meek.http.helper.json
rename to webextension/native/meek.http.helper.json
[View Less]
commit 7530db5bb8ba90c3c895fbc166e8aba9f984868c
Merge: 068306e 975c534
Author: David Fifield <david(a)bamsoftware.com>
Date: Thu Mar 7 15:54:11 2019 -0700
Merge branch 'master' into webextension
meek-client-torbrowser/meek-client-torbrowser.go | 84 ++++++++++++----------
meek-client-torbrowser/protocol_test.go | 89 ++++++++++++++++++++++++
2 files changed, 138 insertions(+), 35 deletions(-)
diff --cc meek-client-torbrowser/meek-client-torbrowser.go
index 48b055c,…
[View More]16f0ebc..37dcf6e
--- a/meek-client-torbrowser/meek-client-torbrowser.go
+++ b/meek-client-torbrowser/meek-client-torbrowser.go
@@@ -203,6 -203,30 +203,30 @@@ func isBrowserProfileUpToDate(templateP
// the path to the Firefox profile to use. Otherwise, the profile is chosen in a
// platform-specific way (see linux.go, mac.go, windows.go).
func runFirefox() (cmd *exec.Cmd, stdout io.Reader, err error) {
+ // Unset environment variables that Firefox sets after a restart (as
+ // caused by, for example, an update or the installation of an add-on).
- // XRE_PROFILE_PATH, in particular, overrides the -profile option that
++ // XRE_PROFILE_PATH, in particular, overrides the --profile option that
+ // runFirefox sets, causing Firefox to run with profile.default instead
+ // of profile.meek-http-helper, which conflicts with the profile.default
+ // that is already running. See https://bugs.torproject.org/13247,
+ // particularly #comment:17 and #comment:18. The environment variable
+ // names come from
+ // https://hg.mozilla.org/mozilla-central/file/cfde3603b020/toolkit/xre/nsAppR…
+ for _, varname := range []string{
+ "XRE_PROFILE_PATH",
+ "XRE_PROFILE_LOCAL_PATH",
+ "XRE_PROFILE_NAME",
+ "XRE_START_OFFLINE",
+ "NO_EM_RESTART",
+ "XUL_APP_FILE",
+ "XRE_BINARY_PATH",
+ } {
+ err = os.Unsetenv(varname)
+ if err != nil {
+ return
+ }
+ }
+
// Mac OS X needs absolute paths for firefox and for the profile.
var absFirefoxPath string
absFirefoxPath, err = filepath.Abs(firefoxPath)
[View Less]
commit d8babfd4a3accb13b4e336724190166c47aa68b1
Author: David Fifield <david(a)bamsoftware.com>
Date: Thu Mar 7 14:45:16 2019 -0700
Revise webextension instructions.
---
README | 7 ++++++-
webextension/README | 13 ++++++++++++-
2 files changed, 18 insertions(+), 2 deletions(-)
diff --git a/README b/README
index e2f04bd..35568b6 100644
--- a/README
+++ b/README
@@ -45,7 +45,9 @@ Reflector web app that runs on Google App Engine. The reflector simply
copies requests …
[View More]and responses to an instance of meek-server somewhere.
firefox:
-Browser extension for TLS camouflage.
+Browser extension for TLS camouflage. Only works with versions of
+Firefox below 60.0. Use the extension in the webextension for newer
+versions of Firefox.
meek-client:
The client transport plugin, run by a censored client.
@@ -70,6 +72,9 @@ terminateprocess-buffer:
An auxiliary program used on Windows to assist with cleanup of
subprocesses.
+webextension:
+Browser extension for TLS camouflage.
+
wsgi:
A WSGI Python reflector.
diff --git a/webextension/README b/webextension/README
index 5b958cb..ceeb74a 100644
--- a/webextension/README
+++ b/webextension/README
@@ -9,12 +9,16 @@ meek-client, because the extension cannot open a socket by itself.
These instructions require Firefox 65.
+== Native component ==
+
1. Compile the native application.
cd native && go build
2. Edit native/meek.http.helper.json and set the "path" field to the
path to the native application.
- "path": "/where/you/installed/native",
+ "path": "/path/to/meek/webextension/native/native",
+ More information:
+ https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/Nati…
3. Copy the edited native/meek.http.helper.json file to the
OS-appropriate location.
@@ -24,11 +28,18 @@ These instructions require Firefox 65.
# other Unix
mkdir -p ~/.mozilla/native-messaging-hosts/
cp native/meek.http.helper.json ~/.mozilla/native-messaging-hosts/
+ # Windows
+ Open regedit.exe and create a new registry key:
+ HKEY_LOCAL_MACHINE\SOFTWARE\Mozilla\NativeMessagingHosts\meek.http.helper
+ Set the default value to the path to meek.http.helper.json:
+ C:\path\to\meek\webextension\native\meek.http.helper.json
The meek.http.helper.json file is called the "host manifest" or "app
manifest" and it tells the browser where to find the native part of
the WebExtension. More information:
https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/Nati…
+== Browser component ==
+
4. Run Firefox in a terminal so you can see its stdout. In Firefox, go
to about:config and set
browser.dom.window.dump.enabled=true
[View Less]
commit e80c5b3217914a033bfc2303f5e043a4bdb3488c
Author: David Fifield <david(a)bamsoftware.com>
Date: Thu Mar 7 15:46:54 2019 -0700
Try deleting the registry key before exiting.
---
meek-client-torbrowser/linux.go | 6 ++++++
meek-client-torbrowser/mac.go | 6 ++++++
meek-client-torbrowser/meek-client-torbrowser.go | 13 ++++++++++++-
meek-client-torbrowser/windows.go | 15 ++++++++-------
4 files changed, 32 insertions(+), 8 …
[View More]deletions(-)
diff --git a/meek-client-torbrowser/linux.go b/meek-client-torbrowser/linux.go
index f728f1d..69ee7b7 100644
--- a/meek-client-torbrowser/linux.go
+++ b/meek-client-torbrowser/linux.go
@@ -29,3 +29,9 @@ func osSpecificCommandSetup(cmd *exec.Cmd) {
func installHelperNativeManifest() error {
return writeNativeManifestToFile(helperNativeManifestDir, helperNativeExecutablePath)
}
+
+func uninstallHelperNativeManifest() error {
+ // Nothing to do here: the host manifest file is written inside the
+ // browser directory, so we assume we don't have to clean it up.
+ return nil
+}
diff --git a/meek-client-torbrowser/mac.go b/meek-client-torbrowser/mac.go
index 995aca5..918a62e 100644
--- a/meek-client-torbrowser/mac.go
+++ b/meek-client-torbrowser/mac.go
@@ -42,3 +42,9 @@ func installHelperNativeManifest() error {
// https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/Nati…
return writeNativeManifestToFile(filepath.Join(homeDir, "Mozilla", "NativeMessagingHosts"), helperNativeExecutablePath)
}
+
+func uninstallHelperNativeManifest() error {
+ // Nothing to do here: the host manifest file is written inside the
+ // browser directory, so we assume we don't have to clean it up.
+ return nil
+}
diff --git a/meek-client-torbrowser/meek-client-torbrowser.go b/meek-client-torbrowser/meek-client-torbrowser.go
index 37dcf6e..f482fb3 100644
--- a/meek-client-torbrowser/meek-client-torbrowser.go
+++ b/meek-client-torbrowser/meek-client-torbrowser.go
@@ -15,6 +15,11 @@
// executed as given, except that a --helper option is added that points to the
// port number read from firefox.
//
+// On Windows, this program assumes that is has exclusive control over the
+// HKEY_CURRENT_USER\SOFTWARE\Mozilla\NativeMessagingHosts\meek.http.helper
+// registry key. It creates the key when run and tries to delete it when
+// exiting.
+//
// This program proxies stdin and stdout to and from meek-client, so it is
// actually meek-client that drives the pluggable transport negotiation with
// tor.
@@ -375,7 +380,13 @@ func main() {
log.Print(err)
return
}
- defer logKill(firefoxCmd.Process)
+ defer func() {
+ logKill(firefoxCmd.Process)
+ err := uninstallHelperNativeManifest()
+ if err != nil {
+ log.Printf("uninstalling native host manifest: %v", err)
+ }
+ }()
// Find out the helper's listening address.
addrChan := make(chan string)
diff --git a/meek-client-torbrowser/windows.go b/meek-client-torbrowser/windows.go
index 907d1dc..c5c52a5 100644
--- a/meek-client-torbrowser/windows.go
+++ b/meek-client-torbrowser/windows.go
@@ -22,6 +22,7 @@ const (
// https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/Nati…
helperNativeManifestDir = "TorBrowser/Data/Browser/.mozilla/native-messaging-hosts"
helperNativeExecutablePath = "TorBrowser/Tor/PluggableTransports/meek-http-helper.exe"
+ registryKey = `SOFTWARE\Mozilla\NativeMessagingHosts\`+nativeAppName
)
func osSpecificCommandSetup(cmd *exec.Cmd) {
@@ -39,16 +40,16 @@ func installHelperNativeManifest() error {
return err
}
- // TODO: Find a way to do this without having to write to the registry.
- // https://bugs.torproject.org/29347#comment:9
+ // On Windows we must set a registry key pointing to the host manifest.
+ // We'll attempt to delete the key in uninstallHelperNativeManifest.
// https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/Nati…
- k, _, err := registry.CreateKey(
- registry.CURRENT_USER,
- `SOFTWARE\Mozilla\NativeMessagingHosts\`+nativeAppName,
- registry.WRITE,
- )
+ k, _, err := registry.CreateKey(registry.CURRENT_USER, registryKey, registry.WRITE)
if err != nil {
return err
}
return k.SetStringValue("", absManifestPath)
}
+
+func uninstallHelperNativeManifest() error {
+ return registry.DeleteKey(registry.CURRENT_USER, registryKey)
+}
[View Less]
commit 068306ebb3c40903daabfd20b01e9a5e4942abff
Author: David Fifield <david(a)bamsoftware.com>
Date: Thu Mar 7 13:56:44 2019 -0700
New bugzilla numbers for proxy-related bugs.
---
webextension/background.js | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/webextension/background.js b/webextension/background.js
index d5bbac7..d26b744 100644
--- a/webextension/background.js
+++ b/webextension/background.js
@@ -206,6 +206,7 @@ async function roundtrip(request) {
…
[View More] let proxyCalled = false;
// async to make exceptions visible to proxy.onError.
// https://bugzilla.mozilla.org/show_bug.cgi?id=1528873#c1
+ // https://bugzilla.mozilla.org/show_bug.cgi?id=1533505
async function proxyFn(details) {
try {
// Sanity assertion: per-request listeners are called at most once.
@@ -264,7 +265,7 @@ async function roundtrip(request) {
// essentially a "can't happen" state under correct configuration. Note that
// proxy.onError doesn't get called for transient errors like a failure to
// connect to the proxy, only for nonsensical ProxyInfo configurations.
-// https://bugzilla.mozilla.org/show_bug.cgi?id=1528873
+// https://bugzilla.mozilla.org/show_bug.cgi?id=1533509
// https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/API/…
let proxyError = null;
browser.proxy.onError.addListener(error => {
[View Less]