Move tor-specific code outside of client library

This commit is contained in:
Cecylia Bocovich 2022-04-11 11:38:52 -04:00
parent 2f89fbc2ed
commit d807e9d370
No known key found for this signature in database
GPG key ID: 009DE379FD9B7B90
3 changed files with 5 additions and 4 deletions

View file

@ -6,6 +6,7 @@ import (
"testing" "testing"
"time" "time"
"git.torproject.org/pluggable-transports/snowflake.git/v2/common/event"
. "github.com/smartystreets/goconvey/convey" . "github.com/smartystreets/goconvey/convey"
) )
@ -171,8 +172,8 @@ func TestSnowflakeClient(t *testing.T) {
func TestWebRTCPeer(t *testing.T) { func TestWebRTCPeer(t *testing.T) {
Convey("WebRTCPeer", t, func(c C) { Convey("WebRTCPeer", t, func(c C) {
eventsLogger := NewPTEventLogger() p := &WebRTCPeer{closed: make(chan struct{}),
p := &WebRTCPeer{closed: make(chan struct{}), eventsLogger: eventsLogger} eventsLogger: event.NewSnowflakeEventDispatcher()}
Convey("checks for staleness", func() { Convey("checks for staleness", func() {
go p.checkForStaleness(time.Second) go p.checkForStaleness(time.Second)
<-time.After(2 * time.Second) <-time.After(2 * time.Second)

View file

@ -1,4 +1,4 @@
package snowflake_client package main
import ( import (
"fmt" "fmt"

View file

@ -104,7 +104,7 @@ func socksAcceptLoop(ln *pt.SocksListener, config sf.ClientConfig, shutdown chan
log.Println("Failed to start snowflake transport: ", err) log.Println("Failed to start snowflake transport: ", err)
return return
} }
transport.AddSnowflakeEventListener(sf.NewPTEventLogger()) transport.AddSnowflakeEventListener(NewPTEventLogger())
err = conn.Grant(&net.TCPAddr{IP: net.IPv4zero, Port: 0}) err = conn.Grant(&net.TCPAddr{IP: net.IPv4zero, Port: 0})
if err != nil { if err != nil {
log.Printf("conn.Grant error: %s", err) log.Printf("conn.Grant error: %s", err)