mirror of
https://gitlab.torproject.org/tpo/anti-censorship/pluggable-transports/snowflake.git
synced 2025-10-14 05: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
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"bytes"
|
||||||
"container/heap"
|
"container/heap"
|
||||||
"crypto/tls"
|
"crypto/tls"
|
||||||
"flag"
|
"flag"
|
||||||
|
@ -60,12 +61,19 @@ func NewBrokerContext(metricsLogger *log.Logger) *BrokerContext {
|
||||||
panic("Failed to create metrics")
|
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{
|
return &BrokerContext{
|
||||||
snowflakes: snowflakes,
|
snowflakes: snowflakes,
|
||||||
restrictedSnowflakes: rSnowflakes,
|
restrictedSnowflakes: rSnowflakes,
|
||||||
idToSnowflake: make(map[string]*Snowflake),
|
idToSnowflake: make(map[string]*Snowflake),
|
||||||
proxyPolls: make(chan *ProxyPoll),
|
proxyPolls: make(chan *ProxyPoll),
|
||||||
metrics: metrics,
|
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 {
|
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 {
|
if err != nil {
|
||||||
return messages.ErrBadRequest
|
return messages.ErrBadRequest
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,6 +3,7 @@ package main
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"container/heap"
|
"container/heap"
|
||||||
|
"encoding/hex"
|
||||||
"io"
|
"io"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"log"
|
"log"
|
||||||
|
@ -36,6 +37,10 @@ func decodeAMPArmorToString(r io.Reader) (string, error) {
|
||||||
|
|
||||||
func TestBroker(t *testing.T) {
|
func TestBroker(t *testing.T) {
|
||||||
|
|
||||||
|
defaultBridgeValue, _ := hex.DecodeString("2B280B23E1107BB62ABFC40DDCC8824814F80A72")
|
||||||
|
var defaultBridge [20]byte
|
||||||
|
copy(defaultBridge[:], defaultBridgeValue)
|
||||||
|
|
||||||
Convey("Context", t, func() {
|
Convey("Context", t, func() {
|
||||||
ctx := NewBrokerContext(NullLogger())
|
ctx := NewBrokerContext(NullLogger())
|
||||||
i := &IPC{ctx}
|
i := &IPC{ctx}
|
||||||
|
@ -253,10 +258,10 @@ func TestBroker(t *testing.T) {
|
||||||
// Pass a fake client offer to this proxy
|
// Pass a fake client offer to this proxy
|
||||||
p := <-ctx.proxyPolls
|
p := <-ctx.proxyPolls
|
||||||
So(p.id, ShouldEqual, "ymbcCMto7KHNGYlp")
|
So(p.id, ShouldEqual, "ymbcCMto7KHNGYlp")
|
||||||
p.offerChannel <- &ClientOffer{sdp: []byte("fake offer")}
|
p.offerChannel <- &ClientOffer{sdp: []byte("fake offer"), fingerprint: defaultBridge}
|
||||||
<-done
|
<-done
|
||||||
So(w.Code, ShouldEqual, http.StatusOK)
|
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() {
|
Convey("return empty 200 OK when no client offer is available.", func() {
|
||||||
|
@ -269,7 +274,7 @@ func TestBroker(t *testing.T) {
|
||||||
// nil means timeout
|
// nil means timeout
|
||||||
p.offerChannel <- nil
|
p.offerChannel <- nil
|
||||||
<-done
|
<-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)
|
So(w.Code, ShouldEqual, http.StatusOK)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
@ -412,7 +417,7 @@ func TestBroker(t *testing.T) {
|
||||||
|
|
||||||
<-polled
|
<-polled
|
||||||
So(wP.Code, ShouldEqual, http.StatusOK)
|
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)
|
So(ctx.idToSnowflake["ymbcCMto7KHNGYlp"], ShouldNotBeNil)
|
||||||
// Follow up with the answer request afterwards
|
// Follow up with the answer request afterwards
|
||||||
wA := httptest.NewRecorder()
|
wA := httptest.NewRecorder()
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue