[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[tor-commits] [flashproxy/master] App Engine app handling /ip and /reg.



commit 427e9834d71ad30274f924dd20d0cd692396bf40
Author: Arlo Breault <arlolra@xxxxxxxxx>
Date:   Fri May 10 15:02:20 2013 -0700

    App Engine app handling /ip and /reg.
    
    Works with the prototype described in #8860
---
 appspot/app.yaml       |    9 +++++++++
 appspot/fp.go          |   32 ++++++++++++++++++++++++++++++++
 flashproxy-reg-appspot |    6 +++---
 3 files changed, 44 insertions(+), 3 deletions(-)

diff --git a/appspot/app.yaml b/appspot/app.yaml
new file mode 100644
index 0000000..27cccb3
--- /dev/null
+++ b/appspot/app.yaml
@@ -0,0 +1,9 @@
+application: flashproxy-reg
+version: 1
+runtime: go
+api_version: go1
+
+handlers:
+- url: /(ip|(reg/.+))
+  script: _go_app
+  secure: always
diff --git a/appspot/fp.go b/appspot/fp.go
new file mode 100644
index 0000000..ee569a2
--- /dev/null
+++ b/appspot/fp.go
@@ -0,0 +1,32 @@
+package fp
+
+import (
+  "fmt"
+  "net/http"
+
+  "appengine"
+  "appengine/urlfetch"
+)
+
+const BASE = "https://fp-facilitator.org/reg/";
+
+func ipHandler(w http.ResponseWriter, r *http.Request) {
+  fmt.Fprintf(w, "%s", r.RemoteAddr)
+}
+
+func regHandler(w http.ResponseWriter, r *http.Request) {
+  c := appengine.NewContext(r)
+  blob := r.URL.String()[5:]
+  client := urlfetch.Client(c)
+  _, err := client.Get(BASE + blob)
+  if err != nil {
+    http.Error(w, err.Error(), http.StatusInternalServerError)
+    return
+  }
+  fmt.Fprintf(w, "Thanks.")
+}
+
+func init() {
+  http.HandleFunc("/ip", ipHandler)
+  http.HandleFunc("/reg/", regHandler)
+}
diff --git a/flashproxy-reg-appspot b/flashproxy-reg-appspot
index 9b9b4c3..cb595ce 100755
--- a/flashproxy-reg-appspot
+++ b/flashproxy-reg-appspot
@@ -32,7 +32,7 @@ def get_facilitator_pubkey():
 
 def get_external_ip():
     try:
-        f = urllib2.urlopen("https://agentgatech.appspot.com/";)
+        f = urllib2.urlopen("https://flashproxy-reg.appspot.com/ip";)
     except:
         return None
     ip = f.read()
@@ -140,5 +140,5 @@ rsa = get_facilitator_pubkey()
 reg_crypt = rsa.public_encrypt(reg_plain, RSA.pkcs1_oaep_padding)
 reg = base64.urlsafe_b64encode(reg_crypt)
 
-url = urlparse.urljoin(options.facilitator_url, "reg/" + reg)
-urllib2.urlopen("https://g-proxy.appspot.com/"; + urllib2.quote(url))
+url = urlparse.urljoin("http://flashproxy-reg.appspot.com/reg/";, reg)
+urllib2.urlopen(url)



_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits