From 6ea2c47577027a1821aedd45428b4d24ebde82f6 Mon Sep 17 00:00:00 2001 From: Kim Alvefur Date: Wed, 23 Jan 2013 22:41:18 +0100 Subject: mod_pubsub: Advertise autocreate_on_publish correctly. --- plugins/mod_pubsub.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'plugins') diff --git a/plugins/mod_pubsub.lua b/plugins/mod_pubsub.lua index 40b119cc..f0aa4e4f 100644 --- a/plugins/mod_pubsub.lua +++ b/plugins/mod_pubsub.lua @@ -210,9 +210,9 @@ module:hook("iq/host/http://jabber.org/protocol/pubsub:pubsub", handle_pubsub_iq local disco_info; local feature_map = { - create = { "create-nodes", autocreate_on_publish and "instant-nodes", "item-ids" }; + create = { "create-nodes", "instant-nodes", "item-ids" }; retract = { "delete-items", "retract-items" }; - publish = { "publish" }; + publish = { "publish", autocreate_on_publish and "auto-create" }; get_items = { "retrieve-items" }; add_subscription = { "subscribe" }; get_subscriptions = { "retrieve-subscriptions" }; -- cgit v1.2.3 From 40709658994b6603968042c9dfebff7363f6ea71 Mon Sep 17 00:00:00 2001 From: Kim Alvefur Date: Thu, 24 Jan 2013 00:58:03 +0100 Subject: mod_pubsub, util.pubsub: Implement the purge action --- plugins/mod_pubsub.lua | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'plugins') diff --git a/plugins/mod_pubsub.lua b/plugins/mod_pubsub.lua index f0aa4e4f..687e38f1 100644 --- a/plugins/mod_pubsub.lua +++ b/plugins/mod_pubsub.lua @@ -178,6 +178,10 @@ function handlers.set_retract(origin, stanza, retract) notify = (notify == "1") or (notify == "true"); local item = retract:get_child("item"); local id = item and item.attr.id + if not (node and id) then + origin.send(st.error_reply(stanza, "modify", "bad-request")); + return true; + end local reply, notifier; if notify then notifier = st.stanza("retract", { id = id }); @@ -191,6 +195,26 @@ function handlers.set_retract(origin, stanza, retract) return origin.send(reply); end +function handlers.set_purge(origin, stanza, purge) + local node, notify = purge.attr.node, purge.attr.notify; + notify = (notify == "1") or (notify == "true"); + local reply, notifier; + if not node then + origin.send(st.error_reply(stanza, "modify", "bad-request")); + return true; + end + if notify then + notifier = st.stanza("purge"); + end + local ok, ret = service:purge(node, stanza.attr.from, notifier); + if ok then + reply = st.reply(stanza); + else + reply = pubsub_error_reply(stanza, ret); + end + return origin.send(reply); +end + function simple_broadcast(node, jids, item) item = st.clone(item); item.attr.xmlns = nil; -- Clear the pubsub namespace @@ -212,6 +236,7 @@ local disco_info; local feature_map = { create = { "create-nodes", "instant-nodes", "item-ids" }; retract = { "delete-items", "retract-items" }; + purge = { "purge-nodes" }; publish = { "publish", autocreate_on_publish and "auto-create" }; get_items = { "retrieve-items" }; add_subscription = { "subscribe" }; -- cgit v1.2.3 From 4517552d8ba7d8c57794e2c74c7d73c64cbeb960 Mon Sep 17 00:00:00 2001 From: Kim Alvefur Date: Thu, 24 Jan 2013 00:58:17 +0100 Subject: s2smanager: Generate session names used for logging the same way everywhere --- plugins/mod_component.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'plugins') diff --git a/plugins/mod_component.lua b/plugins/mod_component.lua index 16084a78..74b02843 100644 --- a/plugins/mod_component.lua +++ b/plugins/mod_component.lua @@ -260,7 +260,7 @@ function listener.onconnect(conn) local session = { type = "component_unauthed", conn = conn, send = function (data) return _send(conn, tostring(data)); end }; -- Logging functions -- - local conn_name = "jcp"..tostring(conn):match("[a-f0-9]+$"); + local conn_name = "jcp"..tostring(session):match("[a-f0-9]+$"); session.log = logger.init(conn_name); session.close = session_close; -- cgit v1.2.3 From 255bd1e311f7dfe1dd48651666d677ed0161d272 Mon Sep 17 00:00:00 2001 From: Kim Alvefur Date: Thu, 24 Jan 2013 00:59:32 +0100 Subject: mod_s2s: Don't try to close sessions that were destroyed before timeout --- plugins/mod_s2s/mod_s2s.lua | 2 ++ 1 file changed, 2 insertions(+) (limited to 'plugins') diff --git a/plugins/mod_s2s/mod_s2s.lua b/plugins/mod_s2s/mod_s2s.lua index ad628a9b..15c89ced 100644 --- a/plugins/mod_s2s/mod_s2s.lua +++ b/plugins/mod_s2s/mod_s2s.lua @@ -429,6 +429,8 @@ local function initialize_session(session) add_task(connect_timeout, function () if session.type == "s2sin" or session.type == "s2sout" then return; -- Ok, we're connected + elseif session.type == "s2s_destroyed" then + return; -- Session already destroyed end -- Not connected, need to close session and clean up (session.log or log)("debug", "Destroying incomplete session %s->%s due to inactivity", -- cgit v1.2.3 From 6132cbab483a3521b4efddf87862ddc68f7f9784 Mon Sep 17 00:00:00 2001 From: Kim Alvefur Date: Thu, 24 Jan 2013 16:36:48 +0100 Subject: mod_pubsub: Ignore subscription options for now, fixes traceback due to missing form --- plugins/mod_pubsub.lua | 3 +++ 1 file changed, 3 insertions(+) (limited to 'plugins') diff --git a/plugins/mod_pubsub.lua b/plugins/mod_pubsub.lua index 687e38f1..c840c7c2 100644 --- a/plugins/mod_pubsub.lua +++ b/plugins/mod_pubsub.lua @@ -111,10 +111,13 @@ end function handlers.set_subscribe(origin, stanza, subscribe) local node, jid = subscribe.attr.node, subscribe.attr.jid; + --[[ local options_tag, options = stanza.tags[1]:get_child("options"), nil; if options_tag then options = options_form:data(options_tag.tags[1]); end + --]] + local options_tag, options; -- FIXME local ok, ret = service:add_subscription(node, stanza.attr.from, jid, options); local reply; if ok then -- cgit v1.2.3 From 4196cca0e08cb9c3404f8b10db51714d1abc0286 Mon Sep 17 00:00:00 2001 From: Florian Zeitz Date: Fri, 25 Jan 2013 01:32:14 +0100 Subject: mod_pubsub, util.pubsub: Don't send purge notifications in an element --- plugins/mod_pubsub.lua | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) (limited to 'plugins') diff --git a/plugins/mod_pubsub.lua b/plugins/mod_pubsub.lua index c840c7c2..56fabaec 100644 --- a/plugins/mod_pubsub.lua +++ b/plugins/mod_pubsub.lua @@ -6,6 +6,7 @@ local uuid_generate = require "util.uuid".generate; local xmlns_pubsub = "http://jabber.org/protocol/pubsub"; local xmlns_pubsub_errors = "http://jabber.org/protocol/pubsub#errors"; local xmlns_pubsub_event = "http://jabber.org/protocol/pubsub#event"; +local xmlns_pubsub_owner = "http://jabber.org/protocol/pubsub#owner"; local autocreate_on_publish = module:get_option_boolean("autocreate_on_publish", false); local autocreate_on_subscribe = module:get_option_boolean("autocreate_on_subscribe", false); @@ -201,15 +202,12 @@ end function handlers.set_purge(origin, stanza, purge) local node, notify = purge.attr.node, purge.attr.notify; notify = (notify == "1") or (notify == "true"); - local reply, notifier; + local reply; if not node then origin.send(st.error_reply(stanza, "modify", "bad-request")); return true; end - if notify then - notifier = st.stanza("purge"); - end - local ok, ret = service:purge(node, stanza.attr.from, notifier); + local ok, ret = service:purge(node, stanza.attr.from, notify); if ok then reply = st.reply(stanza); else @@ -218,12 +216,14 @@ function handlers.set_purge(origin, stanza, purge) return origin.send(reply); end -function simple_broadcast(node, jids, item) - item = st.clone(item); - item.attr.xmlns = nil; -- Clear the pubsub namespace +function simple_broadcast(kind, node, jids, item) + if item then + item = st.clone(item); + item.attr.xmlns = nil; -- Clear the pubsub namespace + end local message = st.message({ from = module.host, type = "headline" }) :tag("event", { xmlns = xmlns_pubsub_event }) - :tag("items", { node = node }) + :tag(kind, { node = node }) :add_child(item); for jid in pairs(jids) do module:log("debug", "Sending notification to %s", jid); @@ -232,7 +232,8 @@ function simple_broadcast(node, jids, item) end end -module:hook("iq/host/http://jabber.org/protocol/pubsub:pubsub", handle_pubsub_iq); +module:hook("iq/host/"..xmlns_pubsub..":pubsub", handle_pubsub_iq); +module:hook("iq/host/"..xmlns_pubsub_owner..":pubsub", handle_pubsub_iq); local disco_info; -- cgit v1.2.3 From f899900fa53a2ca28dc7805971a42e84ae16f974 Mon Sep 17 00:00:00 2001 From: Waqas Hussain Date: Sat, 26 Jan 2013 03:49:45 +0500 Subject: mod_pubsub: Fix nil access error. --- plugins/mod_pubsub.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'plugins') diff --git a/plugins/mod_pubsub.lua b/plugins/mod_pubsub.lua index 56fabaec..d39ba0fa 100644 --- a/plugins/mod_pubsub.lua +++ b/plugins/mod_pubsub.lua @@ -318,7 +318,7 @@ module:hook("iq-get/host/http://jabber.org/protocol/disco#items:query", function end local ok, ret = service:get_nodes(event.stanza.attr.from); if not ok then - event.origin.send(pubsub_error_reply(stanza, ret)); + event.origin.send(pubsub_error_reply(event.stanza, ret)); else local reply = st.reply(event.stanza) :tag("query", { xmlns = "http://jabber.org/protocol/disco#items" }); -- cgit v1.2.3 From 40bfc76ff8bfc16a5097240657ef447c4a232c08 Mon Sep 17 00:00:00 2001 From: Waqas Hussain Date: Sat, 26 Jan 2013 03:50:13 +0500 Subject: mod_pubsub: require usermanager. --- plugins/mod_pubsub.lua | 1 + 1 file changed, 1 insertion(+) (limited to 'plugins') diff --git a/plugins/mod_pubsub.lua b/plugins/mod_pubsub.lua index d39ba0fa..56496584 100644 --- a/plugins/mod_pubsub.lua +++ b/plugins/mod_pubsub.lua @@ -2,6 +2,7 @@ local pubsub = require "util.pubsub"; local st = require "util.stanza"; local jid_bare = require "util.jid".bare; local uuid_generate = require "util.uuid".generate; +local usermanager = require "core.usermanager"; local xmlns_pubsub = "http://jabber.org/protocol/pubsub"; local xmlns_pubsub_errors = "http://jabber.org/protocol/pubsub#errors"; -- cgit v1.2.3 From d11b41d1dd5cbdbdc3f6ec4752767a5fefbf5798 Mon Sep 17 00:00:00 2001 From: Kim Alvefur Date: Sun, 27 Jan 2013 17:11:45 +0100 Subject: mod_component: Look for the correct xmlns (thanks NebuK) --- plugins/mod_component.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'plugins') diff --git a/plugins/mod_component.lua b/plugins/mod_component.lua index 74b02843..68d8a5de 100644 --- a/plugins/mod_component.lua +++ b/plugins/mod_component.lua @@ -313,6 +313,6 @@ module:provides("net", { listener = listener; default_port = 5347; multiplex = { - pattern = "^<.*:stream.*%sxmlns%s*=%s*(['\"])jabber:component%1.*>"; + pattern = "^<.*:stream.*%sxmlns%s*=%s*(['\"])jabber:component:accept%1.*>"; }; }); -- cgit v1.2.3 From 9468212a73173752909bb15af9964e6fbb6d154b Mon Sep 17 00:00:00 2001 From: Kim Alvefur Date: Mon, 28 Jan 2013 01:06:05 +0100 Subject: mod_pubsub: Broadcast items correctly on new subscriptions --- plugins/mod_pubsub.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'plugins') diff --git a/plugins/mod_pubsub.lua b/plugins/mod_pubsub.lua index 56496584..8b6aea6c 100644 --- a/plugins/mod_pubsub.lua +++ b/plugins/mod_pubsub.lua @@ -143,7 +143,7 @@ function handlers.set_subscribe(origin, stanza, subscribe) if items then local jids = { [jid] = options or true }; for id, item in pairs(items) do - service.config.broadcaster(node, jids, item); + service.config.broadcaster("items", node, jids, item); end end end -- cgit v1.2.3 From 8a6d52c9319c5c9e4e79bfcc9d27d88fcb5d6b6f Mon Sep 17 00:00:00 2001 From: Kim Alvefur Date: Thu, 31 Jan 2013 15:33:41 +0100 Subject: mod_pubsub: More strict checks for node and ids --- plugins/mod_pubsub.lua | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) (limited to 'plugins') diff --git a/plugins/mod_pubsub.lua b/plugins/mod_pubsub.lua index 8b6aea6c..96a9eaae 100644 --- a/plugins/mod_pubsub.lua +++ b/plugins/mod_pubsub.lua @@ -32,6 +32,8 @@ end local pubsub_errors = { ["conflict"] = { "cancel", "conflict" }; ["invalid-jid"] = { "modify", "bad-request", nil, "invalid-jid" }; + ["jid-required"] = { "modify", "bad-request", nil, "jid-required" }; + ["nodeid-required"] = { "modify", "bad-request", nil, "nodeid-required" }; ["item-not-found"] = { "cancel", "item-not-found" }; ["not-subscribed"] = { "modify", "unexpected-request", nil, "not-subscribed" }; ["forbidden"] = { "cancel", "forbidden" }; @@ -50,6 +52,9 @@ function handlers.get_items(origin, stanza, items) local item = items:get_child("item"); local id = item and item.attr.id; + if not node then + return origin.send(pubsub_error_reply(stanza, "nodeid-required")); + end local ok, results = service:get_items(node, stanza.attr.from, id); if not ok then return origin.send(pubsub_error_reply(stanza, results)); @@ -72,6 +77,9 @@ end function handlers.get_subscriptions(origin, stanza, subscriptions) local node = subscriptions.attr.node; + if not node then + return origin.send(pubsub_error_reply(stanza, "nodeid-required")); + end local ok, ret = service:get_subscriptions(node, stanza.attr.from, stanza.attr.from); if not ok then return origin.send(pubsub_error_reply(stanza, ret)); @@ -113,6 +121,9 @@ end function handlers.set_subscribe(origin, stanza, subscribe) local node, jid = subscribe.attr.node, subscribe.attr.jid; + if not (node and jid) then + return origin.send(pubsub_error_reply(stanza, jid and "nodeid-required" or "invalid-jid")); + end --[[ local options_tag, options = stanza.tags[1]:get_child("options"), nil; if options_tag then @@ -151,6 +162,9 @@ end function handlers.set_unsubscribe(origin, stanza, unsubscribe) local node, jid = unsubscribe.attr.node, unsubscribe.attr.jid; + if not (node and jid) then + return origin.send(pubsub_error_reply(stanza, jid and "nodeid-required" or "invalid-jid")); + end local ok, ret = service:remove_subscription(node, stanza.attr.from, jid); local reply; if ok then @@ -163,6 +177,9 @@ end function handlers.set_publish(origin, stanza, publish) local node = publish.attr.node; + if not node then + return origin.send(pubsub_error_reply(stanza, "nodeid-required")); + end local item = publish:get_child("item"); local id = (item and item.attr.id) or uuid_generate(); local ok, ret = service:publish(node, stanza.attr.from, id, item); @@ -184,8 +201,7 @@ function handlers.set_retract(origin, stanza, retract) local item = retract:get_child("item"); local id = item and item.attr.id if not (node and id) then - origin.send(st.error_reply(stanza, "modify", "bad-request")); - return true; + return origin.send(pubsub_error_reply(stanza, node and "item-not-found" or "nodeid-required")); end local reply, notifier; if notify then @@ -205,8 +221,7 @@ function handlers.set_purge(origin, stanza, purge) notify = (notify == "1") or (notify == "true"); local reply; if not node then - origin.send(st.error_reply(stanza, "modify", "bad-request")); - return true; + return origin.send(pubsub_error_reply(stanza, "nodeid-required")); end local ok, ret = service:purge(node, stanza.attr.from, notify); if ok then -- cgit v1.2.3 From 5cfdac70c61ae6562f72868ef7b55129b166aa80 Mon Sep 17 00:00:00 2001 From: Kim Alvefur Date: Thu, 31 Jan 2013 18:41:01 +0100 Subject: mod_pubsub, util.pubsub: Add delete action --- plugins/mod_pubsub.lua | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'plugins') diff --git a/plugins/mod_pubsub.lua b/plugins/mod_pubsub.lua index 96a9eaae..fe6c0b0a 100644 --- a/plugins/mod_pubsub.lua +++ b/plugins/mod_pubsub.lua @@ -119,6 +119,22 @@ function handlers.set_create(origin, stanza, create) return origin.send(reply); end +function handlers.set_delete(origin, stanza, delete) + local node = delete.attr.node; + + local reply, notifier; + if not node then + return origin.send(pubsub_error_reply(stanza, "nodeid-required")); + end + local ok, ret = service:delete(node, stanza.attr.from); + if ok then + reply = st.reply(stanza); + else + reply = pubsub_error_reply(stanza, ret); + end + return origin.send(reply); +end + function handlers.set_subscribe(origin, stanza, subscribe) local node, jid = subscribe.attr.node, subscribe.attr.jid; if not (node and jid) then @@ -258,6 +274,7 @@ local feature_map = { retract = { "delete-items", "retract-items" }; purge = { "purge-nodes" }; publish = { "publish", autocreate_on_publish and "auto-create" }; + delete = { "delete-nodes" }; get_items = { "retrieve-items" }; add_subscription = { "subscribe" }; get_subscriptions = { "retrieve-subscriptions" }; @@ -418,6 +435,7 @@ set_service(pubsub.new({ create = true; publish = true; retract = true; + delete = true; get_nodes = true; subscribe = true; -- cgit v1.2.3