Update directory.lua
This commit is contained in:
+15
-15
@@ -117,10 +117,10 @@
|
|||||||
-- variable. So if we have no such variable we do not need build dial-string.
|
-- variable. So if we have no such variable we do not need build dial-string.
|
||||||
dialed_extension = params:getHeader("dialed_extension");
|
dialed_extension = params:getHeader("dialed_extension");
|
||||||
if (dialed_extension == nil) then
|
if (dialed_extension == nil) then
|
||||||
-- freeswitch.consoleLog("notice", "[xml_handler-directory.lua] dialed_extension is null\n");
|
-- freeswitch.consoleLog("notice", "[xml_handler][directory] dialed_extension is null\n");
|
||||||
USE_FS_PATH = false;
|
USE_FS_PATH = false;
|
||||||
else
|
else
|
||||||
-- freeswitch.consoleLog("notice", "[xml_handler-directory.lua] dialed_extension is " .. dialed_extension .. "\n");
|
-- freeswitch.consoleLog("notice", "[xml_handler][directory] dialed_extension is " .. dialed_extension .. "\n");
|
||||||
end
|
end
|
||||||
|
|
||||||
-- verify from_user and number alias for this methods
|
-- verify from_user and number alias for this methods
|
||||||
@@ -156,9 +156,9 @@
|
|||||||
|
|
||||||
if debug['cache'] then
|
if debug['cache'] then
|
||||||
if not XML_STRING then
|
if not XML_STRING then
|
||||||
freeswitch.consoleLog("notice", "[xml_handler-directory][cache] get key: " .. key .. " fail: " .. tostring(err) .. "\n")
|
freeswitch.consoleLog("notice", "[xml_handler][directory][cache] get key: " .. key .. " fail: " .. tostring(err) .. "\n")
|
||||||
else
|
else
|
||||||
freeswitch.consoleLog("notice", "[xml_handler-directory][cache] get key: " .. key .. " pass!" .. "\n")
|
freeswitch.consoleLog("notice", "[xml_handler][directory][cache] get key: " .. key .. " pass!" .. "\n")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -167,7 +167,7 @@
|
|||||||
|
|
||||||
--show the params in the console
|
--show the params in the console
|
||||||
--if (params:serialize() ~= nil) then
|
--if (params:serialize() ~= nil) then
|
||||||
-- freeswitch.consoleLog("notice", "[xml_handler-directory.lua] Params:\n" .. params:serialize() .. "\n");
|
-- freeswitch.consoleLog("notice", "[xml_handler][directory] Params:\n" .. params:serialize() .. "\n");
|
||||||
--end
|
--end
|
||||||
|
|
||||||
local loaded_from_db = false
|
local loaded_from_db = false
|
||||||
@@ -227,7 +227,7 @@
|
|||||||
|
|
||||||
--get the caller hostname
|
--get the caller hostname
|
||||||
local_hostname = trim(api:execute("switchname", ""));
|
local_hostname = trim(api:execute("switchname", ""));
|
||||||
--freeswitch.consoleLog("notice", "[xml_handler-directory.lua] local_hostname is " .. local_hostname .. "\n");
|
--freeswitch.consoleLog("notice", "[xml_handler][directory] local_hostname is " .. local_hostname .. "\n");
|
||||||
|
|
||||||
--add the file_exists function
|
--add the file_exists function
|
||||||
require "resources.functions.file_exists";
|
require "resources.functions.file_exists";
|
||||||
@@ -259,7 +259,7 @@
|
|||||||
database_hostname = row["hostname"];
|
database_hostname = row["hostname"];
|
||||||
end);
|
end);
|
||||||
--freeswitch.consoleLog("notice", "[xml_handler] sql: " .. sql .. "\n");
|
--freeswitch.consoleLog("notice", "[xml_handler] sql: " .. sql .. "\n");
|
||||||
--freeswitch.consoleLog("notice", "[xml_handler-directory.lua] database_hostname is " .. database_hostname .. "\n");
|
--freeswitch.consoleLog("notice", "[xml_handler][directory] database_hostname is " .. database_hostname .. "\n");
|
||||||
|
|
||||||
--hostname was not found set USE_FS_PATH to false to prevent a database_hostname concatenation error
|
--hostname was not found set USE_FS_PATH to false to prevent a database_hostname concatenation error
|
||||||
if (database_hostname == nil) then
|
if (database_hostname == nil) then
|
||||||
@@ -389,16 +389,16 @@
|
|||||||
--set the an alternative dial string if the hostnames don't match
|
--set the an alternative dial string if the hostnames don't match
|
||||||
if (USE_FS_PATH) then
|
if (USE_FS_PATH) then
|
||||||
if (local_hostname == database_hostname) then
|
if (local_hostname == database_hostname) then
|
||||||
freeswitch.consoleLog("notice", "[xml_handler-directory.lua] local_host and database_host are the same\n");
|
freeswitch.consoleLog("notice", "[xml_handler][directory] local_host and database_host are the same\n");
|
||||||
else
|
else
|
||||||
contact = trim(api:execute("sofia_contact", destination));
|
contact = trim(api:execute("sofia_contact", destination));
|
||||||
array = explode('/',contact);
|
array = explode('/',contact);
|
||||||
local profile, proxy = array[2], database_hostname;
|
local profile, proxy = array[2], database_hostname;
|
||||||
dial_string = "{sip_invite_domain=" .. domain_name .. ",presence_id=" .. presence_id .."}sofia/" .. profile .. "/" .. destination .. ";fs_path=sip:" .. proxy;
|
dial_string = "{sip_invite_domain=" .. domain_name .. ",presence_id=" .. presence_id .."}sofia/" .. profile .. "/" .. destination .. ";fs_path=sip:" .. proxy;
|
||||||
--freeswitch.consoleLog("notice", "[xml_handler-directory.lua] dial_string " .. dial_string .. "\n");
|
--freeswitch.consoleLog("notice", "[xml_handler][directory] dial_string " .. dial_string .. "\n");
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
--freeswitch.consoleLog("notice", "[xml_handler-directory.lua] seems balancing is false??" .. tostring(USE_FS_PATH) .. "\n");
|
--freeswitch.consoleLog("notice", "[xml_handler][directory] seems balancing is false??" .. tostring(USE_FS_PATH) .. "\n");
|
||||||
end
|
end
|
||||||
|
|
||||||
--show debug informationa
|
--show debug informationa
|
||||||
@@ -659,21 +659,21 @@
|
|||||||
if cache.support() then
|
if cache.support() then
|
||||||
local key = "directory:" .. sip_from_number .. "@" .. domain_name
|
local key = "directory:" .. sip_from_number .. "@" .. domain_name
|
||||||
if debug['cache'] then
|
if debug['cache'] then
|
||||||
freeswitch.consoleLog("notice", "[xml_handler-directory][memcache] set key: " .. key .. "\n")
|
freeswitch.consoleLog("notice", "[xml_handler][directory][cache] set key: " .. key .. "\n")
|
||||||
end
|
end
|
||||||
local ok, err = cache.set(key, XML_STRING, expire["directory"])
|
local ok, err = cache.set(key, XML_STRING, expire["directory"])
|
||||||
if debug["cache"] and not ok then
|
if debug["cache"] and not ok then
|
||||||
freeswitch.consoleLog("warning", "[xml_handler-directory][memcache] set key: " .. key .. " fail: " .. tostring(err) .. "\n");
|
freeswitch.consoleLog("warning", "[xml_handler][directory][cache] set key: " .. key .. " fail: " .. tostring(err) .. "\n");
|
||||||
end
|
end
|
||||||
|
|
||||||
if sip_from_number ~= sip_from_user then
|
if sip_from_number ~= sip_from_user then
|
||||||
key = "directory:" .. sip_from_user .. "@" .. domain_name
|
key = "directory:" .. sip_from_user .. "@" .. domain_name
|
||||||
if debug['cache'] then
|
if debug['cache'] then
|
||||||
freeswitch.consoleLog("notice", "[xml_handler-directory][memcache] set key: " .. key .. "\n")
|
freeswitch.consoleLog("notice", "[xml_handler][directory][cache] set key: " .. key .. "\n")
|
||||||
end
|
end
|
||||||
ok, err = cache.set(key, XML_STRING, expire["directory"])
|
ok, err = cache.set(key, XML_STRING, expire["directory"])
|
||||||
if debug["cache"] and not ok then
|
if debug["cache"] and not ok then
|
||||||
freeswitch.consoleLog("warning", "[xml_handler-directory][memcache] set key: " .. key .. " fail: " .. tostring(err) .. "\n");
|
freeswitch.consoleLog("warning", "[xml_handler][directory][cache] set key: " .. key .. " fail: " .. tostring(err) .. "\n");
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -716,7 +716,7 @@
|
|||||||
--send to the console
|
--send to the console
|
||||||
if (debug["cache"]) then
|
if (debug["cache"]) then
|
||||||
if (XML_STRING) then
|
if (XML_STRING) then
|
||||||
freeswitch.consoleLog("notice", "[xml_handler] directory:" .. user .. "@" .. domain_name .. " source: memcache \n");
|
freeswitch.consoleLog("notice", "[xml_handler] directory:" .. user .. "@" .. domain_name .. " source: cache \n");
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user