mirror of
https://gitlab.torproject.org/tpo/anti-censorship/pluggable-transports/snowflake.git
synced 2025-10-14 14:11:23 -04:00
begin appengine rendezvous component - domain fronting works,
although it just reflects the offer. next step is to retrieve browser proxy answer (#1)
This commit is contained in:
parent
ff5d23b08c
commit
e4e068640f
6 changed files with 113 additions and 10 deletions
|
@ -5,6 +5,7 @@ package main
|
|||
import (
|
||||
"bytes"
|
||||
"io/ioutil"
|
||||
"log"
|
||||
"net/http"
|
||||
"net/url"
|
||||
|
||||
|
@ -31,8 +32,9 @@ func NewRequestInfo(meekUrl string, front string) *RequestInfo {
|
|||
return nil
|
||||
}
|
||||
info.URL = requestUrl
|
||||
info.Host = info.URL.Host
|
||||
info.URL.Host = front
|
||||
info.Host = front
|
||||
// info.URL.Host = front
|
||||
// info.Host = info.URL.Host
|
||||
return info
|
||||
}
|
||||
|
||||
|
@ -57,13 +59,13 @@ func NewMeekChannel(info *RequestInfo) *MeekChannel {
|
|||
|
||||
// Do an HTTP roundtrip using the payload data in buf.
|
||||
func (m *MeekChannel) roundTripHTTP(buf []byte) (*http.Response, error) {
|
||||
req, err := http.NewRequest("POST", m.info.URL.String(), bytes.NewReader(buf))
|
||||
// Compose an innocent looking request.
|
||||
req, err := http.NewRequest("POST", m.info.Host+"/reg/123", bytes.NewReader(buf))
|
||||
if nil != err {
|
||||
return nil, err
|
||||
}
|
||||
if "" != m.info.Host {
|
||||
req.Host = m.info.Host
|
||||
}
|
||||
// Set actually desired target host.
|
||||
req.Host = m.info.URL.String()
|
||||
// req.Header.Set("X-Session-Id", m.info.SessionID)
|
||||
return m.transport.RoundTrip(req)
|
||||
}
|
||||
|
@ -78,7 +80,12 @@ func (m *MeekChannel) Negotiate(offer *webrtc.SessionDescription) (
|
|||
return nil, err
|
||||
}
|
||||
defer resp.Body.Close()
|
||||
log.Println("MeekChannel Response: ", resp)
|
||||
body, err := ioutil.ReadAll(resp.Body)
|
||||
if nil != err {
|
||||
return nil, err
|
||||
}
|
||||
log.Println("MeekChannel Body: ", string(body))
|
||||
answer := webrtc.DeserializeSessionDescription(string(body))
|
||||
return answer, nil
|
||||
}
|
||||
|
|
|
@ -25,8 +25,9 @@ import (
|
|||
// Hard-coded meek signalling channel for now.
|
||||
// TODO: expose as param
|
||||
const (
|
||||
MEEK_URL = "not implemented yet"
|
||||
FRONT_DOMAIN = "www.google.com"
|
||||
MEEK_URL = "snowflake-reg.appspot.com"
|
||||
FRONT_DOMAIN = "https://www.google.com"
|
||||
// FRONT_DOMAIN = "https://www.google.com"
|
||||
)
|
||||
|
||||
var ptInfo pt.ClientInfo
|
||||
|
@ -187,7 +188,11 @@ func dialWebRTC(config *webrtc.Configuration, meek *MeekChannel) (
|
|||
// if nil == answer {
|
||||
// log.Printf("No answer received from meek channel.")
|
||||
// } else {
|
||||
// signalChan <- answer
|
||||
// // TODO: Once this is correct, uncomment and remove copy-paste
|
||||
// // signalling.
|
||||
// log.Println("Recieved answer from Meek channel: \n",
|
||||
// answer.Serialize())
|
||||
// // signalChan <- answer
|
||||
// }
|
||||
if offerURL != "" {
|
||||
answer, err := sendOfferHTTP(offerURL, offer)
|
||||
|
@ -207,7 +212,7 @@ func dialWebRTC(config *webrtc.Configuration, meek *MeekChannel) (
|
|||
pc.Close()
|
||||
return nil, fmt.Errorf("no answer received")
|
||||
}
|
||||
log.Printf("got answer %s", answer.Serialize())
|
||||
log.Printf("Received Answer: %s", answer.Serialize())
|
||||
err = pc.SetRemoteDescription(answer)
|
||||
if err != nil {
|
||||
pc.Close()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue