项目作者: arlolra

项目描述 :
forked from https://gitweb.torproject.org/pluggable-transports/snowflake-webext.git
高级语言: JavaScript
项目地址: git://github.com/arlolra/snowflake-webext.git
创建时间: 2020-04-16T16:23:35Z
项目社区:https://github.com/arlolra/snowflake-webext

开源协议:Other

下载


Snowflake

This is the browser proxy component of Snowflake.

Embedding

See https://snowflake.torproject.org/ for more info:

  1. <iframe src="https://snowflake.torproject.org/embed.html" width="88" height="16" frameborder="0" scrolling="no"></iframe>

Building the badge / snowflake.torproject.org

  1. npm install
  2. npm run build

which outputs to the build/ directory.

Building the webextension

  1. npm install
  2. npm run webext

and then load the webext/ directory as an unpacked extension.

Testing

Unit testing with Jasmine are available with:

  1. npm install
  2. npm test

To run locally, first build it with:

  1. npm run build

Then start an HTTP server in build/ and navigate to /embed.html.

Preparing to deploy

Background information:

You need to be in LDAP group “snowflake” and have set up an SSH key with your LDAP account.
In your ~/.ssh/config file, you should have something like:

  1. Host staticiforme
  2. HostName staticiforme.torproject.org
  3. User <your user name>
  4. ProxyJump people.torproject.org
  5. IdentityFile ~/.ssh/tor

Deploying

  1. npm install
  2. npm run build

Do a “dry run” rsync with -n to check that only expected files are being changed. If you don’t understand why a file would be updated, you can add the -i option to see the reason.

  1. rsync -n --chown=:snowflake --chmod ug=rw,D+x --perms --delete -crv build/ staticiforme:/srv/snowflake.torproject.org/htdocs/

If it looks good, then repeat the rsync without -n.

  1. rsync --chown=:snowflake --chmod ug=rw,D+x --perms --delete -crv build/ staticiforme:/srv/snowflake.torproject.org/htdocs/

You can ignore errors of the form rsync: failed to set permissions on "<dirname>/": Operation not permitted (1).

Then run the command to copy the new files to the live web servers:

  1. ssh staticiforme 'static-update-component snowflake.torproject.org'

Publishing

Making a new release involves updating a few places,

  1. Uploading the webextension to the Firefox Add-ons and Chrome Web Store
  2. Publishing the new version to the npm repository
  3. Deploying the badge to snowflake.torproject.org

The following is a rough guide to getting that done:

  1. # Clean things up
  2. npm run clean
  3. # Maybe check what's left behind
  4. git clean -n -d -x
  5. # Be sure that translation/en/messages.json has been populated with any new
  6. # strings that may have been merged in the recent patches. It may take some
  7. # time for transifex to have updated. You can check with the following,
  8. git submodule update --remote
  9. # But note that it's also run as part of the "pack-webext" script, so return
  10. # it to previously committed state,
  11. git submodule update
  12. # Bump and pack the webext, where "x.y.z" is the version being released
  13. npm run pack-webext x.y.z
  14. # Push the bump commit and tags
  15. git push origin master
  16. git push origin --tags
  17. # Upload the generated webext.zip (and source.zip) to the webextension stores,
  18. # 1. https://addons.mozilla.org/en-US/developers/addon/torproject-snowflake/versions/submit/
  19. # 2. https://chrome.google.com/webstore/devconsole/
  20. # This time, really clean, because we don't want any extraneous files uploaded
  21. git clean -f -d -x
  22. # Send it off to npm
  23. npm publish
  24. # Clean things up
  25. npm run clean
  26. # From here on out, follow the "Deploying" section of the README

Parameters

With no parameters,
snowflake uses the default relay snowflake.freehaven.net:443 and
uses automatic signaling with the default broker at
https://snowflake-broker.freehaven.net/.

Reuse as a library

The badge and the webextension make use of the same underlying library and
only differ in their UI. That same library can be produced for use with other
interfaces, such as Cupcake, by running,

  1. npm install
  2. npm run library

which outputs a ./snowflake-library.js.

You’d then want to create a subclass of UI to perform various actions as
the state of the snowflake changes,

  1. class MyUI extends UI {
  2. ...
  3. }

See WebExtUI in init-webext.js and BadgeUI in init-badge.js for
examples.

Finally, initialize the snowflake with,

  1. var log = function(msg) {
  2. return console.log('Snowflake: ' + msg);
  3. };
  4. var dbg = log;
  5. var config = new Config("myui"); // NOTE: Set a unique proxy type for metrics
  6. var ui = new MyUI(); // NOTE: Using the class defined above
  7. var broker = new Broker(config.brokerUrl);
  8. var snowflake = new Snowflake(config, ui, broker);
  9. snowflake.setRelayAddr(config.relayAddr);
  10. snowflake.beginWebRTC();

This minimal setup is pretty much what’s currently in init-node.js.

When configuring the snowflake, set a unique proxyType (first argument
to Config) that will be used when recording metrics at the broker. Also,
it would be helpful to get in touch with the Anti-Censorship Team at the
Tor Project to let them know about your tool.