commit bed066b860d14ac16a9bfb6323d21cf40660a45d Author: David Fifield david@bamsoftware.com Date: Sun May 19 19:38:34 2013 -0700
Move fp.go → fp-reg.go --- appengine/fp-reg.go | 37 +++++++++++++++++++++++++++++++++++++ appengine/fp.go | 37 ------------------------------------- 2 files changed, 37 insertions(+), 37 deletions(-)
diff --git a/appengine/fp-reg.go b/appengine/fp-reg.go new file mode 100644 index 0000000..9d0850c --- /dev/null +++ b/appengine/fp-reg.go @@ -0,0 +1,37 @@ +package fp_reg + +import ( + "fmt" + "net" + "net/http" + + "appengine" + "appengine/urlfetch" +) + +const BASE = "https://fp-facilitator.org/reg/" + +func ipHandler(w http.ResponseWriter, r *http.Request) { + remoteAddr := r.RemoteAddr + if net.ParseIP(remoteAddr).To4() == nil { + remoteAddr = "[" + remoteAddr + "]" + } + fmt.Fprintf(w, "%s", remoteAddr) +} + +func regHandler(w http.ResponseWriter, r *http.Request) { + c := appengine.NewContext(r) + blob := r.URL.Path[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/appengine/fp.go b/appengine/fp.go deleted file mode 100644 index 93465c3..0000000 --- a/appengine/fp.go +++ /dev/null @@ -1,37 +0,0 @@ -package fp - -import ( - "fmt" - "net" - "net/http" - - "appengine" - "appengine/urlfetch" -) - -const BASE = "https://fp-facilitator.org/reg/" - -func ipHandler(w http.ResponseWriter, r *http.Request) { - remoteAddr := r.RemoteAddr - if net.ParseIP(remoteAddr).To4() == nil { - remoteAddr = "[" + remoteAddr + "]" - } - fmt.Fprintf(w, "%s", remoteAddr) -} - -func regHandler(w http.ResponseWriter, r *http.Request) { - c := appengine.NewContext(r) - blob := r.URL.Path[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) -}
tor-commits@lists.torproject.org