commit 125e71fa6ee27a929438dafc82bba1ddc0172814 Author: David Fifield david@bamsoftware.com Date: Sat Feb 29 17:29:28 2020 -0700
Remove the now-unused appengine directory.
https://bugs.torproject.org/33429 --- .travis.yml | 1 - appengine/.gcloudignore | 25 ----------- appengine/README | 28 ------------ appengine/app.yaml | 6 --- appengine/reflect.go | 111 ------------------------------------------------ 5 files changed, 171 deletions(-)
diff --git a/.travis.yml b/.travis.yml index b986122..39e777a 100644 --- a/.travis.yml +++ b/.travis.yml @@ -28,7 +28,6 @@ install: - go get -u github.com/dchest/uniuri - go get -u github.com/gorilla/websocket - go get -u git.torproject.org/pluggable-transports/goptlib.git - - go get -u google.golang.org/appengine - go get -u golang.org/x/crypto/acme/autocert - go get -u golang.org/x/net/http2 - pushd proxy diff --git a/appengine/.gcloudignore b/appengine/.gcloudignore deleted file mode 100644 index 199e6d9..0000000 --- a/appengine/.gcloudignore +++ /dev/null @@ -1,25 +0,0 @@ -# This file specifies files that are *not* uploaded to Google Cloud Platform -# using gcloud. It follows the same syntax as .gitignore, with the addition of -# "#!include" directives (which insert the entries of the given .gitignore-style -# file at that point). -# -# For more information, run: -# $ gcloud topic gcloudignore -# -.gcloudignore -# If you would like to upload your .git directory, .gitignore file or files -# from your .gitignore file, remove the corresponding line -# below: -.git -.gitignore - -# Binaries for programs and plugins -*.exe -*.exe~ -*.dll -*.so -*.dylib -# Test binary, build with `go test -c` -*.test -# Output of the go coverage tool, specifically when used with LiteIDE -*.out \ No newline at end of file diff --git a/appengine/README b/appengine/README deleted file mode 100644 index 797b0f9..0000000 --- a/appengine/README +++ /dev/null @@ -1,28 +0,0 @@ -This component runs on Google App Engine. It reflects domain-fronted -requests from a client to the Snowflake broker. - -You need the Go App Engine SDK in order to deploy the app. - https://cloud.google.com/sdk/docs/#linux -After unpacking, install the app-engine-go component: - google-cloud-sdk/bin/gcloud components install app-engine-go - -To test locally, run - google-cloud-sdk/bin/dev_appserver.py app.yaml -The app will be running at http://127.0.0.1:8080/. - -To deploy to App Engine, first create a new project and app. You have to -think of a unique name (marked as "<appname>" in the commands). You only -have to do the "create" step once; subsequent times you can go straight -to the "deploy" step. The "gcloud auth login" command will open a -browser window so you can log in to a Google account. - google-cloud-sdk/bin/gcloud auth login - google-cloud-sdk/bin/gcloud projects create <appname> - google-cloud-sdk/bin/gcloud app create --project=<appname> -Then to deploy the project, run: - google-cloud-sdk/bin/gcloud app deploy --project=<appname> - -To configure the Snowflake client to talk to the App Engine app, provide -"https://<appname>.appspot.com/" as the --url option. - UseBridges 1 - Bridge snowflake 0.0.2.0:1 - ClientTransportPlugin snowflake exec ./client -url https://<appname>.appspot.com/ -front www.google.com diff --git a/appengine/app.yaml b/appengine/app.yaml deleted file mode 100644 index 5d0dcf0..0000000 --- a/appengine/app.yaml +++ /dev/null @@ -1,6 +0,0 @@ -runtime: go111 - -handlers: -- url: /.* - secure: always - script: auto diff --git a/appengine/reflect.go b/appengine/reflect.go deleted file mode 100644 index e09c09e..0000000 --- a/appengine/reflect.go +++ /dev/null @@ -1,111 +0,0 @@ -// A web app for Google App Engine that proxies HTTP requests and responses to -// the Snowflake broker. -package main - -import ( - "context" - "io" - "net/http" - "net/url" - "time" - - "google.golang.org/appengine" - "google.golang.org/appengine/log" - "google.golang.org/appengine/urlfetch" -) - -const ( - forwardURL = "https://snowflake-broker.bamsoftware.com/" - // A timeout of 0 means to use the App Engine default (5 seconds). - urlFetchTimeout = 20 * time.Second -) - -var ctx context.Context - -// Join two URL paths. -func pathJoin(a, b string) string { - if len(a) > 0 && a[len(a)-1] == '/' { - a = a[:len(a)-1] - } - if len(b) == 0 || b[0] != '/' { - b = "/" + b - } - return a + b -} - -// We reflect only a whitelisted set of header fields. Otherwise, we may copy -// headers like Transfer-Encoding that interfere with App Engine's own -// hop-by-hop headers. -var reflectedHeaderFields = []string{ - "Content-Type", - "X-Session-Id", -} - -// Make a copy of r, with the URL being changed to be relative to forwardURL, -// and including only the headers in reflectedHeaderFields. -func copyRequest(r *http.Request) (*http.Request, error) { - u, err := url.Parse(forwardURL) - if err != nil { - return nil, err - } - // Append the requested path to the path in forwardURL, so that - // forwardURL can be something like "https://example.com/reflect". - u.Path = pathJoin(u.Path, r.URL.Path) - c, err := http.NewRequest(r.Method, u.String(), r.Body) - if err != nil { - return nil, err - } - for _, key := range reflectedHeaderFields { - values, ok := r.Header[key] - if ok { - for _, value := range values { - c.Header.Add(key, value) - } - } - } - return c, nil -} - -func handler(w http.ResponseWriter, r *http.Request) { - ctx = appengine.NewContext(r) - fr, err := copyRequest(r) - if err != nil { - log.Errorf(ctx, "copyRequest: %s", err) - http.Error(w, err.Error(), http.StatusInternalServerError) - return - } - if urlFetchTimeout != 0 { - var cancel context.CancelFunc - ctx, cancel = context.WithTimeout(ctx, urlFetchTimeout) - defer cancel() - } - // Use urlfetch.Transport directly instead of urlfetch.Client because we - // want only a single HTTP transaction, not following redirects. - transport := urlfetch.Transport{ - Context: ctx, - } - resp, err := transport.RoundTrip(fr) - if err != nil { - log.Errorf(ctx, "RoundTrip: %s", err) - http.Error(w, err.Error(), http.StatusInternalServerError) - return - } - defer resp.Body.Close() - for _, key := range reflectedHeaderFields { - values, ok := resp.Header[key] - if ok { - for _, value := range values { - w.Header().Add(key, value) - } - } - } - w.WriteHeader(resp.StatusCode) - n, err := io.Copy(w, resp.Body) - if err != nil { - log.Errorf(ctx, "io.Copy after %d bytes: %s", n, err) - } -} - -func init() { - http.HandleFunc("/", handler) -}
tor-commits@lists.torproject.org