Commit 7b9965d1 authored by Youness Alaoui's avatar Youness Alaoui

Return real origin when using a proxy (fixes detecting TURN sockets)

If using a proxy, the 'from' of all packets were of the proxy server
instead of the turn server, causing the check for turn to fail.
Thanks to Madaro Livio.
parent c03ac48b
...@@ -190,8 +190,11 @@ socket_recv (NiceSocket *sock, NiceAddress *from, guint len, gchar *buf) ...@@ -190,8 +190,11 @@ socket_recv (NiceSocket *sock, NiceAddress *from, guint len, gchar *buf)
HttpPriv *priv = sock->priv; HttpPriv *priv = sock->priv;
gint read = -1; gint read = -1;
if (from)
*from = priv->addr;
if (priv->base_socket) if (priv->base_socket)
read = nice_socket_recv (priv->base_socket, from, len, buf); read = nice_socket_recv (priv->base_socket, NULL, len, buf);
if (read <= 0 || priv->state == HTTP_STATE_CONNECTED) { if (read <= 0 || priv->state == HTTP_STATE_CONNECTED) {
return read; return read;
......
...@@ -164,10 +164,13 @@ socket_recv (NiceSocket *sock, NiceAddress *from, guint len, gchar *buf) ...@@ -164,10 +164,13 @@ socket_recv (NiceSocket *sock, NiceAddress *from, guint len, gchar *buf)
{ {
Socks5Priv *priv = sock->priv; Socks5Priv *priv = sock->priv;
if (from)
*from = priv->addr;
switch (priv->state) { switch (priv->state) {
case SOCKS_STATE_CONNECTED: case SOCKS_STATE_CONNECTED:
if (priv->base_socket) if (priv->base_socket)
return nice_socket_recv (priv->base_socket, from, len, buf); return nice_socket_recv (priv->base_socket, NULL, len, buf);
break; break;
case SOCKS_STATE_INIT: case SOCKS_STATE_INIT:
{ {
...@@ -177,7 +180,7 @@ socket_recv (NiceSocket *sock, NiceAddress *from, guint len, gchar *buf) ...@@ -177,7 +180,7 @@ socket_recv (NiceSocket *sock, NiceAddress *from, guint len, gchar *buf)
nice_debug ("Socks5 state Init"); nice_debug ("Socks5 state Init");
if (priv->base_socket) if (priv->base_socket)
ret = nice_socket_recv (priv->base_socket, from, sizeof(data), data); ret = nice_socket_recv (priv->base_socket, NULL, sizeof(data), data);
if (ret <= 0) { if (ret <= 0) {
return ret; return ret;
...@@ -244,7 +247,7 @@ socket_recv (NiceSocket *sock, NiceAddress *from, guint len, gchar *buf) ...@@ -244,7 +247,7 @@ socket_recv (NiceSocket *sock, NiceAddress *from, guint len, gchar *buf)
nice_debug ("Socks5 state auth"); nice_debug ("Socks5 state auth");
if (priv->base_socket) if (priv->base_socket)
ret = nice_socket_recv (priv->base_socket, from, sizeof(data), data); ret = nice_socket_recv (priv->base_socket, NULL, sizeof(data), data);
if (ret <= 0) { if (ret <= 0) {
return ret; return ret;
...@@ -266,7 +269,7 @@ socket_recv (NiceSocket *sock, NiceAddress *from, guint len, gchar *buf) ...@@ -266,7 +269,7 @@ socket_recv (NiceSocket *sock, NiceAddress *from, guint len, gchar *buf)
nice_debug ("Socks5 state connect"); nice_debug ("Socks5 state connect");
if (priv->base_socket) if (priv->base_socket)
ret = nice_socket_recv (priv->base_socket, from, 4, data); ret = nice_socket_recv (priv->base_socket, NULL, 4, data);
if (ret <= 0) { if (ret <= 0) {
return ret; return ret;
...@@ -278,14 +281,14 @@ socket_recv (NiceSocket *sock, NiceAddress *from, guint len, gchar *buf) ...@@ -278,14 +281,14 @@ socket_recv (NiceSocket *sock, NiceAddress *from, guint len, gchar *buf)
struct to_be_sent *tbs = NULL; struct to_be_sent *tbs = NULL;
switch (data[3]) { switch (data[3]) {
case 0x01: /* IPV4 bound address */ case 0x01: /* IPV4 bound address */
ret = nice_socket_recv (priv->base_socket, from, 6, data); ret = nice_socket_recv (priv->base_socket, NULL, 6, data);
if (ret != 6) { if (ret != 6) {
/* Could not read server bound address */ /* Could not read server bound address */
goto error; goto error;
} }
break; break;
case 0x04: /* IPV6 bound address */ case 0x04: /* IPV6 bound address */
ret = nice_socket_recv (priv->base_socket, from, 18, data); ret = nice_socket_recv (priv->base_socket, NULL, 18, data);
if (ret != 18) { if (ret != 18) {
/* Could not read server bound address */ /* Could not read server bound address */
goto error; goto error;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment