DO not trust via header when forwarding WS messages
This commit is contained in:
parent
cb112782f0
commit
7d2e8e8142
|
@ -129,12 +129,12 @@ int tsip_transport_addvia(const tsip_transport_t* self, const char *branch, tsip
|
||||||
tsip_transport_stream_peer_t* peer = tsip_transport_find_stream_peer_by_local_fd(TSIP_TRANSPORT(ws_transport), msg->local_fd);
|
tsip_transport_stream_peer_t* peer = tsip_transport_find_stream_peer_by_local_fd(TSIP_TRANSPORT(ws_transport), msg->local_fd);
|
||||||
if(peer){
|
if(peer){
|
||||||
// hack the first Via as many servers fail to parse "WS" or "WSS" as valid transpors
|
// hack the first Via as many servers fail to parse "WS" or "WSS" as valid transpors
|
||||||
if(tsk_striequals(msg->firstVia->transport, "WS") || tsk_striequals(msg->firstVia->transport, "WSS")){
|
//if(tsk_striequals(msg->firstVia->transport, "WS") || tsk_striequals(msg->firstVia->transport, "WSS")){
|
||||||
TSIP_HEADER_ADD_PARAM(TSIP_HEADER(msg->firstVia), "ws-hacked", msg->firstVia->transport);
|
TSIP_HEADER_ADD_PARAM(TSIP_HEADER(msg->firstVia), "ws-hacked", TNET_SOCKET_TYPE_IS_WSS(msg->src_net_type) ? "WSS" : "WS");
|
||||||
tsk_strupdate(&msg->firstVia->transport, "TCP");
|
tsk_strupdate(&msg->firstVia->transport, "TCP");
|
||||||
tsk_strupdate(&msg->firstVia->host, peer->remote_ip);
|
tsk_strupdate(&msg->firstVia->host, peer->remote_ip);
|
||||||
msg->firstVia->port = peer->remote_port;
|
msg->firstVia->port = peer->remote_port;
|
||||||
}
|
//}
|
||||||
TSK_OBJECT_SAFE_FREE(peer);
|
TSK_OBJECT_SAFE_FREE(peer);
|
||||||
|
|
||||||
// replace first Via with ours
|
// replace first Via with ours
|
||||||
|
|
|
@ -501,8 +501,6 @@ parse_buffer:
|
||||||
goto bail;
|
goto bail;
|
||||||
}
|
}
|
||||||
|
|
||||||
TSK_DEBUG_INFO("%s", (const char*)peer->ws_rcv_buffer);
|
|
||||||
|
|
||||||
// If we are there this mean that we have all SIP headers.
|
// If we are there this mean that we have all SIP headers.
|
||||||
// ==> Parse the SIP message without the content.
|
// ==> Parse the SIP message without the content.
|
||||||
tsk_ragel_state_init(&state, peer->ws_rcv_buffer, (tsk_size_t)pay_len);
|
tsk_ragel_state_init(&state, peer->ws_rcv_buffer, (tsk_size_t)pay_len);
|
||||||
|
|
Loading…
Reference in New Issue