mirror of
https://github.com/fusionpbx/fusionpbx.git
synced 2026-02-22 19:06:37 +00:00
Event Socket settings auto defaults or custom using config.conf
This commit is contained in:
@@ -1,131 +0,0 @@
|
||||
-- xml_handler.lua
|
||||
-- Part of FusionPBX
|
||||
-- Copyright (C) 2023 Mark J Crane <markjcrane@fusionpbx.com>
|
||||
-- All rights reserved.
|
||||
--
|
||||
-- Redistribution and use in source and binary forms, with or without
|
||||
-- modification, are permitted provided that the following conditions are met:
|
||||
--
|
||||
-- 1. Redistributions of source code must retain the above copyright notice,
|
||||
-- this list of conditions and the following disclaimer.
|
||||
--
|
||||
-- 2. Redistributions in binary form must reproduce the above copyright
|
||||
-- notice, this list of conditions and the following disclaimer in the
|
||||
-- documentation and/or other materials provided with the distribution.
|
||||
--
|
||||
-- THIS SOFTWARE IS PROVIDED ''AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||
-- INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
|
||||
-- AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
-- AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
|
||||
-- OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
-- SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
-- INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
-- CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
-- ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
-- POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
|
||||
--include xml library
|
||||
local Xml = require "resources.functions.xml";
|
||||
|
||||
--get the cache
|
||||
local cache = require "resources.functions.cache"
|
||||
local event_socket_cache_key = "configuration:event_socket.conf"
|
||||
XML_STRING, err = cache.get(event_socket_cache_key)
|
||||
|
||||
--set the cache
|
||||
if not XML_STRING then
|
||||
|
||||
--log cache error
|
||||
if (debug["cache"]) then
|
||||
freeswitch.consoleLog("warning", "[xml_handler] configuration:event_socket.conf can not get from the cache: " .. tostring(err) .. "\n");
|
||||
end
|
||||
|
||||
--set a default value
|
||||
if (expire["acl"] == nil) then
|
||||
expire["acl"]= "3600";
|
||||
end
|
||||
|
||||
--connect to the database
|
||||
local Database = require "resources.functions.database";
|
||||
dbh = Database.new('system');
|
||||
|
||||
--include json library
|
||||
local json
|
||||
if (debug["sql"]) then
|
||||
json = require "resources.functions.lunajson"
|
||||
end
|
||||
|
||||
--exits the script if we didn't connect properly
|
||||
assert(dbh:connected());
|
||||
|
||||
--start the xml array
|
||||
local xml = Xml:new();
|
||||
xml:append([[<configuration name="event_socket.conf" description="Socket Client">]]);
|
||||
xml:append([[ <settings>]]);
|
||||
|
||||
--run the query
|
||||
sql = "select default_setting_subcategory as name, default_setting_value as value from v_default_settings ";
|
||||
sql = sql .. "where default_setting_category = 'switch' ";
|
||||
sql = sql .. "and default_setting_subcategory like 'event_socket_%' ";
|
||||
sql = sql .. "and default_setting_enabled = 'true' ";
|
||||
if (debug["sql"]) then
|
||||
freeswitch.consoleLog("notice", "[xml_handler] SQL: " .. sql .. "\n");
|
||||
end
|
||||
x = 0;
|
||||
dbh:query(sql, function(row)
|
||||
if (row.name == 'event_socket_nat_map') then
|
||||
xml:append([[ <param name="nat-map" value="]] .. xml.sanitize(row.value) .. [[" />]]);
|
||||
end
|
||||
if (row.name == 'event_socket_ip_address') then
|
||||
xml:append([[ <param name="listen-ip" value="]] .. xml.sanitize(row.value) .. [["/>]]);
|
||||
end
|
||||
if (row.name == 'event_socket_port') then
|
||||
xml:append([[ <param name="listen-port" value="]] .. xml.sanitize(row.value) .. [["/>]]);
|
||||
end
|
||||
if (row.name == 'event_socket_password') then
|
||||
xml:append([[ <param name="password" value="]] .. xml.sanitize(row.value) .. [["/>]]);
|
||||
end
|
||||
if (row.name == 'event_socket_acl') then
|
||||
xml:append([[ <param name="apply-inbound-acl" value="]] .. xml.sanitize(row.value) .. [["/>]]);
|
||||
end
|
||||
end)
|
||||
|
||||
--close the extension tag if it was left open
|
||||
xml:append([[ </settings>]]);
|
||||
xml:append([[</configuration>]]);
|
||||
XML_STRING = xml:build();
|
||||
-- if (debug["xml_string"]) then
|
||||
-- freeswitch.consoleLog("notice", "[xml_handler] XML_STRING: " .. XML_STRING .. "\n");
|
||||
-- end
|
||||
|
||||
--close the database connection
|
||||
dbh:release();
|
||||
|
||||
--set the cache
|
||||
local ok, err = cache.set(event_socket_cache_key, XML_STRING, expire["acl"]);
|
||||
if debug["cache"] then
|
||||
if ok then
|
||||
freeswitch.consoleLog("notice", "[xml_handler] " .. event_socket_cache_key .. " stored in the cache\n");
|
||||
else
|
||||
freeswitch.consoleLog("warning", "[xml_handler] " .. event_socket_cache_key .. " can not be stored in the cache: " .. tostring(err) .. "\n");
|
||||
end
|
||||
end
|
||||
|
||||
--send to the console
|
||||
if (debug["cache"]) then
|
||||
freeswitch.consoleLog("notice", "[xml_handler] " .. event_socket_cache_key .. " source: database\n");
|
||||
end
|
||||
else
|
||||
--send to the console
|
||||
if (debug["cache"]) then
|
||||
freeswitch.consoleLog("notice", "[xml_handler] " .. event_socket_cache_key .. " source: cache\n");
|
||||
end
|
||||
end --if XML_STRING
|
||||
|
||||
--send the xml to the console
|
||||
if (debug["xml_string"]) then
|
||||
local file = assert(io.open(temp_dir .. "/event_socket.conf.xml", "w"));
|
||||
file:write(XML_STRING);
|
||||
file:close();
|
||||
end
|
||||
@@ -1,191 +1,207 @@
|
||||
|
||||
-- add file_exists function
|
||||
require "resources.functions.file_exists";
|
||||
require "resources.functions.explode";
|
||||
require "resources.functions.trim";
|
||||
require "resources.functions.file_exists";
|
||||
require "resources.functions.explode";
|
||||
require "resources.functions.trim";
|
||||
|
||||
--find and return path to the config.conf
|
||||
function config()
|
||||
if (file_exists("/usr/local/etc/fusionpbx/config.conf")) then
|
||||
return "/usr/local/etc/fusionpbx/config.conf";
|
||||
elseif (file_exists("/etc/fusionpbx/config.conf")) then
|
||||
return "/etc/fusionpbx/config.conf";
|
||||
else
|
||||
require "resources.config";
|
||||
return config_file;
|
||||
end
|
||||
function config()
|
||||
if (file_exists("/usr/local/etc/fusionpbx/config.conf")) then
|
||||
return "/usr/local/etc/fusionpbx/config.conf";
|
||||
elseif (file_exists("/etc/fusionpbx/config.conf")) then
|
||||
return "/etc/fusionpbx/config.conf";
|
||||
else
|
||||
require "resources.config";
|
||||
return config_file;
|
||||
end
|
||||
end
|
||||
|
||||
--load config
|
||||
function load_config()
|
||||
--get the config file
|
||||
config_file = config();
|
||||
function load_config()
|
||||
--get the config file
|
||||
config_file = config();
|
||||
|
||||
--define arrays
|
||||
database = {}
|
||||
database.system = {}
|
||||
database.switch = {}
|
||||
database.backend = {}
|
||||
switch = {}
|
||||
xml_handler = {}
|
||||
cache = {}
|
||||
--define arrays
|
||||
database = {}
|
||||
database.system = {}
|
||||
database.switch = {}
|
||||
database.backend = {}
|
||||
switch = {}
|
||||
xml_handler = {}
|
||||
cache = {}
|
||||
|
||||
--read the config file
|
||||
file = io.open(config_file);
|
||||
lines = file:lines();
|
||||
for line in lines do
|
||||
if (line and string.match(line, "=")) then
|
||||
--parse the setings
|
||||
a = explode("=", line);
|
||||
k = trim(a[1])
|
||||
v = trim(a[2])
|
||||
--read the config file
|
||||
file = io.open(config_file);
|
||||
lines = file:lines();
|
||||
for line in lines do
|
||||
if (line and string.match(line, "=")) then
|
||||
--parse the setings
|
||||
a = explode("=", line);
|
||||
k = trim(a[1])
|
||||
v = trim(a[2])
|
||||
|
||||
--debug information
|
||||
--freeswitch.consoleLog("notice","line " .. line .. "\n");
|
||||
--freeswitch.consoleLog("notice","key: " .. k .. ", value: ".. v .. "\n");
|
||||
--debug information
|
||||
--freeswitch.consoleLog("notice","line " .. line .. "\n");
|
||||
--freeswitch.consoleLog("notice","key: " .. k .. ", value: ".. v .. "\n");
|
||||
|
||||
--database system settings
|
||||
if (k == "database.0.type") then database.system.type = v; end
|
||||
if (k == "database.0.host") then database.system.host = v; end
|
||||
if (k == "database.0.path") then database.system.path = v; end
|
||||
if (k == "database.0.hostaddr") then database.system.hostaddr = v; end
|
||||
if (k == "database.0.port") then database.system.port = v; end
|
||||
if (k == "database.0.sslmode") then database.system.sslmode = v; end
|
||||
if (k == "database.0.name") then database.system.name = v; end
|
||||
if (k == "database.0.username") then database.system.username = v; end
|
||||
if (k == "database.0.password") then database.system.password = v; end
|
||||
if (k == "database.0.backend.base64") then database.system.backend.base64 = v; end
|
||||
--database system settings
|
||||
if (k == "database.0.type") then database.system.type = v; end
|
||||
if (k == "database.0.host") then database.system.host = v; end
|
||||
if (k == "database.0.path") then database.system.path = v; end
|
||||
if (k == "database.0.hostaddr") then database.system.hostaddr = v; end
|
||||
if (k == "database.0.port") then database.system.port = v; end
|
||||
if (k == "database.0.sslmode") then database.system.sslmode = v; end
|
||||
if (k == "database.0.name") then database.system.name = v; end
|
||||
if (k == "database.0.username") then database.system.username = v; end
|
||||
if (k == "database.0.password") then database.system.password = v; end
|
||||
if (k == "database.0.backend.base64") then database.system.backend.base64 = v; end
|
||||
|
||||
--database switch settings
|
||||
if (k == "database.1.type") then database.switch.type = v; end
|
||||
if (k == "database.1.path") then database.switch.path = v; end
|
||||
if (k == "database.1.name") then database.switch.name = v; end
|
||||
if (k == "database.1.host") then database.switch.host = v; end
|
||||
if (k == "database.1.hostaddr") then database.switch.hostaddr = v; end
|
||||
if (k == "database.1.port") then database.switch.port = v; end
|
||||
if (k == "database.1.sslmode") then database.switch.sslmode = v; end
|
||||
if (k == "database.1.username") then database.switch.username = v; end
|
||||
if (k == "database.1.password") then database.switch.password = v; end
|
||||
if (k == "database.1.backend.base64") then database.backend.base64 = v; end
|
||||
--database switch settings
|
||||
if (k == "database.1.type") then database.switch.type = v; end
|
||||
if (k == "database.1.path") then database.switch.path = v; end
|
||||
if (k == "database.1.name") then database.switch.name = v; end
|
||||
if (k == "database.1.host") then database.switch.host = v; end
|
||||
if (k == "database.1.hostaddr") then database.switch.hostaddr = v; end
|
||||
if (k == "database.1.port") then database.switch.port = v; end
|
||||
if (k == "database.1.sslmode") then database.switch.sslmode = v; end
|
||||
if (k == "database.1.username") then database.switch.username = v; end
|
||||
if (k == "database.1.password") then database.switch.password = v; end
|
||||
if (k == "database.1.backend.base64") then database.backend.base64 = v; end
|
||||
|
||||
--switch settings
|
||||
if (k == "switch.conf.dir") then conf_dir = v; end
|
||||
if (k == "switch.sounds.dir") then sounds_dir = v; end
|
||||
if (k == "switch.database.dir") then database_dir = v; end
|
||||
if (k == "switch.database.name") then database_name = v; end
|
||||
if (k == "switch.recordings.dir") then recordings_dir = v; end
|
||||
if (k == "switch.storage.dir") then storage_dir = v; end
|
||||
if (k == "switch.voicemail.dir") then voicemail_dir = v; end
|
||||
if (k == "switch.scripts.dir") then scripts_dir = v; end
|
||||
--switch settings
|
||||
if (k == "switch.conf.dir") then conf_dir = v; end
|
||||
if (k == "switch.sounds.dir") then sounds_dir = v; end
|
||||
if (k == "switch.database.dir") then database_dir = v; end
|
||||
if (k == "switch.database.name") then database_name = v; end
|
||||
if (k == "switch.recordings.dir") then recordings_dir = v; end
|
||||
if (k == "switch.storage.dir") then storage_dir = v; end
|
||||
if (k == "switch.voicemail.dir") then voicemail_dir = v; end
|
||||
if (k == "switch.scripts.dir") then scripts_dir = v; end
|
||||
|
||||
--switch xml handler
|
||||
if (k == "xml_handler.fs_path") then xml_handler.fs_path = v; end
|
||||
if (k == "xml_handler.reg_as_number_alias") then xml_handler.reg_as_number_alias = v; end
|
||||
if (k == "xml_handler.number_as_presence_id") then xml_handler.number_as_presence_id = v; end
|
||||
--switch event socket settings
|
||||
if (k == "switch.event_socket.host") then event_socket_host = v; end
|
||||
if (k == "switch.event_socket.port") then event_socket_port = v; end
|
||||
if (k == "switch.event_socket.password") then event_socket_password = v; end
|
||||
|
||||
--general settings
|
||||
if (k == "php.dir") then php_dir = v; end
|
||||
if (k == "php.bin") then php_bin = v; end
|
||||
if (k == "document.root") then document_root = v; end
|
||||
if (k == "project.path") then project_path = v; end
|
||||
if (k == "temp.dir") then temp_dir = v; end
|
||||
--switch xml handler
|
||||
if (k == "xml_handler.fs_path") then xml_handler.fs_path = v; end
|
||||
if (k == "xml_handler.reg_as_number_alias") then xml_handler.reg_as_number_alias = v; end
|
||||
if (k == "xml_handler.number_as_presence_id") then xml_handler.number_as_presence_id = v; end
|
||||
|
||||
--cache settings
|
||||
if (k == "cache.method") then cache.method = v; end
|
||||
if (k == "cache.location") then cache.location = v; end
|
||||
if (k == "cache.settings") then cache.settings = v; end
|
||||
--general settings
|
||||
if (k == "php.dir") then php_dir = v; end
|
||||
if (k == "php.bin") then php_bin = v; end
|
||||
if (k == "document.root") then document_root = v; end
|
||||
if (k == "project.path") then project_path = v; end
|
||||
if (k == "temp.dir") then temp_dir = v; end
|
||||
|
||||
--show the array
|
||||
--for i,v in ipairs(a) do
|
||||
-- freeswitch.consoleLog("notice","key " .. i .. " value ".. v .. "\n");
|
||||
--end
|
||||
end
|
||||
--cache settings
|
||||
if (k == "cache.method") then cache.method = v; end
|
||||
if (k == "cache.location") then cache.location = v; end
|
||||
if (k == "cache.settings") then cache.settings = v; end
|
||||
|
||||
--show the array
|
||||
--for i,v in ipairs(a) do
|
||||
-- freeswitch.consoleLog("notice","key " .. i .. " value ".. v .. "\n");
|
||||
--end
|
||||
end
|
||||
io.close(file);
|
||||
end
|
||||
io.close(file);
|
||||
|
||||
--set the database values
|
||||
database.type = database.switch.type;
|
||||
if (database.type == 'sqlite') then
|
||||
database.path = database.switch.path;
|
||||
database.name = database.switch.name;
|
||||
end
|
||||
|
||||
--database system dsn
|
||||
system_dsn = {}
|
||||
if (database.system.type == 'pgsql') then
|
||||
--create the system_dsn array
|
||||
table.insert(system_dsn, [[pgsql://]]);
|
||||
if (database.system.host) then
|
||||
table.insert(system_dsn, [[host=]] .. database.system.host .. [[ ]]);
|
||||
end
|
||||
if (database.system.hostaddr) then
|
||||
table.insert(system_dsn, [[hostaddr=]] .. database.system.hostaddr .. [[ ]]);
|
||||
end
|
||||
table.insert(system_dsn, [[port=]] .. database.system.port .. [[ ]]);
|
||||
if (database.switch.sslmode) then
|
||||
table.insert(system_dsn, [[sslmode=]] .. database.system.sslmode .. [[ ]]);
|
||||
end
|
||||
table.insert(system_dsn, [[dbname=]] .. database.system.name .. [[ ]]);
|
||||
table.insert(system_dsn, [[user=]] .. database.system.username .. [[ ]]);
|
||||
table.insert(system_dsn, [[password=]] .. database.system.password .. [[ ]]);
|
||||
elseif (database.system.type == 'sqlite') then
|
||||
--create the system_dsn array
|
||||
table.insert(system_dsn, [[sqlite://]] .. database.system.path .. [[/]].. database.system.name ..[[ ]]);
|
||||
end
|
||||
database.system = table.concat(system_dsn, '');
|
||||
|
||||
--database switch dsn
|
||||
switch_dsn = {}
|
||||
if (database.switch.type == 'pgsql') then
|
||||
--create the switch_dsn array
|
||||
table.insert(switch_dsn, [[pgsql://]]);
|
||||
if (database.switch.host) then
|
||||
table.insert(switch_dsn, [[host=]] .. database.switch.host .. [[ ]]);
|
||||
end
|
||||
if (database.switch.hostaddr) then
|
||||
table.insert(switch_dsn, [[hostaddr=]] .. database.switch.hostaddr .. [[ ]]);
|
||||
end
|
||||
table.insert(switch_dsn, [[host=]] .. database.switch.host .. [[ ]]);
|
||||
table.insert(switch_dsn, [[port=]] .. database.switch.port .. [[ ]]);
|
||||
if (database.switch.sslmode) then
|
||||
table.insert(switch_dsn, [[sslmode=]] .. database.switch.sslmode .. [[ ]]);
|
||||
end
|
||||
table.insert(switch_dsn, [[dbname=]] .. database.switch.name .. [[ ]]);
|
||||
table.insert(switch_dsn, [[user=]] .. database.switch.username .. [[ ]]);
|
||||
table.insert(switch_dsn, [[password=]] .. database.switch.password .. [[ ]]);
|
||||
database.switch = table.concat(switch_dsn, '');
|
||||
elseif (database.switch.type == 'sqlite') then
|
||||
--create the switch_dsn array
|
||||
table.insert(switch_dsn, [[sqlite://]] .. database.switch.path .. [[/]].. database.switch.name ..[[ ]]);
|
||||
end
|
||||
database.switch = table.concat(switch_dsn, '');
|
||||
|
||||
--set defaults
|
||||
expire = {}
|
||||
expire.default = "3600";
|
||||
expire.directory = "3600";
|
||||
expire.dialplan = "3600";
|
||||
expire.languages = "3600";
|
||||
expire.sofia = "3600";
|
||||
expire.acl = "3600";
|
||||
expire.ivr = "3600";
|
||||
|
||||
--set settings
|
||||
settings = {}
|
||||
settings.recordings = {}
|
||||
settings.voicemail = {}
|
||||
settings.fax = {}
|
||||
settings.recordings.storage_type = "";
|
||||
settings.voicemail.storage_type = "";
|
||||
settings.fax.storage_type = "";
|
||||
|
||||
--set the debug options
|
||||
debug = {}
|
||||
debug.params = false;
|
||||
debug.sql = false;
|
||||
debug.xml_request = false;
|
||||
debug.xml_string = false;
|
||||
--set the database values
|
||||
database.type = database.switch.type;
|
||||
if (database.type == 'sqlite') then
|
||||
database.path = database.switch.path;
|
||||
database.name = database.switch.name;
|
||||
end
|
||||
|
||||
--database system dsn
|
||||
system_dsn = {}
|
||||
if (database.system.type == 'pgsql') then
|
||||
--create the system_dsn array
|
||||
table.insert(system_dsn, [[pgsql://]]);
|
||||
if (database.system.host) then
|
||||
table.insert(system_dsn, [[host=]] .. database.system.host .. [[ ]]);
|
||||
end
|
||||
if (database.system.hostaddr) then
|
||||
table.insert(system_dsn, [[hostaddr=]] .. database.system.hostaddr .. [[ ]]);
|
||||
end
|
||||
table.insert(system_dsn, [[port=]] .. database.system.port .. [[ ]]);
|
||||
if (database.switch.sslmode) then
|
||||
table.insert(system_dsn, [[sslmode=]] .. database.system.sslmode .. [[ ]]);
|
||||
end
|
||||
table.insert(system_dsn, [[dbname=]] .. database.system.name .. [[ ]]);
|
||||
table.insert(system_dsn, [[user=]] .. database.system.username .. [[ ]]);
|
||||
table.insert(system_dsn, [[password=]] .. database.system.password .. [[ ]]);
|
||||
elseif (database.system.type == 'sqlite') then
|
||||
--create the system_dsn array
|
||||
table.insert(system_dsn, [[sqlite://]] .. database.system.path .. [[/]].. database.system.name ..[[ ]]);
|
||||
end
|
||||
database.system = table.concat(system_dsn, '');
|
||||
|
||||
--database switch dsn
|
||||
switch_dsn = {}
|
||||
if (database.switch.type == 'pgsql') then
|
||||
--create the switch_dsn array
|
||||
table.insert(switch_dsn, [[pgsql://]]);
|
||||
if (database.switch.host) then
|
||||
table.insert(switch_dsn, [[host=]] .. database.switch.host .. [[ ]]);
|
||||
end
|
||||
if (database.switch.hostaddr) then
|
||||
table.insert(switch_dsn, [[hostaddr=]] .. database.switch.hostaddr .. [[ ]]);
|
||||
end
|
||||
table.insert(switch_dsn, [[host=]] .. database.switch.host .. [[ ]]);
|
||||
table.insert(switch_dsn, [[port=]] .. database.switch.port .. [[ ]]);
|
||||
if (database.switch.sslmode) then
|
||||
table.insert(switch_dsn, [[sslmode=]] .. database.switch.sslmode .. [[ ]]);
|
||||
end
|
||||
table.insert(switch_dsn, [[dbname=]] .. database.switch.name .. [[ ]]);
|
||||
table.insert(switch_dsn, [[user=]] .. database.switch.username .. [[ ]]);
|
||||
table.insert(switch_dsn, [[password=]] .. database.switch.password .. [[ ]]);
|
||||
database.switch = table.concat(switch_dsn, '');
|
||||
elseif (database.switch.type == 'sqlite') then
|
||||
--create the switch_dsn array
|
||||
table.insert(switch_dsn, [[sqlite://]] .. database.switch.path .. [[/]].. database.switch.name ..[[ ]]);
|
||||
end
|
||||
database.switch = table.concat(switch_dsn, '');
|
||||
|
||||
--event socket settings
|
||||
if (event_socket_host == nil) then
|
||||
event_socket_host = '127.0.0.1';
|
||||
end
|
||||
if (event_socket_port == nil) then
|
||||
event_socket_port = '8021';
|
||||
end
|
||||
if (event_socket_password == nil) then
|
||||
event_socket_password = 'ClueCon';
|
||||
end
|
||||
|
||||
--set defaults
|
||||
expire = {}
|
||||
expire.default = "3600";
|
||||
expire.directory = "3600";
|
||||
expire.dialplan = "3600";
|
||||
expire.languages = "3600";
|
||||
expire.sofia = "3600";
|
||||
expire.acl = "3600";
|
||||
expire.ivr = "3600";
|
||||
|
||||
--set settings
|
||||
settings = {}
|
||||
settings.recordings = {}
|
||||
settings.voicemail = {}
|
||||
settings.fax = {}
|
||||
settings.recordings.storage_type = "";
|
||||
settings.voicemail.storage_type = "";
|
||||
settings.fax.storage_type = "";
|
||||
|
||||
--set the debug options
|
||||
debug = {}
|
||||
debug.params = false;
|
||||
debug.sql = false;
|
||||
debug.xml_request = false;
|
||||
debug.xml_string = false;
|
||||
end
|
||||
|
||||
--autoload the configuration
|
||||
load_config();
|
||||
load_config();
|
||||
|
||||
@@ -34,15 +34,10 @@ local host, port, auth
|
||||
|
||||
function EventSocket:__init()
|
||||
if not host then
|
||||
local db = Database.new('system')
|
||||
local sql = [[SELECT
|
||||
MAX(CASE WHEN default_setting_subcategory = 'event_socket_ip_address' THEN default_setting_value END) AS event_socket_address,
|
||||
MAX(CASE WHEN default_setting_subcategory = 'event_socket_port' THEN default_setting_value END) AS event_socket_port,
|
||||
MAX(CASE WHEN default_setting_subcategory = 'event_socket_password' THEN default_setting_value END) AS event_socket_password
|
||||
FROM v_default_settings]];
|
||||
local settings, err = db:first_row(sql)
|
||||
if not settings then return nil, err end
|
||||
host, port, auth = settings.event_socket_ip_address, settings.event_socket_port, settings.event_socket_password
|
||||
require "resources.functions.config";
|
||||
host = event_socket_host;
|
||||
port = event_socket_port;
|
||||
auth = event_socket_password;
|
||||
end
|
||||
|
||||
return self:_connect(host, port, auth)
|
||||
|
||||
Reference in New Issue
Block a user