forked from mirrors/linphone-iphone
Fixes related to tunnel
This commit is contained in:
parent
120b9dc402
commit
53e99b9a22
6 changed files with 79 additions and 40 deletions
|
|
@ -48,7 +48,7 @@ void TunnelManager::addServer(const char *ip, int port) {
|
|||
|
||||
mServerAddrs.push_back(ServerAddr(ip,port));
|
||||
if (mTunnelClient && !mUseDualClient) {
|
||||
((TunnelClient*)mTunnelClient)->addServer(ip,port);
|
||||
static_cast<TunnelClient*>(mTunnelClient)->addServer(ip,port);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -62,12 +62,9 @@ void TunnelManager::addServerPair(const char *ip1, int port1, const char *ip2, i
|
|||
return;
|
||||
}
|
||||
|
||||
pair<ServerAddr, ServerAddr> addr;
|
||||
addr.first = ServerAddr(ip1, port1);
|
||||
addr.second = ServerAddr(ip2, port2);
|
||||
mDualServerAddrs.push_back(addr);
|
||||
mDualServerAddrs.push_back(DualServerAddr(ip1, port1, ip2, port2));
|
||||
if (mTunnelClient && mUseDualClient) {
|
||||
((DualTunnelClient*)mTunnelClient)->addServerPair(ip1, port1, ip2, port2);
|
||||
static_cast<DualTunnelClient*>(mTunnelClient)->addServerPair(ip1, port1, ip2, port2);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -149,13 +146,18 @@ RtpTransport *TunnelManager::createRtpTransport(int port){
|
|||
|
||||
void TunnelManager::startClient() {
|
||||
ms_message("TunnelManager: Starting tunnel client");
|
||||
if (!mTunnelClient){
|
||||
mTunnelClient = new TunnelClient(TRUE);
|
||||
if (!mTunnelClient) {
|
||||
if (mUseDualClient) {
|
||||
mTunnelClient = DualTunnelClient::create(TRUE);
|
||||
} else {
|
||||
mTunnelClient = TunnelClient::create(TRUE);
|
||||
}
|
||||
|
||||
sal_set_tunnel(mCore->sal, mTunnelClient);
|
||||
if (!mUseDualClient) {
|
||||
((TunnelClient*)mTunnelClient)->setCallback(tunnelCallback,this);
|
||||
static_cast<TunnelClient*>(mTunnelClient)->setCallback(tunnelCallback,this);
|
||||
} else {
|
||||
((DualTunnelClient*)mTunnelClient)->setCallback(tunnelCallback2,this);
|
||||
static_cast<DualTunnelClient*>(mTunnelClient)->setCallback(tunnelCallback2,this);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -170,26 +172,28 @@ void TunnelManager::startClient() {
|
|||
}
|
||||
mTunnelClient->cleanServers();
|
||||
if (mUseDualClient) {
|
||||
list<pair<ServerAddr, ServerAddr>>::iterator it;
|
||||
list<DualServerAddr>::iterator it;
|
||||
for(it=mDualServerAddrs.begin();it!=mDualServerAddrs.end();++it){
|
||||
pair<ServerAddr, ServerAddr> &addr=*it;
|
||||
const ServerAddr addr1 = addr.first;
|
||||
const ServerAddr addr2 = addr.second;
|
||||
((DualTunnelClient*)mTunnelClient)->addServerPair(addr1.mAddr.c_str(), addr1.mPort, addr2.mAddr.c_str(), addr2.mPort);
|
||||
const DualServerAddr &addr=*it;
|
||||
static_cast<DualTunnelClient*>(mTunnelClient)->addServerPair(addr.mAddr1.c_str(), addr.mPort1, addr.mAddr2.c_str(), addr.mPort2);
|
||||
}
|
||||
} else {
|
||||
list<ServerAddr>::iterator it;
|
||||
for(it=mServerAddrs.begin();it!=mServerAddrs.end();++it){
|
||||
const ServerAddr &addr=*it;
|
||||
((TunnelClient*)mTunnelClient)->addServer(addr.mAddr.c_str(), addr.mPort);
|
||||
static_cast<TunnelClient*>(mTunnelClient)->addServer(addr.mAddr.c_str(), addr.mPort);
|
||||
}
|
||||
}
|
||||
mTunnelClient->setHttpProxy(mHttpProxyHost.c_str(), mHttpProxyPort, mHttpUserName.c_str(), mHttpPasswd.c_str());
|
||||
if (!mTunnelClient->isStarted())
|
||||
mTunnelClient->start();
|
||||
else
|
||||
mTunnelClient->reconnect(); /*force a reconnection to take into account new parameters*/
|
||||
|
||||
mTunnelClient->setHttpProxy(mHttpProxyHost.c_str(), mHttpProxyPort, mHttpUserName.c_str(), mHttpPasswd.c_str());
|
||||
if (!mTunnelClient->isStarted()) {
|
||||
ms_message("Starting tunnel client");
|
||||
mTunnelClient->start();
|
||||
}
|
||||
else {
|
||||
ms_message("Reconnecting tunnel client");
|
||||
mTunnelClient->reconnect(); /*force a reconnection to take into account new parameters*/
|
||||
}
|
||||
}
|
||||
|
||||
void TunnelManager::stopClient(){
|
||||
|
|
|
|||
|
|
@ -236,8 +236,8 @@ namespace belledonnecomm {
|
|||
std::string mHttpProxyHost;
|
||||
int mHttpProxyPort;
|
||||
LinphoneCoreVTable *mVTable;
|
||||
std::list <ServerAddr> mServerAddrs;
|
||||
std::list <std::pair<ServerAddr, ServerAddr>> mDualServerAddrs;
|
||||
std::list<ServerAddr> mServerAddrs;
|
||||
std::list<DualServerAddr> mDualServerAddrs;
|
||||
UdpMirrorClientList mUdpMirrorClients;
|
||||
UdpMirrorClientList::iterator mCurrentUdpMirrorClient;
|
||||
LinphoneRtpTransportFactories mTransportFactories;
|
||||
|
|
|
|||
|
|
@ -290,12 +290,12 @@ LinphoneTunnelMode linphone_tunnel_get_mode(const LinphoneTunnel *tunnel){
|
|||
return bcTunnel(tunnel)->getMode();
|
||||
}
|
||||
|
||||
void linphone_tunnel_set_dual_mode(LinphoneTunnel *tunnel, bool_t dual_mode_enabled) {
|
||||
void linphone_tunnel_enable_dual_mode(LinphoneTunnel *tunnel, bool_t dual_mode_enabled) {
|
||||
lp_config_set_int(config(tunnel), "tunnel", "dual_mode", (dual_mode_enabled ? TRUE : FALSE));
|
||||
bcTunnel(tunnel)->enableDualMode(dual_mode_enabled);
|
||||
}
|
||||
|
||||
bool_t linphone_tunnel_get_dual_mode(const LinphoneTunnel *tunnel) {
|
||||
bool_t linphone_tunnel_dual_mode_enabled(const LinphoneTunnel *tunnel) {
|
||||
return bcTunnel(tunnel)->isDualModeEnabled();
|
||||
}
|
||||
|
||||
|
|
@ -412,7 +412,7 @@ void linphone_tunnel_configure(LinphoneTunnel *tunnel){
|
|||
bool_t tunnelizeSIPPackets = (bool_t)lp_config_get_int(config(tunnel), "tunnel", "sip", TRUE);
|
||||
bool_t tunnelVerifyServerCertificate = (bool_t)lp_config_get_int(config(tunnel), "tunnel", "verify_cert", FALSE);
|
||||
bool_t useDualMode = (bool_t)lp_config_get_int(config(tunnel), "tunnel", "dual_mode", FALSE);
|
||||
linphone_tunnel_set_dual_mode(tunnel, useDualMode);
|
||||
linphone_tunnel_enable_dual_mode(tunnel, useDualMode);
|
||||
linphone_tunnel_enable_logs_with_handler(tunnel,TRUE,my_ortp_logv);
|
||||
linphone_tunnel_load_config(tunnel);
|
||||
linphone_tunnel_enable_sip(tunnel, tunnelizeSIPPackets);
|
||||
|
|
|
|||
|
|
@ -65,11 +65,11 @@ LinphoneTunnelMode linphone_tunnel_get_mode(const LinphoneTunnel *tunnel){
|
|||
return LinphoneTunnelModeDisable;
|
||||
}
|
||||
|
||||
void linphone_tunnel_set_dual_mode(LinphoneTunnel *tunnel, bool_t dual_mode_enabled) {
|
||||
void linphone_tunnel_enable_dual_mode(LinphoneTunnel *tunnel, bool_t dual_mode_enabled) {
|
||||
ms_warning("linphone_tunnel_set_dual_mode() - stubbed, no implementation");
|
||||
}
|
||||
|
||||
bool_t linphone_tunnel_get_dual_mode(const LinphoneTunnel *tunnel) {
|
||||
bool_t linphone_tunnel_dual_mode_enabled(const LinphoneTunnel *tunnel) {
|
||||
ms_warning("linphone_tunnel_get_dual_mode() - stubbed, no implementation");
|
||||
return FALSE;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -290,14 +290,14 @@ LINPHONE_PUBLIC LinphoneTunnelMode linphone_tunnel_get_mode(const LinphoneTunnel
|
|||
* @param tunnel LinphoneTunnel object
|
||||
* @param dual_mode_enabled TRUE to enable it, FALSE to disable it
|
||||
*/
|
||||
LINPHONE_PUBLIC void linphone_tunnel_set_dual_mode(LinphoneTunnel *tunnel, bool_t dual_mode_enabled);
|
||||
LINPHONE_PUBLIC void linphone_tunnel_enable_dual_mode(LinphoneTunnel *tunnel, bool_t dual_mode_enabled);
|
||||
|
||||
/**
|
||||
* Get the dual tunnel client mode
|
||||
* @param tunnel LinphoneTunnel object
|
||||
* @return TRUE if dual tunnel client mode is enabled, FALSE otherwise
|
||||
**/
|
||||
LINPHONE_PUBLIC bool_t linphone_tunnel_get_dual_mode(const LinphoneTunnel *tunnel);
|
||||
LINPHONE_PUBLIC bool_t linphone_tunnel_dual_mode_enabled(const LinphoneTunnel *tunnel);
|
||||
|
||||
/**
|
||||
* Returns whether the tunnel is activated. If mode is set to auto, this gives indication whether the automatic detection determined
|
||||
|
|
|
|||
|
|
@ -47,7 +47,7 @@ static char* get_public_contact_ip(LinphoneCore* lc) {
|
|||
}
|
||||
|
||||
|
||||
static void call_with_tunnel_base(LinphoneTunnelMode tunnel_mode, bool_t with_sip, LinphoneMediaEncryption encryption, bool_t with_video_and_ice) {
|
||||
static void call_with_tunnel_base(LinphoneTunnelMode tunnel_mode, bool_t with_sip, LinphoneMediaEncryption encryption, bool_t with_video_and_ice, bool_t dual_socket) {
|
||||
if (linphone_core_tunnel_available()){
|
||||
LinphoneCoreManager *pauline = linphone_core_manager_new( "pauline_rc");
|
||||
LinphoneCoreManager *marie = linphone_core_manager_new( "marie_rc");
|
||||
|
|
@ -84,7 +84,18 @@ static void call_with_tunnel_base(LinphoneTunnelMode tunnel_mode, bool_t with_si
|
|||
|
||||
linphone_tunnel_config_set_host(config, "tunnel.linphone.org");
|
||||
linphone_tunnel_config_set_port(config, 443);
|
||||
linphone_tunnel_config_set_remote_udp_mirror_port(config, 12345);
|
||||
if (!dual_socket) {
|
||||
linphone_tunnel_config_set_host(config, "tunnel.linphone.org");
|
||||
linphone_tunnel_config_set_port(config, 443);
|
||||
linphone_tunnel_config_set_remote_udp_mirror_port(config, 12345);
|
||||
} else {
|
||||
linphone_tunnel_config_set_host(config, "94.23.19.176");
|
||||
linphone_tunnel_config_set_port(config, 4443);
|
||||
linphone_tunnel_config_set_host2(config, "188.165.40.171");
|
||||
linphone_tunnel_config_set_port2(config, 4443);
|
||||
linphone_tunnel_config_set_remote_udp_mirror_port(config, -1);
|
||||
linphone_tunnel_enable_dual_mode(tunnel, TRUE);
|
||||
}
|
||||
linphone_tunnel_add_server(tunnel, config);
|
||||
linphone_tunnel_set_mode(tunnel, tunnel_mode);
|
||||
linphone_tunnel_enable_sip(tunnel, with_sip);
|
||||
|
|
@ -107,7 +118,11 @@ static void call_with_tunnel_base(LinphoneTunnelMode tunnel_mode, bool_t with_si
|
|||
*/
|
||||
ms_free(public_ip);
|
||||
public_ip = get_public_contact_ip(pauline->lc);
|
||||
BC_ASSERT_STRING_EQUAL(public_ip, tunnel_ip);
|
||||
if (!dual_socket) {
|
||||
BC_ASSERT_STRING_EQUAL(public_ip, tunnel_ip);
|
||||
} else {
|
||||
BC_ASSERT_STRING_EQUAL(public_ip, "94.23.19.176");
|
||||
}
|
||||
} else {
|
||||
public_ip2 = get_public_contact_ip(pauline->lc);
|
||||
BC_ASSERT_STRING_EQUAL(public_ip, public_ip2);
|
||||
|
|
@ -132,7 +147,11 @@ static void call_with_tunnel_base(LinphoneTunnelMode tunnel_mode, bool_t with_si
|
|||
LinphoneAddress *tmp = linphone_address_new(remote_contact);
|
||||
BC_ASSERT_PTR_NOT_NULL(tmp);
|
||||
if (tmp){
|
||||
BC_ASSERT_STRING_EQUAL(linphone_address_get_domain(tmp), tunnel_ip);
|
||||
if (!dual_socket) {
|
||||
BC_ASSERT_STRING_EQUAL(linphone_address_get_domain(tmp), tunnel_ip);
|
||||
} else {
|
||||
BC_ASSERT_STRING_EQUAL(linphone_address_get_domain(tmp), "94.23.19.176");
|
||||
}
|
||||
linphone_address_unref(tmp);
|
||||
}
|
||||
}
|
||||
|
|
@ -158,30 +177,30 @@ static void call_with_tunnel_base(LinphoneTunnelMode tunnel_mode, bool_t with_si
|
|||
|
||||
|
||||
static void call_with_tunnel(void) {
|
||||
call_with_tunnel_base(LinphoneTunnelModeEnable, TRUE, LinphoneMediaEncryptionNone, FALSE);
|
||||
call_with_tunnel_base(LinphoneTunnelModeEnable, TRUE, LinphoneMediaEncryptionNone, FALSE, FALSE);
|
||||
}
|
||||
|
||||
static void call_with_tunnel_srtp(void) {
|
||||
call_with_tunnel_base(LinphoneTunnelModeEnable, TRUE, LinphoneMediaEncryptionSRTP, FALSE);
|
||||
call_with_tunnel_base(LinphoneTunnelModeEnable, TRUE, LinphoneMediaEncryptionSRTP, FALSE, FALSE);
|
||||
}
|
||||
|
||||
static void call_with_tunnel_without_sip(void) {
|
||||
call_with_tunnel_base(LinphoneTunnelModeEnable, FALSE, LinphoneMediaEncryptionNone, FALSE);
|
||||
call_with_tunnel_base(LinphoneTunnelModeEnable, FALSE, LinphoneMediaEncryptionNone, FALSE, FALSE);
|
||||
}
|
||||
|
||||
static void call_with_tunnel_auto(void) {
|
||||
call_with_tunnel_base(LinphoneTunnelModeAuto, TRUE, LinphoneMediaEncryptionNone, FALSE);
|
||||
call_with_tunnel_base(LinphoneTunnelModeAuto, TRUE, LinphoneMediaEncryptionNone, FALSE, FALSE);
|
||||
}
|
||||
|
||||
static void call_with_tunnel_auto_without_sip_with_srtp(void) {
|
||||
call_with_tunnel_base(LinphoneTunnelModeAuto, FALSE, LinphoneMediaEncryptionSRTP, FALSE);
|
||||
call_with_tunnel_base(LinphoneTunnelModeAuto, FALSE, LinphoneMediaEncryptionSRTP, FALSE, FALSE);
|
||||
}
|
||||
|
||||
#ifdef VIDEO_ENABLED
|
||||
|
||||
static void full_tunnel_video_ice_call(void){
|
||||
if (linphone_core_tunnel_available()){
|
||||
call_with_tunnel_base(LinphoneTunnelModeEnable, TRUE, LinphoneMediaEncryptionNone, TRUE);
|
||||
call_with_tunnel_base(LinphoneTunnelModeEnable, TRUE, LinphoneMediaEncryptionNone, TRUE, FALSE);
|
||||
}else
|
||||
ms_warning("Could not test %s because tunnel functionality is not available",__FUNCTION__);
|
||||
}
|
||||
|
|
@ -281,6 +300,20 @@ static void register_on_second_tunnel(void) {
|
|||
}
|
||||
}
|
||||
|
||||
static void dual_socket_mode(void) {
|
||||
if (linphone_core_tunnel_available())
|
||||
call_with_tunnel_base(LinphoneTunnelModeEnable, FALSE, LinphoneMediaEncryptionNone, FALSE, TRUE);
|
||||
else
|
||||
ms_warning("Could not test %s because tunnel functionality is not available",__FUNCTION__);
|
||||
}
|
||||
|
||||
static void dual_socket_mode_with_sip(void) {
|
||||
if (linphone_core_tunnel_available())
|
||||
call_with_tunnel_base(LinphoneTunnelModeEnable, TRUE, LinphoneMediaEncryptionNone, FALSE, TRUE);
|
||||
else
|
||||
ms_warning("Could not test %s because tunnel functionality is not available",__FUNCTION__);
|
||||
}
|
||||
|
||||
test_t tunnel_tests[] = {
|
||||
TEST_NO_TAG("Simple", call_with_tunnel),
|
||||
TEST_NO_TAG("With SRTP", call_with_tunnel_srtp),
|
||||
|
|
@ -298,6 +331,8 @@ test_t tunnel_tests[] = {
|
|||
TEST_NO_TAG("ZRTP ice video call", tunnel_zrtp_video_ice_call),
|
||||
#endif
|
||||
TEST_NO_TAG("Register on second tunnel", register_on_second_tunnel),
|
||||
TEST_NO_TAG("Dual socket mode", dual_socket_mode),
|
||||
TEST_NO_TAG("Dual socket mode with SIP", dual_socket_mode_with_sip),
|
||||
};
|
||||
|
||||
test_suite_t tunnel_test_suite = {"Tunnel", NULL, NULL, liblinphone_tester_before_each, liblinphone_tester_after_each,
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue