mirror of
https://gitlab.torproject.org/tpo/anti-censorship/pluggable-transports/snowflake.git
synced 2025-10-14 05:11:19 -04:00
Add PT Event Logger
This commit is contained in:
parent
36ca610d6b
commit
ac64d17705
1 changed files with 43 additions and 0 deletions
43
client/lib/pt_event_logger.go
Normal file
43
client/lib/pt_event_logger.go
Normal file
|
@ -0,0 +1,43 @@
|
||||||
|
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.LogSeverityError, fmt.Sprintf("offer creation failure %v", e.Error.Error()))
|
||||||
|
} else {
|
||||||
|
pt.Log(pt.LogSeverityNotice, fmt.Sprintf("offer created %v", e.WebRTCLocalDescription))
|
||||||
|
}
|
||||||
|
|
||||||
|
case event.EventOnBrokerRendezvous:
|
||||||
|
e := e.(event.EventOnBrokerRendezvous)
|
||||||
|
if e.Error != nil {
|
||||||
|
pt.Log(pt.LogSeverityError, fmt.Sprintf("broker failure %v", e.Error.Error()))
|
||||||
|
} else {
|
||||||
|
pt.Log(pt.LogSeverityNotice, fmt.Sprintf("broker rendezvous peer %v", e.WebRTCRemoteDescription))
|
||||||
|
}
|
||||||
|
|
||||||
|
case event.EventOnSnowflakeConnected:
|
||||||
|
pt.Log(pt.LogSeverityNotice, fmt.Sprintf("connected"))
|
||||||
|
|
||||||
|
case event.EventOnSnowflakeConnectionFailed:
|
||||||
|
e := e.(event.EventOnSnowflakeConnectionFailed)
|
||||||
|
pt.Log(pt.LogSeverityError, fmt.Sprintf("connection failed %v", e.Error.Error()))
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
Loading…
Add table
Add a link
Reference in a new issue