aboutsummaryrefslogtreecommitdiff
path: root/broker
diff options
context:
space:
mode:
authorShelikhoo <xiaokangwang@outlook.com>2022-04-11 16:29:08 +0100
committerShelikhoo <xiaokangwang@outlook.com>2022-06-16 14:06:56 +0100
commitc7549d886eb84ef0fb31bbdced6de3bb00818a4e (patch)
treeef102153a7177e46543d0054dbc2422fee5ee28b /broker
parent5d7a3766d6f8af0a3adc24b19aaa30747b49c847 (diff)
downloadsnowflake-c7549d886eb84ef0fb31bbdced6de3bb00818a4e.tar.gz
snowflake-c7549d886eb84ef0fb31bbdced6de3bb00818a4e.zip
Update default snowflake server address
Change snowflake broker test for updated address Amend DefaultBridges Value Add Default Fingerprint Info for Snowflake
Diffstat (limited to 'broker')
-rw-r--r--broker/broker.go8
-rw-r--r--broker/ipc.go3
-rw-r--r--broker/snowflake-broker_test.go13
3 files changed, 19 insertions, 5 deletions
diff --git a/broker/broker.go b/broker/broker.go
index 692cea4..d9e8dea 100644
--- a/broker/broker.go
+++ b/broker/broker.go
@@ -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,
}
}
diff --git a/broker/ipc.go b/broker/ipc.go
index e559c2a..780a9a5 100644
--- a/broker/ipc.go
+++ b/broker/ipc.go
@@ -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
}
diff --git a/broker/snowflake-broker_test.go b/broker/snowflake-broker_test.go
index f7850f8..fdd1114 100644
--- a/broker/snowflake-broker_test.go
+++ b/broker/snowflake-broker_test.go
@@ -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()