Git Product home page Git Product logo

ralphm / wokkel Goto Github PK

View Code? Open in Web Editor NEW
136.0 136.0 37.0 757 KB

Wokkel is collection of enhancements on top of the Twisted networking framework, written in Python. It mostly provides a testing ground for enhancements to the Jabber/XMPP protocol implementation as found in Twisted Words, that are meant to eventually move there.

Home Page: http://wokkel.ik.nu/

License: MIT License

Python 100.00%

wokkel's People

Contributors

goffi-contrib avatar jerome-poisson avatar ralphm avatar souliane avatar twonds avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

wokkel's Issues

wokkel.client.XMPPClient cannot authenticate when JID has escaped characters

I'm using wokkel.client.XMPPClient to automatically authenticate my site's users to the XMPP server so that their vCards may be set.

However, when I try to authenticate with users who have escaped characters in their JIDs (specifically \40 for @) I get a SASLAuthError.

Twisted gives the following log messages:

Starting factory <twisted.words.protocols.jabber.xmlstream.XmlStreamFactory object at 0xc7f1c90>
SEND: "<stream:stream xmlns:stream='http://etherx.jabber.org/streams' xmlns='jabber:client' to='chat.myserver.com' version='1.0'>"
RECV: "<?xml version='1.0'?><stream:stream xmlns='jabber:client' xmlns:stream='http://etherx.jabber.org/streams' id='4213779102' from='chat.myserver.com' version='1.0' xml:lang='en'>"
RECV: "<stream:features><starttls xmlns='urn:ietf:params:xml:ns:xmpp-tls'/><mechanisms xmlns='urn:ietf:params:xml:ns:xmpp-sasl'><mechanism>DIGEST-MD5</mechanism><mechanism>PLAIN</mechanism></mechanisms><c xmlns='http://jabber.org/protocol/caps' hash='sha-1' node='http://www.process-one.net/en/ejabberd/' ver='YUDz8u9BV6d/pR9YmuUwklKsq6c='/><register xmlns='http://jabber.org/features/iq-register'/></stream:features>"
SEND: "<auth xmlns='urn:ietf:params:xml:ns:xmpp-sasl' mechanism='DIGEST-MD5'/>"
RECV: "<challenge xmlns='urn:ietf:params:xml:ns:xmpp-sasl'>bm9uY2U9IjEyMzc1OTIwNjEiLHFvcD0iYXV0aCIsY2hhcnNldD11dGYtOCxhbGdvcml0aG09bWQ1LXNlc3M=</challenge>"
SEND: "<response xmlns='urn:ietf:params:xml:ns:xmpp-sasl'>dXNlcm5hbWU9IndlYndvcmthZG1pblw0MHN0YXJhbGxpYW5jZS5jb20iLG5vbmNlPSIxMjM3NTkyMDYxIixkaWdlc3QtdXJpPSJ4bXBwL2NoYXQuc3RhcmFsbGlhbmNlLmNvbSIsY2hhcnNldD11dGYtOCxyZWFsbT0iY2hhdC5zdGFyYWxsaWFuY2UuY29tIixxb3A9YXV0aCxjbm9uY2U9IjU3NmU5MDcwMGYxYWZkZWM4N2E5MTAyYTM0ZjBjZWU1IixuYz0wMDAwMDAwMSxyZXNwb25zZT0wMjc2NTVlMWVlYjEzNTExNGQ1MGE5MDVhZTZmMWI5Mg==</response>"
RECV: "<failure xmlns='urn:ietf:params:xml:ns:xmpp-sasl'><not-authorized/></failure>"

Ejabberd's log gives the following output:

