Merge 0.10->trunk
authorMatthew Wild <mwild1@gmail.com>
Thu, 10 Dec 2015 18:58:30 +0000 (18:58 +0000)
committerMatthew Wild <mwild1@gmail.com>
Thu, 10 Dec 2015 18:58:30 +0000 (18:58 +0000)
.luacheckrc
core/portmanager.lua
core/usermanager.lua
plugins/mod_admin_telnet.lua
plugins/mod_compression.lua
prosody
util/dataforms.lua

index bcce11552a84e912d3e8a75c6a75dada9d406195..590f9c3718fb6625e12e096dcba5e33249b82efb 100644 (file)
@@ -1,5 +1,5 @@
 cache = true
-read_globals = { "prosody", "hosts" }
+read_globals = { "prosody", "hosts", "import" }
 globals = { "_M" }
 allow_defined_top = true
 module = true
index 9f95077a483ca76f157ffe8abd29bfe7c24a2186..ad1a0be397edd976f45852e5744f2aa354cce5e1 100644 (file)
@@ -111,10 +111,10 @@ local function activate(service_name)
                                        local global_ssl_config = config.get("*", "ssl") or {};
                                        local prefix_ssl_config = config.get("*", config_prefix.."ssl") or global_ssl_config;
                                        ssl, err = certmanager.create_context(service_info.name.." port "..port, "server",
-                                               service_info.ssl_config or {},
                                                prefix_ssl_config[interface],
                                                prefix_ssl_config[port],
                                                prefix_ssl_config,
+                                               service_info.ssl_config or {},
                                                global_ssl_config[interface],
                                                global_ssl_config[port]);
                                        if not ssl then
index d874447d9dc64f59d853e6217c6057976374bdbc..0d8d7f91a125b6ccc671f10d888778714e2555e4 100644 (file)
@@ -111,7 +111,6 @@ local function is_admin(jid, host)
        if host and not hosts[host] then return false; end
        if type(jid) ~= "string" then return false; end
 
-       local is_admin;
        jid = jid_bare(jid);
        host = host or "*";
 
@@ -122,8 +121,7 @@ local function is_admin(jid, host)
                if type(host_admins) == "table" then
                        for _,admin in ipairs(host_admins) do
                                if jid_prep(admin) == jid then
-                                       is_admin = true;
-                                       break;
+                                       return true;
                                end
                        end
                elseif host_admins then
@@ -131,12 +129,11 @@ local function is_admin(jid, host)
                end
        end
 
-       if not is_admin and global_admins then
+       if global_admins then
                if type(global_admins) == "table" then
                        for _,admin in ipairs(global_admins) do
                                if jid_prep(admin) == jid then
-                                       is_admin = true;
-                                       break;
+                                       return true;
                                end
                        end
                elseif global_admins then
@@ -145,10 +142,10 @@ local function is_admin(jid, host)
        end
 
        -- Still not an admin, check with auth provider
-       if not is_admin and host ~= "*" and hosts[host].users and hosts[host].users.is_admin then
-               is_admin = hosts[host].users.is_admin(jid);
+       if host ~= "*" and hosts[host].users and hosts[host].users.is_admin then
+               return hosts[host].users.is_admin(jid);
        end
-       return is_admin or false;
+       return false;
 end
 
 return {
index 7aea28ba659250cf2044a63bca0d1090fe1d23b3..aa7b10cb9c37b02d7862d319216e9c79624f91ef 100644 (file)
@@ -282,6 +282,8 @@ end
 -- Session environment --
 -- Anything in def_env will be accessible within the session as a global variable
 
+--luacheck: ignore 212/self
+
 def_env.server = {};
 
 function def_env.server:insane_reload()
@@ -1125,6 +1127,33 @@ function def_env.dns:cache()
        return true, "Cache:\n"..tostring(dns.cache())
 end
 
+def_env.http = {};
+
+function def_env.http:list()
+       local print = self.session.print;
+
+       for host in pairs(prosody.hosts) do
+               local http_apps = modulemanager.get_items("http-provider", host);
+               if #http_apps > 0 then
+                       local http_host = module:context(host):get_option("http_host");
+                       print("HTTP endpoints on "..host..(http_host and (" (using "..http_host.."):") or ":"));
+                       for _, provider in ipairs(http_apps) do
+                               local url = module:context(host):http_url(provider.name);
+                               print("", url);
+                       end
+                       print("");
+               end
+       end
+
+       local default_host = module:get_option("http_default_host");
+       if not default_host then
+               print("HTTP requests to unknown hosts will return 404 Not Found");
+       else
+               print("HTTP requests to unknown hosts will be handled by "..default_host);
+       end
+       return true;
+end
+
 -------------
 
 function printbanner(session)
index da55e5bbb7f71f2f905afd474cbe914c082d938d..d49e388058a12666f21330669efb566cc8dd3513 100644 (file)
@@ -27,14 +27,12 @@ end
 module:hook("stream-features", function(event)
        local origin, features = event.origin, event.features;
        if not origin.compressed and origin.type == "c2s" then
-               -- FIXME only advertise compression support when TLS layer has no compression enabled
                features:add_child(compression_stream_feature);
        end
 end);
 
 module:hook("s2s-stream-features", function(event)
        local origin, features = event.origin, event.features;
-       -- FIXME only advertise compression support when TLS layer has no compression enabled
        if not origin.compressed and origin.type == "s2sin" then
                features:add_child(compression_stream_feature);
        end
diff --git a/prosody b/prosody
index 47998583168463b238f6998e038f3a544e18c99b..a2cb0e6cdb09319aa1650d7b51f4597728947aab 100755 (executable)
--- a/prosody
+++ b/prosody
@@ -43,6 +43,12 @@ if CFG_DATADIR then
        end
 end
 
+if #arg > 0 and arg[1] ~= "--config" then
+       print("Unknown command-line option: "..tostring(arg[1]));
+       print("Perhaps you meant to use prosodyctl instead?");
+       return 1;
+end
+
 -- Global 'prosody' object
 local prosody = { events = require "util.events".new(); };
 _G.prosody = prosody;
index 05846ab3a5b58614df89ba1c779ecc848d096b36..79b4d1a41b923cf6bd6cb539102c2cf20a968ace 100644 (file)
@@ -118,6 +118,7 @@ local field_readers = {};
 function form_t.data(layout, stanza)
        local data = {};
        local errors = {};
+       local present = {};
 
        for _, field in ipairs(layout) do
                local tag;
@@ -133,6 +134,7 @@ function form_t.data(layout, stanza)
                                errors[field.name] = "Required value missing";
                        end
                else
+                       present[field.name] = true;
                        local reader = field_readers[field.type];
                        if reader then
                                data[field.name], errors[field.name] = reader(tag, field.required);
@@ -140,9 +142,9 @@ function form_t.data(layout, stanza)
                end
        end
        if next(errors) then
-               return data, errors;
+               return data, errors, present;
        end
-       return data;
+       return data, nil, present;
 end
 
 local function simple_text(field_tag, required)