mirror of
https://gitlab.torproject.org/tpo/anti-censorship/pluggable-transports/snowflake.git
synced 2025-10-13 20:11:19 -04:00
Remove local LAN address ICE candidates
Unfortunately, the "public" RTCIceTransportPolicy was removed. https://developer.mozilla.org/en-US/docs/Web/API/RTCConfiguration#RTCIceTransportPolicy_enum Trac: 19026
This commit is contained in:
parent
28cf70bb44
commit
0fae4ee8ea
4 changed files with 89 additions and 13 deletions
|
@ -288,7 +288,7 @@ func TestSnowflakeClient(t *testing.T) {
|
|||
fakeOffer := deserializeSessionDescription(`{"type":"offer","sdp":"test"}`)
|
||||
|
||||
Convey("Construct BrokerChannel with no front domain", func() {
|
||||
b, err := NewBrokerChannel("test.broker", "", transport)
|
||||
b, err := NewBrokerChannel("test.broker", "", transport, false)
|
||||
So(b.url, ShouldNotBeNil)
|
||||
So(err, ShouldBeNil)
|
||||
So(b.url.Path, ShouldResemble, "test.broker")
|
||||
|
@ -296,7 +296,7 @@ func TestSnowflakeClient(t *testing.T) {
|
|||
})
|
||||
|
||||
Convey("Construct BrokerChannel *with* front domain", func() {
|
||||
b, err := NewBrokerChannel("test.broker", "front", transport)
|
||||
b, err := NewBrokerChannel("test.broker", "front", transport, false)
|
||||
So(b.url, ShouldNotBeNil)
|
||||
So(err, ShouldBeNil)
|
||||
So(b.url.Path, ShouldResemble, "test.broker")
|
||||
|
@ -305,7 +305,7 @@ func TestSnowflakeClient(t *testing.T) {
|
|||
})
|
||||
|
||||
Convey("BrokerChannel.Negotiate responds with answer", func() {
|
||||
b, err := NewBrokerChannel("test.broker", "", transport)
|
||||
b, err := NewBrokerChannel("test.broker", "", transport, false)
|
||||
So(err, ShouldBeNil)
|
||||
answer, err := b.Negotiate(fakeOffer)
|
||||
So(err, ShouldBeNil)
|
||||
|
@ -315,7 +315,8 @@ func TestSnowflakeClient(t *testing.T) {
|
|||
|
||||
Convey("BrokerChannel.Negotiate fails with 503", func() {
|
||||
b, err := NewBrokerChannel("test.broker", "",
|
||||
&MockTransport{http.StatusServiceUnavailable, []byte("\n")})
|
||||
&MockTransport{http.StatusServiceUnavailable, []byte("\n")},
|
||||
false)
|
||||
So(err, ShouldBeNil)
|
||||
answer, err := b.Negotiate(fakeOffer)
|
||||
So(err, ShouldNotBeNil)
|
||||
|
@ -325,7 +326,8 @@ func TestSnowflakeClient(t *testing.T) {
|
|||
|
||||
Convey("BrokerChannel.Negotiate fails with 400", func() {
|
||||
b, err := NewBrokerChannel("test.broker", "",
|
||||
&MockTransport{http.StatusBadRequest, []byte("\n")})
|
||||
&MockTransport{http.StatusBadRequest, []byte("\n")},
|
||||
false)
|
||||
So(err, ShouldBeNil)
|
||||
answer, err := b.Negotiate(fakeOffer)
|
||||
So(err, ShouldNotBeNil)
|
||||
|
@ -335,7 +337,8 @@ func TestSnowflakeClient(t *testing.T) {
|
|||
|
||||
Convey("BrokerChannel.Negotiate fails with large read", func() {
|
||||
b, err := NewBrokerChannel("test.broker", "",
|
||||
&MockTransport{http.StatusOK, make([]byte, 100001, 100001)})
|
||||
&MockTransport{http.StatusOK, make([]byte, 100001, 100001)},
|
||||
false)
|
||||
So(err, ShouldBeNil)
|
||||
answer, err := b.Negotiate(fakeOffer)
|
||||
So(err, ShouldNotBeNil)
|
||||
|
@ -345,7 +348,7 @@ func TestSnowflakeClient(t *testing.T) {
|
|||
|
||||
Convey("BrokerChannel.Negotiate fails with unexpected error", func() {
|
||||
b, err := NewBrokerChannel("test.broker", "",
|
||||
&MockTransport{123, []byte("")})
|
||||
&MockTransport{123, []byte("")}, false)
|
||||
So(err, ShouldBeNil)
|
||||
answer, err := b.Negotiate(fakeOffer)
|
||||
So(err, ShouldNotBeNil)
|
||||
|
@ -353,4 +356,22 @@ func TestSnowflakeClient(t *testing.T) {
|
|||
So(err.Error(), ShouldResemble, BrokerErrorUnexpected)
|
||||
})
|
||||
})
|
||||
|
||||
Convey("Strip", t, func() {
|
||||
const offerStart = `{"type":"offer","sdp":"v=0\r\no=- 4358805017720277108 2 IN IP4 8.8.8.8\r\ns=-\r\nt=0 0\r\na=group:BUNDLE data\r\na=msid-semantic: WMS\r\nm=application 56688 DTLS/SCTP 5000\r\nc=IN IP4 8.8.8.8\r\n`
|
||||
const goodCandidate = `a=candidate:3769337065 1 udp 2122260223 8.8.8.8 56688 typ host generation 0 network-id 1 network-cost 50\r\n`
|
||||
const offerEnd = `a=ice-ufrag:aMAZ\r\na=ice-pwd:jcHb08Jjgrazp2dzjdrvPPvV\r\na=ice-options:trickle\r\na=fingerprint:sha-256 C8:88:EE:B9:E7:02:2E:21:37:ED:7A:D1:EB:2B:A3:15:A2:3B:5B:1C:3D:D4:D5:1F:06:CF:52:40:03:F8:DD:66\r\na=setup:actpass\r\na=mid:data\r\na=sctpmap:5000 webrtc-datachannel 1024\r\n"}`
|
||||
|
||||
offer := offerStart + goodCandidate +
|
||||
`a=candidate:3769337065 1 udp 2122260223 192.168.0.100 56688 typ host generation 0 network-id 1 network-cost 50\r\n` + // IsLocal IPv4
|
||||
`a=candidate:3769337065 1 udp 2122260223 fdf8:f53b:82e4::53 56688 typ host generation 0 network-id 1 network-cost 50\r\n` + // IsLocal IPv6
|
||||
`a=candidate:3769337065 1 udp 2122260223 0.0.0.0 56688 typ host generation 0 network-id 1 network-cost 50\r\n` + // IsUnspecified IPv4
|
||||
`a=candidate:3769337065 1 udp 2122260223 :: 56688 typ host generation 0 network-id 1 network-cost 50\r\n` + // IsUnspecified IPv6
|
||||
`a=candidate:3769337065 1 udp 2122260223 127.0.0.1 56688 typ host generation 0 network-id 1 network-cost 50\r\n` + // IsLoopback IPv4
|
||||
`a=candidate:3769337065 1 udp 2122260223 ::1 56688 typ host generation 0 network-id 1 network-cost 50\r\n` + // IsLoopback IPv6
|
||||
offerEnd
|
||||
|
||||
So(stripLocalAddresses(offer), ShouldEqual, offerStart+goodCandidate+offerEnd)
|
||||
})
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue