[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[tor-commits] [pluggable-transports/snowflake] 01/03: Rename *PollRequest methods to distinguish client/proxy



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

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

commit 6fd0f1ae5dd22bb30100353d80f681b70d879d92
Author: Arlo Breault <arlolra@xxxxxxxxx>
AuthorDate: Tue Mar 8 17:49:28 2022 -0500

    Rename *PollRequest methods to distinguish client/proxy
---
 broker/http.go                   | 2 +-
 broker/ipc.go                    | 2 +-
 client/lib/rendezvous.go         | 2 +-
 client/lib/rendezvous_test.go    | 2 +-
 common/messages/client.go        | 2 +-
 common/messages/messages_test.go | 8 ++++----
 common/messages/proxy.go         | 4 ++--
 proxy/lib/snowflake.go           | 2 +-
 8 files changed, 12 insertions(+), 12 deletions(-)

diff --git a/broker/http.go b/broker/http.go
index 9ec95d8..3b0ba1f 100644
--- a/broker/http.go
+++ b/broker/http.go
@@ -149,7 +149,7 @@ func clientOffers(i *IPC, w http.ResponseWriter, r *http.Request) {
 			Offer: string(body),
 			NAT:   r.Header.Get("Snowflake-NAT-Type"),
 		}
-		body, err = req.EncodePollRequest()
+		body, err = req.EncodeClientPollRequest()
 		if err != nil {
 			log.Printf("Error shimming the legacy request: %s", err.Error())
 			w.WriteHeader(http.StatusInternalServerError)
diff --git a/broker/ipc.go b/broker/ipc.go
index c5d66e8..b8359f6 100644
--- a/broker/ipc.go
+++ b/broker/ipc.go
@@ -75,7 +75,7 @@ func (i *IPC) Debug(_ interface{}, response *string) error {
 }
 
 func (i *IPC) ProxyPolls(arg messages.Arg, response *[]byte) error {
-	sid, proxyType, natType, clients, err := messages.DecodePollRequest(arg.Body)
+	sid, proxyType, natType, clients, err := messages.DecodeProxyPollRequest(arg.Body)
 	if err != nil {
 		return messages.ErrBadRequest
 	}
diff --git a/client/lib/rendezvous.go b/client/lib/rendezvous.go
index 1fc2a69..0ce2744 100644
--- a/client/lib/rendezvous.go
+++ b/client/lib/rendezvous.go
@@ -125,7 +125,7 @@ func (bc *BrokerChannel) Negotiate(offer *webrtc.SessionDescription) (
 		Offer: offerSDP,
 		NAT:   bc.natType,
 	}
-	encReq, err := req.EncodePollRequest()
+	encReq, err := req.EncodeClientPollRequest()
 	bc.lock.Unlock()
 	if err != nil {
 		return nil, err
diff --git a/client/lib/rendezvous_test.go b/client/lib/rendezvous_test.go
index 582a979..21b9f57 100644
--- a/client/lib/rendezvous_test.go
+++ b/client/lib/rendezvous_test.go
@@ -45,7 +45,7 @@ func makeEncPollReq(offer string) []byte {
 	encPollReq, err := (&messages.ClientPollRequest{
 		Offer: offer,
 		NAT:   nat.NATUnknown,
-	}).EncodePollRequest()
+	}).EncodeClientPollRequest()
 	if err != nil {
 		panic(err)
 	}
diff --git a/common/messages/client.go b/common/messages/client.go
index edb7115..5a7d73b 100644
--- a/common/messages/client.go
+++ b/common/messages/client.go
@@ -54,7 +54,7 @@ type ClientPollRequest struct {
 }
 
 // Encodes a poll message from a snowflake client
-func (req *ClientPollRequest) EncodePollRequest() ([]byte, error) {
+func (req *ClientPollRequest) EncodeClientPollRequest() ([]byte, error) {
 	body, err := json.Marshal(req)
 	if err != nil {
 		return nil, err
diff --git a/common/messages/messages_test.go b/common/messages/messages_test.go
index a38746b..0d8b450 100644
--- a/common/messages/messages_test.go
+++ b/common/messages/messages_test.go
@@ -97,7 +97,7 @@ func TestDecodeProxyPollRequest(t *testing.T) {
 				fmt.Errorf(""),
 			},
 		} {
-			sid, proxyType, natType, clients, err := DecodePollRequest([]byte(test.data))
+			sid, proxyType, natType, clients, err := DecodeProxyPollRequest([]byte(test.data))
 			So(sid, ShouldResemble, test.sid)
 			So(proxyType, ShouldResemble, test.proxyType)
 			So(natType, ShouldResemble, test.natType)
@@ -110,9 +110,9 @@ func TestDecodeProxyPollRequest(t *testing.T) {
 
 func TestEncodeProxyPollRequests(t *testing.T) {
 	Convey("Context", t, func() {
-		b, err := EncodePollRequest("ymbcCMto7KHNGYlp", "standalone", "unknown", 16)
+		b, err := EncodeProxyPollRequest("ymbcCMto7KHNGYlp", "standalone", "unknown", 16)
 		So(err, ShouldEqual, nil)
-		sid, proxyType, natType, clients, err := DecodePollRequest(b)
+		sid, proxyType, natType, clients, err := DecodeProxyPollRequest(b)
 		So(sid, ShouldEqual, "ymbcCMto7KHNGYlp")
 		So(proxyType, ShouldEqual, "standalone")
 		So(natType, ShouldEqual, "unknown")
@@ -328,7 +328,7 @@ func TestEncodeClientPollRequests(t *testing.T) {
 			NAT:   "unknown",
 			Offer: "fake",
 		}
-		b, err := req1.EncodePollRequest()
+		b, err := req1.EncodeClientPollRequest()
 		So(err, ShouldEqual, nil)
 		fmt.Println(string(b))
 		parts := bytes.SplitN(b, []byte("\n"), 2)
diff --git a/common/messages/proxy.go b/common/messages/proxy.go
index 83606d3..64f139b 100644
--- a/common/messages/proxy.go
+++ b/common/messages/proxy.go
@@ -92,7 +92,7 @@ type ProxyPollRequest struct {
 	Clients int
 }
 
-func EncodePollRequest(sid string, proxyType string, natType string, clients int) ([]byte, error) {
+func EncodeProxyPollRequest(sid string, proxyType string, natType string, clients int) ([]byte, error) {
 	return json.Marshal(ProxyPollRequest{
 		Sid:     sid,
 		Version: version,
@@ -105,7 +105,7 @@ func EncodePollRequest(sid string, proxyType string, natType string, clients int
 // Decodes a poll message from a snowflake proxy and returns the
 // sid, proxy type, nat type and clients of the proxy on success
 // and an error if it failed
-func DecodePollRequest(data []byte) (sid string, proxyType string, natType string, clients int, err error) {
+func DecodeProxyPollRequest(data []byte) (sid string, proxyType string, natType string, clients int, err error) {
 	var message ProxyPollRequest
 
 	err = json.Unmarshal(data, &message)
diff --git a/proxy/lib/snowflake.go b/proxy/lib/snowflake.go
index 8747f66..ae9d5bf 100644
--- a/proxy/lib/snowflake.go
+++ b/proxy/lib/snowflake.go
@@ -199,7 +199,7 @@ func (s *SignalingServer) pollOffer(sid string, shutdown chan struct{}) *webrtc.
 		default:
 			numClients := int((tokens.count() / 8) * 8) // Round down to 8
 			currentNATTypeLoaded := getCurrentNATType()
-			body, err := messages.EncodePollRequest(sid, "standalone", currentNATTypeLoaded, numClients)
+			body, err := messages.EncodeProxyPollRequest(sid, "standalone", currentNATTypeLoaded, numClients)
 			if err != nil {
 				log.Printf("Error encoding poll message: %s", err.Error())
 				return nil

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.
_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits