[Pkg-voip-commits] [janus] 85/282: Cleaned up some currently unused features

Jonas Smedegaard dr at jones.dk
Wed Dec 20 21:53:30 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 38109c95a56a381a2c54ddd9467b7eba7f453421
Author: Lorenzo Miniero <lminiero at gmail.com>
Date:   Fri Jun 30 19:49:07 2017 +0200

    Cleaned up some currently unused features
---
 conf/janus.plugin.sip.cfg.sample   |  1 +
 conf/janus.plugin.sipre.cfg.sample | 11 +------
 html/sipretest.html                |  2 --
 html/sipretest.js                  | 13 ++------
 plugins/janus_sipre.c              | 66 +++++++++-----------------------------
 5 files changed, 19 insertions(+), 74 deletions(-)

diff --git a/conf/janus.plugin.sip.cfg.sample b/conf/janus.plugin.sip.cfg.sample
index f7c76a6..3c02eb0 100644
--- a/conf/janus.plugin.sip.cfg.sample
+++ b/conf/janus.plugin.sip.cfg.sample
@@ -15,6 +15,7 @@ behind_nat = no
 
 ; User-Agent string to be used
 ; user_agent = Cool WebRTC Gateway
+
 ; Expiration time for registrations
 register_ttl = 3600
 
diff --git a/conf/janus.plugin.sipre.cfg.sample b/conf/janus.plugin.sipre.cfg.sample
index f7c76a6..81fcd1c 100644
--- a/conf/janus.plugin.sipre.cfg.sample
+++ b/conf/janus.plugin.sipre.cfg.sample
@@ -3,18 +3,9 @@
 ; guessed from the system
 ;local_ip = 1.2.3.4
 
-; Enable local keep-alives to keep the registration open. Keep-alives are
-; sent in the form of OPTIONS requests, at the given interval inseconds.
-; (0 to disable)
-keepalive_interval = 120
-
-; Indicate if the server is behind NAT. If so, the server will use STUN
-; to guess its own public IP address and use it in the Contact header of
-; outgoing requests
-behind_nat = no
-
 ; User-Agent string to be used
 ; user_agent = Cool WebRTC Gateway
+
 ; Expiration time for registrations
 register_ttl = 3600
 
diff --git a/html/sipretest.html b/html/sipretest.html
index 30f6254..1eb49cc 100644
--- a/html/sipretest.html
+++ b/html/sipretest.html
@@ -11,7 +11,6 @@
 <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.0.2/js/bootstrap.min.js"></script>
 <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/bootbox.js/4.1.0/bootbox.min.js"></script>
 <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/spin.js/2.3.2/spin.min.js"></script>
-<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/blueimp-md5/2.6.0/js/md5.min.js"></script>
 <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/toastr.js/2.1.3/toastr.min.js"></script>
 <script type="text/javascript" src="janus.js" ></script>
 <script type="text/javascript" src="sipretest.js"></script>
@@ -103,7 +102,6 @@
 									</button>
 									<ul id="registerlist" class="dropdown-menu" role="menu">
 										<li><a href='#' id='secret'>Register using plain secret</a></li>
-										<li class="disabled"><a href='#' id='ha1secret'>Register using HA1 secret</a></li>
 										<li><a href='#' id='guest'>Register as a guest (no secret)</a></li>
 									</ul>
 								</div>
