diff options
-rw-r--r-- | core/moduleapi.lua | 1 | ||||
-rw-r--r-- | net/http.lua | 3 | ||||
-rw-r--r-- | net/server_event.lua | 17 | ||||
-rw-r--r-- | plugins/mod_invites.lua | 2 | ||||
-rw-r--r-- | teal-src/util/xtemplate.tl | 5 | ||||
-rw-r--r-- | util/prosodyctl/cert.lua | 2 | ||||
-rw-r--r-- | util/xtemplate.lua | 3 |
7 files changed, 28 insertions, 5 deletions
diff --git a/core/moduleapi.lua b/core/moduleapi.lua index 870a6a50..cbb2da9c 100644 --- a/core/moduleapi.lua +++ b/core/moduleapi.lua @@ -558,6 +558,7 @@ end function api:metric(type_, name, unit, description, label_keys, conf) local metric = require "core.statsmanager".metric; local is_scoped = self.host ~= "*" + label_keys = label_keys or {}; if is_scoped then -- prepend `host` label to label keys if this is not a global module local orig_labels = label_keys diff --git a/net/http.lua b/net/http.lua index aa435719..e81975fd 100644 --- a/net/http.lua +++ b/net/http.lua @@ -294,6 +294,9 @@ local function request(self, u, ex, callback) if ex and ex.use_dane ~= nil then use_dane = ex.use_dane; end + if not sslctx then + error("Attempt to make HTTPS request but no 'sslctx' provided in options"); + end end local http_service = basic_resolver.new(host, port_number, "tcp", { servername = req.host; use_dane = use_dane }); diff --git a/net/server_event.lua b/net/server_event.lua index c30181b8..e0235121 100644 --- a/net/server_event.lua +++ b/net/server_event.lua @@ -705,7 +705,10 @@ local function handleserver( server, addr, port, pattern, listener, sslctx, star debug( "maximal connections reached, refuse client connection; accept delay:", delay ) return EV_TIMEOUT, delay -- delay for next accept attempt end - local client_ip, client_port = client:getpeername( ) + local client_ip, client_port = addr, port; + if client.getpeername then -- Only IP sockets have this method, UNIX sockets don't + client_ip, client_port = client:getpeername( ) + end interface._connections = interface._connections + 1 -- increase connection count local clientinterface = handleclient( client, client_ip, client_port, interface, pattern, listener, sslctx ) --vdebug( "client id:", clientinterface, "startssl:", startssl ) @@ -728,6 +731,17 @@ local function handleserver( server, addr, port, pattern, listener, sslctx, star return interface end +local function wrapserver(conn, addr, port, listeners, config) + config = config or {} + if config.sslctx and not has_luasec then + debug "fatal error: luasec not found" + return nil, "luasec not found" + end + local interface = handleserver( conn, addr, port, config.read_size, listeners, config.tls_ctx, config.tls_direct) -- new server handler + debug( "new server created with id:", tostring(interface)) + return interface +end + local function listen(addr, port, listener, config) config = config or {} if config.sslctx and not has_luasec then @@ -917,6 +931,7 @@ return { listen = listen, addclient = addclient, wrapclient = wrapclient, + wrapserver = wrapserver, setquitting = setquitting, closeall = closeallservers, get_backend = get_backend, diff --git a/plugins/mod_invites.lua b/plugins/mod_invites.lua index 881b851e..88690f7e 100644 --- a/plugins/mod_invites.lua +++ b/plugins/mod_invites.lua @@ -191,7 +191,7 @@ function get(token, username) type = token_info and token_info.type or "roster"; uri = token_info and token_info.uri or get_uri("roster", username.."@"..module.host, token); additional_data = token_info and token_info.additional_data or nil; - reusable = token_info.reusable; + reusable = token_info and token_info.reusable or false; }, valid_invite_mt); end diff --git a/teal-src/util/xtemplate.tl b/teal-src/util/xtemplate.tl index b3bdc400..cdc913bf 100644 --- a/teal-src/util/xtemplate.tl +++ b/teal-src/util/xtemplate.tl @@ -46,7 +46,10 @@ local function render(template : string, root : st.stanza_t, escape : escape_t, if tmpl then tmpl = s_sub(tmpl, 2, -2); end if args then args = s_sub(args, 2, -2); end - if func == "each" and tmpl and st.is_stanza(value) then + if func == "each" and tmpl then + if not st.is_stanza(value) then + return ""; + end if not args then value, args = root, path; end local ns, name = s_match(args, "^(%b{})(.*)$"); if ns then ns = s_sub(ns, 2, -2); else name, ns = args, nil; end diff --git a/util/prosodyctl/cert.lua b/util/prosodyctl/cert.lua index 02c81585..abd2e1d6 100644 --- a/util/prosodyctl/cert.lua +++ b/util/prosodyctl/cert.lua @@ -163,7 +163,7 @@ local function copy(from, to, umask, owner, group) local attrs = lfs.attributes(to); if attrs then -- Move old file out of the way local backup = to..".bkp~"..os.date("%FT%T", attrs.change); - os.rename(to, backup); + assert(os.rename(to, backup)); end -- FIXME friendlier error handling, maybe move above backup back? local input = assert(io.open(from)); diff --git a/util/xtemplate.lua b/util/xtemplate.lua index 254c8af0..88baf1f7 100644 --- a/util/xtemplate.lua +++ b/util/xtemplate.lua @@ -31,7 +31,8 @@ local function render(template, root, escape, filters) if tmpl then tmpl = s_sub(tmpl, 2, -2); end if args then args = s_sub(args, 2, -2); end - if func == "each" and tmpl and st.is_stanza(value) then + if func == "each" and tmpl then + if not st.is_stanza(value) then return "" end if not args then value, args = root, path; end local ns, name = s_match(args, "^(%b{})(.*)$"); if ns then |