提交 3a0c9c38 authored 作者: Mitch Capper's avatar Mitch Capper

Added tls-only option to sofia, fixed broker warning

上级 22e33f7a
......@@ -134,10 +134,10 @@ namespace FSClient {
ReloadSofia();
}
public static void create_gateway_nodes(XmlNode gateways_node, bool tls_enabled) {
public static void create_gateway_nodes(XmlNode gateways_node, bool tls_enabled, bool tls_only) {
foreach (Account account in accounts) {
if (account.enabled)
account.create_gateway_node(gateways_node, tls_enabled);
account.create_gateway_node(gateways_node, tls_enabled, tls_only);
}
}
public static void HandleGatewayEvent(FSEvent evt) {
......@@ -331,7 +331,7 @@ namespace FSClient {
Broker.get_instance().reload_sofia(Sofia.RELOAD_CONFIG_MODE.SOFT);
}
private void create_gateway_node(XmlNode gateways_node, bool tls_enabled) {
private void create_gateway_node(XmlNode gateways_node, bool tls_enabled, bool tls_only) {
XmlNode node = XmlUtils.AddNodeNode(gateways_node, "gateway");
XmlUtils.AddNodeAttrib(node, "name", gateway_id);
old_gateway_id = gateway_id;
......@@ -340,11 +340,19 @@ namespace FSClient {
continue;
if (String.IsNullOrWhiteSpace(value.value) && !AllowedEmptyFields.Contains(value.field.name))
continue;
if (value.field.name == "register-transport" && value.value == "tls" && !tls_enabled) {
MessageBox.Show("Warning the register-transport for account: " + name + " is set to tls, however you have tls disabled in your sofia settings this account will be disabled for now");
gateways_node.RemoveChild(node);
enabled = false;
return;
if (value.field.name == "register-transport") {
if (value.value == "tls" && !tls_enabled){
MessageBox.Show("Warning the register-transport for account: " + name + " is set to tls, however you have tls disabled in your sofia settings this account will be disabled for now");
gateways_node.RemoveChild(node);
enabled = false;
return;
}
if(value.value != "tls" && tls_only){
MessageBox.Show("Warning the register-transport for account: " + name + " is not set to tls, however you have tls only enabled in your sofia settings this account will be disabled for now");
gateways_node.RemoveChild(node);
enabled = false;
return;
}
}
if (value.field.name == "sip_secure_media")
secure_media = value.value == "true";
......
......@@ -606,7 +606,7 @@ namespace FSClient {
}
}
private string _recordings_folder;
public Utils.ObjectEventHandler<string> recordings_folderChanged;
public Utils.ObjectEventHandler<string> recordings_folderChanged=null;
#endregion
......
using System;
using System.Diagnostics;
using System.Linq;
using System.Windows;
using System.Xml;
......@@ -46,6 +47,7 @@ namespace FSClient {
/*Security*/
new Field(Field.FIELD_TYPE.Bool,"TLS","tls","tls","false","Security"),
new Field(Field.FIELD_TYPE.Bool,"TLS Only","tls-only","tls-only","false","Security"),
new Field(Field.FIELD_TYPE.Combo,"TLS Verify Policy","tls-verify-policy","tls-verify-policy","subjects_out|in","Security",new Field.FieldOption{display_value="None", value=""},new Field.FieldOption{display_value="Outbound Certs", value="out"},new Field.FieldOption{display_value="Outbound Certs & Hostnames", value="subjects_out"},new Field.FieldOption{display_value="All Certs", value="all"},new Field.FieldOption{display_value="All Certs & Outbound Hostnames", value="subjects_out|in"}),
new Field(Field.FIELD_TYPE.Combo,"TLS Version","tls-version","tls-version","sslv23","Security","sslv23","tlsv1"),
new Field(Field.FIELD_TYPE.String,"TLS Bind Params","tls-bind-params","tls-bind-params","transport=tls","Security"),
......@@ -81,20 +83,25 @@ namespace FSClient {
XmlNode profile = XmlUtils.AddNodeNode(profiles, "profile");
XmlUtils.AddNodeAttrib(profile, "name", "softphone");
XmlNode gateways = XmlUtils.AddNodeNode(profile, "gateways");
Account.create_gateway_nodes(gateways, FieldValue.GetByName(values, "tls").value == "true");
Account.create_gateway_nodes(gateways, FieldValue.GetByName(values, "tls").value == "true", FieldValue.GetByName(values, "tls-only").value == "true");
XmlNode settings = XmlUtils.AddNodeNode(profile, "settings");
Utils.add_xml_param(settings, "context", "public");
Utils.add_xml_param(settings, "dialplan", "xml");
Utils.add_xml_param(settings, "disable-register", "true");
bool tls_cert_check_already = false;
foreach (FieldValue value in values) {
if (String.IsNullOrEmpty(value.field.xml_name))
continue;
if (String.IsNullOrWhiteSpace(value.value) && !AllowedEmptyFields.Contains(value.field.name))
continue;
String param_value = value.value;
if (value.field.name == "tls" && value.value == "true" && ! tls_cert_exist_check())
param_value = "false";
if ((value.field.name=="tls-only" || value.field.name == "tls") && value.value == "true" && !tls_cert_check_already) {
if (!tls_cert_exist_check())
param_value = "false";
else
tls_cert_check_already = true;
}
Utils.add_xml_param(settings, value.field.xml_name, param_value);
}
......@@ -135,17 +142,30 @@ namespace FSClient {
}
private bool master_profile_ok;
public void sofia_profile_check() {
master_profile_ok = true;
private bool sofia_actual_profile_check(bool is_last_try){
String res = Utils.api_exec("sofia", "status profile softphone");
if (res.Trim() == "Invalid Profile!"){
if (res.Trim() == "Invalid Profile!") {
if (is_last_try)
return false;
String tls_port_msg = "";
if (FieldValue.GetByName(values, "tls").value == "true")
tls_port_msg += " and tls bind port (" + FieldValue.GetByName(values, "tls-sip-port").value + ")";
MessageBox.Show("Warning the master sofia profile was not able to load and the phone will most likely _not_ work, make sure the local bind port (" + FieldValue.GetByName(values, "sip-port").value + ")" + tls_port_msg + " is free(set under the Advanced tab of in the sofia settings) and FSClient is allowed through your firewall, otherwise check the freeswitch.log for more details. You can try reloading the sofia profile by editing the sofia settings and clicking save to see if fixed.");
master_profile_ok = false;
return false;
}
master_profile_ok = true;
return true;
}
public void sofia_profile_check_last(){
bool res = sofia_actual_profile_check(true);
Debug.WriteLine("GOT TO Last Check and its result was: " + res);
}
public void sofia_profile_check() {
if (!sofia_actual_profile_check(false))
DelayedFunction.DelayedCall("SofiaProfileCheck", sofia_profile_check_last, 1200);
}
public void edit() {
if (Broker.get_instance().active_calls != 0) {
......
Markdown 格式
0% 或
您添加了 0 人 到此讨论。请谨慎行事。
请先完成此评论的编辑!
请 注册 或者 后发表评论