res_pjsip_transport_websocket: Ensure secure Websocket clients can be called.
authorJoshua Colp <jcolp@digium.com>
Sun, 24 Aug 2014 18:54:00 +0000 (18:54 +0000)
committerJoshua Colp <jcolp@digium.com>
Sun, 24 Aug 2014 18:54:00 +0000 (18:54 +0000)
This change enforces the transport in the Contact header for Websocket clients.
Previously a client may provide a transport of 'ws' when it is actually using
a transport of 'wss'. This would cause outgoing calls to fail as the existing
connection could not be found.
........

Merged revisions 421931 from http://svn.asterisk.org/svn/asterisk/branches/12
........

Merged revisions 421932 from http://svn.asterisk.org/svn/asterisk/branches/13

git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@421933 65c4cc65-6c06-0410-ace0-fbb531ad65f3

res/res_pjsip_transport_websocket.c

index 38b1071..92e018d 100644 (file)
@@ -300,6 +300,8 @@ static void websocket_cb(struct ast_websocket *session, struct ast_variable *par
  */
 static pj_bool_t websocket_on_rx_msg(pjsip_rx_data *rdata)
 {
+       static const pj_str_t STR_WS = { "ws", 2 };
+       static const pj_str_t STR_WSS = { "wss", 3 };
        pjsip_contact_hdr *contact;
 
        long type = rdata->tp_info.transport->key.type;
@@ -314,6 +316,7 @@ static pj_bool_t websocket_on_rx_msg(pjsip_rx_data *rdata)
 
                pj_cstr(&uri->host, rdata->pkt_info.src_name);
                uri->port = rdata->pkt_info.src_port;
+               pj_strdup(rdata->tp_info.pool, &uri->transport_param, (type == (long)transport_type_ws) ? &STR_WS : &STR_WSS);
        }
 
        rdata->msg_info.via->rport_param = 0;