diff --git a/cmd/cli/commands/room.go b/cmd/cli/commands/room.go index bb282d6d..116b6b66 100644 --- a/cmd/cli/commands/room.go +++ b/cmd/cli/commands/room.go @@ -65,7 +65,6 @@ func createClient(c *cli.Context) error { func createRoom(c *cli.Context) error { ctx := contextWithAccessToken(c, &auth.VideoGrant{RoomCreate: true}) - fmt.Println("context", ctx) room, err := roomClient.CreateRoom(ctx, &livekit.CreateRoomRequest{ Name: c.String("name"), }) diff --git a/cmd/cli/commands/token.go b/cmd/cli/commands/token.go index a25bfd76..3740db6c 100644 --- a/cmd/cli/commands/token.go +++ b/cmd/cli/commands/token.go @@ -11,7 +11,7 @@ import ( var ( TokenCommands = []*cli.Command{ { - Name: "token", + Name: "create-token", Usage: "create token for Room APIs", Action: createToken, Flags: []cli.Flag{ @@ -26,12 +26,14 @@ var ( Usage: "enable token to be used to create rooms", }, &cli.StringFlag{ - Name: "participant", - Usage: "unique name of the participant, used with --join", + Name: "participant", + Aliases: []string{"p"}, + Usage: "unique name of the participant, used with --join", }, &cli.StringFlag{ - Name: "room", - Usage: "name of the room to join, empty to allow joining all rooms", + Name: "room", + Aliases: []string{"r"}, + Usage: "name of the room to join, empty to allow joining all rooms", }, }, }, diff --git a/pkg/rtc/room.go b/pkg/rtc/room.go index a47d8d0a..85514ad8 100644 --- a/pkg/rtc/room.go +++ b/pkg/rtc/room.go @@ -17,8 +17,6 @@ type Room struct { lock sync.RWMutex // map of participantId -> Participant participants map[string]Participant - // Client ID => list of tracks they are publishing - //tracks map[string][]Track } func NewRoomForRequest(req *livekit.CreateRoomRequest, config *WebRTCConfig) *Room { diff --git a/pkg/service/rtc.go b/pkg/service/rtc.go index f2a1fb01..1bfd9d2d 100644 --- a/pkg/service/rtc.go +++ b/pkg/service/rtc.go @@ -27,11 +27,10 @@ func NewRTCService(conf *config.Config, manager *rtc.RoomManager) *RTCService { isDev: conf.Development, } - if s.isDev { - s.upgrader.CheckOrigin = func(r *http.Request) bool { - // allow all in dev - return true - } + // allow connections from any origin, since script may be hosted anywhere + // security is enforced by access tokens + s.upgrader.CheckOrigin = func(r *http.Request) bool { + return true } return s @@ -71,6 +70,8 @@ func (s *RTCService) ServeHTTP(w http.ResponseWriter, r *http.Request) { logger.GetLogger().Warnw("could not upgrade to WS", "err", err, ) + writeJSONError(w, http.StatusInternalServerError, err.Error()) + return } conn.SetCloseHandler(func(code int, text string) error { log.Infow("websocket closed by remote")