Commit 108b8f17 authored by Ghislain MARY's avatar Ghislain MARY

Prevent crashes with wrong tunnel configuration.

parent d4745a0f
......@@ -1122,21 +1122,35 @@ namespace Linphone.Model
// Save tunnel configuration
if (LinphoneManager.Instance.LinphoneCore.IsTunnelAvailable() && Customs.IsTunnelEnabled)
{
Boolean needTunnelReconfigure = false;
if (ValueChanged(TunnelServerKeyName) || ValueChanged(TunnelPortKeyName))
{
Tunnel tunnel = LinphoneManager.Instance.LinphoneCore.GetTunnel();
if (tunnel != null)
{
tunnel.CleanServers();
tunnel.AddServer(GetNew(TunnelServerKeyName), Convert.ToInt32(GetNew(TunnelPortKeyName)));
String server = GetNew(TunnelServerKeyName);
Int32 port = 0;
try
{
port = Convert.ToInt32(GetNew(TunnelPortKeyName));
}
catch (System.FormatException) { }
if ((server.Length > 0) && (port > 0))
{
tunnel.AddServer(GetNew(TunnelServerKeyName), Convert.ToInt32(GetNew(TunnelPortKeyName)));
}
needTunnelReconfigure = true;
}
}
if (ValueChanged(TunnelModeKeyName))
{
String mode = GetNew(TunnelModeKeyName);
Config.SetString(ApplicationSection, TunnelModeKeyName, TunnelModeToString[mode]);
LinphoneManager.Instance.ConfigureTunnel();
needTunnelReconfigure = true;
}
if (needTunnelReconfigure)
LinphoneManager.Instance.ConfigureTunnel();
}
}
#endregion
......
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