gkdr / carbons

Experimental XEP-0280: Message Carbons plugin for libpurple (Pidgin, Finch, etc.)
GNU General Public License v2.0
82 stars 7 forks source link

server carbons support not detected (Prosody, providing urn:xmpp:carbons:2 feature properly) #30

Closed petermolnar closed 4 years ago

petermolnar commented 5 years ago

The newer version of carbons - ever since the /carbons is not needed - fails to detect carbon support on a Prosody server.

The functionality is working fine with Gajim, Conversations, Dino.

Unfortunately the debug window gave this, and nothing more:

(06:12:03) jabber: Recv (ssl)(4095): <iq type='result' from='petermolnar.net' id='purple36e237da' to='mail@petermolnar.net/eTaZUGbq'><query xmlns='http://jabber.org/protocol/disco#info'><identity category='proxy' name='SOCKS5 Bytestreams Service' type='bytestreams'/><identity category='pubsub' name='Prosody' type='pep'/><identity category='store' name='HTTP File Upload' type='file'/><identity category='pubsub' name='Prosody PubSub Service' type='service'/><identity category='server' name='Prosody' type='im'/><feature var='http://jabber.org/protocol/commands'/><feature var='urn:xmpp:time'/><feature var='jabber:iq:time'/><feature var='jabber:iq:roster'/><feature var='jabber:iq:version'/><feature var='msgoffline'/><feature var='http://jabber.org/protocol/bytestreams'/><feature var='jabber:iq:private'/><feature var='http://jabber.org/protocol/pubsub#publish'/><feature var='urn:xmpp:http:upload:0'/><feature var='urn:xmpp:http:upload'/><feature var='urn:xmpp:blocking'/><feature var='http://jabber.org/protocol/pubsub'/><feature var='http://jabber.org/protocol/pubsub#subscribe'/><feature var='http://jabber.org/protocol/pubsub#subscription-options'/><feature var='http://jabber.org/protocol/pubsub#create-nodes'/><feature var='http://jabber.org/protocol/pubsub#purge-nodes'/><feature var='http://jabber.org/protocol/pubsub#delete-items'/><feature var='http://jabber.org/protocol/pubsub#retract-items'/><feature var='http://jabber.org/protocol/pubsub#retrieve-subscriptions'/><feature var='http://jabber.org/protocol/pubsub#publisher-affiliation'/><feature var='http://jabber.org/protocol/pubsub#retrieve-items'/><feature var='http://jabber.org/protocol/pubsub#delete-nodes'/><feature var='http://jabber.org/protocol/pubsub#multi-items'/><feature var='http://jabber.org/protocol/pubsub#access-open'/><feature var='http://jabber.org/protocol/pubsub#member-affiliation'/><feature var='http://jabber.org/protocol/pubsub#modify-affiliations'/><feature var='http://jabber.org/protocol/pubsub#instant-nodes'/><feature var='http://jabber.org/protocol/pubsub#meta-data'/><feature var='http://jabber.org/protocol/pubsub#config-node'/><feature var='http://jabber.org/protocol/pubsub#publish-options'/><feature var='http://jabber.org/protocol/pubsub#item-ids'/><feature var='http://jabber.org/protocol/pubsub#outcast-affiliation'/><feature var='http://jabber.org/protocol/pubsub#retrieve-default'/><feature var='http://jabber.org/protocol/pubsub#create-and-configure'/><feature var='http://jabber.org/protocol/pubsub#persistent-items'/><feature var='urn:xmpp:carbons:2'/><feature var='urn:xmpp:carbons:1'/><feature var='vcard-temp'/><feature var='urn:xmpp:archive:auto'/><feature var='urn:xmpp:archive:manage'/><feature var='urn:xmpp:archive:pref'/><feature var='http://jabber.org/protocol/rsm'/><feature var='jabber:iq:last'/><feature var='http://jabber.org/protocol/disco#info'/><feature var='http://jabber.org/protocol/disco#items'/><feature var='urn:xmpp:ping'/><x type='result' xmlns='jabber:x:data'><field type='hidden' var='FORM_TYPE'><value>http://jabber.org/network/serverinfo</value></field><field type='list-multi' var='abuse-addresses'><value>mailto:abuse@petermolnar.net</value></field><field type='list-multi' var='admin-addresses'><value>mailto:mail@petermolnar.net</value><value>xmpp:mail@petermolnar.net</value></field><field type='list-multi' var='feedback-addresses'/><field type='list-multi' var='sales-addresses'/><field type='list-multi' var='security-addresses'><value>mailto:mail@petermolnar.net</value><value>xmpp:mail@petermolnar.net</value></field><field type='list-multi' var='support-addresses'><value>mailto:mail@petermolnar.net</value><value>xmpp:mail@petermolnar.net</value></field></x><x type='result' xmlns='jabber:x:data'><field type='hidden' var='FORM_TYPE'><value>urn:xmpp:http:upload:0</value></field><field type='text-single' var='max-file-size'><value>1048576</value></field></x><x type='result' xmlns='jabber:x:data'><field type='hidden' var='FORM_TYPE'><value>urn:xmpp:http:upload</value></field><field type='text-single' var='max-file-size'><value>1048576</value></field></x><feature xmlns='u
(06:12:03) carbons: Sent feature discovery request for mail@petermolnar.net/.
(06:12:03) carbons: Server does not support message carbons, therefore doing nothing for mail@petermolnar.net/.
(06:13:10) plugins: probing ~/.purple/plugins/carbons.so
(06:16:27) plugins: probing ~/.purple/plugins/carbons.so

