From 8792771cdcd673f1b612cd6befc7b7e41598036f Mon Sep 17 00:00:00 2001 From: Neel Chauhan Date: Mon, 14 Oct 2024 13:38:20 -0400 Subject: [PATCH] broker and proxy must not reject client offers with no ICE candidates Fixes #40371. Partially reverts !141. --- broker/http.go | 7 ------- broker/snowflake-broker_test.go | 16 ---------------- client/lib/webrtc.go | 5 ----- proxy/lib/snowflake.go | 7 ------- 4 files changed, 35 deletions(-) diff --git a/broker/http.go b/broker/http.go index d3e43c1..b6f449d 100644 --- a/broker/http.go +++ b/broker/http.go @@ -139,13 +139,6 @@ func clientOffers(i *IPC, w http.ResponseWriter, r *http.Request) { return } - err = validateSDP(body) - if err != nil { - log.Println("Error client SDP: ", err.Error()) - w.WriteHeader(http.StatusBadRequest) - return - } - // Handle the legacy version // // We support two client message formats. The legacy format is for backwards diff --git a/broker/snowflake-broker_test.go b/broker/snowflake-broker_test.go index 8e9f4a0..f8a45b9 100644 --- a/broker/snowflake-broker_test.go +++ b/broker/snowflake-broker_test.go @@ -137,14 +137,6 @@ func TestBroker(t *testing.T) { r, err := http.NewRequest("POST", "snowflake.broker/client", data) So(err, ShouldBeNil) - Convey("with HTTP Bad Request when client offer contains invalid SDP", func() { - data, err = createClientOffer("fake", NATUnknown, "") - invalidRequest, err := http.NewRequest("POST", "snowflake.broker/client", data) - So(err, ShouldBeNil) - clientOffers(i, w, invalidRequest) - So(w.Code, ShouldEqual, http.StatusBadRequest) - }) - Convey("with error when no snowflakes are available.", func() { clientOffers(i, w, r) So(w.Code, ShouldEqual, http.StatusOK) @@ -246,14 +238,6 @@ client-sqs-ips So(err, ShouldBeNil) r.Header.Set("Snowflake-NAT-TYPE", "restricted") - Convey("with HTTP Bad Request when client offer contains invalid SDP", func() { - invalidOffer := bytes.NewReader([]byte("{test}")) - invalidRequest, err := http.NewRequest("POST", "snowflake.broker/client", invalidOffer) - So(err, ShouldBeNil) - clientOffers(i, w, invalidRequest) - So(w.Code, ShouldEqual, http.StatusBadRequest) - }) - Convey("with 503 when no snowflakes are available.", func() { clientOffers(i, w, r) So(w.Code, ShouldEqual, http.StatusServiceUnavailable) diff --git a/client/lib/webrtc.go b/client/lib/webrtc.go index 8ccc3d0..39cd6f1 100644 --- a/client/lib/webrtc.go +++ b/client/lib/webrtc.go @@ -4,11 +4,9 @@ import ( "crypto/rand" "encoding/hex" "errors" - "fmt" "io" "log" "net/url" - "strings" "sync" "time" @@ -301,9 +299,6 @@ func (c *WebRTCPeer) preparePeerConnection(config *webrtc.Configuration) error { <-done // Wait for ICE candidate gathering to complete. - if !strings.Contains(c.pc.LocalDescription().SDP, "\na=candidate:") { - return fmt.Errorf("SDP offer contains no candidate") - } return nil } diff --git a/proxy/lib/snowflake.go b/proxy/lib/snowflake.go index 34bda5a..7897200 100644 --- a/proxy/lib/snowflake.go +++ b/proxy/lib/snowflake.go @@ -545,9 +545,6 @@ func (sf *SnowflakeProxy) makePeerConnectionFromOffer( " before the client times out") } - if !strings.Contains(pc.LocalDescription().SDP, "\na=candidate:") { - return nil, fmt.Errorf("SDP answer contains no candidate") - } log.Printf("Answer: \n\t%s", strings.ReplaceAll(pc.LocalDescription().SDP, "\n", "\n\t")) return pc, nil @@ -608,10 +605,6 @@ func (sf *SnowflakeProxy) makeNewPeerConnection( // Wait for ICE candidate gathering to complete <-done - if !strings.Contains(pc.LocalDescription().SDP, "\na=candidate:") { - return nil, fmt.Errorf("Probetest SDP offer contains no candidate") - } - return pc, nil }