mirror of
https://gitlab.torproject.org/tpo/anti-censorship/pluggable-transports/snowflake.git
synced 2025-10-14 05:11:19 -04:00
Implement snowflake client lib as PTv2.1 Go API
This implements a pluggable transports v2.1 compatible Go API in the Snowflake client library, and refactors how the main Snowflake program calls it. The Go API implements the two required client side functions: a constructor that returns a Transport, and a Dial function for the Transport that returns a net.Conn. See the PT specification for more information: https://github.com/Pluggable-Transports/Pluggable-Transports-spec/blob/master/releases/PTSpecV2.1/Pluggable%20Transport%20Specification%20v2.1%20-%20Go%20Transport%20API.pdf
This commit is contained in:
parent
af6e2c30e1
commit
e87b9175dd
4 changed files with 211 additions and 207 deletions
|
@ -156,19 +156,6 @@ func TestSnowflakeClient(t *testing.T) {
|
|||
|
||||
})
|
||||
|
||||
Convey("Snowflake", t, func() {
|
||||
|
||||
SkipConvey("Handler Grants correctly", func() {
|
||||
socks := &FakeSocksConn{}
|
||||
broker := &BrokerChannel{Host: "test"}
|
||||
d := NewWebRTCDialer(broker, nil, 1)
|
||||
|
||||
So(socks.rejected, ShouldEqual, false)
|
||||
Handler(socks, d)
|
||||
So(socks.rejected, ShouldEqual, true)
|
||||
})
|
||||
})
|
||||
|
||||
Convey("Dialers", t, func() {
|
||||
Convey("Can construct WebRTCDialer.", func() {
|
||||
broker := &BrokerChannel{Host: "test"}
|
||||
|
@ -267,3 +254,45 @@ func TestSnowflakeClient(t *testing.T) {
|
|||
})
|
||||
|
||||
}
|
||||
|
||||
func TestICEServerParser(t *testing.T) {
|
||||
Convey("Test parsing of ICE servers", t, func() {
|
||||
for _, test := range []struct {
|
||||
input []string
|
||||
urls [][]string
|
||||
length int
|
||||
}{
|
||||
{
|
||||
[]string{"stun:stun.l.google.com:19302"},
|
||||
[][]string{[]string{"stun:stun.l.google.com:19302"}},
|
||||
1,
|
||||
},
|
||||
{
|
||||
[]string{"stun:stun.l.google.com:19302", "stun.ekiga.net"},
|
||||
[][]string{[]string{"stun:stun.l.google.com:19302"}, []string{"stun.ekiga.net"}},
|
||||
2,
|
||||
},
|
||||
{
|
||||
[]string{"stun:stun.l.google.com:19302", "stun.ekiga.net"},
|
||||
[][]string{[]string{"stun:stun.l.google.com:19302"}, []string{"stun.ekiga.net"}},
|
||||
2,
|
||||
},
|
||||
} {
|
||||
servers := parseIceServers(test.input)
|
||||
|
||||
if test.urls == nil {
|
||||
So(servers, ShouldBeNil)
|
||||
} else {
|
||||
So(servers, ShouldNotBeNil)
|
||||
}
|
||||
|
||||
So(len(servers), ShouldEqual, test.length)
|
||||
|
||||
for _, server := range servers {
|
||||
So(test.urls, ShouldContain, server.URLs)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
})
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue