[tor-commits] [pluggable-transports/snowflake] 01/02: Use event logger for proxy starting message and NAT info
gitolite role
git at cupani.torproject.org
Wed Nov 16 18:11:06 UTC 2022
This is an automated email from the git hooks/post-receive script.
itchyonion pushed a commit to branch main
in repository pluggable-transports/snowflake.
commit 768b80dbdfba8733a614770c93fdbea4d48c7c52
Author: itchyonion <itchyonion at torproject.org>
AuthorDate: Mon Nov 7 15:20:20 2022 -0800
Use event logger for proxy starting message and NAT info
---
common/event/interface.go | 17 +++++++++++++++++
proxy/lib/pt_event_logger.go | 2 ++
proxy/lib/snowflake.go | 4 ++--
3 files changed, 21 insertions(+), 2 deletions(-)
diff --git a/common/event/interface.go b/common/event/interface.go
index 968b270..64132e0 100644
--- a/common/event/interface.go
+++ b/common/event/interface.go
@@ -58,6 +58,14 @@ func (e EventOnSnowflakeConnectionFailed) String() string {
return fmt.Sprintf("trying a new proxy: %s", scrubbed)
}
+type EventOnProxyStarting struct {
+ SnowflakeEvent
+}
+
+func (e EventOnProxyStarting) String() string {
+ return "Proxy starting"
+}
+
type EventOnProxyConnectionOver struct {
SnowflakeEvent
InboundTraffic int
@@ -68,6 +76,15 @@ func (e EventOnProxyConnectionOver) String() string {
return fmt.Sprintf("Proxy connection closed (↑ %d, ↓ %d)", e.InboundTraffic, e.OutboundTraffic)
}
+type EventOnCurrentNATTypeDetermined struct {
+ SnowflakeEvent
+ CurNATType string
+}
+
+func (e EventOnCurrentNATTypeDetermined) String() string {
+ return fmt.Sprintf("NAT type: %v", e.CurNATType)
+}
+
type SnowflakeEventReceiver interface {
// OnNewSnowflakeEvent notify receiver about a new event
// This method MUST not block
diff --git a/proxy/lib/pt_event_logger.go b/proxy/lib/pt_event_logger.go
index cb262e4..b16f5ba 100644
--- a/proxy/lib/pt_event_logger.go
+++ b/proxy/lib/pt_event_logger.go
@@ -33,6 +33,8 @@ func (p *logEventLogger) OnNewSnowflakeEvent(e event.SnowflakeEvent) {
p.inboundSum += e.InboundTraffic
p.outboundSum += e.OutboundTraffic
p.connectionCount += 1
+ default:
+ p.logger.Println(e.String())
}
}
diff --git a/proxy/lib/snowflake.go b/proxy/lib/snowflake.go
index f8a0f2c..b4ca5c3 100644
--- a/proxy/lib/snowflake.go
+++ b/proxy/lib/snowflake.go
@@ -566,7 +566,7 @@ func (sf *SnowflakeProxy) runSession(sid string) {
func (sf *SnowflakeProxy) Start() error {
var err error
- log.Println("starting")
+ sf.EventDispatcher.OnNewSnowflakeEvent(event.EventOnProxyStarting{})
sf.shutdown = make(chan struct{})
// blank configurations revert to default
@@ -621,7 +621,7 @@ func (sf *SnowflakeProxy) Start() error {
currentNATTypeLoaded := getCurrentNATType()
- log.Printf("NAT type: %s", currentNATTypeLoaded)
+ sf.EventDispatcher.OnNewSnowflakeEvent(&event.EventOnCurrentNATTypeDetermined{CurNATType: currentNATTypeLoaded})
NatRetestTask := task.Periodic{
Interval: sf.NATTypeMeasurementInterval,
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
More information about the tor-commits
mailing list