Giter VIP home page Giter VIP logo

node-janus's Introduction

Janus - Privacy & Compression Proxy

Build Status

Requirements

Installation

Get the code first.

git clone https://github.com/mozilla/node-janus

Next, use NPM to install all the dependencies.

cd node-janus  
npm install

Configuration and Usage

Proxy

You can find the default proxy configuration in config/default.yml. All settings are exposed and documented there.

You may edit the settings directly in the default configuration file or preferably override some of settings using a custom configuration file, see the node-config documentation for more details about the configuration system.

To start the proxy, just run

./proxy

The only command-line arguments supported are -h for help and -v for showing the version.

Firefox

Minimal Version

You need at least Firefox 33 for SPDY proxy support.

Self-Signed Certificates

When using a self-signed certificate, you need to add it to Firefox first. To do this, use Firefox to open the proxy via its host-port combination.

https://<proxy.host>:<proxy.port>/

This should prompt you to add an exception for the self-signed certificate.

Automatic Client Configuration Using the Add-On

The prefered way for using the proxy is by installing the Janus add-on. When using the add-on, you can conveniently configure the optional features of the proxy and view some statistics on bandwidth savings.

Should you have reasons to set up the proxy without the add-on, please follow the manual instructions next.

Manual Client Configuration

Desktop

You can configure the secure proxy in Preferences/Advanced/Network/Settings. Select Automatic proxy configuration URL and set it to your custom PAC file or use the default configuration served by the integrated PAC server.

http://<pac.host>:<pac.port>

This will serve a suitable PAC file with the proper host and ports set. Check config/default.yml for the default PAC server connection details.

Android

For Fennec the steps are similar. Open about:config and set network.proxy.autoconfig_url to the location of your PAC file or the Janus PAC server. To load the PAC file and activate the proxy, set network.proxy.type to 2.

Production Deployment

Additional Requirements

By default, the proxy uses a basic in-memory cache and does only log basic metric stats. Additionally, the proxy supports a Redis-based caching solution and StatsD metrics reporting.

To enable the Redis cache, you need to have a running Redis server instance. The proxy-side configuration is straight-forward using config/default.yml, where you set the host and port accordingly and switch caching modes by setting cache.type.

To view and process the full metrics, you need a receiver compatible to StatsD metrics. To establish a connection, simply set the metrics.statsd settings accordingly in config/default.yml or your local overriding config files.

Self-Signed Certificate

You will also need to use your own certificate for your server FQDN. You can generate a new key and a new certificate simply by executing this command from node-janus root directory:

openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout keys/key.pem -out keys/crt.pem

Be careful to correctly set the Common Name with your server FQDN, e.g., for example.com:

Common Name (e.g. server FQDN or YOUR name) []:example.com

Because a self-signed certificate is not delivered by a trusted CA, you will have to manually add it to your browser. Please have a look to the Firefox section for more details.

Development

We would be happy to accept pull requests for known issues or useful new features, so we encourage you to contribute!

Please make sure all tests pass locally before putting the request up for review, additional tests for new features would be great, too.

Tests

To run all tests use

npm test

To get coverage statistics use

npm run-script coverage

To run performance tests using Marionette you need to point the configuration to your Firefox binary in file config/test/test.yml, setting test.firefoxPath. Then launch the tests using

npm run-script marionette

To simulate different mobile network environments, use

npm run-script networksimulation 2G|3G|4G

and stop the system-wide simulation by reverting to the defaults using

npm run-script networksimulation default

node-janus's People

Contributors

ackar avatar eamsen avatar matttbe avatar snorp avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

node-janus's Issues

Firefox repeatedly crashes and internet is slower than ever

After installing this addon, firefox on my pc crashed 32 times in a single day. And also my internet connection speed reduced to half. Then I disabled Janus and everything went back to normal. I tried it once more and the same problems appeared once again.

Build errors on Debian 8

Node-Janus does not build out of the box on Debian Jessie with default node.js v0.10.29 and node-gyp v3.2.1 installed by apt-get.

First, it requires to change the version of marionette-client to 1.9.0 in packages.json.
Next, it requires additional packages: libpng-dev, automake, autoconf, nasm, g++, libtool, gettext.
Finally, the libjpeg-turbo URL is invalid and raises Zlib error.

Mangled text encoding with Redis cache

STR

  1. Activate caching using Redis backend.
  2. Open nytimes.com.
  3. Reload the page.

