rename rendezvous to broker

This commit is contained in:
Serene Han 2016-01-19 18:07:59 -08:00
parent 5e9b23de9e
commit 62e6704d1f
4 changed files with 2 additions and 2 deletions

0
broker/README.md Normal file
View file

10
broker/app.yaml Normal file
View file

@ -0,0 +1,10 @@
# override this with appcfg.py -A $YOUR_APP_ID
application: snowflake-reg
version: 1
runtime: go
api_version: go1
handlers:
- url: /.*
script: _go_app
secure: always

16
broker/config.go Normal file
View file

@ -0,0 +1,16 @@
/*
This is the server-side code that runs on Google App Engine for the
"appspot" registration method.
See doc/appspot-howto.txt for more details about setting up an
application, and advice on running one.
To upload a new version:
$ torify ~/go_appengine/appcfg.py --no_cookies -A $YOUR_APP_ID update .
*/
package snowflake_broker
// host:port/basepath of the facilitator you want to register with
// for example, fp-facilitator.org or example.com:12345/facilitator
// https:// and /reg/ will be prepended and appended respectively.
const SNOWFLAKE_FACILITATOR = ""

View file

@ -0,0 +1,65 @@
package snowflake_broker
import (
// "io"
"io/ioutil"
"log"
"net"
"net/http"
"path"
// "appengine"
// "appengine/urlfetch"
)
// This is an intermediate step - a basic hardcoded appengine rendezvous
// to a single browser snowflake.
var snowflakeProxy = ""
func robotsTxtHandler(w http.ResponseWriter, r *http.Request) {
w.Header().Set("Content-Type", "text/plain; charset=utf-8")
w.Write([]byte("User-agent: *\nDisallow:\n"))
}
func ipHandler(w http.ResponseWriter, r *http.Request) {
remoteAddr := r.RemoteAddr
if net.ParseIP(remoteAddr).To4() == nil {
remoteAddr = "[" + remoteAddr + "]"
}
w.Header().Set("Content-Type", "text/plain; charset=utf-8")
w.Write([]byte(remoteAddr))
}
/*
Expects a WebRTC SDP offer in the Request to give to an assigned
snowflake proxy, which responds with the SDP answer to be sent in
the HTTP response back to the client.
*/
func regHandler(w http.ResponseWriter, r *http.Request) {
// TODO: Maybe don't pass anything on path, since it will always be bidirectional
dir, _ := path.Split(path.Clean(r.URL.Path))
if dir != "/reg/" {
http.NotFound(w, r)
return
}
body, err := ioutil.ReadAll(r.Body)
if nil != err {
return
log.Println("Invalid data.")
}
// TODO: Get browser snowflake to talkto this appengine instance
// so it can reply with an answer, and not just the offer again :)
// TODO: Real facilitator which matches clients and snowflake proxies.
w.Write(body)
}
func init() {
http.HandleFunc("/robots.txt", robotsTxtHandler)
http.HandleFunc("/ip", ipHandler)
http.HandleFunc("/reg/", regHandler)
// if SNOWFLAKE_FACILITATOR == "" {
// panic("SNOWFLAKE_FACILITATOR empty; did you forget to edit config.go?")
// }
}