[Pkg-voip-commits] [janus] 37/282: Integrated fix made for #885 in SIPre plugin as well

Jonas Smedegaard dr at jones.dk
Wed Dec 20 21:53:25 UTC 2017


This is an automated email from the git hooks/post-receive script.

js pushed a commit to annotated tag debian/0.2.6-1
in repository janus.

commit 2a0e4a6fcf6672a95c82ac45cbcd752ad1c3d7de
Author: Lorenzo Miniero <lminiero at gmail.com>
Date:   Thu May 11 11:02:04 2017 +0200

    Integrated fix made for #885 in SIPre plugin as well
---
 html/sipretest.js     | 22 ++++++++++------------
 plugins/janus_sipre.c | 34 +++++++++++++++-------------------
 2 files changed, 25 insertions(+), 31 deletions(-)

diff --git a/html/sipretest.js b/html/sipretest.js
index 6ef163d..afb1a68 100644
--- a/html/sipretest.js
+++ b/html/sipretest.js
@@ -440,20 +440,18 @@ function registerUsername() {
 		if(sipserver !== "")
 			register["proxy"] = sipserver;
 		var username = $('#username').val();
-		if(username !== undefined && username !== null) {
-			if(username === "" || username.indexOf("sip:") != 0 || username.indexOf("@") < 0) {
-				bootbox.alert('Usernames are optional for guests: if you want to specify one anyway, though, please insert a valid SIP address (e.g., sip:goofy at example.com)');
-				$('#server').removeAttr('disabled');
-				$('#username').removeAttr('disabled');
-				$('#displayname').removeAttr('disabled');
-				$('#register').removeAttr('disabled').click(registerUsername);
-				$('#registerset').removeAttr('disabled');
-				return;
-			}
-			register.username = username;
+		if(!username === "" || username.indexOf("sip:") != 0 || username.indexOf("@") < 0) {
+			bootbox.alert("Please insert a valid SIP address (e.g., sip:goofy at example.com): this doesn't need to exist for guests, but is required");
+			$('#server').removeAttr('disabled');
+			$('#username').removeAttr('disabled');
+			$('#displayname').removeAttr('disabled');
+			$('#register').removeAttr('disabled').click(registerUsername);
+			$('#registerset').removeAttr('disabled');
+			return;
 		}
+		register.username = username;
 		var displayname = $('#displayname').val();
-		if (displayname) {
+		if(displayname) {
 			register.display_name = displayname;
 		}
 		if(sipserver === "") {
diff --git a/plugins/janus_sipre.c b/plugins/janus_sipre.c
index f7b2954..a259775 100644
--- a/plugins/janus_sipre.c
+++ b/plugins/janus_sipre.c
@@ -137,7 +137,7 @@ static struct janus_json_parameter register_parameters[] = {
 	{"type", JANUS_JSON_STRING, 0},
 	{"send_register", JANUS_JSON_BOOL, 0},
 	{"sips", JANUS_JSON_BOOL, 0},
-	{"username", JANUS_JSON_STRING, 0},
+	{"username", JANUS_JSON_STRING, JANUS_JSON_PARAM_REQUIRED},
 	{"secret", JANUS_JSON_STRING, 0},
 	{"ha1_secret", JANUS_JSON_STRING, 0},
 	{"authuser", JANUS_JSON_STRING, 0}
@@ -1488,10 +1488,10 @@ static void *janus_sipre_handler(void *data) {
 			if(user_agent && json_is_string(user_agent))
 				user_agent_text = json_string_value(user_agent);
 
-			/* Now the user part, if needed */
+			/* Now the user part (always needed, even for the guest case) */
 			json_t *username = json_object_get(root, "username");
-			if(!guest && !username) {
-				/* The username is mandatory if we're not registering as guests */
+			if(!username) {
+				/* The username is mandatory even when registering as guests */
 				JANUS_LOG(LOG_ERR, "Missing element (username)\n");
 				error_code = JANUS_SIPRE_ERROR_MISSING_ELEMENT;
 				g_snprintf(error_cause, 512, "Missing element (username)");
@@ -1500,23 +1500,19 @@ static void *janus_sipre_handler(void *data) {
 			const char *username_text = NULL;
 			char *user_id = NULL, *user_host = NULL;
 			guint16 user_port = 0;
-			if(username) {
-				/* Parse address */
-				username_text = json_string_value(username);
-				if(janus_sipre_parse_uri(username_text) < 0) {
-					JANUS_LOG(LOG_ERR, "Invalid user address %s\n", username_text);
-					error_code = JANUS_SIPRE_ERROR_INVALID_ADDRESS;
-					g_snprintf(error_cause, 512, "Invalid user address %s\n", username_text);
-					goto error;
-				}
-				user_id = janus_sipre_get_uri_username(username_text);
-				user_host = janus_sipre_get_uri_host(username_text);
-				user_port = janus_sipre_get_uri_port(username_text);
+			/* Parse address */
+			username_text = json_string_value(username);
+			if(janus_sipre_parse_uri(username_text) < 0) {
+				JANUS_LOG(LOG_ERR, "Invalid user address %s\n", username_text);
+				error_code = JANUS_SIPRE_ERROR_INVALID_ADDRESS;
+				g_snprintf(error_cause, 512, "Invalid user address %s\n", username_text);
+				goto error;
 			}
+			user_id = janus_sipre_get_uri_username(username_text);
+			user_host = janus_sipre_get_uri_host(username_text);
+			user_port = janus_sipre_get_uri_port(username_text);
 			if(guest) {
-				/* Not needed, we can stop here: just pick a random username if it wasn't provided and say we're registered */
-				if(!username)
-					g_snprintf(user_id, 255, "janus-sipre-%"SCNu32"", janus_random_uint32());
+				/* Not needed, we can stop here: just say we're registered */
 				JANUS_LOG(LOG_INFO, "Guest will have username %s\n", user_id);
 				send_register = FALSE;
 			} else {

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-voip/janus.git



More information about the Pkg-voip-commits mailing list