diff --git a/html/sipretest.js b/html/sipretest.js
index b8dbe8d..8e49272 100644
--- a/html/sipretest.js
+++ b/html/sipretest.js
@@ -104,9 +104,6 @@ $(document).ready(function() {
 											case "secret":
 												bootbox.alert("Using this approach you'll provide a plain secret to REGISTER");
 												break;
-											case "ha1secret":
-												bootbox.alert("Using this approach might not work with Asterisk because the generated HA1 secret could have the wrong realm");
-												break;
 											case "guest":
 												bootbox.alert("Using this approach you'll try to REGISTER as a guest, that is without providing any secret");
 												break;
@@ -548,14 +545,8 @@ function registerUsername() {
 	if(displayname !== "") {
 		register.display_name = displayname;
 	}
-	if(selectedApproach === "secret") {
-		// Use the plain secret
-		register["secret"] = password;
-	} else if(selectedApproach === "ha1secret") {
-		var sip_user = username.substring(4, username.indexOf('@'));    /* skip sip: */
-		var sip_domain = username.substring(username.indexOf('@')+1);
-		register["ha1_secret"] = md5(sip_user+':'+sip_domain+':'+password);
-	}
+	// Use the plain secret
+	register["secret"] = password;
 	if(sipserver === "") {
 		bootbox.confirm("You didn't specify a SIP Registrar to use: this will cause the plugin to try and conduct a standard (<a href='https://tools.ietf.org/html/rfc3263' target='_blank'>RFC3263</a>) lookup. If this is not what you want or you don't know what this means, hit Cancel and provide a SIP Registrar instead'",
 			function(result) {
diff --git a/plugins/janus_sipre.c b/plugins/janus_sipre.c
index 07a9eb9..afd4632 100644
--- a/plugins/janus_sipre.c
+++ b/plugins/janus_sipre.c
@@ -148,7 +148,6 @@ static struct janus_json_parameter register_parameters[] = {
 	{"sips", JANUS_JSON_BOOL, 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},
 	{"headers", JANUS_JSON_OBJECT, 0},
 	{"refresh", JANUS_JSON_BOOL, 0}
@@ -192,7 +191,6 @@ static gboolean notify_events = TRUE;
 static janus_callbacks *gateway = NULL;
 
 static char *local_ip = NULL;
-static int keepalive_interval = 120;
 static gboolean behind_nat = FALSE;
 static char *user_agent;
 #define JANUS_DEFAULT_REGISTER_TTL	3600
@@ -438,7 +436,6 @@ typedef enum {
 
 typedef struct janus_sipre_account {
 	char *identity;
-	char *user_agent;		/* Used to override the general UA string */
 	gboolean sips;
 	char *username;
 	char *display_name;		/* Used for outgoing calls in the From header */
@@ -743,8 +740,8 @@ static void *janus_sipre_watchdog(void *data) {
 					old_sessions = g_list_delete_link(old_sessions, sl);
 					sl = rm;
 					sipsess_close_all(session->stack.sess_sock);
-					mem_deref(session->stack.dns_client);
-					mem_deref(session->stack.sipstack);
+					sip_close(session->stack.sipstack, FALSE);
+					session->stack.sipstack = NULL;
 					if(session->account.identity) {
 					    g_hash_table_remove(identities, session->account.identity);
 					    g_free(session->account.identity);
@@ -771,10 +768,6 @@ static void *janus_sipre_watchdog(void *data) {
 					    g_free(session->account.display_name);
 					    session->account.display_name = NULL;
 					}
-					if(session->account.user_agent) {
-					    g_free(session->account.user_agent);
-					    session->account.user_agent = NULL;
-					}
 					if(session->account.authuser) {
 					    g_free(session->account.authuser);
 					    session->account.authuser = NULL;
@@ -891,15 +884,13 @@ int janus_sipre_init(janus_callbacks *callback, const char *config_path) {
 			}
 		}
 
-		item = janus_config_get_item_drilldown(config, "general", "keepalive_interval");
-		if(item && item->value) {
-			keepalive_interval = atoi(item->value);
-		}
-		JANUS_LOG(LOG_VERB, "SIPre keep-alive interval set to %d seconds\n", keepalive_interval);
-
 		item = janus_config_get_item_drilldown(config, "general", "register_ttl");
 		if(item && item->value) {
 			register_ttl = atol(item->value);
+			if(register_ttl <= 0) {
+				JANUS_LOG(LOG_WARN, "Invalid value of register_ttl, using default instead\n");
+				register_ttl = JANUS_DEFAULT_REGISTER_TTL;
+			}
 		}
 		JANUS_LOG(LOG_VERB, "SIPre registration TTL set to %d seconds\n", register_ttl);
 
@@ -1075,7 +1066,6 @@ void janus_sipre_create_session(janus_plugin_session *handle, int *error) {
 	session->account.sips = TRUE;
 	session->account.username = NULL;
 	session->account.display_name = NULL;
-	session->account.user_agent = NULL;
 	session->account.authuser = NULL;
 	session->account.secret = NULL;
 	session->account.secret_type = janus_sipre_secret_type_unknown;
@@ -1189,7 +1179,6 @@ json_t *janus_sipre_query_session(janus_plugin_session *handle) {
 	json_t *info = json_object();
 	json_object_set_new(info, "username", session->account.username ? json_string(session->account.username) : NULL);
 	json_object_set_new(info, "display_name", session->account.display_name ? json_string(session->account.display_name) : NULL);
-	json_object_set_new(info, "user_agent", session->account.user_agent ? json_string(session->account.user_agent) : NULL);
 	json_object_set_new(info, "identity", session->account.identity ? json_string(session->account.identity) : NULL);
 	json_object_set_new(info, "registration_status", json_string(janus_sipre_registration_status_string(session->account.registration_status)));
 	json_object_set_new(info, "call_status", json_string(janus_sipre_call_status_string(session->status)));
@@ -1542,7 +1531,7 @@ static void *janus_sipre_handler(void *data) {
 			if(reg_ttl && json_is_integer(reg_ttl))
 				ttl = json_integer_value(reg_ttl);
 			if(ttl <= 0)
-				ttl = JANUS_DEFAULT_REGISTER_TTL;
+				ttl = register_ttl;
 			session->stack.expires = ttl;
 
 			/* Parse display name */
@@ -1551,12 +1540,6 @@ static void *janus_sipre_handler(void *data) {
 			if(display_name && json_is_string(display_name))
 				display_name_text = json_string_value(display_name);
 
-			/* Parse user agent */
-			const char* user_agent_text = NULL;
-			json_t *user_agent = json_object_get(root, "user_agent");
-			if(user_agent && json_is_string(user_agent))
-				user_agent_text = json_string_value(user_agent);
-
 			/* Now the user part (always needed, even for the guest case) */
 			json_t *username = json_object_get(root, "username");
 			if(!username) {
@@ -1589,31 +1572,17 @@ static void *janus_sipre_handler(void *data) {
 				send_register = FALSE;
 			} else {
 				json_t *secret = json_object_get(root, "secret");
-				json_t *ha1_secret = json_object_get(root, "ha1_secret");
 				json_t *authuser = json_object_get(root, "authuser");
-				if(!secret && !ha1_secret) {
+				if(!secret) {
 					g_free(user_id);
 					g_free(user_host);
-					JANUS_LOG(LOG_ERR, "Missing element (secret or ha1_secret)\n");
+					JANUS_LOG(LOG_ERR, "Missing element (secret)\n");
 					error_code = JANUS_SIPRE_ERROR_MISSING_ELEMENT;
-					g_snprintf(error_cause, 512, "Missing element (secret or ha1_secret)");
-					goto error;
-				}
-				if(secret && ha1_secret) {
-					g_free(user_id);
-					g_free(user_host);
-					JANUS_LOG(LOG_ERR, "Conflicting elements specified (secret and ha1_secret)\n");
-					error_code = JANUS_SIPRE_ERROR_INVALID_ELEMENT;
-					g_snprintf(error_cause, 512, "Conflicting elements specified (secret and ha1_secret)");
+					g_snprintf(error_cause, 512, "Missing element (secret)");
 					goto error;
 				}
-				if(secret) {
-					secret_text = json_string_value(secret);
-					secret_type = janus_sipre_secret_type_plaintext;
-				} else {
-					secret_text = json_string_value(ha1_secret);
-					secret_type = janus_sipre_secret_type_hashed;
-				}
+				secret_text = json_string_value(secret);
+				secret_type = janus_sipre_secret_type_plaintext;
 				if(authuser) {
 					authuser_text = json_string_value(authuser);
 				}
@@ -1653,9 +1622,6 @@ static void *janus_sipre_handler(void *data) {
 				if(session->account.outbound_proxy != NULL)
 					g_free(session->account.outbound_proxy);
 				session->account.outbound_proxy = NULL;
-				if(session->account.user_agent != NULL)
-					g_free(session->account.user_agent);
-				session->account.user_agent = NULL;
 				session->account.registration_status = janus_sipre_registration_status_unregistered;
 			}
 			session->account.identity = g_strdup(username_text);
@@ -1668,9 +1634,6 @@ static void *janus_sipre_handler(void *data) {
 			if(display_name_text) {
 				session->account.display_name = g_strdup(display_name_text);
 			}
-			if(user_agent_text) {
-				session->account.user_agent = g_strdup(user_agent_text);
-			}
 			if(proxy_text) {
 				session->account.proxy = g_strdup(proxy_text);
 			} else {
@@ -3777,7 +3740,8 @@ void janus_sipre_mqueue_handler(int id, void *data, void *arg) {
 				return;
 			}
 			/* Let's allocate the stack now */
-			err = sip_alloc(&session->stack.sipstack, session->stack.dns_client, 32, 32, 32, JANUS_SIPRE_NAME, janus_sipre_cb_exit, session);
+			err = sip_alloc(&session->stack.sipstack, session->stack.dns_client, 32, 32, 32,
+				(user_agent ? user_agent : JANUS_SIPRE_NAME), janus_sipre_cb_exit, session);
 			if(err) {
 				JANUS_LOG(LOG_ERR, "Failed to initialize libre SIP stack: %d (%s)\n", err, strerror(err));
 				mem_deref(session->stack.dns_client);
@@ -3801,7 +3765,7 @@ void janus_sipre_mqueue_handler(int id, void *data, void *arg) {
 			err |= sip_transp_add(session->stack.sipstack, SIP_TRANSP_TLS, &laddrs, session->stack.tls);
 			err |= sipsess_listen(&session->stack.sess_sock, session->stack.sipstack, 32, janus_sipre_cb_incoming, session);
 			if(err) {
-				mem_deref(session->stack.sipstack);
+				sip_close(session->stack.sipstack, TRUE);
 				session->stack.sipstack = NULL;
 				mem_deref(session->stack.tls);
 				session->stack.tls = NULL;

-- 
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