Skip to content

Commit

Permalink
Improve auditing of joining sessions (#145)
Browse files Browse the repository at this point in the history
  • Loading branch information
streamer45 authored Jun 5, 2024
1 parent a21f616 commit 05adcec
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 0 deletions.
9 changes: 9 additions & 0 deletions service/rtc/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,15 @@ type SessionConfig struct {
UserID string
// SessionID specifies the unique identifier for the session.
SessionID string
Props map[string]any
}

func (c *SessionConfig) GetStringProp(key string) string {
if c == nil || c.Props == nil {
return ""
}
val, _ := c.Props[key].(string)
return val
}

func (c SessionConfig) IsValid() error {
Expand Down
7 changes: 7 additions & 0 deletions service/rtc/sfu.go
Original file line number Diff line number Diff line change
Expand Up @@ -652,6 +652,13 @@ func (s *Server) InitSession(cfg SessionConfig, closeCb func() error) error {
<-iceDoneCh
}()

s.log.Debug("session has joined call",
mlog.String("userID", cfg.UserID),
mlog.String("sessionID", cfg.SessionID),
mlog.String("channelID", cfg.GetStringProp("channelID")),
mlog.String("callID", cfg.CallID),
)

return nil
}

Expand Down
6 changes: 6 additions & 0 deletions service/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -296,6 +296,7 @@ func (s *Service) handleClientMsg(msg ws.Message) error {
if sessionID == "" {
return fmt.Errorf("missing sessionID in client message")
}
channelID := data["channelID"]

closeCb := func() error {
s.mut.Lock()
Expand All @@ -321,8 +322,13 @@ func (s *Service) handleClientMsg(msg ws.Message) error {
CallID: callID,
UserID: userID,
SessionID: sessionID,
Props: map[string]any{
"channelID": channelID,
},
}

s.log.Debug("join message", mlog.Any("sessionCfg", cfg))

if err := s.rtcServer.InitSession(cfg, closeCb); err != nil {
return fmt.Errorf("failed to initialize rtc session: %w", err)
}
Expand Down

0 comments on commit 05adcec

Please sign in to comment.