mirror of
https://gitlab.torproject.org/tpo/anti-censorship/pluggable-transports/snowflake.git
synced 2025-10-14 05:11:19 -04:00
Move tor-specific code outside of client library
This commit is contained in:
parent
2f89fbc2ed
commit
d807e9d370
3 changed files with 5 additions and 4 deletions
|
@ -6,6 +6,7 @@ import (
|
|||
"testing"
|
||||
"time"
|
||||
|
||||
"git.torproject.org/pluggable-transports/snowflake.git/v2/common/event"
|
||||
. "github.com/smartystreets/goconvey/convey"
|
||||
)
|
||||
|
||||
|
@ -171,8 +172,8 @@ func TestSnowflakeClient(t *testing.T) {
|
|||
|
||||
func TestWebRTCPeer(t *testing.T) {
|
||||
Convey("WebRTCPeer", t, func(c C) {
|
||||
eventsLogger := NewPTEventLogger()
|
||||
p := &WebRTCPeer{closed: make(chan struct{}), eventsLogger: eventsLogger}
|
||||
p := &WebRTCPeer{closed: make(chan struct{}),
|
||||
eventsLogger: event.NewSnowflakeEventDispatcher()}
|
||||
Convey("checks for staleness", func() {
|
||||
go p.checkForStaleness(time.Second)
|
||||
<-time.After(2 * time.Second)
|
||||
|
|
|
@ -1,43 +0,0 @@
|
|||
package snowflake_client
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
pt "git.torproject.org/pluggable-transports/goptlib.git"
|
||||
"git.torproject.org/pluggable-transports/snowflake.git/v2/common/event"
|
||||
)
|
||||
|
||||
func NewPTEventLogger() event.SnowflakeEventReceiver {
|
||||
return &ptEventLogger{}
|
||||
}
|
||||
|
||||
type ptEventLogger struct {
|
||||
}
|
||||
|
||||
func (p ptEventLogger) OnNewSnowflakeEvent(e event.SnowflakeEvent) {
|
||||
switch e.(type) {
|
||||
case event.EventOnOfferCreated:
|
||||
e := e.(event.EventOnOfferCreated)
|
||||
if e.Error != nil {
|
||||
pt.Log(pt.LogSeverityNotice, fmt.Sprintf("offer creation failure %v", e.Error.Error()))
|
||||
} else {
|
||||
pt.Log(pt.LogSeverityNotice, fmt.Sprintf("offer created"))
|
||||
}
|
||||
|
||||
case event.EventOnBrokerRendezvous:
|
||||
e := e.(event.EventOnBrokerRendezvous)
|
||||
if e.Error != nil {
|
||||
pt.Log(pt.LogSeverityNotice, fmt.Sprintf("broker failure %v", e.Error.Error()))
|
||||
} else {
|
||||
pt.Log(pt.LogSeverityNotice, fmt.Sprintf("broker rendezvous peer received"))
|
||||
}
|
||||
|
||||
case event.EventOnSnowflakeConnected:
|
||||
pt.Log(pt.LogSeverityNotice, fmt.Sprintf("connected"))
|
||||
|
||||
case event.EventOnSnowflakeConnectionFailed:
|
||||
e := e.(event.EventOnSnowflakeConnectionFailed)
|
||||
pt.Log(pt.LogSeverityNotice, fmt.Sprintf("connection failed %v", e.Error.Error()))
|
||||
}
|
||||
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue