From aaf882656086171e0711c62f9817b9bd22b3472d Mon Sep 17 00:00:00 2001 From: Cecylia Bocovich Date: Wed, 23 Oct 2024 09:38:14 -0400 Subject: [PATCH] Add proxy event for when client has connected This enables the usage of callbacks that will be called when a client has opened a data channel connection to the proxy. --- common/event/interface.go | 8 ++++++++ proxy/lib/snowflake.go | 1 + 2 files changed, 9 insertions(+) diff --git a/common/event/interface.go b/common/event/interface.go index 38dd6d7..f7001ba 100644 --- a/common/event/interface.go +++ b/common/event/interface.go @@ -67,6 +67,14 @@ func (e EventOnProxyStarting) String() string { return "Proxy starting" } +type EventOnProxyClientConnected struct { + SnowflakeEvent +} + +func (e EventOnProxyClientConnected) String() string { + return fmt.Sprintf("client connected") +} + type EventOnProxyConnectionOver struct { SnowflakeEvent InboundTraffic int64 diff --git a/proxy/lib/snowflake.go b/proxy/lib/snowflake.go index 9041f60..442e013 100644 --- a/proxy/lib/snowflake.go +++ b/proxy/lib/snowflake.go @@ -449,6 +449,7 @@ func (sf *SnowflakeProxy) makePeerConnectionFromOffer( dc.OnOpen(func() { log.Printf("Data Channel %s-%d open\n", dc.Label(), dc.ID()) + sf.EventDispatcher.OnNewSnowflakeEvent(event.EventOnProxyClientConnected{}) if sf.OutboundAddress != "" { selectedCandidatePair, err := pc.SCTP().Transport().ICETransport().GetSelectedCandidatePair()