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

Add support for SOCKS5 proxy servers

parent 09d4596b
......@@ -909,7 +909,29 @@ priv_add_new_candidate_discovery_turn (NiceAgent *agent,
}
cdisco->nicesock = socket;
} else {
socket = nice_tcp_bsd_socket_new (agent, component->ctx, &turn->server);
NiceAddress proxy_server;
socket = NULL;
if (agent->proxy_type != NICE_PROXY_TYPE_NONE &&
agent->proxy_ip != NULL &&
nice_address_set_from_string (&proxy_server, agent->proxy_ip)) {
nice_address_set_port (&proxy_server, agent->proxy_port);
socket = nice_tcp_bsd_socket_new (agent, component->ctx, &proxy_server);
if (socket &&
agent->proxy_type == NICE_PROXY_TYPE_SOCKS5) {
socket = nice_socks5_socket_new (agent, socket, &turn->server,
agent->proxy_username, agent->proxy_password);
} else {
/* TODO add HTTP support */
nice_socket_free (socket);
socket = NULL;
}
}
if (socket == NULL) {
socket = nice_tcp_bsd_socket_new (agent, component->ctx, &turn->server);
}
if (turn->type == NICE_RELAY_TYPE_TURN_TLS &&
agent->compatibility == NICE_COMPATIBILITY_GOOGLE) {
socket = nice_pseudossl_socket_new (agent, socket);
......
......@@ -28,6 +28,8 @@ libsocket_la_SOURCES = \
tcp-bsd.c \
pseudossl.h \
pseudossl.c \
socks5.h \
socks5.c \
turn.h \
turn.c \
tcp-turn.h \
......@@ -40,5 +42,5 @@ test_bsd_LDADD = $(COMMON_LDADD)
TESTS = $(check_PROGRAMS)
pkginclude_HEADERS = socket.h udp-bsd.h tcp-bsd.h pseudossl.h turn.h tcp-turn.h
pkginclude_HEADERS = socket.h udp-bsd.h tcp-bsd.h pseudossl.h turn.h tcp-turn.h socks5.h
......@@ -85,6 +85,7 @@ nice_socket_free (NiceSocket *sock);
#include "udp-bsd.h"
#include "tcp-bsd.h"
#include "pseudossl.h"
#include "socks5.h"
#include "turn.h"
#include "tcp-turn.h"
......
This diff is collapsed.
/*
* This file is part of the Nice GLib ICE library.
*
* (C) 2006, 2007 Collabora Ltd.
* Contact: Dafydd Harries
* (C) 2006, 2007 Nokia Corporation. All rights reserved.
* Contact: Kai Vehmanen
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is the Nice GLib ICE library.
*
* The Initial Developers of the Original Code are Collabora Ltd and Nokia
* Corporation. All Rights Reserved.
*
* Contributors:
* Dafydd Harries, Collabora Ltd.
*
* Alternatively, the contents of this file may be used under the terms of the
* the GNU Lesser General Public License Version 2.1 (the "LGPL"), in which
* case the provisions of LGPL are applicable instead of those above. If you
* wish to allow use of your version of this file only under the terms of the
* LGPL and not to allow others to use your version of this file under the
* MPL, indicate your decision by deleting the provisions above and replace
* them with the notice and other provisions required by the LGPL. If you do
* not delete the provisions above, a recipient may use your version of this
* file under either the MPL or the LGPL.
*/
#ifndef _SOCKS5_H
#define _SOCKS5_H
#include "socket.h"
#include "agent.h"
G_BEGIN_DECLS
NiceSocket *
nice_socks5_socket_new (NiceAgent *agent, NiceSocket *base_socket,
NiceAddress *addr, gchar *username, gchar *password);
G_END_DECLS
#endif /* _SOCKS5_H */
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