broker and proxy must not reject client offers with no ICE candidates

Fixes #40371. Partially reverts !141.
This commit is contained in:
Neel Chauhan 2024-10-14 13:38:20 -04:00 committed by Cecylia Bocovich
parent 9ff205dd7f
commit 8792771cdc
No known key found for this signature in database
GPG key ID: 009DE379FD9B7B90
4 changed files with 0 additions and 35 deletions

View file

@ -139,13 +139,6 @@ func clientOffers(i *IPC, w http.ResponseWriter, r *http.Request) {
return return
} }
err = validateSDP(body)
if err != nil {
log.Println("Error client SDP: ", err.Error())
w.WriteHeader(http.StatusBadRequest)
return
}
// Handle the legacy version // Handle the legacy version
// //
// We support two client message formats. The legacy format is for backwards // We support two client message formats. The legacy format is for backwards

View file

@ -137,14 +137,6 @@ func TestBroker(t *testing.T) {
r, err := http.NewRequest("POST", "snowflake.broker/client", data) r, err := http.NewRequest("POST", "snowflake.broker/client", data)
So(err, ShouldBeNil) 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() { Convey("with error when no snowflakes are available.", func() {
clientOffers(i, w, r) clientOffers(i, w, r)
So(w.Code, ShouldEqual, http.StatusOK) So(w.Code, ShouldEqual, http.StatusOK)
@ -246,14 +238,6 @@ client-sqs-ips
So(err, ShouldBeNil) So(err, ShouldBeNil)
r.Header.Set("Snowflake-NAT-TYPE", "restricted") 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() { Convey("with 503 when no snowflakes are available.", func() {
clientOffers(i, w, r) clientOffers(i, w, r)
So(w.Code, ShouldEqual, http.StatusServiceUnavailable) So(w.Code, ShouldEqual, http.StatusServiceUnavailable)

View file

@ -4,11 +4,9 @@ import (
"crypto/rand" "crypto/rand"
"encoding/hex" "encoding/hex"
"errors" "errors"
"fmt"
"io" "io"
"log" "log"
"net/url" "net/url"
"strings"
"sync" "sync"
"time" "time"
@ -301,9 +299,6 @@ func (c *WebRTCPeer) preparePeerConnection(config *webrtc.Configuration) error {
<-done // Wait for ICE candidate gathering to complete. <-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 return nil
} }

View file

@ -545,9 +545,6 @@ func (sf *SnowflakeProxy) makePeerConnectionFromOffer(
" before the client times out") " 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")) log.Printf("Answer: \n\t%s", strings.ReplaceAll(pc.LocalDescription().SDP, "\n", "\n\t"))
return pc, nil return pc, nil
@ -608,10 +605,6 @@ func (sf *SnowflakeProxy) makeNewPeerConnection(
// Wait for ICE candidate gathering to complete // Wait for ICE candidate gathering to complete
<-done <-done
if !strings.Contains(pc.LocalDescription().SDP, "\na=candidate:") {
return nil, fmt.Errorf("Probetest SDP offer contains no candidate")
}
return pc, nil return pc, nil
} }