SpectrumIM / spectrum2

Spectrum 2 IM transports
https://spectrum.im
409 stars 90 forks source link

Server mode: from="localhost" in IQ replies confuses clients #159

Open dequis opened 8 years ago

dequis commented 8 years ago

"localhost" being the value of service.jid in the config, that is.

Pidgin:

(18:04:22) jabber: Sending
<iq type='get' id='purple56177e38'><query xmlns='jabber:iq:roster'/></iq>
[...]
(18:04:22) jabber: Recv (787):
<iq from="localhost" id="purple56177e38" to="rqsskek_narayananwitz_1450582457%tfbnw.net@localhost/uzeeytufhd" type="result"><query xmlns="jabber:iq:roster"><item jid="100010841476193@localhost" name="Ruth Alajhdadgfaic Riceman" subscription="both"><group>Buddies</group></item><item jid="100010849335141@localhost" name="James Alajhdicceada Chengescu" subscription="both"><group>Buddies</group></item><item jid="100010870422970@localhost" name="Mary Alajhgjdbbigj Seligsteinwitz" subscription="both"><group>Buddies</group></item><item jid="100010924566904@localhost" name="Susan Alajibdeffijd Sadanson" subscription="both"><group>Buddies</group></item><item jid="100010934405934@localhost" name="Nancy Alajicddjeicd Chaiman" subscription="both"><group>Buddies</group></item></query></iq>
(18:04:22) jabber: Received bogon roster push from localhost

From the pidgin source:

void jabber_roster_parse(JabberStream *js, const char *from,
                         JabberIqType type, const char *id, xmlnode *query)
{
    xmlnode *item, *group;

    if (!jabber_is_own_account(js, from)) {
        purple_debug_warning("jabber", "Received bogon roster push from %s\n",
                             from);
        return;
    }

jabber_is_own_account succeeds if "from" is either NULL (the attribute is missing, which is how things should be normally) or the users's own JID (this is probably for compatibility with some broken servers, a bug points at "studivz" behaving like that).

Similar issue, with gajim:

<!-- In Sat 23 Jul 2016 07:05:01 PM ART -->
<iq from="localhost" id="Gajim_18" to="rqsskek_narayananwitz_1450582457%tfbnw.net@localhost/dfwgxfszwm" type="result">
<query xmlns="http://jabber.org/protocol/disco#items"/>
</iq>

Debug output says:

07/23/2016 19:05:01 (I) gajim.c.p.caps Received Disco from unknown contact localhost

And for some reason I didn't quite figure out (but i'm betting it's related to this), it doesn't seem to load the contact list even though the roster processing code seems to succeed. I think gajim thinks the login isn't over.

banexx commented 6 years ago

I am using version 2.0.5 and can confirm that problem.
Messages from Skype are coming through nicely as far as I can tell. Of course as the roster is empty pidgin throws a lot of messages a la

Got presence for unknown buddy xxxxxxx@localhost on account yyyyyy@localhost/ (0xabcdef12345)

Is this actually a spectrum or a Swiften problem?

vitalyster commented 6 years ago

Actually, there are two different issues: original issue is the purple-jabber problem, which doesn't follow RFC rules for IQ While your issue is purple-skypeweb related: presences are generated before contacts actually received, and need more debugging to understand why.

dequis commented 6 years ago

Actually, there are two different issues: original issue is the purple-jabber problem, which doesn't follow RFC rules for IQ

@vitalyster hm, could you be more specific? jabber_is_own_account sounds correct going by point 3 of the link - it expects bare jid or nothing.

To be clear, the prpl used in spectrum in the original issue is facebook (not really relevant, anyway). purple-jabber is only involved as the XMPP client part of pidgin, but gajim also showed the same behavior.

banexx commented 6 years ago

Hi @vitalyster,
thanks for the quick response.

I cross-checked the response to some public servers and this is the response
from spectrum

(23:40:58) jabber: Sending (xxxxxxxx@localhost/imdonybqus): <iq type='get' id='purplec67843de'><query xmlns='jabber:iq:roster'/></iq>
(23:40:58) jabber: Recv (4095): <iq from="localhost" id="purplec67843de" to="xxxxxxx@localhost/imdonybqus" type="result"><query xmlns="jabber:iq:roster"><item jid=....

from public server running ejabberd

(23:50:14) jabber: Sending (ssl) (xxxxxxxx@jabber.ccc.de/def): <iq type='get' id='purplec67843de'><query xmlns='jabber:iq:roster'/></iq>
(23:50:14) jabber: Recv (ssl)(1971): <iq xml:lang='en' to='xxxxxxx@jabber.ccc.de/def' from='xxxxxxxx@jabber.ccc.de' type='result' id='purplec67843de'><query xmlns='jabber:iq:roster'><item subscription=

Please correct me if I'm wrong, but if I ask the server for an info, which I do here, then it should generate a stanza on behalf of the client and should behave like described in point 3.

As for the presence, I guess there is another issue that I can comment on, so I won't spam this one.

vitalyster commented 6 years ago

Agreed, it's a spectrum server issue