Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[MM-45236] Improve auditing of joining sessions #145

Merged
merged 1 commit into from
Jun 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading