-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
List private rooms if valid admin_key was provided. #2161
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3546,16 +3546,32 @@ static json_t *janus_videoroom_process_synchronous_request(janus_videoroom_sessi | |
GHashTableIter iter; | ||
gpointer value; | ||
g_hash_table_iter_init(&iter, rooms); | ||
gboolean lock_room_list = TRUE; | ||
if(admin_key != NULL) { | ||
json_t *admin_key_json = json_object_get(root, "admin_key"); | ||
/* Verify admin_key if it was provided */ | ||
if(admin_key_json != NULL && strlen(json_string_value(admin_key_json)) > 0) { | ||
JANUS_CHECK_SECRET(admin_key, root, "admin_key", error_code, error_cause, | ||
JANUS_VIDEOROOM_ERROR_MISSING_ELEMENT, JANUS_VIDEOROOM_ERROR_INVALID_ELEMENT, JANUS_VIDEOROOM_ERROR_UNAUTHORIZED); | ||
if(error_code != 0) { | ||
janus_mutex_unlock(&rooms_mutex); | ||
goto prepare_response; | ||
} | ||
else { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please put the |
||
lock_room_list = FALSE; | ||
} | ||
} | ||
} | ||
while(g_hash_table_iter_next(&iter, NULL, &value)) { | ||
janus_videoroom *room = value; | ||
if(!room) | ||
continue; | ||
janus_refcount_increase(&room->ref); | ||
if(room->is_private) { | ||
/* Skip private room */ | ||
JANUS_LOG(LOG_VERB, "Skipping private room '%s'\n", room->room_name); | ||
janus_refcount_decrease(&room->ref); | ||
continue; | ||
if(room->is_private && lock_room_list) { | ||
/* Skip private room if no valid admin_key was provided */ | ||
JANUS_LOG(LOG_VERB, "Skipping private room '%s'\n", room->room_name); | ||
janus_refcount_decrease(&room->ref); | ||
continue; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Looks like you added an extra tab for the lines above? |
||
} | ||
if(!g_atomic_int_get(&room->destroyed)) { | ||
json_t *rl = json_object(); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should also have a check on
json_is_string(admin_key_json)
, as there's no guaranteeadmin_key
is a string in the JSON (it's not part of the objects we use for validation in "list", since list requires no arguments).