Add Propagate EventLogger Setting

This commit is contained in:
Shelikhoo 2021-12-13 16:29:10 +00:00
parent 8d2f662c8c
commit 7536dd6fb7
No known key found for this signature in database
GPG key ID: C4D5E79D22B25316
2 changed files with 12 additions and 3 deletions

View file

@ -10,6 +10,7 @@ import (
"sync" "sync"
"time" "time"
"git.torproject.org/pluggable-transports/snowflake.git/v2/common/event"
"git.torproject.org/pluggable-transports/snowflake.git/v2/common/messages" "git.torproject.org/pluggable-transports/snowflake.git/v2/common/messages"
"git.torproject.org/pluggable-transports/snowflake.git/v2/common/nat" "git.torproject.org/pluggable-transports/snowflake.git/v2/common/nat"
"git.torproject.org/pluggable-transports/snowflake.git/v2/common/util" "git.torproject.org/pluggable-transports/snowflake.git/v2/common/util"
@ -141,10 +142,16 @@ type WebRTCDialer struct {
*BrokerChannel *BrokerChannel
webrtcConfig *webrtc.Configuration webrtcConfig *webrtc.Configuration
max int max int
eventLogger event.SnowflakeEventReceiver
} }
// NewWebRTCDialer constructs a new WebRTCDialer.
func NewWebRTCDialer(broker *BrokerChannel, iceServers []webrtc.ICEServer, max int) *WebRTCDialer { func NewWebRTCDialer(broker *BrokerChannel, iceServers []webrtc.ICEServer, max int) *WebRTCDialer {
return NewWebRTCDialer4E(broker, iceServers, max, nil)
}
// NewWebRTCDialer4E constructs a new WebRTCDialer.
func NewWebRTCDialer4E(broker *BrokerChannel, iceServers []webrtc.ICEServer, max int, eventLogger event.SnowflakeEventReceiver) *WebRTCDialer {
config := webrtc.Configuration{ config := webrtc.Configuration{
ICEServers: iceServers, ICEServers: iceServers,
} }
@ -153,6 +160,8 @@ func NewWebRTCDialer(broker *BrokerChannel, iceServers []webrtc.ICEServer, max i
BrokerChannel: broker, BrokerChannel: broker,
webrtcConfig: &config, webrtcConfig: &config,
max: max, max: max,
eventLogger: eventLogger,
} }
} }
@ -160,7 +169,7 @@ func NewWebRTCDialer(broker *BrokerChannel, iceServers []webrtc.ICEServer, max i
func (w WebRTCDialer) Catch() (*WebRTCPeer, error) { func (w WebRTCDialer) Catch() (*WebRTCPeer, error) {
// TODO: [#25591] Fetch ICE server information from Broker. // TODO: [#25591] Fetch ICE server information from Broker.
// TODO: [#25596] Consider TURN servers here too. // TODO: [#25596] Consider TURN servers here too.
return NewWebRTCPeer(w.webrtcConfig, w.BrokerChannel) return NewWebRTCPeer3E(w.webrtcConfig, w.BrokerChannel, w.eventLogger)
} }
// GetMax returns the maximum number of snowflakes to collect. // GetMax returns the maximum number of snowflakes to collect.

View file

@ -135,7 +135,7 @@ func NewSnowflakeClient(config ClientConfig) (*Transport, error) {
if config.Max > max { if config.Max > max {
max = config.Max max = config.Max
} }
transport := &Transport{dialer: NewWebRTCDialer(broker, iceServers, max)} transport := &Transport{dialer: NewWebRTCDialer4E(broker, iceServers, max, config.EventDispatcher)}
return transport, nil return transport, nil
} }