Expected

Content is partly loaded from cache and corresponds to the original content.

Actual

Content is partly loaded from cache with some text encoding broken.

Screenshot

Text-only/super-compressed mode

For people who just want to read an article or have used up their high-speed quota and are stuck on EDGE for the rest of the month.

Imagetype exception

STR

  1. Activate proxy.
  2. Open link.
  3. Inspect debug logs and page layout.

Expected

Page loads correctly, no errors reported.

Actual

Page layout is mangled, images missing, etc.

Debug output

Multi-phase response chain

We need to separate the response handling chain into the quick response phase and the slow recoding and caching phase.

First Phase

Load the resource from cache or the original source and forward it directly back to the client.

Second Phase

Decide whether the resource is cacheable. If not, terminate the chain. Otherwise, proceed with the compression plugins and cache the result.

Things to consider

  • Return second phase results instead (optional)
  • ???

Add a server in Europe

Could you please add a test server in some EU country? The round-trip times from Poland to the USA and back take way too long right now (~300 ms).

Thanks!

CODE_OF_CONDUCT.md file missing

As of January 1 2019, Mozilla requires that all GitHub projects include this CODE_OF_CONDUCT.md file in the project root. The file has two parts:

  1. Required Text - All text under the headings Community Participation Guidelines and How to Report, are required, and should not be altered.
  2. Optional Text - The Project Specific Etiquette heading provides a space to speak more specifically about ways people can work effectively and inclusively together. Some examples of those can be found on the Firefox Debugger project, and Common Voice. (The optional part is commented out in the raw template file, and will not be visible until you modify and uncomment that part.)

If you have any questions about this file, or Code of Conduct policies and procedures, please see Mozilla-GitHub-Standards or email [email protected].

(Message COC001)

JPG images are broken when using mozjpeg

Some JPG images are broken and doesn't appear in the latest Firefox when using Janus, e.g. http://mozliwosci.com/blog/wp-content/uploads/2012/08/tvp_estetyka_top.jpg
Response headers:

HTTP/1.1 200 OK
Date: Thu, 28 Jan 2016 16:52:56 GMT
Server: Apache
Last-Modified: Fri, 31 Aug 2012 16:57:48 GMT
Etag: "4dd6ab2-acf6-4c892b10c5b00"
Accept-Ranges: bytes
Content-Type: image/jpeg
Via: janus/0.7.0
x-original-content-length: 44278
X-Firefox-Spdy: 3.1

There is missing Content-Length. Debug log does not show anything wrong, just:
info: [worker 8960] [INFO] Recompressing JPEG...
It happens only when using mozjpeg. libjpeg-turbo works fine.

Fix cache key

The current caching key isn't adequate for most real-world scenarios, it needs to include following elements

  • UA
  • accept-encoding headers for xz support
  • query

Dynamic content won't load

STR

  1. Activate proxy.
  2. Open link.
  3. Scroll down to the comments section (clicking on the comments button will navigate you there).

Expected

The comments section shows the comments.

Actual

The comments never load, only the loading animation is shown.

Notes

Tested with Firefox Nightly 2014-07-17.
Works with Google Chrome 35.

npm install fails during compilation of marionette-client dependency

$ npm install
...
> [email protected] install /home/gaul/work/node-janus/node_modules/marionette-client/node_modules/sockit-to-me
> CC=clang CXX=clang++ node-gyp configure build --verbose

