[tor-commits] [flashproxy/master] Support for running flashproxy.js in node.js

dcf at torproject.org dcf at torproject.org
Wed Jul 31 00:19:47 UTC 2013


commit e84a25ccdd93d027e30136c4b3011b676526fac5
Author: Arlo Breault <arlolra at gmail.com>
Date:   Sat Jun 1 14:49:37 2013 -0700

    Support for running flashproxy.js in node.js
---
 .gitignore                  |    2 ++
 modules/nodejs/Makefile     |    4 ++++
 modules/nodejs/README       |   29 +++++++++++++++++++++++++++++
 modules/nodejs/main.js      |   30 ++++++++++++++++++++++++++++++
 modules/nodejs/package.json |   30 ++++++++++++++++++++++++++++++
 5 files changed, 95 insertions(+)

diff --git a/.gitignore b/.gitignore
index cc97752..6195b6c 100644
--- a/.gitignore
+++ b/.gitignore
@@ -3,3 +3,5 @@
 /py2exe-tmp
 /websocket-transport/websocket-client
 /websocket-transport/websocket-server
+/modules/nodejs/node_modules
+/modules/nodejs/flashproxy.js
diff --git a/modules/nodejs/Makefile b/modules/nodejs/Makefile
new file mode 100644
index 0000000..e4a11d4
--- /dev/null
+++ b/modules/nodejs/Makefile
@@ -0,0 +1,4 @@
+.PHONY: prepublish
+prepublish: flashproxy.js
+flashproxy.js: ../../proxy/flashproxy.js
+	cp -f $< $@
diff --git a/modules/nodejs/README b/modules/nodejs/README
new file mode 100644
index 0000000..cbda782
--- /dev/null
+++ b/modules/nodejs/README
@@ -0,0 +1,29 @@
+== Headless flash proxies with node.js
+
+Traditionally, flash proxies have run in the browser. However, it may be
+desirable to run them as background daemons. This directory contains a main.js
+file which wraps the regular flashproxy.js (symlinked here) and runs
+headlessly from node.js.
+
+To install the requirements (known to be in Debian testing and Ubuntu universe),
+
+    > apt-get install git nodejs npm
+
+Then, if you've checked out the flashproxy source from git,
+
+    > git clone https://git.torproject.org/flashproxy.git
+    > cd flashproxy/modules/nodejs
+    > npm install
+    > npm start  # or, node main.js
+
+This package is also being published on the npm registry. To add a `flashproxy`
+bin to your path without checking out from git, at any time run,
+
+    > npm install -g flashproxy
+    > flashproxy
+
+Rather than install globally, you can also,
+
+    > cd ~/  # or, to the dir of your choice
+    > npm install flashproxy
+    > npm start flashproxy  # or, node node_modules/flashproxy
diff --git a/modules/nodejs/main.js b/modules/nodejs/main.js
new file mode 100755
index 0000000..64e50b9
--- /dev/null
+++ b/modules/nodejs/main.js
@@ -0,0 +1,30 @@
+#!/usr/bin/env node
+
+var path = require("path");
+var fs = require("fs");
+
+// Get a querystring from the command line
+var location_search = "debug=1&initial_facilitator_poll_interval=10";
+if (process.argv[2] != null)
+    location_search = process.argv[2];
+
+// Setup environment variables for node.js
+var XMLHttpRequest = require("xmlhttprequest").XMLHttpRequest;
+var window = {
+    location: { search: "?" + location_search },
+    navigator: { userAgent: "Chrome/16" },
+    WebSocket: require("ws")
+};
+
+// Include flashproxy.js using eval to avoid modifying it.
+var file = path.join(__dirname, "flashproxy.js");
+try {
+    var data = fs.readFileSync(file, "utf8");
+} catch (e) {
+    console.log("Can't locate the flashproxy.js file. You probably need to run \"npm install\".");
+    process.exit(1);
+}
+eval(data);
+
+// Start 'er up
+flashproxy_badge_new().start();
diff --git a/modules/nodejs/package.json b/modules/nodejs/package.json
new file mode 100644
index 0000000..15cdf4c
--- /dev/null
+++ b/modules/nodejs/package.json
@@ -0,0 +1,30 @@
+{
+    "name": "flashproxy",
+    "version": "1.1.0",
+    "description": "Standalone flash proxy. A flash proxy is a lightweight proxy providing access to the Tor network.",
+    "main": "main.js",
+    "scripts": {
+        "prepublish": "make prepublish",
+        "start": "node main.js"
+    },
+    "bin": {
+        "flashproxy": "main.js"
+    },
+    "dependencies": {
+        "xmlhttprequest": "1.5.0",
+        "ws": "0.4.27"
+    },
+    "repository": {
+        "type": "git",
+        "url": "https://git.torproject.org/flashproxy.git"
+    },
+    "keywords": [
+        "flashproxy",
+        "tor",
+        "bridge",
+        "relay",
+        "websocket",
+        "pluggable transport"
+    ],
+    "license": "MIT"
+}





More information about the tor-commits mailing list