How can I help to find the root cause of the non-detection?

petermolnar commented 5 years ago

If I replace the ! in https://github.com/gkdr/carbons/blob/v0.2.0/src/carbons.c#L208, it activates:

if (g_strcmp0(CARBONS_XMLNS, feature_name)) {

instead of

if (!g_strcmp0(CARBONS_XMLNS, feature_name)) {
EionRobb commented 5 years ago

That's because you've changed it to say "if the feature we're checking is not carbons, then activate carbons"

petermolnar commented 5 years ago

that's... valid, I misread https://developer.gnome.org/glib/stable/glib-String-Utility-Functions.html#g-strcmp0 .

The problem stands though, the server supports carbons, it even has it in the discovery list returned, but the plugin doesn't see it.

petermolnar commented 5 years ago

OK, I added an extra debug line:

purple_debug_info(CARBONS_LOG_CATEGORY, "parsing feature name %s.\n", feature_name);

after L#208, got the following debug log:

(07:36:32) jabber: Recv (ssl)(4095): <iq type='result' from='petermolnar.net' id='purplebdbf98bb' to='mail@petermolnar.net/4teXdrTO'><query xmlns='http://jabber.org/protocol/disco#info'><identity category='proxy' name='SOCKS5 Bytestreams Service' type='bytestreams'/><identity category='pubsub' name='Prosody' type='pep'/><identity category='store' name='HTTP File Upload' type='file'/><identity category='pubsub' name='Prosody PubSub Service' type='service'/><identity category='server' name='Prosody' type='im'/><feature var='http://jabber.org/protocol/commands'/><feature var='urn:xmpp:time'/><feature var='jabber:iq:time'/><feature var='jabber:iq:roster'/><feature var='jabber:iq:version'/><feature var='msgoffline'/><feature var='http://jabber.org/protocol/bytestreams'/><feature var='jabber:iq:private'/><feature var='http://jabber.org/protocol/pubsub#publish'/><feature var='urn:xmpp:http:upload:0'/><feature var='urn:xmpp:http:upload'/><feature var='urn:xmpp:blocking'/><feature var='http://jabber.org/protocol/pubsub'/><feature var='http://jabber.org/protocol/pubsub#subscribe'/><feature var='http://jabber.org/protocol/pubsub#subscription-options'/><feature var='http://jabber.org/protocol/pubsub#create-nodes'/><feature var='http://jabber.org/protocol/pubsub#purge-nodes'/><feature var='http://jabber.org/protocol/pubsub#delete-items'/><feature var='http://jabber.org/protocol/pubsub#retract-items'/><feature var='http://jabber.org/protocol/pubsub#retrieve-subscriptions'/><feature var='http://jabber.org/protocol/pubsub#publisher-affiliation'/><feature var='http://jabber.org/protocol/pubsub#retrieve-items'/><feature var='http://jabber.org/protocol/pubsub#delete-nodes'/><feature var='http://jabber.org/protocol/pubsub#multi-items'/><feature var='http://jabber.org/protocol/pubsub#access-open'/><feature var='http://jabber.org/protocol/pubsub#member-affiliation'/><feature var='http://jabber.org/protocol/pubsub#modify-affiliations'/><feature var='http://jabber.org/protocol/pubsub#instant-nodes'/><feature var='http://jabber.org/protocol/pubsub#meta-data'/><feature var='http://jabber.org/protocol/pubsub#config-node'/><feature var='http://jabber.org/protocol/pubsub#publish-options'/><feature var='http://jabber.org/protocol/pubsub#item-ids'/><feature var='http://jabber.org/protocol/pubsub#outcast-affiliation'/><feature var='http://jabber.org/protocol/pubsub#retrieve-default'/><feature var='http://jabber.org/protocol/pubsub#create-and-configure'/><feature var='http://jabber.org/protocol/pubsub#persistent-items'/><feature var='urn:xmpp:carbons:2'/><feature var='urn:xmpp:carbons:1'/><feature var='vcard-temp'/><feature var='urn:xmpp:archive:auto'/><feature var='urn:xmpp:archive:manage'/><feature var='urn:xmpp:archive:pref'/><feature var='http://jabber.org/protocol/rsm'/><feature var='jabber:iq:last'/><feature var='http://jabber.org/protocol/disco#info'/><feature var='http://jabber.org/protocol/disco#items'/><feature var='urn:xmpp:ping'/><x type='result' xmlns='jabber:x:data'><field type='hidden' var='FORM_TYPE'><value>http://jabber.org/network/serverinfo</value></field><field type='list-multi' var='abuse-addresses'><value>mailto:abuse@petermolnar.net</value></field><field type='list-multi' var='admin-addresses'><value>mailto:mail@petermolnar.net</value><value>xmpp:mail@petermolnar.net</value></field><field type='list-multi' var='feedback-addresses'/><field type='list-multi' var='sales-addresses'/><field type='list-multi' var='security-addresses'><value>mailto:mail@petermolnar.net</value><value>xmpp:mail@petermolnar.net</value></field><field type='list-multi' var='support-addresses'><value>mailto:mail@petermolnar.net</value><value>xmpp:mail@petermolnar.net</value></field></x><x type='result' xmlns='jabber:x:data'><field type='hidden' var='FORM_TYPE'><value>urn:xmpp:http:upload:0</value></field><field type='text-single' var='max-file-size'><value>1048576</value></field></x><x type='result' xmlns='jabber:x:data'><field type='hidden' var='FORM_TYPE'><value>urn:xmpp:http:upload</value></field><field type='text-single' var='max-file-size'><value>1048576</value></field></x><feature xmlns='u
(07:36:32) carbons: Sent feature discovery request for mail@petermolnar.net/.
(07:36:32) carbons: parsing feature name http://jabber.org/protocol/pubsub#subscribe.
(07:36:32) carbons: parsing feature name http://jabber.org/protocol/pubsub#subscription-options.
(07:36:32) carbons: parsing feature name http://jabber.org/protocol/pubsub#create-nodes.
(07:36:32) carbons: parsing feature name http://jabber.org/protocol/pubsub#purge-nodes.
(07:36:32) carbons: parsing feature name http://jabber.org/protocol/pubsub#access-presence.
(07:36:32) carbons: parsing feature name http://jabber.org/protocol/pubsub#delete-items.
(07:36:32) carbons: parsing feature name http://jabber.org/protocol/pubsub#presence-notifications.
(07:36:32) carbons: parsing feature name http://jabber.org/protocol/pubsub#last-published.
(07:36:32) carbons: parsing feature name http://jabber.org/protocol/pubsub#retract-items.
(07:36:32) carbons: parsing feature name http://jabber.org/protocol/pubsub#auto-create.
(07:36:32) carbons: parsing feature name http://jabber.org/protocol/pubsub#retrieve-subscriptions.
(07:36:32) carbons: parsing feature name http://jabber.org/protocol/pubsub#multi-items.
(07:36:32) carbons: parsing feature name http://jabber.org/protocol/pubsub#filtered-notifications.
(07:36:32) carbons: parsing feature name http://jabber.org/protocol/pubsub#publisher-affiliation.
(07:36:32) carbons: parsing feature name http://jabber.org/protocol/pubsub#retrieve-items.
(07:36:32) carbons: parsing feature name http://jabber.org/protocol/pubsub#presence-subscribe.
(07:36:32) carbons: parsing feature name http://jabber.org/protocol/pubsub#member-affiliation.
(07:36:32) carbons: parsing feature name http://jabber.org/protocol/pubsub#publish.
(07:36:32) carbons: parsing feature name http://jabber.org/protocol/pubsub#auto-subscribe.
(07:36:32) carbons: parsing feature name http://jabber.org/protocol/pubsub#create-and-configure.
(07:36:32) carbons: parsing feature name http://jabber.org/protocol/pubsub#instant-nodes.
(07:36:32) carbons: parsing feature name http://jabber.org/protocol/pubsub#retrieve-default.
(07:36:32) carbons: parsing feature name http://jabber.org/protocol/pubsub#config-node.
(07:36:32) carbons: parsing feature name http://jabber.org/protocol/pubsub#publish-options.
(07:36:32) carbons: parsing feature name http://jabber.org/protocol/pubsub#item-ids.
(07:36:32) carbons: parsing feature name http://jabber.org/protocol/pubsub#outcast-affiliation.
(07:36:32) carbons: parsing feature name http://jabber.org/protocol/pubsub#meta-data.
(07:36:32) carbons: parsing feature name http://jabber.org/protocol/pubsub#modify-affiliations.
(07:36:32) carbons: parsing feature name http://jabber.org/protocol/pubsub#persistent-items.
(07:36:32) carbons: parsing feature name http://jabber.org/protocol/pubsub#delete-nodes.
(07:36:32) carbons: parsing feature name urn:ietf:params:xml:ns:vcard-4.0.
(07:36:32) carbons: parsing feature name urn:xmpp:mam:2.
(07:36:32) carbons: parsing feature name urn:xmpp:sid:0.
(07:36:32) carbons: parsing feature name urn:xmpp:push:0.
(07:36:32) carbons: Server does not support message carbons, therefore doing nothing for mail@petermolnar.net/.

It never gets to check the carbons feature from the discovery response.

EionRobb commented 5 years ago

Oh I see, the for() loop uses feature_node_p = feature_node_p->next instead of feature_node_p = xmlnode_get_next_twin(feature_node_p)

petermolnar commented 5 years ago

Tried it; didn't make a difference. I looks like it doesn't loop through all the features returned by the discovery.

gkdr commented 5 years ago

If I remember correctly, I used the next pointer instead of the xmlnode_get_next_twin() function for this reason in the first place - it gave me a node somewhere in the middle and I couldn't get to all of them, even on my rather minimal Prosody installation. It seems I also should not use xmlnode_get_child() for the same reason, as it only worked for me by chance. The child pointer should definitely give me the first child though, and I can filter them by name.

gkdr commented 5 years ago

After trying it that way I think it might be an issue with the new Prosody version, or how Pidgin handles what Prosody now sends. Because my VM wouldn't boot I reinstalled it and ended up with the newest version of Prosody, 0.11.1. I had already implemented what I suggested, but I ran into the same issue. Looking at the debug log, the response looked like this:

<iq id='purple2c7f744c' type='result' to='a@localhost/fwnRayEE' from='a@localhost'><query xmlns='http://jabber.org/protocol/disco#info'><identity type='registered' category='account'/><identity type='pep' category='pubsub'/><feature var='http://jabber.org/protocol/pubsub#access-presence'/><feature var='http://jabber.org/protocol/pubsub#delete-items'/><feature var='http://jabber.org/protocol/pubsub#meta-data'/><feature var='http://jabber.org/protocol/pubsub#presence-notifications'/><feature var='http://jabber.org/protocol/pubsub#retract-items'/><feature var='http://jabber.org/protocol/pubsub#modify-affiliations'/><feature var='http://jabber.org/protocol/pubsub#member-affiliation'/><feature var='http://jabber.org/protocol/pubsub#multi-items'/><feature var='http://jabber.org/protocol/pubsub#presence-subscribe'/><feature var='http://jabber.org/protocol/pubsub#publish'/><feature var='http://jabber.org/protocol/pubsub#auto-subscribe'/><feature var='http://jabber.org/protocol/pubsub#outcast-affiliation'/><feature var='http://jabber.org/protocol/pubsub#subscription-options'/><feature var='http://jabber.org/protocol/pubsub#retrieve-items'/><feature var='http://jabber.org/protocol/pubsub#last-published'/><feature var='http://jabber.org/protocol/pubsub#filtered-notifications'/><feature var='http://jabber.org/protocol/pubsub#delete-nodes'/><feature var='http://jabber.org/protocol/pubsub#retrieve-default'/><feature var='http://jabber.org/protocol/pubsub#retrieve-subscriptions'/><feature var='http://jabber.org/protocol/pubsub#persistent-items'/><feature var='http://jab

Notice that it just stops in the middle, and there is no followup. I noticed the same thing in what you posted, but I assumed it was a copypaste issue, but it seems it really wasn't. In my case, carbons was in fact not contained in the features, but who knows what the XML parser does when it runs into something like this. (I know that carbons is installed and the code works because the same works for the second account, for which the reply was not cut off.)

I'm not sure what to do here, to be honest. It might work for you since it's in your reply, making the solution a bit more resilient, but the issue lies elsewhere. If you want, you can try it, just replace the loop with the following:

  for (child_node_p = query_node_p->child; child_node_p; child_node_p = child_node_p->next) {
    if (g_strcmp0(child_node_p->name, "feature")) {
      continue;
    }

    feature_name = xmlnode_get_attrib(child_node_p, "var");
    if (!g_strcmp0(CARBONS_XMLNS, feature_name)) {
      purple_debug_info(CARBONS_LOG_CATEGORY, "Found carbons in server features, sending enable request for %s.\n", accname);
      carbons_autoenable(purple_connection_get_account(js_p->gc));
      return;
    }
  }
gkdr commented 5 years ago

I made the change I suggested on the dev branch a while ago, just to make sure it's my fault if something similar happens in the future. (But then I can point to the unit tests, yay.)

In any case, as I said I could see the same cut off discovery result and reproduce the issue. Now with Prosody 0.11.2 it seems to be gone. The question that remains is why the other clients still worked - maybe they just save the (positive) discovery result and don't ask the server every single time?

gkdr commented 4 years ago

Closing this as it was a Prosody bug. Might implement the technically not correct but better alternative from #40 .