npm http 304 https://registry.npmjs.org/asap
gyp info it worked if it ends with ok
gyp verb cli [ 'nodejs',
gyp verb cli   '/usr/bin/node-gyp',
gyp verb cli   'configure',
gyp verb cli   'build',
gyp verb cli   '--verbose' ]
gyp info using [email protected]
gyp info using [email protected] | linux | x64
gyp verb command configure []
gyp verb check python checking for Python executable "python" in the PATH
gyp verb `which` succeeded python /usr/bin/python
gyp verb check python version `python -c "import platform; print(platform.python_version());"` returned: "2.7.6\n"
gyp verb get node dir no --target version specified, falling back to host node version: v0.10.25
gyp verb build dir attempting to create "build" dir: /home/gaul/work/node-janus/node_modules/marionette-client/node_modules/sockit-to-me/build
gyp verb build dir "build" dir needed to be created? null
gyp verb build/config.gypi creating config file
gyp verb build/config.gypi writing out config file: /home/gaul/work/node-janus/node_modules/marionette-client/node_modules/sockit-to-me/build/config.gypi
gyp verb config.gypi checking for gypi file: /home/gaul/work/node-janus/node_modules/marionette-client/node_modules/sockit-to-me/config.gypi
gyp verb common.gypi checking for gypi file: /home/gaul/work/node-janus/node_modules/marionette-client/node_modules/sockit-to-me/common.gypi
gyp verb gyp gyp format was not specified; forcing "make"
gyp info spawn python
gyp info spawn args [ '/usr/share/node-gyp/gyp/gyp',
gyp info spawn args   'binding.gyp',
gyp info spawn args   '-f',
gyp info spawn args   'make',
gyp info spawn args   '-I',
gyp info spawn args   '/home/gaul/work/node-janus/node_modules/marionette-client/node_modules/sockit-to-me/build/config.gypi',
gyp info spawn args   '-I',
gyp info spawn args   '/usr/share/node-gyp/addon.gypi',
gyp info spawn args   '-I',
gyp info spawn args   '/usr/include/nodejs/common.gypi',
gyp info spawn args   '-Dlibrary=shared_library',
gyp info spawn args   '-Dvisibility=default',
gyp info spawn args   '-Dnode_root_dir=/usr/include/nodejs',
gyp info spawn args   '-Dmodule_root_dir=/home/gaul/work/node-janus/node_modules/marionette-client/node_modules/sockit-to-me',
gyp info spawn args   '--depth=.',
gyp info spawn args   '--generator-output',
gyp info spawn args   'build',
gyp info spawn args   '-Goutput_dir=.' ]
gyp verb command build []
gyp verb build type Release
gyp verb architecture x64
gyp verb node dev dir /usr/include/nodejs
gyp verb `which` succeeded for `make` /usr/bin/make
gyp info spawn make
gyp info spawn args [ 'V=1', 'BUILDTYPE=Release', '-C', 'build' ]
make: Entering directory `/home/gaul/work/node-janus/node_modules/marionette-client/node_modules/sockit-to-me/build'
  clang++ '-D_LARGEFILE_SOURCE' '-D_FILE_OFFSET_BITS=64' '-DBUILDING_NODE_EXTENSION' -I/usr/include/nodejs/src -I/usr/include/nodejs/deps/uv/include -I/usr/include/nodejs/deps/v8/include  -fPIC -Wall -Wextra -Wno-unused-parameter -pthread -m64 -O2 -fno-strict-aliasing -fno-tree-vrp -fno-omit-frame-pointer -fno-rtti -fno-exceptions -MMD -MF ./Release/.deps/Release/obj.target/sockit/src/addon.o.d.raw   -c -o Release/obj.target/sockit/src/addon.o ../src/addon.cc
clang: warning: optimization flag '-fno-tree-vrp' is not supported
In file included from ../src/addon.cc:5:
../src/sockit.h:17:29: error: no type named 'FunctionCallbackInfo' in namespace 'v8'
  static void New(const v8::FunctionCallbackInfo<v8::Value>&);
                        ~~~~^
../src/sockit.h:17:49: error: expected ')'
  static void New(const v8::FunctionCallbackInfo<v8::Value>&);
                                                ^
../src/sockit.h:17:18: note: to match this '('
  static void New(const v8::FunctionCallbackInfo<v8::Value>&);
                 ^
../src/sockit.h:19:33: error: no type named 'FunctionCallbackInfo' in namespace 'v8'
  static void Connect(const v8::FunctionCallbackInfo<v8::Value>&);
                            ~~~~^
../src/sockit.h:19:53: error: expected ')'
  static void Connect(const v8::FunctionCallbackInfo<v8::Value>&);
                                                    ^
../src/sockit.h:19:22: note: to match this '('
  static void Connect(const v8::FunctionCallbackInfo<v8::Value>&);
                     ^
../src/sockit.h:21:30: error: no type named 'FunctionCallbackInfo' in namespace 'v8'
  static void Read(const v8::FunctionCallbackInfo<v8::Value>&);
                         ~~~~^
../src/sockit.h:21:50: error: expected ')'
  static void Read(const v8::FunctionCallbackInfo<v8::Value>&);
                                                 ^
../src/sockit.h:21:19: note: to match this '('
  static void Read(const v8::FunctionCallbackInfo<v8::Value>&);
                  ^
../src/sockit.h:23:31: error: no type named 'FunctionCallbackInfo' in namespace 'v8'
  static void Write(const v8::FunctionCallbackInfo<v8::Value>&);
                          ~~~~^
../src/sockit.h:23:51: error: expected ')'
  static void Write(const v8::FunctionCallbackInfo<v8::Value>&);
                                                  ^
../src/sockit.h:23:20: note: to match this '('
  static void Write(const v8::FunctionCallbackInfo<v8::Value>&);
                   ^
../src/sockit.h:27:31: error: no type named 'FunctionCallbackInfo' in namespace 'v8'
  static void Close(const v8::FunctionCallbackInfo<v8::Value>&);
                          ~~~~^
../src/sockit.h:27:51: error: expected ')'
  static void Close(const v8::FunctionCallbackInfo<v8::Value>&);
                                                  ^
../src/sockit.h:27:20: note: to match this '('
  static void Close(const v8::FunctionCallbackInfo<v8::Value>&);
                   ^
../src/sockit.h:29:40: error: no type named 'FunctionCallbackInfo' in namespace 'v8'
  static void SetPollTimeout(const v8::FunctionCallbackInfo<v8::Value>&);
                                   ~~~~^
../src/sockit.h:29:60: error: expected ')'
  static void SetPollTimeout(const v8::FunctionCallbackInfo<v8::Value>&);
                                                           ^
../src/sockit.h:29:29: note: to match this '('
  static void SetPollTimeout(const v8::FunctionCallbackInfo<v8::Value>&);
                            ^
../src/sockit.h:30:37: error: no type named 'FunctionCallbackInfo' in namespace 'v8'
  static void SetDebugLog(const v8::FunctionCallbackInfo<v8::Value>&);
                                ~~~~^
../src/sockit.h:30:57: error: expected ')'
  static void SetDebugLog(const v8::FunctionCallbackInfo<v8::Value>&);
                                                        ^
../src/sockit.h:30:26: note: to match this '('
  static void SetDebugLog(const v8::FunctionCallbackInfo<v8::Value>&);
                         ^
14 errors generated.
make: *** [Release/obj.target/sockit/src/addon.o] Error 1
make: Leaving directory `/home/gaul/work/node-janus/node_modules/marionette-client/node_modules/sockit-to-me/build'
gyp ERR! build error
gyp ERR! stack Error: `make` failed with exit code: 2
gyp ERR! stack     at ChildProcess.onExit (/usr/share/node-gyp/lib/build.js:267:23)
gyp ERR! stack     at ChildProcess.EventEmitter.emit (events.js:98:17)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (child_process.js:797:12)
gyp ERR! System Linux 3.13.0-101-generic
gyp ERR! command "nodejs" "/usr/bin/node-gyp" "configure" "build" "--verbose"
gyp ERR! cwd /home/gaul/work/node-janus/node_modules/marionette-client/node_modules/sockit-to-me
gyp ERR! node -v v0.10.25
gyp ERR! node-gyp -v v0.10.10
gyp ERR! not ok
npm WARN This failure might be due to the use of legacy binary "node"
npm WARN For further explanations, please read
/usr/share/doc/nodejs/README.Debian