=INFO REPORT==== 2013-08-27 16:58:20 ===
I(<0.6053.0>:ejabberd_c2s:733) : ({socket_state,gen_tcp,#Port<0.12456>,<0.6052.0>}) Failed authentication for [email protected]

=INFO REPORT==== 2013-08-27 16:58:20 ===
D(<0.6053.0>:ejabberd_c2s:1456) : Send XML on stream = <<"<failure xmlns='urn:ietf:params:xml:ns:xmpp-sasl'><not-authorized/></failure>">>

What I find interesting from the ejabberd log is that the escaped character \40 is shown as only 40. This is what made me realise that this has to do with the fact that there is an escaped character in the first place.

Users without escaped characters in their JIDs authenticate fine.

As far as I can tell, my JID is correctly escaped, so I assume this must be a bug somewhere during the authentication routine.

(Pdb) pp jid
JID(u'jeff\\[email protected]')

I tried to dive into the Wokkel and Twisted code to debug this further but without luck.

Any help would be greatly appreciated.

Ability to reconnect

Hi there,

I am building an app which needs xmpp, and I love twisted and wokkel :)

But I am running into some problems when the machine got waken from sleep state. Wokkel doesn't seem to be reconnecting.

Can you help?

Thanks!

Timeout trying to join a room, even though join apparently succeeds

This only started recently, but I'm having trouble joining a room:

2015-01-08 14:58:00-0800 [-] Join failed
Traceback (most recent call last):
Failure: twisted.words.protocols.jabber.xmlstream.TimeoutError: Timeout waiting for response.

However the bot (wokkel-driven user) does appear in the group chat to other clients, and the traffic log shows that the bot receives a user list and even subsequent messages:

2015-01-08 14:57:30-0800 [XmlStream,client] SEND: "<presence to='[email protected]/argus'><x xmlns='http://jabber.org/protocol/muc'><history maxstanzas='0'/></x></presence>"
2015-01-08 14:57:30-0800 [XmlStream,client] RECV: "<message xmlns='jabber:client' type='groupchat' to='[email protected]/01ce4bee0a09bc234712bf780f381eadeb3376f9' from='[email protected]'><body>argusdev</body></message>"
2015-01-08 14:57:30-0800 [XmlStream,client] RECV: "<iq xmlns='jabber:client' type='get' id='iChat_2CAFF128' to='[email protected]/01ce4bee0a09bc234712bf780f381eadeb3376f9' from='[email protected]/rzg'><query xmlns='http://jabber.org/protocol/disco#info'/></iq>"
2015-01-08 15:00:32-0800 [XmlStream,client] RECV: "<message xmlns='jabber:client' to='[email protected]/01ce4bee0a09bc234712bf780f381eadeb3376f9' type='groupchat' id='iChat_14F19D10' from='[email protected]/rzg'><body>test123</body>\n<html xmlns='http://jabber.org/protocol/xhtml-im'><body xmlns='http://www.w3.org/1999/xhtml'>test123</body></html></message>"

It seems like wokkel is missing some indicator that the join was successful, but I don't know what.

My code is effectively the same as in muc_client.tac.

Wokkel release

Hello!
For another project (Cowrie), we are using Wokkel, but the latest release (not master tree) does not contain all the Py3 patches. Could you make another release from current master?

Specifying python 3 classifiers in setup.py

Hi! Tools like 'caniusepython3' examine the trove classifiers in pypi to determine if a library is python 3 ready.

Wokkel's .travisci.yml file specifies tests to run on 2.7, 3.3, and 3.5. It would be great to have equivalent trove classifiers specified in the setup.py. Should be as simple as:

Programming Language :: Python :: 2.6
Programming Language :: Python :: 2.7
Programming Language :: Python :: 3.4

Cheers!

Error building with utf characters

Hi, building package for debian archive and with locales es_ES.utf-8 we found this error:

I: pybuild base:217: python3.6 setup.py clean
Traceback (most recent call last):
File "setup.py", line 31, in
long_description = f.read()
File "/usr/lib/python3.6/encodings/ascii.py", line 26, in decode
return codecs.ascii_decode(input, self.errors)[0]
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 1213: ordinal not in range(128)
E: pybuild pybuild:336: clean: plugin distutils failed with: exit code=1: python3.6 setup.py clean

We applied the attached patch for temporal fix

Cheers
fix-utf-encoding.txt

Python Twisted Wokkel keeps disconnecting

For some reason my bot keeps disconnecting, following by a reconnect. I thought it might had to do with responding to probes to keep alive, but I'm still being disconnected after ~3 minutes. Example code:

from twisted.words.xish import domish
from wokkel.xmppim import MessageProtocol, AvailablePresence
from twisted.words.protocols.jabber.jid import JID
from wokkel.client import XMPPClient
from wokkel import component, server, xmppim


#Config
THIS_JID = JID('[email protected]')
ROOM_JID = JID('[email protected]')
NICK = 'Bad Robot'
SECRET = 'testpwd'


# Protocol handlers

class PresenceAcceptingHandler(xmppim.PresenceProtocol):
    """
    Presence accepting XMPP subprotocol handler.

    This handler blindly accepts incoming presence subscription requests,
    confirms unsubscription requests and responds to presence probes.

    Note that this handler does not remember any contacts, so it will not
    send presence when starting.
    """
    def subscribedReceived(self, presence):
        """
        Subscription approval confirmation was received.

        This is just a confirmation. Don't respond.
        """
        pass


    def unsubscribedReceived(self, presence):
        """
        Unsubscription confirmation was received.

        This is just a confirmation. Don't respond.
        """
        pass


    def subscribeReceived(self, presence):
        """
        Subscription request was received.

        Always grant permission to see our presence.
        """
        self.subscribed(recipient=presence.sender,
                        sender=presence.recipient)
        self.available(recipient=presence.sender,
                       status=u"I'm here",
                       sender=presence.recipient)


    def unsubscribeReceived(self, presence):
        """
        Unsubscription request was received.

        Always confirm unsubscription requests.
        """
        self.unsubscribed(recipient=presence.sender,
                          sender=presence.recipient)



    def probeReceived(self, presence):
        """
        A presence probe was received.

        Always send available presence to whoever is asking.
        """
        self.available(recipient=presence.sender,
                       status=u"I'm here",
                       sender=presence.recipient)
        print "probe send!"



class EchoBotProtocol(MessageProtocol):
    def connectionMade(self):
        print "Connected!"

        # send initial presence
        self.send(AvailablePresence())

    def connectionLost(self, reason):
        print "Disconnected! "+str(reason)

    def onMessage(self, msg):
        print str(msg)

        if msg["type"] == 'chat' and hasattr(msg, "body"):
            reply = domish.Element((None, "message"))
            reply["to"] = msg["from"]
            reply["from"] = msg["to"]
            reply["type"] = 'chat'
            reply.addElement("body", content="echo: " + str(msg.body))

            self.send(reply)

if __name__ == "__main__":
    # Start as a regular Python script.

    import sys
    from twisted.python import log
    from twisted.internet import reactor

    log.startLogging(sys.stdout, setStdout=0)
    client = XMPPClient(THIS_JID, SECRET)
    client.logTraffic = False
    client.send('<presence/>') # Hello, OpenFire!
    client.startService()

    presenceHandler = PresenceAcceptingHandler()
    presenceHandler.setHandlerParent(client)

    personalHandler = EchoBotProtocol()
    personalHandler.setHandlerParent(client)


    reactor.run()
else:
    # Start as a Twisted Application

    from twisted.application import service
    application = service.Application("MUC Client")

    client = XMPPClient(THIS_JID, SECRET)
    client.logTraffic = False
    client.setServiceParent(application)

    presenceHandler = PresenceAcceptingHandler()
    presenceHandler.setHandlerParent(client)

    personalHandler = EchoBotProtocol()
    personalHandler.setHandlerParent(client)

The log looks like this:

Connected!
Disconnected! [Failure instance: Traceback (failure with no frames): <class 'twisted.internet.error.ConnectionDone'>: Connection was closed cleanly.
]
2012-03-08 11:24:06+0100 [XmlStream,client] <wokkel.client.XMPPClientConnector instance at 0x1016d1ea8> will retry in 3 seconds
2012-03-08 11:24:06+0100 [XmlStream,client] Stopping factory <twisted.words.protocols.jabber.xmlstream.XmlStreamFactory object at 0x1016d4710>
2012-03-08 11:24:09+0100 [-] Starting factory <twisted.words.protocols.jabber.xmlstream.XmlStreamFactory object at 0x1016d4710>
2012-03-08 11:24:09+0100 [-] DNSDatagramProtocol starting on 56948
2012-03-08 11:24:09+0100 [-] Starting protocol <twisted.names.dns.DNSDatagramProtocol object at 0x1016f0a50>
2012-03-08 11:24:09+0100 [-] (UDP Port 56948 Closed)
2012-03-08 11:24:09+0100 [-] Stopping protocol <twisted.names.dns.DNSDatagramProtocol object at 0x1016f0a50>
Connected!

Enabling logTraffic doesn't help, as I don't see any messages about my disconnect. Can you help me out? Many thanks!

No longer possible to use a non-TLS connection with Twisted 19.7.0+

As of Twisted 19.7.0, xmlstream.TLSInitiatingInitializer is required by default (as I'm sure you know since you pushed the changes yourself)

Unfortunately Wokkel doesn't expose the functionality in XMPPClient so it's no longer possible to make non-TLS connections at all.

Python 3 Python Decorator issues

Hello,

Is this project still open? The latest version of master fixes a problem however for XMPP client with python 3. However, the version on PIP has an issue with Python 3 with some class decorator issues.
I can post exception that I was getting with available version on pip if needed.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.