[tor-commits] [pluggable-transports/snowflake] 09/31: Update default snowflake server address

gitolite role git at cupani.torproject.org
Thu Jun 16 17:03:56 UTC 2022


This is an automated email from the git hooks/post-receive script.

shelikhoo pushed a commit to branch main
in repository pluggable-transports/snowflake.

commit c7549d886eb84ef0fb31bbdced6de3bb00818a4e
Author: Shelikhoo <xiaokangwang at outlook.com>
AuthorDate: Mon Apr 11 16:29:08 2022 +0100

    Update default snowflake server address
    
    Change snowflake broker test for updated address
    
    Amend DefaultBridges Value
    
    Add Default Fingerprint Info for Snowflake
---
 broker/broker.go                |  8 ++++++++
 broker/ipc.go                   |  3 ++-
 broker/snowflake-broker_test.go | 13 +++++++++----
 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()

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.


More information about the tor-commits mailing list