[tor-commits] [meek/master] A php reflector for meek

arlo at torproject.org arlo at torproject.org
Sat Sep 20 18:36:05 UTC 2014


commit f5726d12dca8135144433c93a16500b05d742f88
Author: Arlo Breault <arlolra at gmail.com>
Date:   Fri Sep 19 23:39:37 2014 -0700

    A php reflector for meek
---
 README        |    5 +++++
 php/README    |   13 +++++++++++++
 php/index.php |   38 ++++++++++++++++++++++++++++++++++++++
 3 files changed, 56 insertions(+)

diff --git a/README b/README
index 47639ed..b216059 100644
--- a/README
+++ b/README
@@ -58,6 +58,11 @@ latencytest:
 A test program for App Engine that measures roundtrip times to different
 destinations.
 
+php:
+A php reflector similar to the appengine one above. Ideally, it can be run on
+any platform that supports php. A public instance is at:
+https://meek-reflect.herokuapp.com/
+
 To the extent possible under law, the authors have dedicated all
 copyright and related and neighboring rights to this software to the
 public domain worldwide. This software is distributed without any
diff --git a/php/README b/php/README
new file mode 100644
index 0000000..1df27d5
--- /dev/null
+++ b/php/README
@@ -0,0 +1,13 @@
+Ideally, this component can run on any platform that supports PHP. It lies
+between meek-client and meek-server, and receives requests from the client and
+forwards them to the server, then receives responses from the server and
+forwards them to the client.
+
+To test locally, run:
+	php -S 127.0.0.1:8080
+
+The app will be running at http://127.0.0.1:8080/. To configure meek-client to
+talk to the locally running app, put this in torrc:
+	UseBridges 1
+	Bridge meek 0.0.2.0:1
+	ClientTransportPlugin meek exec ./meek-client --url=http://127.0.0.1:8080/ --log meek-client.log
\ No newline at end of file
diff --git a/php/index.php b/php/index.php
new file mode 100644
index 0000000..b6fb9ef
--- /dev/null
+++ b/php/index.php
@@ -0,0 +1,38 @@
+<?php
+
+	/**
+	 * A php reflector for meek.
+	 */
+
+	$forwardURL = "http://meek.bamsoftware.com:7002/";
+
+	$headerArray = array();
+	if ( array_key_exists("HTTP_X_SESSION_ID", $_SERVER) ) {
+		$headerArray[] = "X-Session-Id: " . $_SERVER["HTTP_X_SESSION_ID"];
+	}
+
+	function HeaderFunc( $ch, $header ) {
+		if ( explode( ":", $header )[0] == "Content-Type" ) {
+			header( $header );
+		}
+		return strlen( $header );
+	}
+
+	$curlOpt = array(
+		CURLOPT_HTTPHEADER => $headerArray,
+		CURLOPT_CUSTOMREQUEST => $_SERVER["REQUEST_METHOD"],
+		CURLOPT_POSTFIELDS => file_get_contents("php://input"),
+		CURLOPT_HEADERFUNCTION => "HeaderFunc",
+	);
+
+	$ch = curl_init( $forwardURL );
+	curl_setopt_array( $ch, $curlOpt );
+
+	if ( !curl_exec( $ch ) ) {
+		header("HTTP/1.1 502 Bad Gateway");
+		echo "502 Bad Gateway\n";
+	}
+
+	curl_close( $ch );
+
+?>
\ No newline at end of file



More information about the tor-commits mailing list