prosody
changeset 580 9ff2c3c87065
parent 576 c8442d9f02a5
child 605 8458be0941e7
equal deleted inserted replaced
579:81e68e5afce2 580:9ff2c3c87065
   110 
   110 
   111 local path_separator = "/"; if os.getenv("WINDIR") then path_separator = "\\" end
   111 local path_separator = "/"; if os.getenv("WINDIR") then path_separator = "\\" end
   112 local _mkdir = {}
   112 local _mkdir = {}
   113 function mkdir(path)
   113 function mkdir(path)
   114 	path = path:gsub("/", path_separator);
   114 	path = path:gsub("/", path_separator);
   115 	--print("mkdir",path);
       
   116 	local x = io.popen("mkdir \""..path.."\" 2>&1"):read("*a");
   115 	local x = io.popen("mkdir \""..path.."\" 2>&1"):read("*a");
   117 end
   116 end
   118 function encode(s) return s and (s:gsub("%W", function (c) return string.format("%%%x", c:byte()); end)); end
   117 function encode(s) return s and (s:gsub("%W", function (c) return string.format("%%%x", c:byte()); end)); end
   119 function mkdirs(host)
   118 function mkdirs(host)
   120 	if not _mkdir[host] then
   119 	if not _mkdir[host] then
   136 
   135 
   137 eventmanager.fire_event("server-starting");
   136 eventmanager.fire_event("server-starting");
   138 
   137 
   139 
   138 
   140 -- setup error handling
   139 -- setup error handling
   141 setmetatable(_G, { __index = function (t, k) print("WARNING: ATTEMPT TO READ A NIL GLOBAL!!!", k); error("Attempt to read a non-existent global. Naughty boy.", 2); end, __newindex = function (t, k, v) print("ATTEMPT TO SET A GLOBAL!!!!", tostring(k).." = "..tostring(v)); error("Attempt to set a global. Naughty boy.", 2); end }) --]][][[]][];
   140 setmetatable(_G, { __index = function (t, k) error("Attempt to read a non-existent global '"..k.."'", 2); end, __newindex = function (t, k, v) error("Attempt to set a global: "..tostring(k).." = "..tostring(v), 2); end });
   142 
       
   143 local protected_handler = function (conn, data, err) local success, ret = pcall(handler, conn, data, err); if not success then print("ERROR on "..tostring(conn)..": "..ret); conn:close(); end end;
       
   144 local protected_disconnect = function (conn, err) local success, ret = pcall(disconnect, conn, err); if not success then print("ERROR on "..tostring(conn).." disconnect: "..ret); conn:close(); end end;
       
   145 
       
   146 
   141 
   147 local global_ssl_ctx = config.get("*", "core", "ssl");
   142 local global_ssl_ctx = config.get("*", "core", "ssl");
   148 if global_ssl_ctx then
   143 if global_ssl_ctx then
   149 	local default_ssl_ctx = { mode = "server", protocol = "sslv23", capath = "/etc/ssl/certs", verify = "none"; };
   144 	local default_ssl_ctx = { mode = "server", protocol = "sslv23", capath = "/etc/ssl/certs", verify = "none"; };
   150 	setmetatable(global_ssl_ctx, { __index = default_ssl_ctx });
   145 	setmetatable(global_ssl_ctx, { __index = default_ssl_ctx });