npm ERR! weird error 1
npm ERR! not ok code 0

Migrate to HTTP/2

With HTTP/2's finalization, we should migrate to a Node HTTP/2 module from the currently used SPDY module.
We should have performance tests in place before attempting this, to avoid unregistered regressions on that level.

Wiki changes

FYI: The following changes were made to this repository's wiki:

These were made as the result of a recent automated defacement of publically writeable wikis.

Forum software loses logins/fails to log in

Observed on several PHP-based forums, including vBulletin based and IPB based.

  1. Try to load hydrogenaud.io
  2. Observe very slow load
  3. Observe the site layout breaks (at least it did here sometimes, may be timing out)
  4. Try to log in (need to create an account)
  5. Logging in always fails, you are always directed back to the front page.

Support server push

The proxy should

  1. accept and handle PUSH_PROMISE frames
  2. initiate PUSH_PROMISE frames based on
  • x-associated-content headers
  • pre-emptive resource link analysis
  • ???

Authentication

I am interested in running my own Janus instance but am worried about security. Does Janus support any authentication and authorization mechanisms?

Debug metrics

While developing, we don't have the whole Graphite/StatsD infrastructure locally.
In order to test metrics output, we need a lightweight deployment option for StatsD and reasonable metrics output for debugging purposes.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.