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.
This commit is contained in:
Cecylia Bocovich 2024-10-23 09:38:14 -04:00
parent 0d8bd159ec
commit aaf8826560
No known key found for this signature in database
GPG key ID: 009DE379FD9B7B90
2 changed files with 9 additions and 0 deletions

View file

@ -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

View file

@ -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()