mirror of
https://gitlab.torproject.org/tpo/anti-censorship/pluggable-transports/snowflake.git
synced 2025-10-13 20:11:19 -04:00
Update default snowflake server address
Change snowflake broker test for updated address Amend DefaultBridges Value Add Default Fingerprint Info for Snowflake
This commit is contained in:
parent
5d7a3766d6
commit
c7549d886e
3 changed files with 19 additions and 5 deletions
|
@ -6,6 +6,7 @@ SessionDescriptions in order to negotiate a WebRTC connection.
|
|||
package main
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"container/heap"
|
||||
"crypto/tls"
|
||||
"flag"
|
||||
|
@ -60,12 +61,19 @@ func NewBrokerContext(metricsLogger *log.Logger) *BrokerContext {
|
|||
panic("Failed to create metrics")
|
||||
}
|
||||
|
||||
bridgeListHolder := NewBridgeListHolder()
|
||||
|
||||
const DefaultBridges = `{"displayName":"default", "webSocketAddress":"wss://snowflake.torproject.net/", "fingerprint":"2B280B23E1107BB62ABFC40DDCC8824814F80A72"}
|
||||
`
|
||||
bridgeListHolder.LoadBridgeInfo(bytes.NewReader([]byte(DefaultBridges)))
|
||||
|
||||
return &BrokerContext{
|
||||
snowflakes: snowflakes,
|
||||
restrictedSnowflakes: rSnowflakes,
|
||||
idToSnowflake: make(map[string]*Snowflake),
|
||||
proxyPolls: make(chan *ProxyPoll),
|
||||
metrics: metrics,
|
||||
bridgeList: bridgeListHolder,
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -66,7 +66,8 @@ func (i *IPC) Debug(_ interface{}, response *string) error {
|
|||
}
|
||||
|
||||
func (i *IPC) ProxyPolls(arg messages.Arg, response *[]byte) error {
|
||||
sid, proxyType, natType, clients, err := messages.DecodeProxyPollRequest(arg.Body)
|
||||
sid, proxyType, natType, clients, relayPattern, err := messages.DecodeProxyPollRequestWithRelayPrefix(arg.Body)
|
||||
_ = relayPattern
|
||||
if err != nil {
|
||||
return messages.ErrBadRequest
|
||||
}
|
||||
|
|
|
@ -3,6 +3,7 @@ package main
|
|||
import (
|
||||
"bytes"
|
||||
"container/heap"
|
||||
"encoding/hex"
|
||||
"io"
|
||||
"io/ioutil"
|
||||
"log"
|
||||
|
@ -36,6 +37,10 @@ func decodeAMPArmorToString(r io.Reader) (string, error) {
|
|||
|
||||
func TestBroker(t *testing.T) {
|
||||
|
||||
defaultBridgeValue, _ := hex.DecodeString("2B280B23E1107BB62ABFC40DDCC8824814F80A72")
|
||||
var defaultBridge [20]byte
|
||||
copy(defaultBridge[:], defaultBridgeValue)
|
||||
|
||||
Convey("Context", t, func() {
|
||||
ctx := NewBrokerContext(NullLogger())
|
||||
i := &IPC{ctx}
|
||||
|
@ -253,10 +258,10 @@ func TestBroker(t *testing.T) {
|
|||
// Pass a fake client offer to this proxy
|
||||
p := <-ctx.proxyPolls
|
||||
So(p.id, ShouldEqual, "ymbcCMto7KHNGYlp")
|
||||
p.offerChannel <- &ClientOffer{sdp: []byte("fake offer")}
|
||||
p.offerChannel <- &ClientOffer{sdp: []byte("fake offer"), fingerprint: defaultBridge}
|
||||
<-done
|
||||
So(w.Code, ShouldEqual, http.StatusOK)
|
||||
So(w.Body.String(), ShouldEqual, `{"Status":"client match","Offer":"fake offer","NAT":""}`)
|
||||
So(w.Body.String(), ShouldEqual, `{"Status":"client match","Offer":"fake offer","NAT":"","RelayURL":"wss://snowflake.torproject.net/"}`)
|
||||
})
|
||||
|
||||
Convey("return empty 200 OK when no client offer is available.", func() {
|
||||
|
@ -269,7 +274,7 @@ func TestBroker(t *testing.T) {
|
|||
// nil means timeout
|
||||
p.offerChannel <- nil
|
||||
<-done
|
||||
So(w.Body.String(), ShouldEqual, `{"Status":"no match","Offer":"","NAT":""}`)
|
||||
So(w.Body.String(), ShouldEqual, `{"Status":"no match","Offer":"","NAT":"","RelayURL":""}`)
|
||||
So(w.Code, ShouldEqual, http.StatusOK)
|
||||
})
|
||||
})
|
||||
|
@ -412,7 +417,7 @@ func TestBroker(t *testing.T) {
|
|||
|
||||
<-polled
|
||||
So(wP.Code, ShouldEqual, http.StatusOK)
|
||||
So(wP.Body.String(), ShouldResemble, `{"Status":"client match","Offer":"fake","NAT":"unknown"}`)
|
||||
So(wP.Body.String(), ShouldResemble, `{"Status":"client match","Offer":"fake","NAT":"unknown","RelayURL":"wss://snowflake.torproject.net/"}`)
|
||||
So(ctx.idToSnowflake["ymbcCMto7KHNGYlp"], ShouldNotBeNil)
|
||||
// Follow up with the answer request afterwards
|
||||
wA := httptest.NewRecorder()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue