mirror of
https://gitlab.linphone.org/BC/public/linphone-iphone.git
synced 2026-01-18 03:28:07 +00:00
Add a function to prevent SIP packets to pass through tunnels
This commit is contained in:
parent
32cd807f61
commit
ef404cd319
2 changed files with 39 additions and 20 deletions
|
|
@ -147,7 +147,8 @@ TunnelManager::TunnelManager(LinphoneCore* lc) :TunnelClientController()
|
|||
,mAutoDetectStarted(false)
|
||||
,mReady(false)
|
||||
,mHttpProxyPort(0)
|
||||
,mPreviousRegistrationEnabled(false){
|
||||
,mPreviousRegistrationEnabled(false)
|
||||
,mTunnelizeSipPackets(true){
|
||||
|
||||
linphone_core_add_iterate_hook(mCore,(LinphoneCoreIterateHook)sOnIterate,this);
|
||||
mTransportFactories.audio_rtcp_func=sCreateRtpTransport;
|
||||
|
|
@ -179,11 +180,11 @@ void TunnelManager::registration(){
|
|||
if (isReady()){
|
||||
linphone_core_set_firewall_policy(mCore,LinphonePolicyNoFirewall);
|
||||
linphone_core_set_rtp_transport_factories(mCore,&mTransportFactories);
|
||||
|
||||
sal_enable_tunnel(mCore->sal, mTunnelClient);
|
||||
if(mTunnelizeSipPackets) {
|
||||
sal_enable_tunnel(mCore->sal, mTunnelClient);
|
||||
}
|
||||
// tunnel was disabled
|
||||
} else {
|
||||
linphone_core_set_sip_transports(mCore, &mRegularTransport);
|
||||
linphone_core_set_firewall_policy(mCore, mPreviousFirewallPolicy);
|
||||
}
|
||||
|
||||
|
|
@ -243,8 +244,7 @@ void TunnelManager::enable(bool isEnable) {
|
|||
ms_message("Turning tunnel [%s]", isEnable ?"on" : "off");
|
||||
if (isEnable && !mEnabled){
|
||||
mEnabled=true;
|
||||
//1 save transport and firewall policy
|
||||
linphone_core_get_sip_transports(mCore, &mRegularTransport);
|
||||
//1 save firewall policy
|
||||
mPreviousFirewallPolicy=linphone_core_get_firewall_policy(mCore);
|
||||
//2 unregister
|
||||
waitUnRegistration();
|
||||
|
|
@ -259,17 +259,9 @@ void TunnelManager::enable(bool isEnable) {
|
|||
stopClient();
|
||||
mReady=false;
|
||||
linphone_core_set_rtp_transport_factories(mCore,NULL);
|
||||
|
||||
sal_disable_tunnel(mCore->sal);
|
||||
// Set empty transports to force the setting of regular transport, otherwise it is not applied
|
||||
LCSipTransports lTransport;
|
||||
lTransport.udp_port = 0;
|
||||
lTransport.tcp_port = 0;
|
||||
lTransport.tls_port = 0;
|
||||
lTransport.dtls_port = 0;
|
||||
linphone_core_set_sip_transports(mCore, &lTransport);
|
||||
|
||||
// register
|
||||
// 3 register
|
||||
registration();
|
||||
}
|
||||
}
|
||||
|
|
@ -404,6 +396,16 @@ void TunnelManager::setHttpProxyAuthInfo(const char* username,const char* passwd
|
|||
if (mTunnelClient) mTunnelClient->setHttpProxyAuthInfo(username,passwd);
|
||||
}
|
||||
|
||||
void TunnelManager::tunnelizeSipPackets(bool enable){
|
||||
if(enable != mTunnelizeSipPackets) {
|
||||
mTunnelizeSipPackets = enable;
|
||||
if(mEnabled && isReady()) {
|
||||
waitUnRegistration();
|
||||
registration();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void TunnelManager::setHttpProxy(const char *host,int port, const char *username, const char *passwd){
|
||||
mHttpUserName=username?username:"";
|
||||
mHttpPasswd=passwd?passwd:"";
|
||||
|
|
|
|||
|
|
@ -33,7 +33,7 @@ class UdpMirrorClient;
|
|||
* The TunnelManager class extends the LinphoneCore functionnality in order to provide an easy to use API to
|
||||
* - provision tunnel servers ip addresses and ports
|
||||
* - start/stop the tunneling service
|
||||
* - be informed of of connection and disconnection events to the tunnel server
|
||||
* - be informed of connection and disconnection events to the tunnel server
|
||||
* - perform auto-detection whether tunneling is required, based on a test of sending/receiving a flow of UDP packets.
|
||||
*
|
||||
* It takes in charge automatically the SIP registration procedure when connecting or disconnecting to a tunnel server.
|
||||
|
|
@ -91,8 +91,8 @@ class UdpMirrorClient;
|
|||
void enable(bool isEnabled);
|
||||
/**
|
||||
* In auto detect mode, the tunnel manager try to establish a real time rtp cummunication with the tunnel server on specified port.
|
||||
*<br>In case of success, the tunnel is automatically turned off. Otherwise, if no udp commmunication is feasible, tunnel mode is turned on.
|
||||
*<br> Call this method each time to run the auto detection algorithm
|
||||
*<br/>In case of success, the tunnel is automatically turned off. Otherwise, if no udp commmunication is feasible, tunnel mode is turned on.
|
||||
*<br/> Call this method each time to run the auto detection algorithm
|
||||
*/
|
||||
void autoDetect();
|
||||
/**
|
||||
|
|
@ -115,7 +115,22 @@ class UdpMirrorClient;
|
|||
* @param passwd The password.
|
||||
**/
|
||||
void setHttpProxyAuthInfo(const char* username,const char* passwd);
|
||||
/**
|
||||
* Indicate to the tunnel manager whether SIP packets must pass
|
||||
* through the tunnel. That featurte is automatically enabled at
|
||||
* the creation of the TunnelManager instance.
|
||||
* @param enable If set to TRUE, SIP packets will pass through the tunnel.
|
||||
* If set to FALSE, SIP packets will pass by the configured proxies.
|
||||
*/
|
||||
void tunnelizeSipPackets(bool enable = true);
|
||||
/**
|
||||
* @brief Destructor
|
||||
*/
|
||||
~TunnelManager();
|
||||
/**
|
||||
* @brief Constructor
|
||||
* @param lc The LinphoneCore instance of which the TunnelManager will be associated to.
|
||||
*/
|
||||
TunnelManager(LinphoneCore* lc);
|
||||
/**
|
||||
* Destroy the given RtpTransport.
|
||||
|
|
@ -161,8 +176,10 @@ class UdpMirrorClient;
|
|||
void processTunnelEvent(const Event &ev);
|
||||
void processUdpMirrorEvent(const Event &ev);
|
||||
void postEvent(const Event &ev);
|
||||
void stopClient();
|
||||
|
||||
private:
|
||||
LinphoneCore* mCore;
|
||||
LCSipTransports mRegularTransport;
|
||||
#ifndef USE_BELLESIP
|
||||
TunnelSocket *mSipSocket;
|
||||
eXosip_transport_hooks_t mExosipTransport;
|
||||
|
|
@ -175,7 +192,6 @@ class UdpMirrorClient;
|
|||
UdpMirrorClientList mUdpMirrorClients;
|
||||
UdpMirrorClientList::iterator mCurrentUdpMirrorClient;
|
||||
TunnelClient* mTunnelClient;
|
||||
void stopClient();
|
||||
Mutex mMutex;
|
||||
static Mutex sMutex;
|
||||
bool mAutoDetectStarted;
|
||||
|
|
@ -187,6 +203,7 @@ class UdpMirrorClient;
|
|||
int mHttpProxyPort;
|
||||
LinphoneFirewallPolicy mPreviousFirewallPolicy;
|
||||
bool mPreviousRegistrationEnabled;
|
||||
bool mTunnelizeSipPackets;
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue